|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.carbide.cpp.pi.address; |
|
19 |
|
20 import java.awt.Toolkit; |
|
21 import java.awt.datatransfer.Clipboard; |
|
22 import java.awt.datatransfer.StringSelection; |
|
23 import java.awt.event.MouseEvent; |
|
24 import java.util.ArrayList; |
|
25 import java.util.Enumeration; |
|
26 import java.util.Vector; |
|
27 |
|
28 import org.eclipse.jface.action.Action; |
|
29 import org.eclipse.jface.action.ActionContributionItem; |
|
30 import org.eclipse.jface.action.IAction; |
|
31 import org.eclipse.jface.action.IContributionManager; |
|
32 import org.eclipse.jface.action.IMenuManager; |
|
33 import org.eclipse.jface.action.SubMenuManager; |
|
34 import org.eclipse.jface.wizard.Wizard; |
|
35 import org.eclipse.jface.wizard.WizardDialog; |
|
36 import org.eclipse.swt.SWT; |
|
37 import org.eclipse.swt.events.FocusListener; |
|
38 import org.eclipse.swt.events.MouseListener; |
|
39 import org.eclipse.swt.events.SelectionAdapter; |
|
40 import org.eclipse.swt.events.SelectionEvent; |
|
41 import org.eclipse.swt.widgets.Composite; |
|
42 import org.eclipse.swt.widgets.Decorations; |
|
43 import org.eclipse.swt.widgets.Menu; |
|
44 import org.eclipse.swt.widgets.MenuItem; |
|
45 import org.eclipse.swt.widgets.Table; |
|
46 import org.eclipse.swt.widgets.TableItem; |
|
47 import org.eclipse.ui.IActionBars; |
|
48 import org.eclipse.ui.PlatformUI; |
|
49 import org.eclipse.ui.actions.ActionFactory; |
|
50 import org.eclipse.ui.ide.IIDEActionConstants; |
|
51 |
|
52 import com.nokia.carbide.cpp.internal.pi.interfaces.ISaveSamples; |
|
53 import com.nokia.carbide.cpp.internal.pi.interfaces.ISaveTable; |
|
54 import com.nokia.carbide.cpp.internal.pi.model.ProfiledBinary; |
|
55 import com.nokia.carbide.cpp.internal.pi.model.ProfiledFunction; |
|
56 import com.nokia.carbide.cpp.internal.pi.model.ProfiledGeneric; |
|
57 import com.nokia.carbide.cpp.internal.pi.model.ProfiledThread; |
|
58 import com.nokia.carbide.cpp.internal.pi.save.SaveTableWizard; |
|
59 import com.nokia.carbide.cpp.internal.pi.visual.Defines; |
|
60 import com.nokia.carbide.cpp.internal.pi.visual.GenericTable; |
|
61 import com.nokia.carbide.cpp.pi.editors.PIPageEditor; |
|
62 |
|
63 |
|
64 public abstract class GenericAddrTable extends GenericTable |
|
65 { |
|
66 protected GppTraceGraph myGraph; |
|
67 protected Composite parent; |
|
68 |
|
69 // sorting column and order |
|
70 protected int sortColumn = COLUMN_ID_SAMPLE_COUNT; |
|
71 protected boolean sortAscending; |
|
72 |
|
73 protected GppTableSorter sorter; |
|
74 protected boolean sorting = false; |
|
75 |
|
76 abstract protected Menu getTableMenu(Decorations parent, int graphIndex, int drawMode); |
|
77 |
|
78 protected boolean isDrilldown = false; |
|
79 |
|
80 // menu items |
|
81 protected Action selectAllAction; |
|
82 protected Action copyTableAction; |
|
83 protected Action copyAction; |
|
84 protected Action copyDrilldownAction; |
|
85 protected Action saveTableAction; |
|
86 protected Action saveDrilldownAction; |
|
87 |
|
88 protected static int SAMPLES_AT_ONE_TIME = 1000; |
|
89 |
|
90 // class to pass sample data to the save wizard |
|
91 public class SaveSampleString implements ISaveSamples { |
|
92 int graphIndex; |
|
93 int drawMode; |
|
94 int startIndex = 0; |
|
95 |
|
96 public SaveSampleString(int graphIndex, int drawMode) { |
|
97 this.graphIndex = graphIndex; |
|
98 this.drawMode = drawMode; |
|
99 } |
|
100 |
|
101 public String getData() { |
|
102 return getData(SAMPLES_AT_ONE_TIME); |
|
103 } |
|
104 |
|
105 public String getData(int size) { |
|
106 String returnString = getSampleString(graphIndex, drawMode, this.startIndex, this.startIndex + size); |
|
107 if (returnString == null) |
|
108 this.startIndex = 0; |
|
109 else |
|
110 this.startIndex += size; |
|
111 return returnString; |
|
112 } |
|
113 |
|
114 public int getIndex() { |
|
115 return this.startIndex; |
|
116 } |
|
117 |
|
118 public void clear() { |
|
119 this.startIndex = 0; |
|
120 } |
|
121 } |
|
122 |
|
123 protected MenuItem getSaveSamplesItem(Menu menu, String sampleType, boolean enabled) { |
|
124 MenuItem saveSamplesItem = new MenuItem(menu, SWT.PUSH); |
|
125 |
|
126 saveSamplesItem.setText(Messages.getString("GenericAddrTable.saveSamples1") + sampleType + Messages.getString("GenericAddrTable.saveSamples2")); //$NON-NLS-1$ //$NON-NLS-2$ |
|
127 saveSamplesItem.setEnabled(enabled); |
|
128 |
|
129 if (enabled) { |
|
130 saveSamplesItem.addSelectionListener(new SelectionAdapter() { |
|
131 public void widgetSelected(SelectionEvent e) { |
|
132 action("saveSamples"); //$NON-NLS-1$ |
|
133 } |
|
134 }); |
|
135 } |
|
136 |
|
137 return saveSamplesItem; |
|
138 } |
|
139 |
|
140 public GppTraceGraph getGraph() { |
|
141 return myGraph; |
|
142 } |
|
143 |
|
144 protected class TableMouseListener implements MouseListener |
|
145 { |
|
146 public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e) { |
|
147 if (e.button == MouseEvent.BUTTON1) |
|
148 { |
|
149 TableItem[] selectedItems = table.getSelection(); |
|
150 if (selectedItems.length == 0) |
|
151 return; |
|
152 |
|
153 if (selectedItems[0].getData() instanceof ProfiledGeneric) |
|
154 { |
|
155 ProfiledGeneric pg = (ProfiledGeneric)(selectedItems[0].getData()); |
|
156 if (pg.isEnabled(myGraph.getGraphIndex())) |
|
157 action("remove"); //$NON-NLS-1$ |
|
158 else |
|
159 action("add"); //$NON-NLS-1$ |
|
160 action("doubleClick"); //$NON-NLS-1$ |
|
161 } |
|
162 } |
|
163 } |
|
164 |
|
165 public void mouseDown(org.eclipse.swt.events.MouseEvent e) { |
|
166 } |
|
167 |
|
168 public void mouseUp(org.eclipse.swt.events.MouseEvent e) { |
|
169 if (e.button == MouseEvent.BUTTON3) { |
|
170 Menu menu = getTableMenu(table.getShell(), myGraph.getGraphIndex(), myGraph.getDrawMode()); |
|
171 menu.setLocation(parent.toDisplay(e.x + table.getLocation().x, e.y + table.getLocation().y)); |
|
172 table.setMenu(menu); |
|
173 } |
|
174 } |
|
175 } |
|
176 |
|
177 public void setVisualisationColumnVisible(boolean flag) {} |
|
178 |
|
179 public void valueChanged(SelectionEvent e) {} |
|
180 |
|
181 protected Vector<ProfiledGeneric> setTableItemData(Enumeration<ProfiledGeneric> enu) { |
|
182 Vector<ProfiledGeneric> tmpItems = new Vector<ProfiledGeneric>(); |
|
183 |
|
184 while (enu.hasMoreElements()) |
|
185 { |
|
186 tmpItems.add(enu.nextElement()); |
|
187 } |
|
188 return tmpItems; |
|
189 } |
|
190 |
|
191 protected void addDrillDownItems(Menu tableMenu, int drawMode) |
|
192 { |
|
193 switch (drawMode) |
|
194 { |
|
195 case Defines.THREADS: |
|
196 { |
|
197 // thread drill down items |
|
198 threadItem (tableMenu, true); |
|
199 threadBinaryItem (tableMenu, false); |
|
200 threadFunctionItem(tableMenu, false); |
|
201 break; |
|
202 } |
|
203 case Defines.THREADS_BINARIES: |
|
204 { |
|
205 // thread drill down items |
|
206 threadItem (tableMenu, false); |
|
207 threadBinaryItem (tableMenu, true); |
|
208 threadBinaryFunctionItem(tableMenu, false); |
|
209 break; |
|
210 } |
|
211 case Defines.THREADS_BINARIES_FUNCTIONS: |
|
212 { |
|
213 // thread drill down items |
|
214 threadItem (tableMenu, false); |
|
215 threadBinaryItem (tableMenu, false); |
|
216 threadBinaryFunctionItem(tableMenu, true); |
|
217 break; |
|
218 } |
|
219 case Defines.THREADS_FUNCTIONS: |
|
220 { |
|
221 // thread drill down items |
|
222 threadItem (tableMenu, false); |
|
223 threadFunctionItem (tableMenu, true); |
|
224 newThreadFunctionBinary(tableMenu, false); |
|
225 break; |
|
226 } |
|
227 case Defines.THREADS_FUNCTIONS_BINARIES: |
|
228 { |
|
229 // thread drill down items |
|
230 threadItem (tableMenu, false); |
|
231 threadFunctionItem (tableMenu, false); |
|
232 newThreadFunctionBinary(tableMenu, true); |
|
233 break; |
|
234 } |
|
235 case Defines.BINARIES: |
|
236 { |
|
237 // binary drill down items |
|
238 binaryItem (tableMenu, true); |
|
239 binaryThreadItem (tableMenu, false); |
|
240 binaryFunctionItem(tableMenu, false); |
|
241 break; |
|
242 } |
|
243 case Defines.BINARIES_THREADS: |
|
244 { |
|
245 // binary drill down items |
|
246 binaryItem (tableMenu, false); |
|
247 binaryThreadItem (tableMenu, true); |
|
248 binaryThreadFunctionItem(tableMenu, false); |
|
249 break; |
|
250 } |
|
251 case Defines.BINARIES_THREADS_FUNCTIONS: |
|
252 { |
|
253 // binary drill down items |
|
254 binaryItem (tableMenu, false); |
|
255 binaryThreadItem (tableMenu, false); |
|
256 binaryThreadFunctionItem(tableMenu, true); |
|
257 break; |
|
258 } |
|
259 case Defines.BINARIES_FUNCTIONS: |
|
260 { |
|
261 // binary drill down items |
|
262 binaryItem (tableMenu, false); |
|
263 binaryFunctionItem (tableMenu, true); |
|
264 binaryFunctionThreadItem(tableMenu, false); |
|
265 break; |
|
266 } |
|
267 case Defines.BINARIES_FUNCTIONS_THREADS: |
|
268 { |
|
269 // binary drill down items |
|
270 binaryItem (tableMenu, false); |
|
271 binaryFunctionItem (tableMenu, false); |
|
272 binaryFunctionThreadItem(tableMenu, true); |
|
273 break; |
|
274 } |
|
275 case Defines.FUNCTIONS: |
|
276 { |
|
277 // function drill down items |
|
278 functionItem (tableMenu, true); |
|
279 functionThreadItem(tableMenu, false); |
|
280 functionBinaryItem(tableMenu, false); |
|
281 break; |
|
282 } |
|
283 case Defines.FUNCTIONS_THREADS: |
|
284 { |
|
285 // function drill down items |
|
286 functionItem (tableMenu, false); |
|
287 functionThreadItem (tableMenu, true); |
|
288 functionThreadBinaryItem(tableMenu, false); |
|
289 break; |
|
290 } |
|
291 case Defines.FUNCTIONS_THREADS_BINARIES: |
|
292 { |
|
293 // function drill down items |
|
294 functionItem (tableMenu, false); |
|
295 functionThreadItem (tableMenu, false); |
|
296 functionThreadBinaryItem(tableMenu, true); |
|
297 break; |
|
298 } |
|
299 case Defines.FUNCTIONS_BINARIES: |
|
300 { |
|
301 // function drill down items |
|
302 functionItem (tableMenu, false); |
|
303 functionBinaryItem (tableMenu, true); |
|
304 functionBinaryThreadItem(tableMenu, false); |
|
305 break; |
|
306 } |
|
307 case Defines.FUNCTIONS_BINARIES_THREADS: |
|
308 { |
|
309 // function drill down items |
|
310 functionItem (tableMenu, false); |
|
311 functionBinaryItem (tableMenu, false); |
|
312 functionBinaryThreadItem(tableMenu, true); |
|
313 break; |
|
314 } |
|
315 default: |
|
316 break; |
|
317 } |
|
318 } |
|
319 |
|
320 /* |
|
321 * Find if any threads with checkboxes checked |
|
322 */ |
|
323 protected boolean haveCheckedThread(GppTrace trace, int graphIndex) |
|
324 { |
|
325 ProfiledThread pThread; |
|
326 for (ProfiledGeneric pGeneric: trace.getIndexedThreads()) { |
|
327 if (pGeneric instanceof ProfiledThread) { |
|
328 pThread = (ProfiledThread) pGeneric; |
|
329 if (pThread.isEnabled(graphIndex)) |
|
330 return true; |
|
331 } |
|
332 } |
|
333 return false; |
|
334 } |
|
335 |
|
336 |
|
337 /* |
|
338 * Find if any binaries with checkboxes checked |
|
339 */ |
|
340 protected boolean haveCheckedBinary(GppTrace trace, int graphIndex) |
|
341 { |
|
342 ProfiledBinary pBinary; |
|
343 for (ProfiledGeneric pGeneric: trace.getIndexedBinaries()) { |
|
344 if (pGeneric instanceof ProfiledBinary) { |
|
345 pBinary = (ProfiledBinary) pGeneric; |
|
346 if (pBinary.isEnabled(graphIndex)) |
|
347 return true; |
|
348 } |
|
349 } |
|
350 return false; |
|
351 } |
|
352 |
|
353 /* |
|
354 * Find if any functions with checkboxes checked |
|
355 */ |
|
356 protected boolean haveCheckedFunction(GppTrace trace, int graphIndex) |
|
357 { |
|
358 ProfiledFunction pFunction; |
|
359 for (ProfiledGeneric pGeneric: trace.getIndexedFunctions()) { |
|
360 if (pGeneric instanceof ProfiledFunction) { |
|
361 pFunction = (ProfiledFunction) pGeneric; |
|
362 if (pFunction.isEnabled(graphIndex)) |
|
363 return true; |
|
364 } |
|
365 } |
|
366 return false; |
|
367 } |
|
368 |
|
369 /* |
|
370 * get list of matching samples based on draw mode |
|
371 */ |
|
372 private ArrayList<GppSample> getMatchingSamples(int drawMode, GppTrace trace, int startIndex, int endIndex, int graphIndex) |
|
373 { |
|
374 ArrayList<GppSample> samplesArray = new ArrayList<GppSample>(endIndex - startIndex > 1000 ? 1000 : endIndex - startIndex); |
|
375 Vector<ProfiledGeneric> traceThreads = trace.getIndexedThreads(); |
|
376 Vector<ProfiledGeneric> traceBinaries = trace.getIndexedBinaries(); |
|
377 Vector<ProfiledGeneric> traceFunctions = trace.getIndexedFunctions(); |
|
378 GppSample[] samples = trace.getSortedGppSamples(); |
|
379 GppSample sample; |
|
380 |
|
381 switch (drawMode) |
|
382 { |
|
383 case Defines.THREADS: |
|
384 for (int i = startIndex; i < endIndex; i++) { |
|
385 sample = samples[i]; |
|
386 ProfiledThread pThread = (ProfiledThread) traceThreads.elementAt(sample.threadIndex); |
|
387 if (pThread.isEnabled(graphIndex)) |
|
388 samplesArray.add(sample); |
|
389 } |
|
390 break; |
|
391 case Defines.BINARIES: |
|
392 for (int i = startIndex; i < endIndex; i++) { |
|
393 sample = samples[i]; |
|
394 ProfiledBinary pBinary = (ProfiledBinary) traceBinaries.elementAt(sample.binaryIndex); |
|
395 if (pBinary.isEnabled(graphIndex)) |
|
396 samplesArray.add(sample); |
|
397 } |
|
398 break; |
|
399 case Defines.FUNCTIONS: |
|
400 for (int i = startIndex; i < endIndex; i++) { |
|
401 sample = samples[i]; |
|
402 ProfiledFunction pFunction = (ProfiledFunction) traceFunctions.elementAt(sample.functionIndex); |
|
403 if (pFunction.isEnabled(graphIndex)) |
|
404 samplesArray.add(sample); |
|
405 } |
|
406 break; |
|
407 case Defines.THREADS_BINARIES: |
|
408 case Defines.BINARIES_THREADS: |
|
409 for (int i = startIndex; i < endIndex; i++) { |
|
410 sample = samples[i]; |
|
411 ProfiledThread pThread = (ProfiledThread) traceThreads.elementAt(sample.threadIndex); |
|
412 if (pThread.isEnabled(graphIndex)) { |
|
413 ProfiledBinary pBinary = (ProfiledBinary) traceBinaries.elementAt(sample.binaryIndex); |
|
414 if (pBinary.isEnabled(graphIndex)) { |
|
415 samplesArray.add(sample); |
|
416 } |
|
417 } |
|
418 } |
|
419 break; |
|
420 case Defines.THREADS_FUNCTIONS: |
|
421 case Defines.FUNCTIONS_THREADS: |
|
422 for (int i = startIndex; i < endIndex; i++) { |
|
423 sample = samples[i]; |
|
424 ProfiledThread pThread = (ProfiledThread) traceThreads.elementAt(sample.threadIndex); |
|
425 if (pThread.isEnabled(graphIndex)) { |
|
426 ProfiledFunction pFunction = (ProfiledFunction) traceFunctions.elementAt(sample.functionIndex); |
|
427 if (pFunction.isEnabled(graphIndex)) { |
|
428 samplesArray.add(sample); |
|
429 } |
|
430 } |
|
431 } |
|
432 break; |
|
433 case Defines.BINARIES_FUNCTIONS: |
|
434 case Defines.FUNCTIONS_BINARIES: |
|
435 for (int i = startIndex; i < endIndex; i++) { |
|
436 sample = samples[i]; |
|
437 ProfiledBinary pBinary = (ProfiledBinary) traceBinaries.elementAt(sample.binaryIndex); |
|
438 if (pBinary.isEnabled(graphIndex)) { |
|
439 ProfiledFunction pFunction = (ProfiledFunction) traceFunctions.elementAt(sample.functionIndex); |
|
440 if (pFunction.isEnabled(graphIndex)) { |
|
441 samplesArray.add(sample); |
|
442 } |
|
443 } |
|
444 } |
|
445 break; |
|
446 case Defines.THREADS_FUNCTIONS_BINARIES: |
|
447 case Defines.THREADS_BINARIES_FUNCTIONS: |
|
448 for (int i = startIndex; i < endIndex; i++) { |
|
449 sample = samples[i]; |
|
450 ProfiledThread pThread = (ProfiledThread) traceThreads.elementAt(sample.threadIndex); |
|
451 if (pThread.isEnabled(graphIndex)) { |
|
452 ProfiledBinary pBinary = (ProfiledBinary) traceBinaries.elementAt(sample.binaryIndex); |
|
453 if (pBinary.isEnabled(graphIndex)) { |
|
454 ProfiledFunction pFunction = (ProfiledFunction) traceFunctions.elementAt(sample.functionIndex); |
|
455 if (pFunction.isEnabled(graphIndex)) { |
|
456 samplesArray.add(sample); |
|
457 } |
|
458 } |
|
459 } |
|
460 } |
|
461 break; |
|
462 } |
|
463 |
|
464 samplesArray.trimToSize(); |
|
465 return samplesArray; |
|
466 } |
|
467 |
|
468 /* |
|
469 * return the thread, binary, or function samples selected in the interval |
|
470 */ |
|
471 protected String getSampleString(int graphIndex, int drawMode, int startIndex, int endIndex) |
|
472 { |
|
473 boolean threads = false; |
|
474 boolean binaries = false; |
|
475 boolean functions = false; |
|
476 GppTraceGraph graph = (GppTraceGraph)(this.myGraph); |
|
477 GppTrace trace = (GppTrace)(graph.getTrace()); |
|
478 |
|
479 // The current graph shows either threads, binaries, or functions |
|
480 switch (drawMode) |
|
481 { |
|
482 case Defines.THREADS: |
|
483 case Defines.BINARIES_THREADS: |
|
484 case Defines.BINARIES_FUNCTIONS_THREADS: |
|
485 case Defines.FUNCTIONS_THREADS: |
|
486 case Defines.FUNCTIONS_BINARIES_THREADS: |
|
487 threads = true; |
|
488 break; |
|
489 case Defines.BINARIES: |
|
490 case Defines.THREADS_BINARIES: |
|
491 case Defines.THREADS_FUNCTIONS_BINARIES: |
|
492 case Defines.FUNCTIONS_BINARIES: |
|
493 case Defines.FUNCTIONS_THREADS_BINARIES: |
|
494 binaries = true; |
|
495 break; |
|
496 case Defines.FUNCTIONS: |
|
497 case Defines.THREADS_FUNCTIONS: |
|
498 case Defines.THREADS_BINARIES_FUNCTIONS: |
|
499 case Defines.BINARIES_FUNCTIONS: |
|
500 case Defines.BINARIES_THREADS_FUNCTIONS: |
|
501 functions = true; |
|
502 break; |
|
503 default: |
|
504 break; |
|
505 } |
|
506 |
|
507 int startTime = trace.getStartSampleIndex(); |
|
508 int endTime = trace.getEndSampleIndex(); |
|
509 |
|
510 // check if we have returned everything |
|
511 if (startIndex > (endTime - startTime)) |
|
512 return null; |
|
513 |
|
514 ArrayList<GppSample> matchingSamples = getMatchingSamples(drawMode, trace, startTime, endTime, graphIndex); |
|
515 |
|
516 String returnString = ""; //$NON-NLS-1$ |
|
517 |
|
518 if (threads) { |
|
519 Vector<ProfiledGeneric> traceThreads = trace.getIndexedThreads(); |
|
520 if (startIndex == 0) |
|
521 returnString = Messages.getString("GenericAddrTable.threadSampleHeading"); //$NON-NLS-1$ |
|
522 |
|
523 for (int i = startIndex; i < matchingSamples.size() && i < endIndex; i++) { |
|
524 GppSample sample = matchingSamples.get(i); |
|
525 returnString += sample.sampleSynchTime + ",0x" + Long.toHexString(sample.programCounter) + "," //$NON-NLS-1$ //$NON-NLS-2$; $NON-NLS-2$; |
|
526 + traceThreads.get(sample.threadIndex).getNameString() + "\n"; //$NON-NLS-1$ |
|
527 } |
|
528 } else if (binaries) { |
|
529 if (startIndex == 0) |
|
530 returnString = Messages.getString("GenericAddrTable.binarySampleHeading"); //$NON-NLS-1$ |
|
531 |
|
532 for (int i = startIndex; i < matchingSamples.size() && i < endIndex; i++) { |
|
533 GppSample sample = matchingSamples.get(i); |
|
534 ProfiledBinary binary = (ProfiledBinary) trace.getIndexedBinaries().get(sample.binaryIndex); |
|
535 returnString += sample.sampleSynchTime + ",0x" + Long.toHexString(sample.programCounter) + "," //$NON-NLS-1$ //$NON-NLS-2$; $NON-NLS-2$; |
|
536 + binary.getNameString() + "\n"; // $NON-NLS-1$; //$NON-NLS-1$ |
|
537 } |
|
538 } else if (functions) { |
|
539 if (startIndex == 0) |
|
540 returnString = Messages.getString("GenericAddrTable.functionSampleHeading"); //$NON-NLS-1$ |
|
541 |
|
542 for (int i = startIndex; i < matchingSamples.size() && i < endIndex; i++) { |
|
543 GppSample sample = matchingSamples.get(i); |
|
544 ProfiledFunction function = (ProfiledFunction) trace.getIndexedFunctions().get(sample.functionIndex); |
|
545 returnString += sample.sampleSynchTime + ",0x" + Long.toHexString(sample.programCounter) + ",\"" //$NON-NLS-1$ //$NON-NLS-2$; $NON-NLS-2$; |
|
546 + function.getNameString() + "\",0x" + Long.toHexString(function.getFunctionAddress()) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$; $NON-NLS-2$; |
|
547 } |
|
548 } |
|
549 |
|
550 return returnString; |
|
551 } |
|
552 |
|
553 private void threadItem(Menu menu, boolean chosen) { |
|
554 MenuItem menuItem = new MenuItem(menu, SWT.RADIO); |
|
555 menuItem.setText(Messages.getString("GenericAddrTable.threadOnly")); //$NON-NLS-1$ |
|
556 menuItem.setSelection(chosen); |
|
557 menuItem.addSelectionListener(new SelectionAdapter() { |
|
558 public void widgetSelected(SelectionEvent e) { |
|
559 action("thread-only"); //$NON-NLS-1$ |
|
560 } |
|
561 }); |
|
562 } |
|
563 |
|
564 private void threadBinaryItem(Menu menu, boolean chosen) { |
|
565 MenuItem menuItem = new MenuItem(menu, SWT.RADIO); |
|
566 menuItem.setText(Messages.getString("GenericAddrTable.threadBinary")); //$NON-NLS-1$ |
|
567 menuItem.setSelection(chosen); |
|
568 menuItem.addSelectionListener(new SelectionAdapter() { |
|
569 public void widgetSelected(SelectionEvent e) { |
|
570 action("thread-binary"); //$NON-NLS-1$ |
|
571 } |
|
572 }); |
|
573 } |
|
574 |
|
575 private void threadBinaryFunctionItem(Menu menu, boolean chosen) { |
|
576 MenuItem menuItem = new MenuItem(menu, SWT.RADIO); |
|
577 menuItem.setText(Messages.getString("GenericAddrTable.threadBinaryFunction")); //$NON-NLS-1$ |
|
578 menuItem.setSelection(chosen); |
|
579 menuItem.addSelectionListener(new SelectionAdapter() { |
|
580 public void widgetSelected(SelectionEvent e) { |
|
581 action("thread-binary-function"); //$NON-NLS-1$ |
|
582 } |
|
583 }); |
|
584 } |
|
585 |
|
586 private void threadFunctionItem(Menu menu, boolean chosen) { |
|
587 MenuItem menuItem = new MenuItem(menu, SWT.RADIO); |
|
588 menuItem.setText(Messages.getString("GenericAddrTable.threadFunction")); //$NON-NLS-1$ |
|
589 menuItem.setSelection(chosen); |
|
590 menuItem.addSelectionListener(new SelectionAdapter() { |
|
591 public void widgetSelected(SelectionEvent e) { |
|
592 action("thread-function"); //$NON-NLS-1$ |
|
593 } |
|
594 }); |
|
595 } |
|
596 |
|
597 private void newThreadFunctionBinary(Menu menu, boolean chosen) { |
|
598 MenuItem menuItem = new MenuItem(menu, SWT.RADIO); |
|
599 menuItem.setText(Messages.getString("GenericAddrTable.threadFunctionBinary")); //$NON-NLS-1$ |
|
600 menuItem.setSelection(chosen); |
|
601 menuItem.addSelectionListener(new SelectionAdapter() { |
|
602 public void widgetSelected(SelectionEvent e) { |
|
603 action("thread-function-binary"); //$NON-NLS-1$ |
|
604 } |
|
605 }); |
|
606 } |
|
607 |
|
608 private void binaryItem(Menu menu, boolean chosen) { |
|
609 MenuItem menuItem = new MenuItem(menu, SWT.RADIO); |
|
610 menuItem.setText(Messages.getString("GenericAddrTable.binaryOnly")); //$NON-NLS-1$ |
|
611 menuItem.setSelection(chosen); |
|
612 menuItem.addSelectionListener(new SelectionAdapter() { |
|
613 public void widgetSelected(SelectionEvent e) { |
|
614 action("binary-only"); //$NON-NLS-1$ |
|
615 } |
|
616 }); |
|
617 } |
|
618 |
|
619 private void binaryThreadItem(Menu menu, boolean chosen) { |
|
620 MenuItem menuItem = new MenuItem(menu, SWT.RADIO); |
|
621 menuItem.setText(Messages.getString("GenericAddrTable.binaryThread")); //$NON-NLS-1$ |
|
622 menuItem.setSelection(chosen); |
|
623 menuItem.addSelectionListener(new SelectionAdapter() { |
|
624 public void widgetSelected(SelectionEvent e) { |
|
625 action("binary-thread"); //$NON-NLS-1$ |
|
626 } |
|
627 }); |
|
628 } |
|
629 |
|
630 private void binaryThreadFunctionItem(Menu menu, boolean chosen) { |
|
631 MenuItem menuItem = new MenuItem(menu, SWT.RADIO); |
|
632 menuItem.setText(Messages.getString("GenericAddrTable.binaryThreadFunction")); //$NON-NLS-1$ |
|
633 menuItem.setSelection(chosen); |
|
634 menuItem.addSelectionListener(new SelectionAdapter() { |
|
635 public void widgetSelected(SelectionEvent e) { |
|
636 action("binary-thread-function"); //$NON-NLS-1$ |
|
637 } |
|
638 }); |
|
639 } |
|
640 |
|
641 private void binaryFunctionItem(Menu menu, boolean chosen) { |
|
642 MenuItem menuItem = new MenuItem(menu, SWT.RADIO); |
|
643 menuItem.setText(Messages.getString("GenericAddrTable.binaryFunction")); //$NON-NLS-1$ |
|
644 menuItem.setSelection(chosen); |
|
645 menuItem.addSelectionListener(new SelectionAdapter() { |
|
646 public void widgetSelected(SelectionEvent e) { |
|
647 action("binary-function"); //$NON-NLS-1$ |
|
648 } |
|
649 }); |
|
650 } |
|
651 |
|
652 private void binaryFunctionThreadItem(Menu menu, boolean chosen) { |
|
653 MenuItem menuItem = new MenuItem(menu, SWT.RADIO); |
|
654 menuItem.setText(Messages.getString("GenericAddrTable.binaryFunctionThread")); //$NON-NLS-1$ |
|
655 menuItem.setSelection(chosen); |
|
656 menuItem.addSelectionListener(new SelectionAdapter() { |
|
657 public void widgetSelected(SelectionEvent e) { |
|
658 action("binary-function-thread"); //$NON-NLS-1$ |
|
659 } |
|
660 }); |
|
661 } |
|
662 |
|
663 private void functionItem(Menu menu, boolean chosen) { |
|
664 MenuItem menuItem = new MenuItem(menu, SWT.RADIO); |
|
665 menuItem.setText(Messages.getString("GenericAddrTable.functionOnly")); //$NON-NLS-1$ |
|
666 menuItem.setSelection(chosen); |
|
667 menuItem.addSelectionListener(new SelectionAdapter() { |
|
668 public void widgetSelected(SelectionEvent e) { |
|
669 action("function-only"); //$NON-NLS-1$ |
|
670 } |
|
671 }); |
|
672 } |
|
673 |
|
674 private void functionThreadItem(Menu menu, boolean chosen) { |
|
675 MenuItem menuItem = new MenuItem(menu, SWT.RADIO); |
|
676 menuItem.setText(Messages.getString("GenericAddrTable.functionThread")); //$NON-NLS-1$ |
|
677 menuItem.setSelection(chosen); |
|
678 menuItem.addSelectionListener(new SelectionAdapter() { |
|
679 public void widgetSelected(SelectionEvent e) { |
|
680 action("function-thread"); //$NON-NLS-1$ |
|
681 } |
|
682 }); |
|
683 } |
|
684 |
|
685 private void functionThreadBinaryItem(Menu menu, boolean chosen) { |
|
686 MenuItem menuItem = new MenuItem(menu, SWT.RADIO); |
|
687 menuItem.setText(Messages.getString("GenericAddrTable.functionThreadBinary")); //$NON-NLS-1$ |
|
688 menuItem.setSelection(chosen); |
|
689 menuItem.addSelectionListener(new SelectionAdapter() { |
|
690 public void widgetSelected(SelectionEvent e) { |
|
691 action("function-thread-binary"); //$NON-NLS-1$ |
|
692 } |
|
693 }); |
|
694 } |
|
695 |
|
696 private void functionBinaryItem(Menu menu, boolean chosen) { |
|
697 MenuItem menuItem = new MenuItem(menu, SWT.RADIO); |
|
698 menuItem.setText(Messages.getString("GenericAddrTable.functionBinary")); //$NON-NLS-1$ |
|
699 menuItem.setSelection(chosen); |
|
700 menuItem.addSelectionListener(new SelectionAdapter() { |
|
701 public void widgetSelected(SelectionEvent e) { |
|
702 action("function-binary"); //$NON-NLS-1$ |
|
703 } |
|
704 }); |
|
705 } |
|
706 |
|
707 private void functionBinaryThreadItem(Menu menu, boolean chosen) { |
|
708 MenuItem menuItem = new MenuItem(menu, SWT.RADIO); |
|
709 menuItem.setText(Messages.getString("GenericAddrTable.functionBinaryThread")); //$NON-NLS-1$ |
|
710 menuItem.setSelection(chosen); |
|
711 menuItem.addSelectionListener(new SelectionAdapter() { |
|
712 public void widgetSelected(SelectionEvent e) { |
|
713 action("function-binary-thread"); //$NON-NLS-1$ |
|
714 } |
|
715 }); |
|
716 } |
|
717 |
|
718 protected String copyDrilldown(int tableCount, Table[] tables, String separator) |
|
719 { |
|
720 // make sure it's a valid drilldown |
|
721 if ( (tableCount < 2) || (tableCount > 3) |
|
722 || (tables[0] == null) || (tables[1] == null) |
|
723 || (tableCount == 2 && tables[2] != null) |
|
724 || (tableCount == 3 && tables[2] == null)) |
|
725 return ""; //$NON-NLS-1$ |
|
726 |
|
727 String copyString = ""; //$NON-NLS-1$ |
|
728 |
|
729 // create the multiple table heading line (e.g., "Threads Binaries") |
|
730 // space them out based on how many columns are in their table |
|
731 for (int i = 0; i < tableCount; i++) { |
|
732 if (tables[i].getData() instanceof String) { |
|
733 copyString += (String) (tables[i].getData()); |
|
734 } |
|
735 for (int j = 0; j < tables[i].getColumnCount(); j++) { |
|
736 copyString += separator; |
|
737 } |
|
738 } |
|
739 copyString += "\n"; //$NON-NLS-1$ |
|
740 |
|
741 // create the multiple table column headings |
|
742 for (int i = 0; i < tableCount; i++) { |
|
743 if (i != tableCount - 1) { |
|
744 copyString += copyHeading(tables[i], CHECKBOX_NO_TEXT, separator, separator); //$NON-NLS-1$ |
|
745 } else { |
|
746 copyString += copyHeading(tables[i], CHECKBOX_NO_TEXT, separator, "\n"); //$NON-NLS-1$ |
|
747 } |
|
748 } |
|
749 |
|
750 // determine the row, column count, and column ordering in each table |
|
751 int rowCount0 = tables[0].getItemCount(); |
|
752 int columnCount0 = tables[0].getColumnCount(); |
|
753 int[] columnOrder0 = tables[0].getColumnOrder(); |
|
754 boolean[] isHex0 = (boolean[]) tables[0].getData("isHex"); //$NON-NLS-1$ |
|
755 String emptyRow0 = ""; //$NON-NLS-1$ |
|
756 |
|
757 int rowCount1 = tables[1].getItemCount(); |
|
758 int columnCount1 = tables[1].getColumnCount(); |
|
759 int[] columnOrder1 = tables[1].getColumnOrder(); |
|
760 boolean[] isHex1 = (boolean[]) tables[1].getData("isHex"); //$NON-NLS-1$ |
|
761 String emptyRow1 = ""; //$NON-NLS-1$ |
|
762 |
|
763 int rowCount2 = tableCount > 2 ? tables[2].getItemCount() : 0; |
|
764 int columnCount2 = tableCount > 2 ? tables[2].getColumnCount() : 0; |
|
765 int[] columnOrder2 = tableCount > 2 ? tables[2].getColumnOrder() : null; |
|
766 boolean[] isHex2 = tableCount > 2 ? ((boolean[]) tables[2].getData("isHex")) : null; //$NON-NLS-1$ |
|
767 String emptyRow2 = ""; //$NON-NLS-1$ |
|
768 |
|
769 // determine the number of multiple table rows (max of any table's rows) |
|
770 int rowCount = rowCount0 >= rowCount1 ? rowCount0 : rowCount1; |
|
771 rowCount = rowCount > rowCount2 ? rowCount : rowCount2; |
|
772 |
|
773 // generate empty row strings, to speed things up |
|
774 if (rowCount0 < rowCount) { |
|
775 for (int j = 0; j < columnCount0 - 1; j++) { |
|
776 emptyRow0 += separator; |
|
777 } |
|
778 } |
|
779 |
|
780 if (rowCount1 < rowCount) { |
|
781 for (int j = 0; j < columnCount1; j++) { |
|
782 emptyRow1 += separator; |
|
783 } |
|
784 } |
|
785 |
|
786 if ((tableCount > 2) && (rowCount2 < rowCount)) { |
|
787 for (int j = 0; j < columnCount2; j++) { |
|
788 emptyRow2 += separator; |
|
789 } |
|
790 } |
|
791 |
|
792 // generate the rows |
|
793 for (int i = 0; i < rowCount; i++) { |
|
794 if (i < rowCount0) { |
|
795 copyString += copyRow(isHex0, tables[0].getItem(i), CHECKBOX_NO_TEXT, columnCount0, columnOrder0, separator); |
|
796 } else { |
|
797 copyString += emptyRow0; |
|
798 } |
|
799 |
|
800 if (i < rowCount1) { |
|
801 copyString += separator + copyRow(isHex1, tables[1].getItem(i), CHECKBOX_NO_TEXT, columnCount1, columnOrder1, separator); |
|
802 } else { |
|
803 // NOTE: if this is the last table, or the 3rd table has nothing but empty |
|
804 // rows left, we may not need to fill in these fields |
|
805 copyString += emptyRow1; |
|
806 } |
|
807 |
|
808 if (tableCount > 2) { |
|
809 if (i < rowCount2) { |
|
810 copyString += separator + copyRow(isHex2, tables[2].getItem(i), CHECKBOX_NO_TEXT, columnCount2, columnOrder2, separator); |
|
811 } else { |
|
812 // NOTE: we may not need to fill in the empty fields of the last table |
|
813 copyString += emptyRow2; |
|
814 } |
|
815 } |
|
816 |
|
817 copyString += "\n"; //$NON-NLS-1$ |
|
818 } |
|
819 |
|
820 return copyString; |
|
821 } |
|
822 |
|
823 // class to pass drilldown tables to the save wizard |
|
824 class SaveDrillDownString implements ISaveTable { |
|
825 private int tableCount; |
|
826 private Table[] tables; |
|
827 private String separator; |
|
828 |
|
829 public SaveDrillDownString(int tableCount, Table[] tables, String separator) { |
|
830 this.tableCount = tableCount; |
|
831 this.tables = tables; |
|
832 this.separator = separator; |
|
833 } |
|
834 |
|
835 public String getData() { |
|
836 return copyDrilldown(tableCount, tables, separator); |
|
837 } |
|
838 } |
|
839 |
|
840 public Table[] getDrillDownTables() |
|
841 { |
|
842 // copy all tables in a drilldown to the clipboard or save to a file |
|
843 int drawMode = this.myGraph.getDrawMode(); |
|
844 |
|
845 int tableCount = 0; |
|
846 Table[] tables = new Table[3]; |
|
847 |
|
848 // determine which tables are in the drilldown |
|
849 switch (drawMode) |
|
850 { |
|
851 case Defines.THREADS_BINARIES: |
|
852 tables[tableCount++] = this.myGraph.getThreadTable().getTable(); |
|
853 tables[tableCount++] = this.myGraph.getBinaryTable().getTable(); |
|
854 break; |
|
855 case Defines.THREADS_BINARIES_FUNCTIONS: |
|
856 tables[tableCount++] = this.myGraph.getThreadTable().getTable(); |
|
857 tables[tableCount++] = this.myGraph.getBinaryTable().getTable(); |
|
858 tables[tableCount++] = this.myGraph.getFunctionTable().getTable(); |
|
859 break; |
|
860 case Defines.THREADS_FUNCTIONS: |
|
861 tables[tableCount++] = this.myGraph.getThreadTable().getTable(); |
|
862 tables[tableCount++] = this.myGraph.getFunctionTable().getTable(); |
|
863 break; |
|
864 case Defines.THREADS_FUNCTIONS_BINARIES: |
|
865 tables[tableCount++] = this.myGraph.getThreadTable().getTable(); |
|
866 tables[tableCount++] = this.myGraph.getFunctionTable().getTable(); |
|
867 tables[tableCount++] = this.myGraph.getBinaryTable().getTable(); |
|
868 break; |
|
869 case Defines.BINARIES_THREADS: |
|
870 tables[tableCount++] = this.myGraph.getBinaryTable().getTable(); |
|
871 tables[tableCount++] = this.myGraph.getThreadTable().getTable(); |
|
872 break; |
|
873 case Defines.BINARIES_THREADS_FUNCTIONS: |
|
874 tables[tableCount++] = this.myGraph.getBinaryTable().getTable(); |
|
875 tables[tableCount++] = this.myGraph.getThreadTable().getTable(); |
|
876 tables[tableCount++] = this.myGraph.getFunctionTable().getTable(); |
|
877 break; |
|
878 case Defines.BINARIES_FUNCTIONS: |
|
879 tables[tableCount++] = this.myGraph.getBinaryTable().getTable(); |
|
880 tables[tableCount++] = this.myGraph.getFunctionTable().getTable(); |
|
881 break; |
|
882 case Defines.BINARIES_FUNCTIONS_THREADS: |
|
883 tables[tableCount++] = this.myGraph.getBinaryTable().getTable(); |
|
884 tables[tableCount++] = this.myGraph.getFunctionTable().getTable(); |
|
885 tables[tableCount++] = this.myGraph.getThreadTable().getTable(); |
|
886 break; |
|
887 case Defines.FUNCTIONS_THREADS: |
|
888 tables[tableCount++] = this.myGraph.getFunctionTable().getTable(); |
|
889 tables[tableCount++] = this.myGraph.getThreadTable().getTable(); |
|
890 break; |
|
891 case Defines.FUNCTIONS_THREADS_BINARIES: |
|
892 tables[tableCount++] = this.myGraph.getFunctionTable().getTable(); |
|
893 tables[tableCount++] = this.myGraph.getThreadTable().getTable(); |
|
894 tables[tableCount++] = this.myGraph.getBinaryTable().getTable(); |
|
895 break; |
|
896 case Defines.FUNCTIONS_BINARIES: |
|
897 tables[tableCount++] = this.myGraph.getFunctionTable().getTable(); |
|
898 tables[tableCount++] = this.myGraph.getBinaryTable().getTable(); |
|
899 break; |
|
900 case Defines.FUNCTIONS_BINARIES_THREADS: |
|
901 tables[tableCount++] = this.myGraph.getFunctionTable().getTable(); |
|
902 tables[tableCount++] = this.myGraph.getBinaryTable().getTable(); |
|
903 tables[tableCount++] = this.myGraph.getThreadTable().getTable(); |
|
904 break; |
|
905 default: |
|
906 } |
|
907 |
|
908 return tables; |
|
909 } |
|
910 |
|
911 protected void actionCopyOrSaveDrilldown(boolean doCopy, String separator) |
|
912 { |
|
913 Table[] tables = getDrillDownTables(); |
|
914 |
|
915 int tableCount = 0; |
|
916 while ((tableCount < tables.length) && (tables[tableCount] != null)) |
|
917 tableCount++; |
|
918 |
|
919 |
|
920 if (doCopy) { |
|
921 // change the clipboard contents |
|
922 Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); |
|
923 String copyString = copyDrilldown(tableCount, tables, separator); |
|
924 StringSelection contents = new StringSelection(copyString); |
|
925 cb.setContents(contents, contents); |
|
926 } else { |
|
927 // save to a file |
|
928 SaveDrillDownString getString = new SaveDrillDownString(tableCount, tables, separator); |
|
929 WizardDialog dialog; |
|
930 Wizard w = new SaveTableWizard(getString); |
|
931 dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), w); |
|
932 dialog.open(); |
|
933 } |
|
934 } |
|
935 |
|
936 protected void createDefaultActions() |
|
937 { |
|
938 selectAllAction = new Action("SelectAll") { //$NON-NLS-1$ |
|
939 public void run() { |
|
940 action("selectAll"); //$NON-NLS-1$ |
|
941 } |
|
942 }; |
|
943 selectAllAction.setEnabled(true); |
|
944 |
|
945 copyAction = new Action("Copy") { //$NON-NLS-1$ |
|
946 public void run() { |
|
947 action("copy"); //$NON-NLS-1$ |
|
948 } |
|
949 }; |
|
950 copyAction.setEnabled(false); |
|
951 |
|
952 copyTableAction = new Action("CopyTable") { //$NON-NLS-1$ |
|
953 public void run() { |
|
954 action("copyTable"); //$NON-NLS-1$ |
|
955 } |
|
956 }; |
|
957 copyTableAction.setEnabled(true); |
|
958 copyTableAction.setId("PICopyTable"); //$NON-NLS-1$ |
|
959 copyTableAction.setText(Messages.getString("GenericAddrTable.copyTable")); //$NON-NLS-1$ |
|
960 |
|
961 copyDrilldownAction = new Action("CopyDrilldown") { //$NON-NLS-1$ |
|
962 public void run() { |
|
963 action("copyDrilldown"); //$NON-NLS-1$ |
|
964 } |
|
965 }; |
|
966 copyDrilldownAction.setEnabled(false); |
|
967 copyDrilldownAction.setId("PICopyDrilldown"); //$NON-NLS-1$ |
|
968 copyDrilldownAction.setText(Messages.getString("GenericAddrTable.copyDrilldownTables")); //$NON-NLS-1$ |
|
969 |
|
970 saveTableAction = new Action("SaveTable") { //$NON-NLS-1$ |
|
971 public void run() { |
|
972 action("saveTable"); //$NON-NLS-1$ |
|
973 } |
|
974 }; |
|
975 saveTableAction.setEnabled(true); |
|
976 saveTableAction.setId("PISaveTable"); //$NON-NLS-1$ |
|
977 saveTableAction.setText(Messages.getString("GenericAddrTable.saveTable")); //$NON-NLS-1$ |
|
978 |
|
979 saveDrilldownAction = new Action("SaveDrilldown") { //$NON-NLS-1$ |
|
980 public void run() { |
|
981 action("saveDrilldown"); //$NON-NLS-1$ |
|
982 } |
|
983 }; |
|
984 saveDrilldownAction.setEnabled(false); |
|
985 saveDrilldownAction.setId("PISaveDrilldown"); //$NON-NLS-1$ |
|
986 saveDrilldownAction.setText(Messages.getString("GenericAddrTable.saveDrilldownTables")); //$NON-NLS-1$ |
|
987 |
|
988 // saveSamplesAction = new Action("SaveSamples") { //$NON-NLS-1$ |
|
989 // public void run() { |
|
990 // action("saveSamples"); //$NON-NLS-1$ |
|
991 // } |
|
992 // }; |
|
993 // saveSamplesAction.setEnabled(true); |
|
994 // saveSamplesAction.setId("PISaveAddressSamples"); //$NON-NLS-1$ |
|
995 // saveSamplesAction.setText(Messages.getString("GenericAddrTable.23") + sampleType + Messages.getString("GenericAddrTable.24")); //$NON-NLS-1$ //$NON-NLS-2$ |
|
996 } |
|
997 |
|
998 public void setIsDrilldown(boolean isDrilldown) |
|
999 { |
|
1000 this.isDrilldown = isDrilldown; |
|
1001 copyDrilldownAction.setEnabled(isDrilldown); |
|
1002 saveDrilldownAction.setEnabled(isDrilldown); |
|
1003 |
|
1004 // may need to clean up stale Edit & File menu entry for PICopyDrilldown and PISaveDrilldown |
|
1005 if (!isDrilldown) { |
|
1006 IMenuManager editMenuManager = PIPageEditor.getActionBars().getMenuManager().findMenuUsingPath(IIDEActionConstants.M_EDIT); |
|
1007 |
|
1008 if (editMenuManager instanceof SubMenuManager) |
|
1009 { |
|
1010 IContributionManager editManager = ((SubMenuManager)editMenuManager).getParent(); |
|
1011 ActionContributionItem item; |
|
1012 |
|
1013 editMenuManager.remove("PICopyDrilldown"); //$NON-NLS-1$ |
|
1014 item = new ActionContributionItem(copyDrilldownAction); |
|
1015 item.setVisible(true); |
|
1016 editManager.prependToGroup(IIDEActionConstants.CUT_EXT, item); |
|
1017 |
|
1018 editMenuManager.remove("PICopyTable"); //$NON-NLS-1$ |
|
1019 copyTableAction.setEnabled(table.getItemCount() > 0); |
|
1020 item = new ActionContributionItem(copyTableAction); |
|
1021 item.setVisible(true); |
|
1022 editManager.prependToGroup(IIDEActionConstants.CUT_EXT, item); |
|
1023 } |
|
1024 |
|
1025 IMenuManager fileMenuManager = PIPageEditor.getActionBars().getMenuManager().findMenuUsingPath(IIDEActionConstants.M_FILE); |
|
1026 |
|
1027 if (fileMenuManager instanceof SubMenuManager) |
|
1028 { |
|
1029 IContributionManager fileManager = ((SubMenuManager)fileMenuManager).getParent(); |
|
1030 ActionContributionItem item; |
|
1031 |
|
1032 fileMenuManager.remove("PISaveTable"); //$NON-NLS-1$ |
|
1033 saveTableAction.setEnabled(table.getItemCount() > 0); |
|
1034 item = new ActionContributionItem(saveTableAction); |
|
1035 item.setVisible(true); |
|
1036 fileManager.insertAfter("saveAll", item); //$NON-NLS-1$ |
|
1037 |
|
1038 fileMenuManager.remove("PISaveDrilldown"); //$NON-NLS-1$ |
|
1039 item = new ActionContributionItem(saveDrilldownAction); |
|
1040 item.setVisible(true); |
|
1041 fileManager.insertAfter("PISaveTable", item); //$NON-NLS-1$ |
|
1042 fileManager.update(true); |
|
1043 } |
|
1044 } |
|
1045 } |
|
1046 |
|
1047 protected MenuItem getCopyDrilldownItem(Menu menu, boolean enabled) { |
|
1048 MenuItem copyDrilldownItem = new MenuItem(menu, SWT.PUSH); |
|
1049 |
|
1050 copyDrilldownItem.setText(Messages.getString("GenericAddrTable.copyDrilldownTables")); //$NON-NLS-1$ |
|
1051 copyDrilldownItem.setEnabled(enabled); |
|
1052 |
|
1053 if (enabled) { |
|
1054 copyDrilldownItem.addSelectionListener(new SelectionAdapter() { |
|
1055 public void widgetSelected(SelectionEvent e) { |
|
1056 action("copyDrilldown"); //$NON-NLS-1$ |
|
1057 } |
|
1058 }); |
|
1059 } |
|
1060 |
|
1061 return copyDrilldownItem; |
|
1062 } |
|
1063 |
|
1064 protected MenuItem getSaveDrilldownItem(Menu menu, boolean enabled) { |
|
1065 MenuItem saveDrilldownItem = new MenuItem(menu, SWT.PUSH); |
|
1066 |
|
1067 saveDrilldownItem.setText(Messages.getString("GenericAddrTable.saveDrilldownTables")); //$NON-NLS-1$ |
|
1068 saveDrilldownItem.setEnabled(enabled); |
|
1069 |
|
1070 if (enabled) { |
|
1071 saveDrilldownItem.addSelectionListener(new SelectionAdapter() { |
|
1072 public void widgetSelected(SelectionEvent e) { |
|
1073 action("saveDrilldown"); //$NON-NLS-1$ |
|
1074 } |
|
1075 }); |
|
1076 } |
|
1077 |
|
1078 return saveDrilldownItem; |
|
1079 } |
|
1080 |
|
1081 protected class AddrTableFocusListener implements FocusListener |
|
1082 { |
|
1083 IAction oldSelectAllAction = null; |
|
1084 IAction oldCopyAction = null; |
|
1085 |
|
1086 public void focusGained(org.eclipse.swt.events.FocusEvent arg0) { |
|
1087 IActionBars bars = PIPageEditor.getActionBars(); |
|
1088 |
|
1089 // modify what is executed when Select All and Copy are called from the Edit menu |
|
1090 oldSelectAllAction = bars.getGlobalActionHandler(ActionFactory.SELECT_ALL.getId()); |
|
1091 oldCopyAction = bars.getGlobalActionHandler(ActionFactory.COPY.getId()); |
|
1092 |
|
1093 bars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction); |
|
1094 bars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), selectAllAction); |
|
1095 |
|
1096 copyAction.setEnabled(table.getSelectionCount() > 0); |
|
1097 selectAllAction.setEnabled(table.getItemCount() > 0); |
|
1098 bars.updateActionBars(); |
|
1099 |
|
1100 // add to the Edit menu |
|
1101 IMenuManager editMenuManager = bars.getMenuManager().findMenuUsingPath(IIDEActionConstants.M_EDIT); |
|
1102 |
|
1103 if (editMenuManager instanceof SubMenuManager) |
|
1104 { |
|
1105 IContributionManager editManager = ((SubMenuManager)editMenuManager).getParent(); |
|
1106 ActionContributionItem item; |
|
1107 |
|
1108 editMenuManager.remove("PICopyDrilldown"); //$NON-NLS-1$ |
|
1109 item = new ActionContributionItem(copyDrilldownAction); |
|
1110 item.setVisible(true); |
|
1111 editManager.prependToGroup(IIDEActionConstants.CUT_EXT, item); |
|
1112 |
|
1113 editMenuManager.remove("PICopyTable"); //$NON-NLS-1$ |
|
1114 copyTableAction.setEnabled(table.getItemCount() > 0); |
|
1115 item = new ActionContributionItem(copyTableAction); |
|
1116 item.setVisible(true); |
|
1117 editManager.prependToGroup(IIDEActionConstants.CUT_EXT, item); |
|
1118 } |
|
1119 |
|
1120 // add to the File menu |
|
1121 IMenuManager fileMenuManager = bars.getMenuManager().findMenuUsingPath(IIDEActionConstants.M_FILE); |
|
1122 |
|
1123 if (fileMenuManager instanceof SubMenuManager) |
|
1124 { |
|
1125 IContributionManager fileManager = ((SubMenuManager)fileMenuManager).getParent(); |
|
1126 ActionContributionItem item; |
|
1127 |
|
1128 fileMenuManager.remove("PISaveTable"); //$NON-NLS-1$ |
|
1129 saveTableAction.setEnabled(table.getItemCount() > 0); |
|
1130 item = new ActionContributionItem(saveTableAction); |
|
1131 item.setVisible(true); |
|
1132 fileManager.insertAfter("saveAll", item); //$NON-NLS-1$ |
|
1133 |
|
1134 fileMenuManager.remove("PISaveDrilldown"); //$NON-NLS-1$ |
|
1135 item = new ActionContributionItem(saveDrilldownAction); |
|
1136 item.setVisible(true); |
|
1137 fileManager.insertAfter("PISaveTable", item); //$NON-NLS-1$ |
|
1138 } |
|
1139 } |
|
1140 |
|
1141 public void focusLost(org.eclipse.swt.events.FocusEvent arg0) { |
|
1142 IActionBars bars = PIPageEditor.getActionBars(); |
|
1143 bars.setGlobalActionHandler(ActionFactory.COPY.getId(), oldCopyAction); |
|
1144 bars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), oldSelectAllAction); |
|
1145 bars.updateActionBars(); |
|
1146 |
|
1147 SubMenuManager editMenuManager = (SubMenuManager) PIPageEditor.getMenuManager().find(IIDEActionConstants.M_EDIT); |
|
1148 editMenuManager.remove("PICopyTable"); //$NON-NLS-1$ |
|
1149 editMenuManager.remove("PICopyDrilldown"); //$NON-NLS-1$ |
|
1150 |
|
1151 SubMenuManager fileMenuManager = (SubMenuManager) PIPageEditor.getMenuManager().find(IIDEActionConstants.M_FILE); |
|
1152 fileMenuManager.remove("PISaveTable"); //$NON-NLS-1$ |
|
1153 fileMenuManager.remove("PISaveDrilldown"); //$NON-NLS-1$ |
|
1154 } |
|
1155 } |
|
1156 } |