changeset 6 | f65f740e69f9 |
parent 1 | 1050670c6980 |
child 15 | 0367d2db2c06 |
5:844b047e260d | 6:f65f740e69f9 |
---|---|
1 /* |
1 /* |
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
37 import org.eclipse.core.runtime.IStatus; |
37 import org.eclipse.core.runtime.IStatus; |
38 import org.eclipse.core.runtime.Path; |
38 import org.eclipse.core.runtime.Path; |
39 import org.eclipse.core.runtime.Status; |
39 import org.eclipse.core.runtime.Status; |
40 import org.eclipse.core.runtime.jobs.Job; |
40 import org.eclipse.core.runtime.jobs.Job; |
41 import org.eclipse.jface.action.Action; |
41 import org.eclipse.jface.action.Action; |
42 import org.eclipse.jface.action.IAction; |
|
42 import org.eclipse.jface.action.IMenuListener; |
43 import org.eclipse.jface.action.IMenuListener; |
43 import org.eclipse.jface.action.IMenuManager; |
44 import org.eclipse.jface.action.IMenuManager; |
44 import org.eclipse.jface.action.IToolBarManager; |
45 import org.eclipse.jface.action.IToolBarManager; |
45 import org.eclipse.jface.action.MenuManager; |
46 import org.eclipse.jface.action.MenuManager; |
46 import org.eclipse.jface.action.Separator; |
47 import org.eclipse.jface.action.Separator; |
58 import org.eclipse.jface.viewers.StructuredSelection; |
59 import org.eclipse.jface.viewers.StructuredSelection; |
59 import org.eclipse.jface.viewers.TreeExpansionEvent; |
60 import org.eclipse.jface.viewers.TreeExpansionEvent; |
60 import org.eclipse.jface.viewers.TreeViewer; |
61 import org.eclipse.jface.viewers.TreeViewer; |
61 import org.eclipse.jface.viewers.Viewer; |
62 import org.eclipse.jface.viewers.Viewer; |
62 import org.eclipse.jface.viewers.ViewerSorter; |
63 import org.eclipse.jface.viewers.ViewerSorter; |
64 import org.eclipse.jface.window.Window; |
|
63 import org.eclipse.swt.SWT; |
65 import org.eclipse.swt.SWT; |
64 import org.eclipse.swt.custom.CTabFolder; |
66 import org.eclipse.swt.custom.CTabFolder; |
65 import org.eclipse.swt.custom.CTabItem; |
67 import org.eclipse.swt.custom.CTabItem; |
66 import org.eclipse.swt.custom.SashForm; |
68 import org.eclipse.swt.custom.SashForm; |
67 import org.eclipse.swt.dnd.Clipboard; |
69 import org.eclipse.swt.dnd.Clipboard; |
68 import org.eclipse.swt.dnd.TextTransfer; |
70 import org.eclipse.swt.dnd.TextTransfer; |
69 import org.eclipse.swt.dnd.Transfer; |
71 import org.eclipse.swt.dnd.Transfer; |
72 import org.eclipse.swt.events.DisposeEvent; |
|
73 import org.eclipse.swt.events.DisposeListener; |
|
70 import org.eclipse.swt.events.KeyEvent; |
74 import org.eclipse.swt.events.KeyEvent; |
71 import org.eclipse.swt.events.KeyListener; |
75 import org.eclipse.swt.events.KeyListener; |
76 import org.eclipse.swt.events.SelectionEvent; |
|
77 import org.eclipse.swt.events.SelectionListener; |
|
72 import org.eclipse.swt.graphics.Image; |
78 import org.eclipse.swt.graphics.Image; |
73 import org.eclipse.swt.layout.GridData; |
79 import org.eclipse.swt.layout.GridData; |
74 import org.eclipse.swt.widgets.Composite; |
80 import org.eclipse.swt.widgets.Composite; |
75 import org.eclipse.swt.widgets.Label; |
81 import org.eclipse.swt.widgets.Label; |
76 import org.eclipse.swt.widgets.Menu; |
82 import org.eclipse.swt.widgets.Menu; |
82 import org.eclipse.ui.IWorkbenchPage; |
88 import org.eclipse.ui.IWorkbenchPage; |
83 import org.eclipse.ui.IWorkbenchPart; |
89 import org.eclipse.ui.IWorkbenchPart; |
84 import org.eclipse.ui.PlatformUI; |
90 import org.eclipse.ui.PlatformUI; |
85 import org.eclipse.ui.dialogs.PreferencesUtil; |
91 import org.eclipse.ui.dialogs.PreferencesUtil; |
86 import org.eclipse.ui.ide.IDE; |
92 import org.eclipse.ui.ide.IDE; |
93 import org.eclipse.ui.navigator.CommonNavigator; |
|
87 import org.eclipse.ui.part.ViewPart; |
94 import org.eclipse.ui.part.ViewPart; |
95 import org.eclipse.ui.views.navigator.ResourceNavigator; |
|
88 |
96 |
89 import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin; |
97 import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin; |
90 import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration; |
98 import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration; |
91 import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo; |
99 import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo; |
100 import com.nokia.carbide.cpp.internal.project.ui.views.SymbianProjectNavigatorView; |
|
92 import com.nokia.s60tools.analyzetool.Activator; |
101 import com.nokia.s60tools.analyzetool.Activator; |
93 import com.nokia.s60tools.analyzetool.AnalyzeToolHelpContextIDs; |
102 import com.nokia.s60tools.analyzetool.AnalyzeToolHelpContextIDs; |
94 import com.nokia.s60tools.analyzetool.builder.BuilderUtil; |
103 import com.nokia.s60tools.analyzetool.builder.BuilderUtil; |
95 import com.nokia.s60tools.analyzetool.engine.AnalysisItem; |
104 import com.nokia.s60tools.analyzetool.engine.AnalysisItem; |
96 import com.nokia.s60tools.analyzetool.engine.AnalyzeFactory; |
105 import com.nokia.s60tools.analyzetool.engine.AnalyzeFactory; |
97 import com.nokia.s60tools.analyzetool.engine.CallstackItem; |
106 import com.nokia.s60tools.analyzetool.engine.CallstackItem; |
107 import com.nokia.s60tools.analyzetool.engine.DeferredCallstackManager; |
|
98 import com.nokia.s60tools.analyzetool.engine.EpocReader; |
108 import com.nokia.s60tools.analyzetool.engine.EpocReader; |
99 import com.nokia.s60tools.analyzetool.engine.IMemoryActivityModel; |
109 import com.nokia.s60tools.analyzetool.engine.IMemoryActivityModel; |
100 import com.nokia.s60tools.analyzetool.engine.MMPInfo; |
110 import com.nokia.s60tools.analyzetool.engine.MMPInfo; |
101 import com.nokia.s60tools.analyzetool.engine.ParseAnalyzeData; |
111 import com.nokia.s60tools.analyzetool.engine.ParseAnalyzeData; |
102 import com.nokia.s60tools.analyzetool.engine.ParseXMLFileSAX; |
112 import com.nokia.s60tools.analyzetool.engine.ParseXMLFileSAX; |
103 import com.nokia.s60tools.analyzetool.engine.ProjectResults; |
113 import com.nokia.s60tools.analyzetool.engine.ProjectResults; |
104 import com.nokia.s60tools.analyzetool.engine.RunResults; |
114 import com.nokia.s60tools.analyzetool.engine.RunResults; |
115 import com.nokia.s60tools.analyzetool.engine.SimpleCallstackManager; |
|
105 import com.nokia.s60tools.analyzetool.engine.UseAtool; |
116 import com.nokia.s60tools.analyzetool.engine.UseAtool; |
106 import com.nokia.s60tools.analyzetool.engine.statistic.ProcessInfo; |
117 import com.nokia.s60tools.analyzetool.engine.statistic.ProcessInfo; |
107 import com.nokia.s60tools.analyzetool.engine.statistic.ReadFile; |
118 import com.nokia.s60tools.analyzetool.engine.statistic.ReadFile; |
108 import com.nokia.s60tools.analyzetool.global.Constants; |
119 import com.nokia.s60tools.analyzetool.global.Constants; |
109 import com.nokia.s60tools.analyzetool.global.Util; |
120 import com.nokia.s60tools.analyzetool.global.Util; |
111 import com.nokia.s60tools.analyzetool.ui.actions.DropDownMenu; |
122 import com.nokia.s60tools.analyzetool.ui.actions.DropDownMenu; |
112 import com.nokia.s60tools.analyzetool.ui.actions.FileActionHistory; |
123 import com.nokia.s60tools.analyzetool.ui.actions.FileActionHistory; |
113 import com.nokia.s60tools.analyzetool.ui.statistic.StatisticView; |
124 import com.nokia.s60tools.analyzetool.ui.statistic.StatisticView; |
114 |
125 |
115 /** |
126 /** |
116 * Class to display memory analysis results also provides all the |
127 * AnalyzeTool main view which displays memory analysis results and provides |
117 * functionalities what AnalyzeTool has. |
128 * interface for all the functionalities what AnalyzeTool has. |
118 * |
129 * |
119 * @author kihe |
130 * @author kihe |
120 * |
131 * |
121 */ |
132 */ |
122 public class MainView extends ViewPart implements ISelectionListener, |
133 public class MainView extends ViewPart implements ISelectionListener, |
123 ITreeViewerListener, IActionListener, ISelectionChangedListener, KeyListener { |
134 ITreeViewerListener, IActionListener, ISelectionChangedListener, |
135 KeyListener { |
|
124 |
136 |
125 /** |
137 /** |
126 * Sorts tree view objects. |
138 * Sorts tree view objects. |
127 * |
139 * |
128 * @author kihe |
140 * @author kihe |
129 */ |
141 */ |
130 public static class NameSorter extends ViewerSorter { |
142 public static class NameSorter extends ViewerSorter { |
131 |
143 |
132 /** |
144 /** |
133 * Compares view items. |
145 * Compares view items. |
134 * |
146 * |
135 * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, |
147 * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, |
136 * java.lang.Object, java.lang.Object) |
148 * java.lang.Object, java.lang.Object) |
137 * |
149 * |
138 * @param viewer |
150 * @param viewer |
139 * Viewer |
151 * Viewer |
140 * @param e1 |
152 * @param e1 |
141 * Object |
153 * Object |
142 * @param e2 |
154 * @param e2 |
157 * example). |
169 * example). |
158 */ |
170 */ |
159 class ViewContentProvider implements ITreeContentProvider { |
171 class ViewContentProvider implements ITreeContentProvider { |
160 |
172 |
161 /** |
173 /** |
162 * |
174 * |
163 * @see org.eclipse.jface.viewers.IContentProvider#dispose() |
175 * @see org.eclipse.jface.viewers.IContentProvider#dispose() |
164 */ |
176 */ |
165 public void dispose() { |
177 public void dispose() { |
166 // MethodDeclaration/Block[count(BlockStatement) = 0 and |
178 // MethodDeclaration/Block[count(BlockStatement) = 0 and |
167 // @containsComment = 'false'] |
179 // @containsComment = 'false'] |
168 } |
180 } |
169 |
181 |
170 /** |
182 /** |
171 * |
183 * |
172 * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) |
184 * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) |
173 */ |
185 */ |
174 public Object[] getChildren(Object parent) { |
186 public Object[] getChildren(Object parent) { |
175 if (parent instanceof TreeParent) { |
187 if (parent instanceof TreeParent) { |
176 return ((TreeParent) parent).getChildren(); |
188 return ((TreeParent) parent).getChildren(); |
178 return new Object[0]; |
190 return new Object[0]; |
179 } |
191 } |
180 |
192 |
181 /* |
193 /* |
182 * (non-Javadoc) |
194 * (non-Javadoc) |
183 * |
195 * |
184 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) |
196 * @see |
197 * org.eclipse.jface.viewers.IStructuredContentProvider#getElements( |
|
198 * java.lang.Object) |
|
185 */ |
199 */ |
186 public Object[] getElements(Object parent) { |
200 public Object[] getElements(Object parent) { |
187 if (parent.equals(getViewSite())) { |
201 if (parent.equals(getViewSite())) { |
188 if (invisibleRoot == null) { |
202 if (invisibleRoot == null) { |
189 getStartupContent(); |
203 getStartupContent(); |
193 return getChildren(parent); |
207 return getChildren(parent); |
194 } |
208 } |
195 |
209 |
196 /* |
210 /* |
197 * (non-Javadoc) |
211 * (non-Javadoc) |
198 * |
212 * |
199 * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) |
213 * @see |
214 * org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang |
|
215 * .Object) |
|
200 */ |
216 */ |
201 public Object getParent(Object child) { |
217 public Object getParent(Object child) { |
202 if (child instanceof TreeObject) { |
218 if (child instanceof TreeObject) { |
203 return ((TreeObject) child).getParent(); |
219 return ((TreeObject) child).getParent(); |
204 } |
220 } |
205 return null; |
221 return null; |
206 } |
222 } |
207 |
223 |
208 /* |
224 /* |
209 * (non-Javadoc) |
225 * (non-Javadoc) |
210 * |
226 * |
211 * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) |
227 * @see |
228 * org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang |
|
229 * .Object) |
|
212 */ |
230 */ |
213 public boolean hasChildren(Object parent) { |
231 public boolean hasChildren(Object parent) { |
214 if (parent instanceof TreeParent) { |
232 if (parent instanceof TreeParent) { |
215 return ((TreeParent) parent).hasChildren(); |
233 return ((TreeParent) parent).hasChildren(); |
216 } |
234 } |
217 return false; |
235 return false; |
218 } |
236 } |
219 |
237 |
220 /* |
238 /* |
221 * (non-Javadoc) |
239 * (non-Javadoc) |
222 * |
240 * |
223 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, |
241 * @see |
224 * java.lang.Object, java.lang.Object) |
242 * org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse |
243 * .jface.viewers.Viewer, java.lang.Object, java.lang.Object) |
|
225 */ |
244 */ |
226 public void inputChanged(Viewer v, Object oldInput, Object newInput) { |
245 public void inputChanged(Viewer v, Object oldInput, Object newInput) { |
227 // MethodDeclaration/Block[count(BlockStatement) = 0 and |
246 // MethodDeclaration/Block[count(BlockStatement) = 0 and |
228 // @containsComment = 'false'] |
247 // @containsComment = 'false'] |
229 } |
248 } |
230 |
249 |
231 } |
250 } |
232 |
251 |
233 /** |
252 /** |
234 * Provides elements of tree view. |
253 * Provides elements of tree view. |
235 * |
254 * |
236 * @author kihe |
255 * @author kihe |
237 * |
256 * |
238 */ |
257 */ |
239 public class ViewLabelProvider extends LabelProvider { |
258 public class ViewLabelProvider extends LabelProvider { |
240 |
259 |
241 /** |
260 /** |
242 * Used when tree model item is TreeParent. |
261 * Used when tree model item is TreeParent. |
283 .createImage(); |
302 .createImage(); |
284 } |
303 } |
285 |
304 |
286 /** |
305 /** |
287 * Gets current tree object image. |
306 * Gets current tree object image. |
288 * |
307 * |
289 * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) |
308 * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) |
290 * |
309 * |
291 * @param obj |
310 * @param obj |
292 * Current tree model item |
311 * Current tree model item |
293 * @return Corresponding image of tree view object |
312 * @return Corresponding image of tree view object |
294 */ |
313 */ |
295 @Override |
314 @Override |
322 return element; |
341 return element; |
323 } |
342 } |
324 |
343 |
325 /** |
344 /** |
326 * Gets current tree view object name. |
345 * Gets current tree view object name. |
327 * |
346 * |
328 * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) |
347 * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) |
329 * |
348 * |
330 * @return Current tree view object name |
349 * @return Current tree view object name |
331 */ |
350 */ |
332 @Override |
351 @Override |
333 public final String getText(final Object obj) { |
352 public final String getText(final Object obj) { |
334 return obj.toString(); |
353 return obj.toString(); |
359 private Action clickAction; |
378 private Action clickAction; |
360 /** Change detail level action. */ |
379 /** Change detail level action. */ |
361 public Action changeDetails; |
380 public Action changeDetails; |
362 /** Select S60 log file action. */ |
381 /** Select S60 log file action. */ |
363 private Action s60LogTargetAction; |
382 private Action s60LogTargetAction; |
364 /** Select Tracing utility connection action. */ |
383 /** Select TraceViewer connection action. */ |
365 private Action externalLogTargetAction; |
384 private Action externalLogTargetAction; |
366 /** Select fast data gathering mode */ |
385 /** Select fast data gathering mode */ |
367 private Action externalFastLogTargetAction; |
386 private Action externalFastLogTargetAction; |
368 /** Select Ask always action. */ |
387 /** Select Ask always action. */ |
369 private Action askLogTargetAction; |
388 private Action askLogTargetAction; |
381 public Action traceAction; |
400 public Action traceAction; |
382 /** Start subtest action. */ |
401 /** Start subtest action. */ |
383 private Action startSubtest; |
402 private Action startSubtest; |
384 /** Stop subtest action. */ |
403 /** Stop subtest action. */ |
385 private Action stopSubtest; |
404 private Action stopSubtest; |
386 /**Refresh(re-creates) project results*/ |
405 /** Refresh(re-creates) project results */ |
387 private Action refreshResults; |
406 private Action refreshResults; |
388 /**Copies selected memory leak item info to the clipboard.*/ |
407 /** Copies selected memory leak item info to the clipboard. */ |
389 private Action copyAction; |
408 private Action copyAction; |
390 /** Action to open AnalyzeTool preference page.*/ |
409 /** Action to open AnalyzeTool preference page. */ |
391 private Action openPrefs; |
410 private Action openPrefs; |
392 /** |
411 /** |
393 * Clears selected project results without removing temporary files |
412 * Clears selected project results without removing temporary files |
394 */ |
413 */ |
395 private Action clearProjectResults; |
414 private Action clearProjectResults; |
428 private final ProjectResults projectResults; |
447 private final ProjectResults projectResults; |
429 |
448 |
430 /** Job for analyzing data files. */ |
449 /** Job for analyzing data files. */ |
431 private Job analyzeJob; |
450 private Job analyzeJob; |
432 |
451 |
452 /** Job for reading the data files for the graph. */ |
|
453 private GraphLoadJob graphLoadJob; |
|
454 |
|
433 /** Last selected tree item. */ |
455 /** Last selected tree item. */ |
434 private Object lastSelectedObject; |
456 private Object lastSelectedObject; |
435 |
457 |
436 /** Contains information of which files is opened. */ |
458 /** Contains information of which files were opened. */ |
437 public FileActionHistory fileOpenHistory; |
459 public FileActionHistory fileOpenHistory; |
438 |
460 |
439 /** File open drop down menu. */ |
461 /** File open drop down menu. */ |
440 private DropDownMenu fileOpenMenu; |
462 private DropDownMenu fileOpenMenu; |
441 |
463 |
446 private DropDownMenu saveFileMenu; |
468 private DropDownMenu saveFileMenu; |
447 |
469 |
448 /** Tab item for the "Top allocation locations" tab */ |
470 /** Tab item for the "Top allocation locations" tab */ |
449 CTabItem memoryTab; |
471 CTabItem memoryTab; |
450 |
472 |
451 /** Tab item for the memory results tab*/ |
473 /** Tab item for the memory results tab */ |
452 CTabItem mainTab; |
474 CTabItem mainTab; |
453 |
475 |
454 /** StatisticView reference */ |
476 /** StatisticView reference */ |
455 StatisticView statisticView; |
477 StatisticView statisticView; |
456 |
478 |
457 /** Contains project related modules */ |
479 /** Contains project related modules */ |
458 private final Hashtable<IProject, AbstractList<MMPInfo>> projectModules; |
480 private final Hashtable<IProject, AbstractList<MMPInfo>> projectModules; |
459 |
481 |
460 /**Reads epocwind.out file*/ |
482 /** Reads epocwind.out file */ |
461 EpocReader listeningJob; |
483 EpocReader listeningJob; |
462 |
484 |
463 /** The chart view composite */ |
485 /** The chart view composite */ |
464 protected ChartContainer chart; |
486 protected ChartContainer chart; |
465 |
487 |
466 |
|
467 /** |
488 /** |
468 * The constructor. |
489 * The constructor. |
469 */ |
490 */ |
470 public MainView() { |
491 public MainView() { |
471 parser = new ParseAnalyzeData(true, false); |
492 parser = new ParseAnalyzeData(true, false, true); |
472 cppFileNames = new ArrayList<String>(); |
493 cppFileNames = new ArrayList<String>(); |
473 startedSubtest = new ArrayList<ActiveSubtests>(); |
494 startedSubtest = new ArrayList<ActiveSubtests>(); |
474 projectResults = new ProjectResults(); |
495 projectResults = new ProjectResults(); |
475 fileOpenHistory = new FileActionHistory(Constants.HISTORY_LEVEL); |
496 fileOpenHistory = new FileActionHistory(Constants.HISTORY_LEVEL); |
476 projectModules = new Hashtable<IProject, AbstractList<MMPInfo>>(); |
497 projectModules = new Hashtable<IProject, AbstractList<MMPInfo>>(); |
497 |
518 |
498 } |
519 } |
499 |
520 |
500 /* |
521 /* |
501 * (non-Javadoc) |
522 * (non-Javadoc) |
502 * |
523 * |
503 * @see com.nokia.s60tools.analyzetool.ui.IActionListener#allModulesBuilt() |
524 * @see com.nokia.s60tools.analyzetool.ui.IActionListener#allModulesBuilt() |
504 */ |
525 */ |
505 public final void buildStateChanged(final IProject projRef) { |
526 public final void buildStateChanged(final IProject projRef) { |
506 |
527 |
507 //check validity |
528 // check validity |
508 if(!project.equals(projRef) || projectResults == null) { |
529 if (!project.equals(projRef) || projectResults == null) { |
509 return; |
530 return; |
510 } |
531 } |
511 |
|
512 |
532 |
513 final String datafile = projectResults.getDataFileName(projRef); |
533 final String datafile = projectResults.getDataFileName(projRef); |
514 |
534 |
515 // if trace is captured or data file is opened |
535 // if trace is captured or data file is opened |
516 if (datafile != null && runView != null) { |
536 if (datafile != null && runView != null) { |
541 } catch (java.io.IOException ioe) { |
561 } catch (java.io.IOException ioe) { |
542 ioe.printStackTrace(); |
562 ioe.printStackTrace(); |
543 } |
563 } |
544 } |
564 } |
545 |
565 |
546 |
566 // data file is available |
547 //data file is available |
|
548 int dataFileType = UseAtool.checkFileType(datafile); |
567 int dataFileType = UseAtool.checkFileType(datafile); |
549 |
568 |
550 if( dataFileType == Constants.DATAFILE_INVALID || dataFileType == Constants.DATAFILE_XML || dataFileType == Constants.DATAFILE_EMPTY ) { |
569 if (dataFileType == Constants.DATAFILE_INVALID |
570 || dataFileType == Constants.DATAFILE_XML |
|
571 || dataFileType == Constants.DATAFILE_EMPTY) { |
|
551 return; |
572 return; |
552 } |
573 } |
553 boolean reGenerate = Util.openConfirmationDialog(Constants.BUILD_STATE_CHANGED); |
574 boolean reGenerate = Util |
554 |
575 .openConfirmationDialog(Constants.BUILD_STATE_CHANGED); |
555 if( reGenerate ) { |
576 |
577 if (reGenerate) { |
|
556 // sync with UI thread |
578 // sync with UI thread |
557 runView.getControl().getDisplay().asyncExec(new Runnable() { |
579 runView.getControl().getDisplay().asyncExec(new Runnable() { |
558 public void run() { |
580 public void run() { |
559 analyzeDataFile(Constants.ANALYZE_USE_DATA_FILE, datafile, |
581 analyzeDataFile(Constants.ANALYZE_USE_DATA_FILE, |
560 false); |
582 datafile, false); |
561 } |
583 } |
562 }); |
584 }); |
563 } |
585 } |
564 |
586 |
565 } |
587 } |
566 } |
588 } |
567 |
589 |
568 |
|
569 /** |
590 /** |
570 * Opens file dialog and analyzing data file for given location. |
591 * Opens file dialog and analyzing data file for given location. |
571 * |
592 * |
572 * @param type |
593 * @param type |
573 * Type to define is data file asked from the user or using the |
594 * Type to define is data file asked from the user or using the |
574 * give data file |
595 * give data file |
575 * @param existingDataFile |
596 * @param existingDataFile |
576 * Data file path |
597 * Data file path |
608 clearCallstackViewContent(); |
629 clearCallstackViewContent(); |
609 updateInformationLabel(""); |
630 updateInformationLabel(""); |
610 runView.setInput(getStartupContent()); |
631 runView.setInput(getStartupContent()); |
611 changeViewTitle(viewTitle); |
632 changeViewTitle(viewTitle); |
612 |
633 |
613 AbstractList<MMPInfo> modules = Util.loadProjectTargetsInfo(project); |
634 AbstractList<MMPInfo> modules = Util |
635 .loadProjectTargetsInfo(project); |
|
614 projectModules.put(project, modules); |
636 projectModules.put(project, modules); |
615 |
637 |
616 boolean xmlFile = Util.isFileXML(selectedFile); |
638 boolean xmlFile = Util.isFileXML(selectedFile); |
617 // if file is xml file |
639 // if file is xml file |
618 // no need to analyze data file |
640 // no need to analyze data file |
624 |
646 |
625 // update progress monitor state |
647 // update progress monitor state |
626 monitor.beginTask(Constants.PROGRESSDIALOG_TITLE, |
648 monitor.beginTask(Constants.PROGRESSDIALOG_TITLE, |
627 IProgressMonitor.UNKNOWN); |
649 IProgressMonitor.UNKNOWN); |
628 // Parse the data file |
650 // Parse the data file |
629 ParseXMLFileSAX dataFileParser = new ParseXMLFileSAX(project, selectedFile, projectResults); |
651 ParseXMLFileSAX dataFileParser = new ParseXMLFileSAX( |
652 project, selectedFile, projectResults); |
|
630 boolean ret = dataFileParser.parse(); |
653 boolean ret = dataFileParser.parse(); |
631 |
654 |
632 // set used datafile name |
655 // set used datafile name |
633 usedDataFileName = selectedFile; |
656 usedDataFileName = selectedFile; |
634 |
657 |
636 |
659 |
637 // if parsing success |
660 // if parsing success |
638 // display memory leak results |
661 // display memory leak results |
639 if (ret) { |
662 if (ret) { |
640 // update project results |
663 // update project results |
641 projectResults.setProjectModules(project, projectModules.get(project), dataFileParser.getModules()); |
664 projectResults.setProjectModules(project, |
665 projectModules.get(project), dataFileParser |
|
666 .getModules()); |
|
642 } else { |
667 } else { |
643 fileOpenHistory.removeFileName(selectedFile); |
668 fileOpenHistory.removeFileName(selectedFile); |
644 if (showErrorInfo) { |
669 if (showErrorInfo) { |
645 showErrorMessage(Constants.INFO_FILE_INVALID); |
670 showErrorMessage(Constants.INFO_FILE_INVALID); |
646 } |
671 } |
655 }; |
680 }; |
656 analyzingXMLJob.setUser(true); |
681 analyzingXMLJob.setUser(true); |
657 analyzingXMLJob.schedule(); |
682 analyzingXMLJob.schedule(); |
658 |
683 |
659 } else { |
684 } else { |
660 try{ |
685 try { |
661 analyzeWithAtool(project, selectedFile, showErrorInfo); |
686 analyzeWithAtool(project, selectedFile, showErrorInfo); |
662 } |
687 } catch (Exception e) { |
663 catch( Exception e ) { |
|
664 analyzeJob = null; |
688 analyzeJob = null; |
665 } |
689 } |
666 } |
690 } |
667 } |
691 } |
668 } |
692 } |
669 |
693 |
670 /** |
694 /** |
671 * Analyzing memory analysis results using atool.exe. |
695 * Analyzing memory analysis results using atool.exe. |
672 * |
696 * |
673 * @param projectRef |
697 * @param projectRef |
674 * Project reference |
698 * Project reference |
675 * @param usedFile |
699 * @param usedFile |
676 * Data file which contains memory analyze data |
700 * Data file which contains memory analyze data |
677 * @param showErrorInfo |
701 * @param showErrorInfo |
688 protected IStatus run(IProgressMonitor monitor) { |
712 protected IStatus run(IProgressMonitor monitor) { |
689 // inform progressdialog that task execution starts |
713 // inform progressdialog that task execution starts |
690 // this make progressdialog visible on the UI |
714 // this make progressdialog visible on the UI |
691 monitor.beginTask(Constants.PROGRESSDIALOG_ATOOL, |
715 monitor.beginTask(Constants.PROGRESSDIALOG_ATOOL, |
692 IProgressMonitor.UNKNOWN); |
716 IProgressMonitor.UNKNOWN); |
693 |
717 |
694 fileOpenHistory.setFileName(usedFile); |
718 fileOpenHistory.setFileName(usedFile); |
695 // add2UserActionHistory( "File opened: " + usedFile ); |
719 // add2UserActionHistory( "File opened: " + usedFile ); |
696 |
720 |
697 // set used datafile name |
721 // set used datafile name |
698 usedDataFileName = usedFile; |
722 usedDataFileName = usedFile; |
699 |
723 |
724 if (chart != null) { |
|
725 resetGraphView();// clear out the graph view |
|
726 } |
|
727 |
|
700 // create atool object and execute atool |
728 // create atool object and execute atool |
701 UseAtool atool = new UseAtool(); |
729 UseAtool atool = new UseAtool(); |
702 |
730 |
703 // create xml file |
731 // create xml file |
704 Constants.COMMAND_LINE_ERROR_CODE errorCode = atool.createXMLFileToCarbide( |
732 Constants.COMMAND_LINE_ERROR_CODE errorCode = atool |
705 monitor, projectRef, usedFile, "-a"); |
733 .createXMLFileToCarbide(monitor, projectRef, |
734 usedFile, "-a"); |
|
706 String xmlFileLocation = null; |
735 String xmlFileLocation = null; |
707 xmlFileLocation = atool.getDataFileName(); |
736 xmlFileLocation = atool.getDataFileName(); |
708 |
737 |
709 // if some error occurs display it to user. |
738 // if some error occurs display it to user. |
710 if( errorCode != Constants.COMMAND_LINE_ERROR_CODE.OK ) { |
739 if (errorCode != Constants.COMMAND_LINE_ERROR_CODE.OK) { |
711 fileOpenHistory.removeFileName(usedFile); |
740 fileOpenHistory.removeFileName(usedFile); |
712 Util.displayCommandLineError(errorCode); |
741 Util.displayCommandLineError(errorCode); |
713 } |
742 } |
714 // if XML file generation failed => info to the user |
743 // if XML file generation failed => info to the user |
715 else if (xmlFileLocation == null) { |
744 else if (xmlFileLocation == null) { |
716 fileOpenHistory.removeFileName(usedFile); |
745 fileOpenHistory.removeFileName(usedFile); |
717 if (showErrorInfo) { |
746 if (showErrorInfo) { |
718 showErrorMessage(Constants.INFO_FILE_INVALID); |
747 showErrorMessage(Constants.INFO_FILE_INVALID); |
719 } |
748 } |
720 } else { |
749 } else { |
721 // Parse the xml file |
750 // Parse the xml file |
722 ParseXMLFileSAX dataFileParser = new ParseXMLFileSAX(project, |
751 ParseXMLFileSAX dataFileParser = new ParseXMLFileSAX( |
723 xmlFileLocation, projectResults); |
752 project, xmlFileLocation, projectResults); |
724 boolean error = dataFileParser.parse(); |
753 boolean error = dataFileParser.parse(); |
725 if (showErrorInfo && !error) { |
754 if (showErrorInfo && !error) { |
726 fileOpenHistory.removeFileName(usedFile); |
755 fileOpenHistory.removeFileName(usedFile); |
727 showErrorMessage(Constants.INFO_FILE_INVALID); |
756 showErrorMessage(Constants.INFO_FILE_INVALID); |
728 } |
757 } |
729 |
758 |
730 projectResults.setProjectModules(project, projectModules.get(project), dataFileParser.getModules()); |
759 projectResults.setProjectModules(project, |
731 projectResults.setDataFileName(projectRef, usedDataFileName); |
760 projectModules.get(project), dataFileParser |
761 .getModules()); |
|
762 projectResults.setDataFileName(projectRef, |
|
763 usedDataFileName); |
|
732 // update display |
764 // update display |
733 refreshView(); |
765 refreshView(); |
734 } |
766 } |
735 |
767 |
736 updateChangeDetailState(projectRef); |
768 updateChangeDetailState(projectRef); |
737 |
769 |
738 // //this only generates statistics and this feature is currently disabled |
770 // //this only generates statistics and this feature is |
739 // if( !monitor.isCanceled() ) { |
771 // currently disabled |
740 // |
772 // if( !monitor.isCanceled() ) { |
741 // IPreferenceStore store = Activator.getPreferences(); |
773 // |
742 // boolean generateStatistic = store.getBoolean(Constants.CREATE_STATISTIC); |
774 // IPreferenceStore store = Activator.getPreferences(); |
743 // //used file data file create statistic also |
775 // boolean generateStatistic = |
744 // if( generateStatistic && UseAtool.checkFileType(usedFile) == Constants.DATAFILE_TRACE ) |
776 // store.getBoolean(Constants.CREATE_STATISTIC); |
745 // { |
777 // //used file data file create statistic also |
746 // monitor.setTaskName(Constants.STATISTICS_GENERATING_PROG_TITLE); |
778 // if( generateStatistic && UseAtool.checkFileType(usedFile) |
747 // |
779 // == Constants.DATAFILE_TRACE ) |
748 // ReadFile fileReader = new ReadFile(); |
780 // { |
749 // boolean error = fileReader.readFile(usedFile); |
781 // monitor.setTaskName(Constants.STATISTICS_GENERATING_PROG_TITLE); |
750 // if( error && statisticView != null) { |
782 // |
751 // AbstractList<ProcessInfo> processes = fileReader.getStatistic(); |
783 // ReadFile fileReader = new ReadFile(); |
752 // statisticView.setData( project, processes); |
784 // boolean error = fileReader.readFile(usedFile); |
753 // fileReader.finish(); |
785 // if( error && statisticView != null) { |
754 // } |
786 // AbstractList<ProcessInfo> processes = |
755 // |
787 // fileReader.getStatistic(); |
756 // } |
788 // statisticView.setData( project, processes); |
757 // } |
789 // fileReader.finish(); |
790 // } |
|
791 // |
|
792 // } |
|
793 // } |
|
758 if (!monitor.isCanceled()) { |
794 if (!monitor.isCanceled()) { |
759 |
795 |
760 monitor.setTaskName(Constants.GRAPH_GENERATING_PROG_TITLE); |
796 // create the job for loading the graph model |
761 try { |
797 // but only schedule it when the user gets to the graph |
762 ReadFile fileReader = new ReadFile(); |
798 // tab |
763 boolean success = fileReader.readFile(usedFile); |
799 graphLoadJob = new GraphLoadJob(usedFile); |
764 if (success) { |
800 graphLoadJob.setUser(true);// set progress bar |
765 if (chart != null){ |
801 graphLoadJob.setPriority(Job.LONG); |
766 resetGraphView(); |
802 |
767 } |
803 // run the following in UI thread, since widgets get |
768 AbstractList<ProcessInfo> processes = fileReader.getStatistic(); |
804 // accessed |
769 IMemoryActivityModel model = new AnalyzeFactory().createModel(processes.size() == 0); |
805 PlatformUI.getWorkbench().getDisplay().syncExec( |
770 chart.setInput(project, model); |
806 new Runnable() { |
771 model.addProcesses(processes); |
807 public void run() { |
772 fileReader.finish(); |
808 if (((CTabFolder) chart.getParent()) |
773 } |
809 .getSelection() != null && ((CTabFolder) chart.getParent()) |
774 }catch( OutOfMemoryError oome ) { |
810 .getSelection().getControl() == chart) { |
775 Activator.getDefault().logInfo(IStatus.ERROR, IStatus.ERROR, "Can not allocate enough memory for the memory usage graph model."); |
811 // chart tab is currently selected |
776 analyzeJob = null; |
812 // so we can run the load job |
777 }catch (Exception e ) { |
813 // straight away |
778 Activator.getDefault().log(IStatus.ERROR, "Error while generating graph model", e); |
814 graphLoadJob.schedule(); |
779 analyzeJob = null; |
815 } |
780 } |
816 } |
817 }); |
|
781 } |
818 } |
782 analyzeJob = null; |
819 analyzeJob = null; |
783 return new Status(IStatus.OK, Constants.ANALYZE_CONSOLE_ID, |
820 return new Status(IStatus.OK, Constants.ANALYZE_CONSOLE_ID, |
784 IStatus.OK, |
821 IStatus.OK, |
785 Constants.PROGRESSDIALOG_ANALYZE_COMPLETE, null); |
822 Constants.PROGRESSDIALOG_ANALYZE_COMPLETE, null); |
786 } |
823 } |
787 }; |
824 }; |
825 |
|
826 if (graphLoadJob != null && graphLoadJob.getState() == Job.RUNNING) { |
|
827 graphLoadJob.cancel(); |
|
828 } |
|
829 graphLoadJob = null; |
|
788 |
830 |
789 analyzeJob.setUser(true); |
831 analyzeJob.setUser(true); |
790 analyzeJob.setPriority(Job.LONG); |
832 analyzeJob.setPriority(Job.LONG); |
791 analyzeJob.schedule(); |
833 analyzeJob.schedule(); |
792 |
834 |
793 } else { // if existing job is running display info to user |
835 } else { // if existing job is running display info to user |
794 showMessage(Constants.INFO_ALLREADY_RUNNING); |
836 showMessage(Constants.INFO_ALLREADY_RUNNING); |
795 } |
837 } |
796 } |
838 } |
797 |
|
798 |
839 |
799 /** |
840 /** |
800 * Change report detail level. |
841 * Change report detail level. |
801 */ |
842 */ |
802 public final void changeDetailLevel() { |
843 public final void changeDetailLevel() { |
863 |
904 |
864 } |
905 } |
865 |
906 |
866 /** |
907 /** |
867 * Change logging mode. |
908 * Change logging mode. |
868 * |
909 * |
869 * @param loggingMode |
910 * @param loggingMode |
870 * Used logging mode |
911 * Used logging mode |
871 */ |
912 */ |
872 public final void changeLogTarget(final String loggingMode) { |
913 public final void changeLogTarget(final String loggingMode) { |
873 |
914 |
893 if (Constants.LOGGING_EXT.equals(usedLoggingMode)) { |
934 if (Constants.LOGGING_EXT.equals(usedLoggingMode)) { |
894 logTargetMenu.setImageDescriptor(Activator |
935 logTargetMenu.setImageDescriptor(Activator |
895 .getImageDescriptor(Constants.BUTTON_COMPUTER)); |
936 .getImageDescriptor(Constants.BUTTON_COMPUTER)); |
896 logTargetMenu |
937 logTargetMenu |
897 .setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_EXT); |
938 .setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_EXT); |
898 if (loggingMode == null){ |
939 if (loggingMode == null) { |
899 externalLogTargetAction.setChecked(true); |
940 externalLogTargetAction.setChecked(true); |
900 s60LogTargetAction.setChecked(false); |
941 s60LogTargetAction.setChecked(false); |
901 externalFastLogTargetAction.setChecked(false); |
942 externalFastLogTargetAction.setChecked(false); |
902 askLogTargetAction.setChecked(false); |
943 askLogTargetAction.setChecked(false); |
903 } |
944 } |
907 |
948 |
908 logTargetMenu.setImageDescriptor(Activator |
949 logTargetMenu.setImageDescriptor(Activator |
909 .getImageDescriptor(Constants.BUTTON_CELLURAR)); |
950 .getImageDescriptor(Constants.BUTTON_CELLURAR)); |
910 logTargetMenu |
951 logTargetMenu |
911 .setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_S60); |
952 .setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_S60); |
912 if (loggingMode == null){ |
953 if (loggingMode == null) { |
913 externalLogTargetAction.setChecked(false); |
954 externalLogTargetAction.setChecked(false); |
914 s60LogTargetAction.setChecked(true); |
955 s60LogTargetAction.setChecked(true); |
915 externalFastLogTargetAction.setChecked(false); |
956 externalFastLogTargetAction.setChecked(false); |
916 askLogTargetAction.setChecked(false); |
957 askLogTargetAction.setChecked(false); |
917 } |
958 } |
918 } |
959 } |
919 |
960 |
920 else if( Constants.LOGGING_EXT_FAST.equals(usedLoggingMode)) { |
961 else if (Constants.LOGGING_EXT_FAST.equals(usedLoggingMode)) { |
921 logTargetMenu.setImageDescriptor(Activator |
962 logTargetMenu.setImageDescriptor(Activator |
922 .getImageDescriptor(Constants.BUTTON_COMPUTER_FAST)); |
963 .getImageDescriptor(Constants.BUTTON_COMPUTER_FAST)); |
923 logTargetMenu.setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_FAST); |
964 logTargetMenu |
924 if( loggingMode == null) { |
965 .setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_FAST); |
966 if (loggingMode == null) { |
|
925 externalLogTargetAction.setChecked(false); |
967 externalLogTargetAction.setChecked(false); |
926 s60LogTargetAction.setChecked(false); |
968 s60LogTargetAction.setChecked(false); |
927 externalFastLogTargetAction.setChecked(true); |
969 externalFastLogTargetAction.setChecked(true); |
928 askLogTargetAction.setChecked(false); |
970 askLogTargetAction.setChecked(false); |
929 } |
971 } |
932 else { |
974 else { |
933 logTargetMenu.setImageDescriptor(Activator |
975 logTargetMenu.setImageDescriptor(Activator |
934 .getImageDescriptor(Constants.BUTTON_ASK)); |
976 .getImageDescriptor(Constants.BUTTON_ASK)); |
935 logTargetMenu |
977 logTargetMenu |
936 .setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_ASK); |
978 .setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_ASK); |
937 if (loggingMode == null){ |
979 if (loggingMode == null) { |
938 externalLogTargetAction.setChecked(false); |
980 externalLogTargetAction.setChecked(false); |
939 s60LogTargetAction.setChecked(false); |
981 s60LogTargetAction.setChecked(false); |
940 externalFastLogTargetAction.setChecked(false); |
982 externalFastLogTargetAction.setChecked(false); |
941 askLogTargetAction.setChecked(true); |
983 askLogTargetAction.setChecked(true); |
942 } |
984 } |
943 } |
985 } |
944 |
986 |
945 // if the fast data gathering mode is enabled by the preference page => enable also toolbar option |
987 // if the fast data gathering mode is enabled by the preference page => |
988 // enable also toolbar option |
|
946 // else disable fast data gathering mode |
989 // else disable fast data gathering mode |
947 externalFastLogTargetAction.setEnabled(store.getBoolean(Constants.LOGGING_FAST_ENABLED)); |
990 externalFastLogTargetAction.setEnabled(store |
991 .getBoolean(Constants.LOGGING_FAST_ENABLED)); |
|
948 } |
992 } |
949 |
993 |
950 /** |
994 /** |
951 * Changes "Change report detail level" action tooltip. |
995 * Changes "Change report detail level" action tooltip. |
952 */ |
996 */ |
981 |
1025 |
982 } |
1026 } |
983 |
1027 |
984 /** |
1028 /** |
985 * Change view title. |
1029 * Change view title. |
986 * |
1030 * |
987 * @param newTitle |
1031 * @param newTitle |
988 * New title text |
1032 * New title text |
989 */ |
1033 */ |
990 private void changeViewTitle(final String newTitle) { |
1034 private void changeViewTitle(final String newTitle) { |
991 |
1035 |
994 super.setContentDescription(newTitle); |
1038 super.setContentDescription(newTitle); |
995 } |
1039 } |
996 } |
1040 } |
997 |
1041 |
998 /** |
1042 /** |
999 * Check project validity that is project is selected. |
1043 * Check that selected project is open and project information can be read. |
1000 * |
1044 * |
1001 * @return True if project is open and accessible otherwise False |
1045 * @return True if project is open and accessible otherwise False |
1002 */ |
1046 */ |
1003 public final boolean checkProjectValidity() { |
1047 public final boolean checkProjectValidity() { |
1004 // project is not selected show info to user |
1048 // project is not selected show info to user |
1005 if (project == null || !project.isOpen()) { |
1049 if (project == null || !project.isOpen()) { |
1027 boolean ret = Util.openConfirmationDialog(Constants.CONFIRM_DELETE_ALL); |
1071 boolean ret = Util.openConfirmationDialog(Constants.CONFIRM_DELETE_ALL); |
1028 |
1072 |
1029 // if user confirms |
1073 // if user confirms |
1030 if (ret) { |
1074 if (ret) { |
1031 // clear AnalyzeTool made changes |
1075 // clear AnalyzeTool made changes |
1032 Util util = new Util(); |
1076 Util.clearAtoolChanges(project); |
1033 util.clearAtoolChanges(project); |
|
1034 |
1077 |
1035 cleanAnalyzeData(null); |
1078 cleanAnalyzeData(null); |
1079 resetGraphView(); |
|
1036 updateChangeDetailState(project); |
1080 updateChangeDetailState(project); |
1037 } |
1081 } |
1038 |
1082 |
1039 if( statisticView != null ) { |
1083 if (statisticView != null) { |
1040 statisticView.clean(null); |
1084 statisticView.clean(null); |
1041 } |
1085 } |
1042 |
|
1043 if (chart != null){ |
|
1044 resetGraphView(); |
|
1045 } |
|
1046 |
|
1047 } |
1086 } |
1048 |
1087 |
1049 /** |
1088 /** |
1050 * Cleans all the saved data. |
1089 * Cleans all the saved data. |
1051 */ |
1090 */ |
1053 // clean all data if project not specified |
1092 // clean all data if project not specified |
1054 if (projectRef == null) { |
1093 if (projectRef == null) { |
1055 // clean all the project related info and data |
1094 // clean all the project related info and data |
1056 projectResults.clear(); |
1095 projectResults.clear(); |
1057 projectModules.clear(); |
1096 projectModules.clear(); |
1058 } |
1097 } else { |
1059 else { |
|
1060 // clear only one project results |
1098 // clear only one project results |
1061 if (projectResults.contains(projectRef)) { |
1099 if (projectResults.contains(projectRef)) { |
1062 projectResults.clearProjectData(projectRef); |
1100 projectResults.clearProjectData(projectRef); |
1063 } |
1101 } |
1064 |
1102 |
1065 if( projectModules.contains(projectRef)) { |
1103 if (projectModules.contains(projectRef)) { |
1066 projectModules.remove(projectRef); |
1104 projectModules.remove(projectRef); |
1067 } |
1105 } |
1068 } |
1106 } |
1069 |
|
1070 |
|
1071 |
1107 |
1072 cppFileNames.clear(); |
1108 cppFileNames.clear(); |
1073 |
1109 |
1074 // update variables |
1110 // update variables |
1075 activeTreeItem = null; |
1111 activeTreeItem = null; |
1076 usedDataFileName = ""; |
1112 usedDataFileName = ""; |
1077 |
|
1078 |
1113 |
1079 // set default view contents |
1114 // set default view contents |
1080 if (runView != null) { |
1115 if (runView != null) { |
1081 runView.getControl().getDisplay().syncExec(new Runnable() { |
1116 runView.getControl().getDisplay().syncExec(new Runnable() { |
1082 public void run() { |
1117 public void run() { |
1084 if (informationLabel != null) { |
1119 if (informationLabel != null) { |
1085 updateInformationLabel(""); |
1120 updateInformationLabel(""); |
1086 } |
1121 } |
1087 |
1122 |
1088 changeViewTitle(viewTitle); |
1123 changeViewTitle(viewTitle); |
1089 if( statisticView != null ) { |
1124 if (statisticView != null) { |
1090 statisticView.clean(projectRef); |
1125 statisticView.clean(projectRef); |
1091 } |
1126 } |
1092 } |
1127 } |
1093 }); |
1128 }); |
1094 } |
1129 } |
1095 |
1130 |
1096 clearCallstackViewContent(); |
1131 clearCallstackViewContent(); |
1097 if( clearProjectResults != null && clearProjectResults != null ) { |
1132 if (clearProjectResults != null && clearProjectResults != null) { |
1098 clearProjectResults.setEnabled(false); |
1133 clearProjectResults.setEnabled(false); |
1099 }else if( clearProjectResults != null ) { |
1134 } else if (clearProjectResults != null) { |
1100 updateChangeDetailState(projectRef); |
1135 updateChangeDetailState(projectRef); |
1101 } |
1136 } |
1102 |
1137 |
1103 } |
1138 } |
1104 |
1139 |
1132 IActionBars bars = getViewSite().getActionBars(); |
1167 IActionBars bars = getViewSite().getActionBars(); |
1133 fillLocalPullDown(bars.getMenuManager()); |
1168 fillLocalPullDown(bars.getMenuManager()); |
1134 fillLocalToolBar(bars.getToolBarManager()); |
1169 fillLocalToolBar(bars.getToolBarManager()); |
1135 } |
1170 } |
1136 |
1171 |
1137 |
1172 /** |
1138 /** |
1173 * This is a callback that will allow us to create the viewer and initialize |
1139 * This is a callback that will allow us |
1174 * it. |
1140 * to create the viewer and initialize it. |
1175 */ |
1141 */ |
|
1142 @Override |
1176 @Override |
1143 public void createPartControl( Composite parent ){ |
1177 public void createPartControl(Composite parent) { |
1144 |
1178 |
1145 //create new Tab |
1179 // create new Tab |
1146 CTabFolder mainFolder = new CTabFolder( parent, SWT.TOP ); |
1180 final CTabFolder mainFolder = new CTabFolder(parent, SWT.TOP); |
1147 |
1181 |
1148 //create main view and add it tab |
1182 // create main view and add it tab |
1149 createMainView( mainFolder ); |
1183 createMainView(mainFolder); |
1150 |
1184 |
1151 //create new statistic view |
1185 // create new statistic view |
1152 //createMemoryView( mainFolder ); |
1186 // createMemoryView( mainFolder ); |
1153 //create graph |
1187 // create graph |
1154 createGraphView(mainFolder); |
1188 createGraphView(mainFolder); |
1155 |
1189 |
1156 //set initial selection |
1190 // set initial selection |
1157 mainFolder.setSelection( mainTab ); |
1191 mainFolder.setSelection(mainTab); |
1192 |
|
1193 mainFolder.addSelectionListener(new SelectionListener() { |
|
1194 |
|
1195 public void widgetDefaultSelected(SelectionEvent e) { |
|
1196 widgetSelected(e); |
|
1197 } |
|
1198 |
|
1199 public void widgetSelected(SelectionEvent e) { |
|
1200 // if we changed to the graph tab and the graph load job isn't already running |
|
1201 // schedule it now |
|
1202 if (graphLoadJob != null |
|
1203 && graphLoadJob.getState() != Job.RUNNING |
|
1204 && mainFolder.getSelection() != null |
|
1205 && mainFolder.getSelection().getControl() == chart) { |
|
1206 graphLoadJob.schedule(); |
|
1207 } |
|
1208 |
|
1209 |
|
1210 if (mainFolder.getSelectionIndex() == 1) { |
|
1211 changeDetails.setEnabled(false); |
|
1212 } else { |
|
1213 changeDetails.setEnabled(true); |
|
1214 |
|
1215 } |
|
1216 } |
|
1217 }); |
|
1218 |
|
1219 // stop any jobs that may be scheduled |
|
1220 mainFolder.addDisposeListener(new DisposeListener(){ |
|
1221 public void widgetDisposed(DisposeEvent e) { |
|
1222 if (graphLoadJob != null){ |
|
1223 graphLoadJob.cancel(); |
|
1224 graphLoadJob = null; |
|
1225 } |
|
1226 if (analyzeJob != null){ |
|
1227 analyzeJob.cancel(); |
|
1228 analyzeJob = null; |
|
1229 } |
|
1230 } |
|
1231 }); |
|
1232 |
|
1158 } |
1233 } |
1159 |
1234 |
1160 /** |
1235 /** |
1161 * Creates graph view and add it to graph tab |
1236 * Creates graph view and add it to graph tab |
1162 * @param parent CTabFolder parent of the view |
1237 * |
1238 * @param mainFolder |
|
1239 * CTabFolder parent of the view |
|
1163 */ |
1240 */ |
1164 private void createGraphView(CTabFolder mainFolder) { |
1241 private void createGraphView(CTabFolder mainFolder) { |
1165 final CTabItem chartTabItem = new CTabItem(mainFolder, SWT.NONE); |
1242 final CTabItem chartTabItem = new CTabItem(mainFolder, SWT.NONE); |
1166 chartTabItem.setText("Graph"); |
1243 chartTabItem.setText("Graph"); |
1167 chartTabItem.setToolTipText("AnalyzeTool graph per process"); |
1244 chartTabItem.setToolTipText("AnalyzeTool graph per process"); |
1168 |
1245 |
1169 chart = new ChartContainer(mainFolder, SWT.NONE); |
1246 chart = new ChartContainer(mainFolder, SWT.NONE); |
1170 chartTabItem.setControl(chart); |
1247 chartTabItem.setControl(chart); |
1171 IMemoryActivityModel model = AnalyzeFactory.getEmptyModel(); |
1248 IMemoryActivityModel model = AnalyzeFactory.getEmptyModel(); |
1172 chart.setInput(project, model); |
1249 chart.setInput(project, model); |
1173 model.addProcesses(model.getProcesses());//charts should get notified via listeners on the model |
1250 model.addProcesses(model.getProcesses());// charts should get notified |
1174 } |
1251 // via listeners on the |
1175 |
1252 // model |
1253 } |
|
1254 |
|
1176 /** |
1255 /** |
1177 * Clears the graph by setting an empty model and causing paint events |
1256 * Clears the graph by setting an empty model and causing paint events |
1178 */ |
1257 */ |
1179 private void resetGraphView(){ |
1258 private void resetGraphView() { |
1180 if (chart != null){ |
1259 if (chart != null) { |
1181 chart.setInput(project, AnalyzeFactory.getEmptyModel()); |
1260 chart.setInput(project, AnalyzeFactory.getEmptyModel()); |
1182 //chart.update(); |
1261 // chart.update(); |
1183 } |
1262 } |
1184 } |
1263 } |
1185 |
1264 |
1186 /** |
1265 /** |
1187 * Creates new statistic view and add it to memory tab |
1266 * Creates new statistic view and add it to memory tab |
1188 * @param parent Statistic view parent( CTabFolder ) |
1267 * |
1189 */ |
1268 * @param parent |
1190 public void createMemoryView( CTabFolder parent ) |
1269 * Statistic view parent( CTabFolder ) |
1191 { |
1270 */ |
1271 public void createMemoryView(CTabFolder parent) { |
|
1192 statisticView = new StatisticView(); |
1272 statisticView = new StatisticView(); |
1193 memoryTab = statisticView.createView( parent ); |
1273 memoryTab = statisticView.createView(parent); |
1194 } |
1274 } |
1195 |
1275 |
1196 /** |
1276 /** |
1197 * Creates memory results view |
1277 * Creates memory results view |
1198 * @param parent View parent ( CTabFolder ) |
1278 * |
1279 * @param parent |
|
1280 * View parent ( CTabFolder ) |
|
1199 */ |
1281 */ |
1200 public void createMainView(CTabFolder parent) { |
1282 public void createMainView(CTabFolder parent) { |
1201 |
1283 |
1202 // Create SashForm this form includes all the current view components |
1284 // Create SashForm this form includes all the current view components |
1203 SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL); |
1285 SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL); |
1204 |
1286 |
1205 mainTab = new CTabItem( parent, SWT.NONE ); |
1287 mainTab = new CTabItem(parent, SWT.NONE); |
1206 mainTab.setControl( sashForm ); |
1288 mainTab.setControl(sashForm); |
1207 mainTab.setText(Constants.MAIN_TAB_TITLE); |
1289 mainTab.setText(Constants.MAIN_TAB_TITLE); |
1208 |
1290 |
1209 // create new treeviewer to shown memory analysis runs and leaks |
1291 // create new treeviewer to shown memory analysis runs and leaks |
1210 runView = new TreeViewer(sashForm, SWT.VIRTUAL); |
1292 runView = new TreeViewer(sashForm, SWT.VIRTUAL); |
1211 |
1293 |
1261 hookDoubleClickAction(); |
1343 hookDoubleClickAction(); |
1262 hookClicks(); |
1344 hookClicks(); |
1263 contributeToActionBars(); |
1345 contributeToActionBars(); |
1264 |
1346 |
1265 // set view title |
1347 // set view title |
1266 viewTitle = String.format(Constants.ANALYZE_TOOL_TITLE_WITH_VERSION, Util.getAToolFeatureVersionNumber()); |
1348 viewTitle = String.format(Constants.ANALYZE_TOOL_TITLE_WITH_VERSION, |
1349 Util.getAToolFeatureVersionNumber()); |
|
1267 this.setContentDescription(viewTitle); |
1350 this.setContentDescription(viewTitle); |
1268 |
1351 |
1269 // add selection listener |
1352 // add selection listener |
1270 if (getSite() != null) { |
1353 if (getSite() != null) { |
1271 getSite().getPage().addSelectionListener(this); |
1354 getSite().getPage().addSelectionListener(this); |
1280 callstackView.getControl(), |
1363 callstackView.getControl(), |
1281 AnalyzeToolHelpContextIDs.ANALYZE_MAIN); |
1364 AnalyzeToolHelpContextIDs.ANALYZE_MAIN); |
1282 PlatformUI.getWorkbench().getHelpSystem().setHelp(runView.getControl(), |
1365 PlatformUI.getWorkbench().getHelpSystem().setHelp(runView.getControl(), |
1283 AnalyzeToolHelpContextIDs.ANALYZE_MAIN); |
1366 AnalyzeToolHelpContextIDs.ANALYZE_MAIN); |
1284 |
1367 |
1285 ResourcesPlugin.getWorkspace().addResourceChangeListener(new ATResourceListener()); |
1368 ResourcesPlugin.getWorkspace().addResourceChangeListener( |
1286 |
1369 new ATResourceListener()); |
1287 //get used command line engine version |
1370 |
1288 String version = Util.getAtoolVersionNumber(Util.getAtoolInstallFolder()); |
1371 // get used command line engine version |
1289 |
1372 String version = Util.getAtoolVersionNumber(Util |
1290 //compare current version to min version |
1373 .getAtoolInstallFolder()); |
1291 int comp = Util.compareVersionNumber(Constants.CS_SUPPORT_MIN_VERSION, version); |
1374 |
1292 |
1375 // compare current version to min version |
1376 int comp = Util.compareVersionNumber(Constants.CS_SUPPORT_MIN_VERSION, |
|
1377 version); |
|
1378 |
|
1293 IPreferenceStore store = Activator.getPreferences(); |
1379 IPreferenceStore store = Activator.getPreferences(); |
1294 //if current version is same or higher than required version => set flag to true |
1380 // if current version is same or higher than required version => set |
1295 if( comp == Constants.VERSION_NUMBERS_EQUALS || comp == Constants.VERSION_NUMBERS_SECOND ) { |
1381 // flag to true |
1382 if (comp == Constants.VERSION_NUMBERS_EQUALS |
|
1383 || comp == Constants.VERSION_NUMBERS_SECOND) { |
|
1296 store.setValue(Constants.LOGGING_FAST_ENABLED, true); |
1384 store.setValue(Constants.LOGGING_FAST_ENABLED, true); |
1297 } |
1385 } else { |
1298 else { |
|
1299 store.setValue(Constants.LOGGING_FAST_ENABLED, false); |
1386 store.setValue(Constants.LOGGING_FAST_ENABLED, false); |
1300 } |
1387 } |
1301 |
1388 |
1302 // get default value for logging mode |
1389 // get default value for logging mode |
1303 preferenceChanged(); |
1390 preferenceChanged(); |
1304 } |
1391 } |
1305 |
1392 |
1306 /** |
1393 /** |
1307 * When AnalyzeTool view is activated and Tracing utility plug-in is not |
1394 * When AnalyzeTool view is activated and TraceViewer plug-in is not |
1308 * available disable AnalyzeTool trace actions. |
1395 * available disable AnalyzeTool trace actions. |
1309 * |
1396 * |
1310 * @see com.nokia.s60tools.analyzetool.ui.IActionListener#disableTraceActions(boolean) |
1397 * @see com.nokia.s60tools.analyzetool.ui.IActionListener#disableTraceActions(boolean) |
1311 * |
1398 * |
1312 * @param disable |
1399 * @param disable |
1313 * Boolean state of trace action |
1400 * Boolean state of trace action |
1314 */ |
1401 */ |
1315 public void disableTraceActions(final boolean disable) { |
1402 public void disableTraceActions(final boolean disable) { |
1316 |
1403 |
1327 traceActive = false; |
1414 traceActive = false; |
1328 } |
1415 } |
1329 |
1416 |
1330 /** |
1417 /** |
1331 * Fills context menu. |
1418 * Fills context menu. |
1332 * |
1419 * |
1333 * @param manager |
1420 * @param manager |
1334 * Menu manager |
1421 * Menu manager |
1335 */ |
1422 */ |
1336 private void fillContextMenu(IMenuManager manager) { |
1423 private void fillContextMenu(IMenuManager manager) { |
1337 |
1424 |
1351 manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); |
1438 manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); |
1352 } |
1439 } |
1353 |
1440 |
1354 /** |
1441 /** |
1355 * Fills local pull down menu. |
1442 * Fills local pull down menu. |
1356 * |
1443 * |
1357 * @param manager |
1444 * @param manager |
1358 * Menu manager |
1445 * Menu manager |
1359 */ |
1446 */ |
1360 private void fillLocalPullDown(IMenuManager manager) { |
1447 private void fillLocalPullDown(IMenuManager manager) { |
1361 manager.add(buildWithAtool); |
1448 manager.add(buildWithAtool); |
1372 manager.add(openPrefs); |
1459 manager.add(openPrefs); |
1373 } |
1460 } |
1374 |
1461 |
1375 /** |
1462 /** |
1376 * Fills local toolbar. |
1463 * Fills local toolbar. |
1377 * |
1464 * |
1378 * @param manager |
1465 * @param manager |
1379 * Menu manager |
1466 * Menu manager |
1380 */ |
1467 */ |
1381 private void fillLocalToolBar(IToolBarManager manager) { |
1468 private void fillLocalToolBar(IToolBarManager manager) { |
1382 |
1469 |
1417 manager.add(openPrefs); |
1504 manager.add(openPrefs); |
1418 } |
1505 } |
1419 |
1506 |
1420 /** |
1507 /** |
1421 * Gets call stack information of current leak. |
1508 * Gets call stack information of current leak. |
1422 * |
1509 * |
1423 * @param treeObject |
1510 * @param treeObject |
1424 * Tree object |
1511 * Tree object |
1425 * @return Object |
1512 * @return Object |
1426 */ |
1513 */ |
1427 Object getCallStack(final TreeObject treeObject) { |
1514 Object getCallStack(final TreeObject treeObject) { |
1460 TreeParent parent = helper.getCallstack(item, modules); |
1547 TreeParent parent = helper.getCallstack(item, modules); |
1461 |
1548 |
1462 return parent; |
1549 return parent; |
1463 } |
1550 } |
1464 |
1551 |
1465 |
|
1466 /** |
1552 /** |
1467 * Gets callstack item name. |
1553 * Gets callstack item name. |
1468 * |
1554 * |
1469 * @param callstackItem |
1555 * @param callstackItem |
1470 * One callstack item |
1556 * One callstack item |
1471 * @return Callstack name if found otherwise null |
1557 * @return Callstack name if found otherwise null |
1472 */ |
1558 */ |
1473 public final String getCallstackItemName(final CallstackItem callstackItem) { |
1559 public final String getCallstackItemName(final CallstackItem callstackItem) { |
1484 } |
1570 } |
1485 |
1571 |
1486 // check that project contains cpp file which is parsed from call stack |
1572 // check that project contains cpp file which is parsed from call stack |
1487 // list |
1573 // list |
1488 Iterator<String> iterCppFiles = cppFileNames.iterator(); |
1574 Iterator<String> iterCppFiles = cppFileNames.iterator(); |
1489 while( iterCppFiles.hasNext() ) { |
1575 while (iterCppFiles.hasNext()) { |
1490 String cppFileLocation = iterCppFiles.next(); |
1576 String cppFileLocation = iterCppFiles.next(); |
1491 |
1577 |
1492 //parse file name from the source path |
1578 // parse file name from the source path |
1493 int slash = Util.getLastSlashIndex(cppFileLocation); |
1579 int slash = Util.getLastSlashIndex(cppFileLocation); |
1494 if( slash != -1 ) { |
1580 if (slash != -1) { |
1495 String cppFile = cppFileLocation.substring(slash+1, cppFileLocation.length()); |
1581 String cppFile = cppFileLocation.substring(slash + 1, |
1496 if( cppFile.equalsIgnoreCase(fileName)) { |
1582 cppFileLocation.length()); |
1583 if (cppFile.equalsIgnoreCase(fileName)) { |
|
1497 cppFileName = cppFileLocation; |
1584 cppFileName = cppFileLocation; |
1498 break; |
1585 break; |
1499 } |
1586 } |
1500 } |
1587 } |
1501 } |
1588 } |
1502 return cppFileName; |
1589 return cppFileName; |
1503 } |
1590 } |
1504 |
1591 |
1505 /** |
1592 /** |
1506 * Gets file info for current project. |
1593 * Gets file info for current project. |
1507 * |
1594 * |
1508 * @param projectRef |
1595 * @param projectRef |
1509 * Project reference |
1596 * Project reference |
1510 */ |
1597 */ |
1511 private void getFileInfos(final IProject projectRef) { |
1598 private void getFileInfos(final IProject projectRef) { |
1512 ResourceVisitor visitor = new ResourceVisitor(this); |
1599 ResourceVisitor visitor = new ResourceVisitor(this); |
1539 } |
1626 } |
1540 } |
1627 } |
1541 |
1628 |
1542 /** |
1629 /** |
1543 * Gets project results. |
1630 * Gets project results. |
1544 * |
1631 * |
1545 * @param projectRef |
1632 * @param projectRef |
1546 * Project reference |
1633 * Project reference |
1547 */ |
1634 */ |
1548 public void getProjectResults(final IProject projectRef) { |
1635 public void getProjectResults(final IProject projectRef) { |
1549 // if project reference is null => leave |
1636 // if project reference is null => leave |
1571 updateBuildState(lastProjectRef); |
1658 updateBuildState(lastProjectRef); |
1572 updateChangeDetailState(lastProjectRef); |
1659 updateChangeDetailState(lastProjectRef); |
1573 } |
1660 } |
1574 } |
1661 } |
1575 |
1662 |
1576 //update clear project results action state |
1663 // update clear project results action state |
1577 if( projectResults.contains(projectRef) ) { |
1664 if (projectResults.contains(projectRef)) { |
1578 clearProjectResults.setEnabled(true); |
1665 clearProjectResults.setEnabled(true); |
1579 } |
1666 } else { |
1580 else { |
|
1581 clearProjectResults.setEnabled(false); |
1667 clearProjectResults.setEnabled(false); |
1582 } |
1668 } |
1583 } |
1669 } |
1584 |
1670 |
1585 /** |
1671 /** |
1586 * Gets memory leak analysis results. |
1672 * Gets memory leak analysis results. |
1587 * |
1673 * |
1588 * @param showErrorInfo |
1674 * @param showErrorInfo |
1589 * Display error info or not |
1675 * Display error info or not |
1590 * @return Object memory leak analysis results |
1676 * @return Object memory leak analysis results |
1591 */ |
1677 */ |
1592 private Object getResults(final boolean showErrorInfo) { |
1678 private Object getResults(final boolean showErrorInfo) { |
1604 changeViewTitle(viewTitle); |
1690 changeViewTitle(viewTitle); |
1605 updateInformationLabel(Constants.INFO_NO_DATA); |
1691 updateInformationLabel(Constants.INFO_NO_DATA); |
1606 return getStartupContent(); |
1692 return getStartupContent(); |
1607 } |
1693 } |
1608 |
1694 |
1609 if( !projectModules.containsKey(project) ) |
1695 if (!projectModules.containsKey(project)) { |
1610 { |
1696 AbstractList<MMPInfo> modules = Util |
1611 AbstractList<MMPInfo> modules = Util.loadProjectTargetsInfo(project); |
1697 .loadProjectTargetsInfo(project); |
1612 projectModules.put(project, modules); |
1698 projectModules.put(project, modules); |
1613 } |
1699 } |
1614 |
1700 |
1615 // get run results |
1701 // get run results |
1616 AbstractList<RunResults> runs = projectResults.getResults(project); |
1702 AbstractList<RunResults> runs = projectResults.getResults(project); |
1637 |
1723 |
1638 IPreferenceStore store = Activator.getPreferences(); |
1724 IPreferenceStore store = Activator.getPreferences(); |
1639 |
1725 |
1640 // create TreeHelper object |
1726 // create TreeHelper object |
1641 // TreeHelper class creates tree model to this view. |
1727 // TreeHelper class creates tree model to this view. |
1642 TreeHelper helper = new TreeHelper(lastSelectedObject, |
1728 TreeHelper helper = new TreeHelper(lastSelectedObject, store); |
1643 store); |
|
1644 |
1729 |
1645 // clear active item |
1730 // clear active item |
1646 activeTreeItem = null; |
1731 activeTreeItem = null; |
1647 |
1732 |
1648 // update used data file name |
1733 // update used data file name |
1649 usedDataFileName = projectResults.getDataFileName(project); |
1734 usedDataFileName = projectResults.getDataFileName(project); |
1650 |
1735 |
1651 // change view title |
1736 // change view title |
1652 changeViewTitle(viewTitle |
1737 changeViewTitle(viewTitle + " results from file: " |
1653 + " results from file: " + usedDataFileName); |
1738 + usedDataFileName); |
1654 |
1739 |
1655 // thru runs |
1740 // thru runs |
1656 Iterator<RunResults> runIterator = runs.iterator(); |
1741 Iterator<RunResults> runIterator = runs.iterator(); |
1657 while (runIterator.hasNext()) { |
1742 while (runIterator.hasNext()) { |
1658 // get one run info |
1743 // get one run info |
1659 RunResults oneRunResults = runIterator.next(); |
1744 RunResults oneRunResults = runIterator.next(); |
1660 |
1745 |
1661 // creates one run information at the time |
1746 // creates one run information at the time |
1662 TreeParent oneRunTree = helper.createRunResults(oneRunResults, modules); |
1747 TreeParent oneRunTree = helper.createRunResults(oneRunResults, |
1748 modules); |
|
1663 |
1749 |
1664 // get active item |
1750 // get active item |
1665 // active must ask from the TreeHelper class |
1751 // active must ask from the TreeHelper class |
1666 // because it can be filtered out when creating new tree model |
1752 // because it can be filtered out when creating new tree model |
1667 activeTreeItem = helper.getActiveItem(); |
1753 activeTreeItem = helper.getActiveItem(); |
1680 return invisibleRoot; |
1766 return invisibleRoot; |
1681 } |
1767 } |
1682 |
1768 |
1683 /** |
1769 /** |
1684 * Sets startup contents for view. |
1770 * Sets startup contents for view. |
1685 * |
1771 * |
1686 * @return Object which can be displayd |
1772 * @return Object which can be displayd |
1687 */ |
1773 */ |
1688 public TreeParent getStartupContent() { |
1774 public TreeParent getStartupContent() { |
1689 // create default treeviewer content |
1775 // create default treeviewer content |
1690 invisibleRoot = new TreeParent(Constants.ANALYZE_TOOL_TITLE); |
1776 invisibleRoot = new TreeParent(Constants.ANALYZE_TOOL_TITLE); |
1732 } |
1818 } |
1733 }); |
1819 }); |
1734 } |
1820 } |
1735 |
1821 |
1736 /** |
1822 /** |
1737 * Check that if subtest by given name allready exists. |
1823 * Check that if subtest by given name already exists. |
1738 * |
1824 * |
1739 * @param subTestName |
1825 * @param subTestName |
1740 * Subtest name |
1826 * Subtest name |
1741 * @param target |
1827 * @param target |
1742 * Testing target |
1828 * Testing target |
1743 * @return True if allready exists otherwise False |
1829 * @return True if already exists otherwise False |
1744 */ |
1830 */ |
1745 public final boolean isSubtestExists(final String subTestName, |
1831 public final boolean isSubtestExists(final String subTestName, |
1746 final String target) { |
1832 final String target) { |
1747 Iterator<ActiveSubtests> subTestIter = startedSubtest.iterator(); |
1833 Iterator<ActiveSubtests> subTestIter = startedSubtest.iterator(); |
1748 while (subTestIter.hasNext()) { |
1834 while (subTestIter.hasNext()) { |
1754 |
1840 |
1755 } |
1841 } |
1756 return false; |
1842 return false; |
1757 } |
1843 } |
1758 |
1844 |
1759 |
|
1760 |
|
1761 /** |
1845 /** |
1762 * Go thru the project files and stores mmp files. |
1846 * Go thru the project files and stores mmp files. |
1763 * |
1847 * |
1764 * @param resource |
1848 * @param resource |
1765 * One resource file of project |
1849 * One resource file of project |
1766 */ |
1850 */ |
1767 public final void loadFileInfo(IResource resource) { |
1851 public final void loadFileInfo(IResource resource) { |
1768 // get all the cpp file info which are imported to workspace |
1852 // get all the cpp file info which are imported to workspace |
1802 |
1886 |
1803 // get call stack addresses to view |
1887 // get call stack addresses to view |
1804 if (obj instanceof TreeObject) { |
1888 if (obj instanceof TreeObject) { |
1805 lastSelectedObject = obj; |
1889 lastSelectedObject = obj; |
1806 |
1890 |
1807 //get callstack items |
1891 // get callstack items |
1808 Object resultObject = getCallStack((TreeObject) obj); |
1892 Object resultObject = getCallStack((TreeObject) obj); |
1809 |
1893 |
1810 // if results not found |
1894 // if results not found |
1811 if( resultObject == null ) { |
1895 if (resultObject == null) { |
1812 copyAction.setEnabled(false); |
1896 copyAction.setEnabled(false); |
1813 } |
1897 } else { |
1814 else { |
|
1815 callstackView.setInput(resultObject); |
1898 callstackView.setInput(resultObject); |
1816 copyAction.setEnabled(true); |
1899 copyAction.setEnabled(true); |
1817 } |
1900 } |
1818 |
1901 |
1819 } |
1902 } |
1965 |
2048 |
1966 clearProjectResults = new Action() { |
2049 clearProjectResults = new Action() { |
1967 @Override |
2050 @Override |
1968 public void run() { |
2051 public void run() { |
1969 cleanAnalyzeData(project); |
2052 cleanAnalyzeData(project); |
1970 if(statisticView != null ) { |
2053 if (statisticView != null) { |
1971 statisticView.clean(project); |
2054 statisticView.clean(project); |
1972 } |
2055 } |
1973 updateChangeDetailState(project); |
2056 updateChangeDetailState(project); |
1974 } |
2057 } |
1975 }; |
2058 }; |
1977 clearProjectResults.setToolTipText(Constants.ACTION_CLEAR_RESULTS); |
2060 clearProjectResults.setToolTipText(Constants.ACTION_CLEAR_RESULTS); |
1978 |
2061 |
1979 refreshResults = new Action() { |
2062 refreshResults = new Action() { |
1980 @Override |
2063 @Override |
1981 public void run() { |
2064 public void run() { |
1982 if( project != null && project.isOpen() && projectResults != null ) { |
2065 if (project != null && project.isOpen() |
2066 && projectResults != null) { |
|
1983 String dataFile = projectResults.getDataFileName(project); |
2067 String dataFile = projectResults.getDataFileName(project); |
1984 if( dataFile != null || !("").equals(dataFile) ) { |
2068 if (dataFile != null || !("").equals(dataFile)) { |
1985 analyzeDataFile(Constants.ANALYZE_USE_DATA_FILE, dataFile, true); |
2069 analyzeDataFile(Constants.ANALYZE_USE_DATA_FILE, |
1986 } |
2070 dataFile, true); |
1987 else { |
2071 } else { |
1988 //some internal error occurred => disable this action |
2072 // some internal error occurred => disable this action |
1989 refreshResults.setEnabled(false); |
2073 refreshResults.setEnabled(false); |
1990 } |
2074 } |
1991 |
2075 |
1992 } |
2076 } |
1993 } |
2077 } |
1994 }; |
2078 }; |
1995 refreshResults.setText(Constants.ACTION_RE_ANALYZE); |
2079 refreshResults.setText(Constants.ACTION_RE_ANALYZE); |
1996 refreshResults.setToolTipText(Constants.ACTION_RE_ANALYZE_TOOLTIP); |
2080 refreshResults.setToolTipText(Constants.ACTION_RE_ANALYZE_TOOLTIP); |
1997 refreshResults.setEnabled(false); |
2081 refreshResults.setEnabled(false); |
1998 |
2082 |
1999 //copy active item contents to clipboard |
2083 // copy active item contents to clipboard |
2000 copyAction = new Action(){ |
2084 copyAction = new Action() { |
2001 @Override |
2085 @Override |
2002 public void run() { |
2086 public void run() { |
2003 //copy active item contents to clipboard |
2087 // copy active item contents to clipboard |
2004 |
2088 |
2005 //Create new clipboard object |
2089 // Create new clipboard object |
2006 Clipboard cp = new Clipboard(runView.getControl().getDisplay()); |
2090 Clipboard cp = new Clipboard(runView.getControl().getDisplay()); |
2007 |
2091 |
2008 //Create new TextTransfer object |
2092 // Create new TextTransfer object |
2009 //TextTransfer converts plain text represented as a java String to a platform specific representation of the data and vice versa |
2093 // TextTransfer converts plain text represented as a java String |
2094 // to a platform specific representation of the data and vice |
|
2095 // versa |
|
2010 TextTransfer tt = TextTransfer.getInstance(); |
2096 TextTransfer tt = TextTransfer.getInstance(); |
2011 |
2097 |
2012 //new StringBuffer which contains the copied text |
2098 // new StringBuffer which contains the copied text |
2013 StringBuffer sb = new StringBuffer(64); |
2099 StringBuffer sb = new StringBuffer(64); |
2014 |
2100 |
2015 // chech that project contains results |
2101 // chech that project contains results |
2016 if( projectResults == null || !projectResults.contains(project) || activeTreeItem == null ) { |
2102 if (projectResults == null || !projectResults.contains(project) |
2103 || activeTreeItem == null) { |
|
2017 return; |
2104 return; |
2018 } |
2105 } |
2019 //get active item info (also callstack info) |
2106 // get active item info (also callstack info) |
2020 AnalysisItem item = null; |
2107 AnalysisItem item = null; |
2021 |
2108 |
2022 // if selected item is subtest |
2109 // if selected item is subtest |
2023 if( activeTreeItem.isSubTest() ) { |
2110 if (activeTreeItem.isSubTest()) { |
2024 item = projectResults.getSubtestItem(project, |
2111 item = projectResults.getSubtestItem(project, |
2025 activeTreeItem.getRunID(), activeTreeItem.getMemLeakID(), |
2112 activeTreeItem.getRunID(), activeTreeItem |
2026 activeTreeItem.getSubtestID()); |
2113 .getMemLeakID(), activeTreeItem |
2027 } |
2114 .getSubtestID()); |
2028 else { |
2115 } else { |
2029 item = projectResults.getSpecific(project, activeTreeItem.getRunID(), activeTreeItem.getMemLeakID()); |
2116 item = projectResults.getSpecific(project, activeTreeItem |
2117 .getRunID(), activeTreeItem.getMemLeakID()); |
|
2030 } |
2118 } |
2031 |
2119 |
2032 // check that item found |
2120 // check that item found |
2033 if( item == null ) { |
2121 if (item == null) { |
2034 return; |
2122 return; |
2035 } |
2123 } |
2036 |
2124 |
2037 sb.append(activeTreeItem.getName()); |
2125 sb.append(activeTreeItem.getName()); |
2038 String separator = System.getProperty ( "line.separator" ); |
2126 String separator = System.getProperty("line.separator"); |
2039 sb.append(separator); |
2127 sb.append(separator); |
2040 char space = ' '; |
2128 char space = ' '; |
2041 AbstractList<CallstackItem> callstackItems = item.getCallstackItems(); |
2129 AbstractList<CallstackItem> callstackItems = item |
2042 Iterator<CallstackItem> iterCallstack = callstackItems.iterator(); |
2130 .getCallstackItems(); |
2043 while( iterCallstack.hasNext() ) { |
2131 Iterator<CallstackItem> iterCallstack = callstackItems |
2132 .iterator(); |
|
2133 while (iterCallstack.hasNext()) { |
|
2044 CallstackItem oneItem = iterCallstack.next(); |
2134 CallstackItem oneItem = iterCallstack.next(); |
2045 sb.append(" "); |
2135 sb.append(" "); |
2046 sb.append(oneItem.getMemoryAddress()); |
2136 sb.append(oneItem.getMemoryAddress()); |
2047 sb.append(space); |
2137 sb.append(space); |
2048 sb.append(oneItem.getModuleName()); |
2138 sb.append(oneItem.getModuleName()); |
2050 sb.append(oneItem.getFunctionName()); |
2140 sb.append(oneItem.getFunctionName()); |
2051 sb.append(space); |
2141 sb.append(space); |
2052 sb.append(oneItem.getFileName()); |
2142 sb.append(oneItem.getFileName()); |
2053 sb.append(space); |
2143 sb.append(space); |
2054 int lineNbr = oneItem.getLeakLineNumber(); |
2144 int lineNbr = oneItem.getLeakLineNumber(); |
2055 if( lineNbr > 0 ) { |
2145 if (lineNbr > 0) { |
2056 sb.append(lineNbr); |
2146 sb.append(lineNbr); |
2057 } |
2147 } |
2058 sb.append(separator); |
2148 sb.append(separator); |
2059 } |
2149 } |
2060 |
2150 |
2061 //info is ready => now copy info to clipboard |
2151 // info is ready => now copy info to clipboard |
2062 cp.setContents(new Object[] { sb.toString() }, |
2152 cp.setContents(new Object[] { sb.toString() }, |
2063 new Transfer[] { tt }); |
2153 new Transfer[] { tt }); |
2064 } |
2154 } |
2065 }; |
2155 }; |
2066 copyAction.setText(Constants.ACTION_COPY); |
2156 copyAction.setText(Constants.ACTION_COPY); |
2067 copyAction.setEnabled(false); |
2157 copyAction.setEnabled(false); |
2068 |
2158 |
2069 // open preferences action |
2159 // open preferences action |
2070 openPrefs = new Action() { |
2160 openPrefs = new Action() { |
2071 @Override |
2161 @Override |
2072 public void run() { |
2162 public void run() { |
2073 PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), |
2163 PreferenceDialog dialog = PreferencesUtil |
2074 Constants.ANALYZE_TOOL_PREFS_ID, null, null); |
2164 .createPreferenceDialogOn(PlatformUI.getWorkbench() |
2075 |
2165 .getActiveWorkbenchWindow().getShell(), |
2076 if( dialog != null ) { |
2166 Constants.ANALYZE_TOOL_PREFS_ID, null, null); |
2167 |
|
2168 if (dialog != null) { |
|
2077 dialog.open(); |
2169 dialog.open(); |
2078 } |
2170 } |
2079 } |
2171 } |
2080 }; |
2172 }; |
2081 openPrefs.setText(Constants.ACTION_OPEN_PREFS); |
2173 openPrefs.setText(Constants.ACTION_OPEN_PREFS); |
2082 openPrefs.setToolTipText(Constants.ACTION_OPEN_PREFS_TOOLTIP); |
2174 openPrefs.setToolTipText(Constants.ACTION_OPEN_PREFS_TOOLTIP); |
2083 openPrefs.setImageDescriptor(Activator.getImageDescriptor(Constants.BUTTON_OPEN_PREFS)); |
2175 openPrefs.setImageDescriptor(Activator |
2084 |
2176 .getImageDescriptor(Constants.BUTTON_OPEN_PREFS)); |
2177 |
|
2085 changeReportActionTooltip(); |
2178 changeReportActionTooltip(); |
2086 updateChangeDetailState(project); |
2179 updateChangeDetailState(project); |
2087 updateBuildState(project); |
2180 updateBuildState(project); |
2088 } |
2181 } |
2089 |
2182 |
2096 fileOpenMenu.setImageDescriptor(Activator |
2189 fileOpenMenu.setImageDescriptor(Activator |
2097 .getImageDescriptor(Constants.BUTTON_OPEN)); |
2190 .getImageDescriptor(Constants.BUTTON_OPEN)); |
2098 } |
2191 } |
2099 |
2192 |
2100 /** |
2193 /** |
2101 * Creates file open actions. |
2194 * Creates data gathering actions. |
2102 */ |
2195 */ |
2103 private void makeLogTargetActions() { |
2196 private void makeLogTargetActions() { |
2104 |
2197 |
2105 s60LogTargetAction = new Action(Constants.LOGGING_S60, Action.AS_RADIO_BUTTON) { |
2198 s60LogTargetAction = new Action(Constants.LOGGING_S60, |
2199 IAction.AS_RADIO_BUTTON) { |
|
2106 @Override |
2200 @Override |
2107 public void run() { |
2201 public void run() { |
2108 changeLogTarget(Constants.LOGGING_S60); |
2202 changeLogTarget(Constants.LOGGING_S60); |
2109 } |
2203 } |
2110 }; |
2204 }; |
2112 s60LogTargetAction |
2206 s60LogTargetAction |
2113 .setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_S60); |
2207 .setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_S60); |
2114 s60LogTargetAction.setImageDescriptor(Activator |
2208 s60LogTargetAction.setImageDescriptor(Activator |
2115 .getImageDescriptor(Constants.BUTTON_CELLURAR)); |
2209 .getImageDescriptor(Constants.BUTTON_CELLURAR)); |
2116 |
2210 |
2117 externalLogTargetAction = new Action(Constants.LOGGING_EXT, Action.AS_RADIO_BUTTON) { |
2211 externalLogTargetAction = new Action(Constants.LOGGING_EXT, |
2212 IAction.AS_RADIO_BUTTON) { |
|
2118 @Override |
2213 @Override |
2119 public void run() { |
2214 public void run() { |
2120 changeLogTarget(Constants.LOGGING_EXT); |
2215 changeLogTarget(Constants.LOGGING_EXT); |
2121 } |
2216 } |
2122 }; |
2217 }; |
2124 externalLogTargetAction |
2219 externalLogTargetAction |
2125 .setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_EXT); |
2220 .setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_EXT); |
2126 externalLogTargetAction.setImageDescriptor(Activator |
2221 externalLogTargetAction.setImageDescriptor(Activator |
2127 .getImageDescriptor(Constants.BUTTON_COMPUTER)); |
2222 .getImageDescriptor(Constants.BUTTON_COMPUTER)); |
2128 |
2223 |
2129 externalFastLogTargetAction = new Action(Constants.LOGGING_EXT_FAST, Action.AS_RADIO_BUTTON) { |
2224 externalFastLogTargetAction = new Action(Constants.LOGGING_EXT_FAST, |
2225 IAction.AS_RADIO_BUTTON) { |
|
2130 @Override |
2226 @Override |
2131 public void run() { |
2227 public void run() { |
2132 changeLogTarget(Constants.LOGGING_EXT_FAST); |
2228 changeLogTarget(Constants.LOGGING_EXT_FAST); |
2133 } |
2229 } |
2134 }; |
2230 }; |
2135 externalFastLogTargetAction.setText(Constants.PREFS_EXT_FAST); |
2231 externalFastLogTargetAction.setText(Constants.PREFS_EXT_FAST); |
2136 externalFastLogTargetAction.setToolTipText(Constants.PREFS_EXT_FAST_TOOLTIP); |
2232 externalFastLogTargetAction |
2233 .setToolTipText(Constants.PREFS_EXT_FAST_TOOLTIP); |
|
2137 externalFastLogTargetAction.setImageDescriptor(Activator |
2234 externalFastLogTargetAction.setImageDescriptor(Activator |
2138 .getImageDescriptor(Constants.BUTTON_COMPUTER_FAST)); |
2235 .getImageDescriptor(Constants.BUTTON_COMPUTER_FAST)); |
2139 |
2236 |
2140 askLogTargetAction = new Action(Constants.LOGGING_ASK_ALLWAYS, Action.AS_RADIO_BUTTON) { |
2237 askLogTargetAction = new Action(Constants.LOGGING_ASK_ALLWAYS, |
2238 IAction.AS_RADIO_BUTTON) { |
|
2141 @Override |
2239 @Override |
2142 public void run() { |
2240 public void run() { |
2143 changeLogTarget(Constants.LOGGING_ASK_ALLWAYS); |
2241 changeLogTarget(Constants.LOGGING_ASK_ALLWAYS); |
2144 } |
2242 } |
2145 }; |
2243 }; |
2146 |
|
2147 |
2244 |
2148 askLogTargetAction.setText(Constants.PREFS_ASK_ALWAYS); |
2245 askLogTargetAction.setText(Constants.PREFS_ASK_ALWAYS); |
2149 askLogTargetAction |
2246 askLogTargetAction |
2150 .setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_ASK); |
2247 .setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_ASK); |
2151 askLogTargetAction.setImageDescriptor(Activator |
2248 askLogTargetAction.setImageDescriptor(Activator |
2152 .getImageDescriptor(Constants.BUTTON_ASK)); |
2249 .getImageDescriptor(Constants.BUTTON_ASK)); |
2153 |
2250 |
2154 } |
2251 } |
2155 |
2252 |
2156 /** |
2253 /** |
2157 * Opens current callstack item on default editor and pinpoints memory leak. |
2254 * Displays selected callstack item location on default file editor. |
2158 * line |
2255 * |
2159 * |
|
2160 * @param treeObject |
2256 * @param treeObject |
2161 * Tree object |
2257 * Tree object |
2162 */ |
2258 */ |
2163 public final void openEditor(final TreeObject treeObject) { |
2259 public final void openEditor(final TreeObject treeObject) { |
2164 // get file info for all projects |
2260 // get file info for all projects |
2243 } |
2339 } |
2244 } |
2340 } |
2245 |
2341 |
2246 /** |
2342 /** |
2247 * Updates log target action and report action tooltips. |
2343 * Updates log target action and report action tooltips. |
2248 * |
2344 * |
2249 * @see com.nokia.s60tools.analyzetool.ui.IActionListener#preferenceChanged() |
2345 * @see com.nokia.s60tools.analyzetool.ui.IActionListener#preferenceChanged() |
2250 */ |
2346 */ |
2251 public void preferenceChanged() { |
2347 public void preferenceChanged() { |
2252 // get active logging mode |
2348 // get active logging mode |
2253 changeLogTarget(null); |
2349 changeLogTarget(null); |
2268 // refresh view |
2364 // refresh view |
2269 runView.setInput(getResults(false)); |
2365 runView.setInput(getResults(false)); |
2270 |
2366 |
2271 // refresh callstack view |
2367 // refresh callstack view |
2272 getCallStack(activeTreeItem); |
2368 getCallStack(activeTreeItem); |
2273 if( project != null && project.isOpen() && projectResults.contains(project)) { |
2369 if (project != null && project.isOpen() |
2370 && projectResults.contains(project)) { |
|
2274 clearProjectResults.setEnabled(true); |
2371 clearProjectResults.setEnabled(true); |
2275 } |
2372 } else { |
2276 else { |
|
2277 clearProjectResults.setEnabled(false); |
2373 clearProjectResults.setEnabled(false); |
2278 } |
2374 } |
2279 updateChangeDetailState(project); |
2375 updateChangeDetailState(project); |
2280 |
2376 |
2281 } |
2377 } |
2282 }); |
2378 }); |
2283 } |
2379 } |
2284 |
2380 |
2285 /** |
2381 /** |
2286 * Runs user selected AnalyzeTool action. |
2382 * Runs user selected AnalyzeTool action. |
2287 * |
2383 * |
2288 * @see com.nokia.s60tools.analyzetool.ui.IActionListener#runAction(IProject, com.nokia.s60tools.analyzetool.global.Constants.ACTIONS) |
2384 * @see com.nokia.s60tools.analyzetool.ui.IActionListener#runAction(IProject, |
2289 * |
2385 * com.nokia.s60tools.analyzetool.global.Constants.ACTIONS) |
2386 * |
|
2290 * @param projectRef |
2387 * @param projectRef |
2291 * Project reference |
2388 * Project reference |
2292 * |
2389 * |
2293 * @param action |
2390 * @param action |
2294 * Which action to execute |
2391 * Which action to execute |
2295 */ |
2392 */ |
2296 public void runAction(IProject projectRef, Constants.ACTIONS action) { |
2393 public void runAction(IProject projectRef, Constants.ACTIONS action) { |
2297 project = projectRef; |
2394 project = projectRef; |
2313 break; |
2410 break; |
2314 } |
2411 } |
2315 } |
2412 } |
2316 |
2413 |
2317 /** |
2414 /** |
2318 * Saves existing report or data file asks user where to save. |
2415 * Copies existing report or data file to the new location. Asks from user |
2319 * |
2416 * new location where to copy the file. |
2417 * |
|
2320 * @param type |
2418 * @param type |
2321 * Which kind of type the file is. Possible types xml or data |
2419 * Which kind of type the file is. Possible types xml or data |
2322 * file |
2420 * file |
2323 * |
2421 * |
2324 * @return True if saving successfully otherwise false |
2422 * @return True if saving successfully otherwise false |
2325 */ |
2423 */ |
2326 public final boolean saveReportFile(final int type) { |
2424 public final boolean saveReportFile(final int type) { |
2327 // copy success? |
2425 // copy success? |
2328 boolean success = false; |
2426 boolean success = false; |
2430 } |
2528 } |
2431 |
2529 |
2432 /** |
2530 /** |
2433 * Notifies this action delegate that the selection in the workbench has |
2531 * Notifies this action delegate that the selection in the workbench has |
2434 * changed. |
2532 * changed. |
2435 * |
2533 * |
2436 * @param part |
2534 * @param part |
2437 * Workbench part |
2535 * Workbench part |
2438 * |
2536 * |
2439 * @param selection |
2537 * @param selection |
2440 * User selection |
2538 * User selection |
2441 */ |
2539 */ |
2442 @SuppressWarnings("restriction") |
2540 @SuppressWarnings("restriction") |
2443 public void selectionChanged(IWorkbenchPart part, ISelection selection) { |
2541 public void selectionChanged(IWorkbenchPart part, ISelection selection) { |
2444 // project reference |
2542 // project reference |
2445 IProject selectedProject = null; |
2543 IProject selectedProject = null; |
2446 |
2544 |
2447 // check where the selection comes |
2545 // Check where the selection comes from |
2448 // supported views: CommonNavigator and SymbianProjectNavigator |
2546 // Supported views: CommonNavigator, SymbianProjectNavigatorView and |
2449 if (!(part instanceof org.eclipse.ui.navigator.CommonNavigator) ) { |
2547 // ResourceNavigator |
2548 |
|
2549 if (!(part instanceof CommonNavigator |
|
2550 || part instanceof SymbianProjectNavigatorView || part instanceof ResourceNavigator)) { |
|
2450 return; |
2551 return; |
2451 } |
2552 } |
2452 |
2553 |
2453 // get selection |
2554 // get selection |
2454 IStructuredSelection structuredSelection = (IStructuredSelection) selection; |
2555 IStructuredSelection structuredSelection = (IStructuredSelection) selection; |
2468 .getCProject().getProject(); |
2569 .getCProject().getProject(); |
2469 } else if (adaptable instanceof org.eclipse.cdt.core.model.ICProject) { |
2570 } else if (adaptable instanceof org.eclipse.cdt.core.model.ICProject) { |
2470 selectedProject = ((org.eclipse.cdt.core.model.ICProject) adaptable) |
2571 selectedProject = ((org.eclipse.cdt.core.model.ICProject) adaptable) |
2471 .getProject(); |
2572 .getProject(); |
2472 } else { |
2573 } else { |
2473 resource = (IResource) adaptable |
2574 resource = (IResource) adaptable.getAdapter(IResource.class); |
2474 .getAdapter(IResource.class); |
|
2475 } |
2575 } |
2476 |
2576 |
2477 // resource found => get resource project |
2577 // resource found => get resource project |
2478 if (resource != null) { |
2578 if (resource != null) { |
2479 selectedProject = resource.getProject(); |
2579 selectedProject = resource.getProject(); |
2488 // if project found and it is open => get project results |
2588 // if project found and it is open => get project results |
2489 if (selectedProject != null && selectedProject.isOpen()) { |
2589 if (selectedProject != null && selectedProject.isOpen()) { |
2490 project = selectedProject; |
2590 project = selectedProject; |
2491 getProjectResults(selectedProject); |
2591 getProjectResults(selectedProject); |
2492 updateBuildState(project); |
2592 updateBuildState(project); |
2493 if( statisticView != null ) { |
2593 if (statisticView != null) { |
2494 statisticView.handleProjectChange(project); |
2594 statisticView.handleProjectChange(project); |
2495 } |
2595 } |
2496 } |
2596 } |
2497 } |
2597 } |
2498 |
2598 |
2499 |
2599 /** |
2500 /** |
2600 * Executes clickAction when user selects item in the AnalyzeTool view. |
2501 * Executes clicAction when user selects item in the AnalyzeTool view. |
2601 * |
2502 * |
|
2503 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) |
2602 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) |
2504 * |
2603 * |
2505 * @param event |
2604 * @param event |
2506 * Selection changed event |
2605 * Selection changed event |
2507 */ |
2606 */ |
2508 public void selectionChanged(SelectionChangedEvent event) { |
2607 public void selectionChanged(SelectionChangedEvent event) { |
2509 clickAction.run(); |
2608 clickAction.run(); |
2556 |
2655 |
2557 } |
2656 } |
2558 |
2657 |
2559 /** |
2658 /** |
2560 * Shows error message. |
2659 * Shows error message. |
2561 * |
2660 * |
2562 * @param message |
2661 * @param message |
2563 * Error message to show |
2662 * Error message to show |
2564 */ |
2663 */ |
2565 public final void showErrorMessage(final String message) { |
2664 public final void showErrorMessage(final String message) { |
2566 runView.getControl().getDisplay().syncExec(new Runnable() { |
2665 runView.getControl().getDisplay().syncExec(new Runnable() { |
2570 }); |
2669 }); |
2571 } |
2670 } |
2572 |
2671 |
2573 /** |
2672 /** |
2574 * Shows message. |
2673 * Shows message. |
2575 * |
2674 * |
2576 * @param message |
2675 * @param message |
2577 * Message to show |
2676 * Message to show |
2578 */ |
2677 */ |
2579 public final void showMessage(final String message) { |
2678 public final void showMessage(final String message) { |
2580 runView.getControl().getDisplay().syncExec(new Runnable() { |
2679 runView.getControl().getDisplay().syncExec(new Runnable() { |
2612 |
2711 |
2613 // delete existing data file |
2712 // delete existing data file |
2614 Util.deleteDataFile(project); |
2713 Util.deleteDataFile(project); |
2615 } |
2714 } |
2616 |
2715 |
2617 ICarbideProjectInfo info = CarbideBuilderPlugin.getBuildManager().getProjectInfo(project); |
2716 ICarbideProjectInfo info = CarbideBuilderPlugin.getBuildManager() |
2717 .getProjectInfo(project); |
|
2618 ICarbideBuildConfiguration config = info.getDefaultConfiguration(); |
2718 ICarbideBuildConfiguration config = info.getDefaultConfiguration(); |
2619 |
2719 |
2620 //start listening emulator output |
2720 // start listening emulator output |
2621 if( config.getPlatformString().equals(Constants.BUILD_TARGET_WINSCW) ) { |
2721 if (config.getPlatformString().equals(Constants.BUILD_TARGET_WINSCW)) { |
2722 |
|
2723 String dbghelpDllVersionInfo = Util.getDbghelpDllVersionInfo(Util |
|
2724 .getAtoolInstallFolder()); |
|
2725 |
|
2726 if (dbghelpDllVersionInfo != Constants.DBGHELPDLL_IS_UP_TO_DATE) { |
|
2727 |
|
2728 DbghelpDllVersionInfoDialog dialog = new DbghelpDllVersionInfoDialog( |
|
2729 getSite().getShell(), dbghelpDllVersionInfo); |
|
2730 |
|
2731 if (dialog.open() == Window.CANCEL) |
|
2732 return; |
|
2733 } |
|
2622 |
2734 |
2623 listeningJob = new EpocReader(project, this); |
2735 listeningJob = new EpocReader(project, this); |
2624 listeningJob.start(); |
2736 listeningJob.start(); |
2625 |
2737 |
2626 traceStarted(); |
2738 traceStarted(); |
2627 |
2739 |
2628 return; |
2740 return; |
2629 } |
2741 } |
2630 |
2742 |
2631 // else start trace capturing using Tracing utility connection |
2743 // else start trace capturing using TraceViewer connection |
2632 |
2744 |
2633 // main view class instance |
2745 // main view class instance |
2634 // this instance if passed to the TraceWrapper class |
2746 // this instance if passed to the TraceWrapper class |
2635 final MainView selfInstance = this; |
2747 final MainView selfInstance = this; |
2636 Job activateTrace = new Job(Constants.STARTING_TRACE) { |
2748 Job activateTrace = new Job(Constants.STARTING_TRACE) { |
2748 } else { |
2860 } else { |
2749 target = Util.openSelectionDialog(Constants.SUBTEST_SELECT_TARGET, |
2861 target = Util.openSelectionDialog(Constants.SUBTEST_SELECT_TARGET, |
2750 Constants.SUBTEST_RUNNING_PROCESSES_INFO, targets); |
2862 Constants.SUBTEST_RUNNING_PROCESSES_INFO, targets); |
2751 |
2863 |
2752 } |
2864 } |
2753 if (target == null || ("").equals(target) ) { |
2865 if (target == null || ("").equals(target)) { |
2754 return; |
2866 return; |
2755 } |
2867 } |
2756 |
2868 |
2757 // ask for subtest name |
2869 // ask for subtest name |
2758 CustomInputDialog dialog = new CustomInputDialog( |
2870 CustomInputDialog dialog = new CustomInputDialog( |
2765 } |
2877 } |
2766 |
2878 |
2767 // get process id for selected target |
2879 // get process id for selected target |
2768 int processID = startedPros.get(target); |
2880 int processID = startedPros.get(target); |
2769 |
2881 |
2770 // if subtest allready exists |
2882 // if subtest already exists |
2771 if (isSubtestExists(subTestName, target)) { |
2883 if (isSubtestExists(subTestName, target)) { |
2772 Util.showMessage(Constants.SUBTEST_ALLREADY_RUNNING); |
2884 Util.showMessage(Constants.SUBTEST_ALLREADY_RUNNING); |
2773 return; |
2885 return; |
2774 } |
2886 } |
2775 |
2887 |
2777 ActiveSubtests subtes = new ActiveSubtests(subTestName, target, |
2889 ActiveSubtests subtes = new ActiveSubtests(subTestName, target, |
2778 processID); |
2890 processID); |
2779 startedSubtest.add(subtes); |
2891 startedSubtest.add(subtes); |
2780 |
2892 |
2781 // start subtest |
2893 // start subtest |
2782 parser.parse(Constants.PREFIX + " " + processID + " TEST_START 0000 " |
2894 parser.parse(Constants.PREFIX + " " + subtes.getProcessID() |
2783 + subTestName); |
2895 + " TEST_START 0000 " + subTestName); |
2784 updateSubtestInfoText(Constants.SUBTEST_STARTED + target |
2896 updateSubtestInfoText(Constants.SUBTEST_STARTED + target |
2785 + Constants.ENRULE + subTestName); |
2897 + Constants.ENRULE + subTestName); |
2786 |
2898 |
2787 stopSubtest.setEnabled(true); |
2899 stopSubtest.setEnabled(true); |
2788 } |
2900 } |
2790 /** |
2902 /** |
2791 * Stop external message tracing. |
2903 * Stop external message tracing. |
2792 */ |
2904 */ |
2793 public final void stop(boolean analyze) { |
2905 public final void stop(boolean analyze) { |
2794 |
2906 |
2795 ICarbideProjectInfo info = CarbideBuilderPlugin.getBuildManager().getProjectInfo(project); |
2907 ICarbideProjectInfo info = CarbideBuilderPlugin.getBuildManager() |
2908 .getProjectInfo(project); |
|
2796 ICarbideBuildConfiguration config = info.getDefaultConfiguration(); |
2909 ICarbideBuildConfiguration config = info.getDefaultConfiguration(); |
2797 if( config.getPlatformString().equalsIgnoreCase(Constants.BUILD_TARGET_WINSCW) ) { |
2910 if (config.getPlatformString().equalsIgnoreCase( |
2911 Constants.BUILD_TARGET_WINSCW)) { |
|
2798 listeningJob.stop(); |
2912 listeningJob.stop(); |
2799 traceStopped(analyze); |
2913 traceStopped(analyze); |
2800 return; |
2914 return; |
2801 } |
2915 } |
2802 |
2916 |
2803 //else stop Tracing utility connection |
2917 // else stop TraceViewer connection |
2804 try { |
2918 try { |
2805 Class<?> buildManagerClass = Class |
2919 Class<?> buildManagerClass = Class |
2806 .forName("com.nokia.s60tools.analyzetool.trace.TraceWrapper"); |
2920 .forName("com.nokia.s60tools.analyzetool.trace.TraceWrapper"); |
2807 |
2921 |
2808 java.lang.reflect.Method[] methods = buildManagerClass.getMethods(); |
2922 java.lang.reflect.Method[] methods = buildManagerClass.getMethods(); |
2815 String returnValue = (String) oneMethod.invoke( |
2929 String returnValue = (String) oneMethod.invoke( |
2816 buildManagerClass.newInstance(), new Object[] {}); |
2930 buildManagerClass.newInstance(), new Object[] {}); |
2817 if (("").equals(returnValue)) { |
2931 if (("").equals(returnValue)) { |
2818 traceStopped(analyze); |
2932 traceStopped(analyze); |
2819 } else { |
2933 } else { |
2820 showErrorMessage("Error while disconnecting Tracing utility"); |
2934 showErrorMessage("Error while disconnecting TraceViewer"); |
2821 traceAction.setImageDescriptor(Activator |
2935 traceAction.setImageDescriptor(Activator |
2822 .getImageDescriptor((Constants.BUTTON_STOP))); |
2936 .getImageDescriptor((Constants.BUTTON_STOP))); |
2823 traceActive = true; |
2937 traceActive = true; |
2824 } |
2938 } |
2825 } |
2939 } |
2851 private void traceStopped(boolean analyze) { |
2965 private void traceStopped(boolean analyze) { |
2852 // update icon and information text |
2966 // update icon and information text |
2853 traceAction.setImageDescriptor(Activator |
2967 traceAction.setImageDescriptor(Activator |
2854 .getImageDescriptor((Constants.BUTTON_RUN))); |
2968 .getImageDescriptor((Constants.BUTTON_RUN))); |
2855 traceAction.setText(Constants.ACTION_START_TRACE); |
2969 traceAction.setText(Constants.ACTION_START_TRACE); |
2856 traceAction |
2970 traceAction.setToolTipText(Constants.ACTION_START_TRACE); |
2857 .setToolTipText(Constants.ACTION_START_TRACE); |
|
2858 traceActive = false; |
2971 traceActive = false; |
2859 |
2972 |
2860 // close any active subtests |
2973 // close any active subtests |
2861 if (!startedSubtest.isEmpty()) { |
2974 if (!startedSubtest.isEmpty()) { |
2862 for (int j = 0; j < startedSubtest.size(); j++) { |
2975 for (int j = 0; j < startedSubtest.size(); j++) { |
2863 ActiveSubtests oneSubtest = startedSubtest |
2976 ActiveSubtests oneSubtest = startedSubtest.get(j); |
2864 .get(j); |
2977 parser.parse(Constants.PREFIX + " " + oneSubtest.getProcessID() |
2865 parser.parse(Constants.PREFIX + " " |
2978 + " TEST_END" + " 0000 " + oneSubtest.getName()); |
2866 + oneSubtest.getProcessID() |
|
2867 + " TEST_END" + " 0000 " |
|
2868 + oneSubtest.getName()); |
|
2869 } |
2979 } |
2870 startedSubtest.clear(); |
2980 startedSubtest.clear(); |
2871 } |
2981 } |
2872 |
2982 |
2873 // tell parser to finish => write data to file |
2983 // tell parser to finish => write data to file |
2884 cleanAtoolChanges.setEnabled(true); |
2994 cleanAtoolChanges.setEnabled(true); |
2885 |
2995 |
2886 project = traceStartedProjectRef; |
2996 project = traceStartedProjectRef; |
2887 |
2997 |
2888 // parse and analyze saved data file |
2998 // parse and analyze saved data file |
2889 if( analyze ) { |
2999 if (analyze) { |
2890 analyzeDataFile(Constants.ANALYZE_USE_DATA_FILE, null, |
3000 analyzeDataFile(Constants.ANALYZE_USE_DATA_FILE, null, true); |
2891 true); |
3001 } |
2892 } |
3002 } |
2893 } |
3003 |
2894 |
3004 /** |
2895 /** |
3005 * Stop one subtest. If there is multiple subtests running ask for user to |
2896 * Stop one subtest If there multiple subtest running ask for user to which |
3006 * which one to stop. |
2897 * one to stop. |
|
2898 */ |
3007 */ |
2899 public final void stopSubTest() { |
3008 public final void stopSubTest() { |
2900 // no processes show info |
3009 // no processes show info |
2901 if (startedSubtest.isEmpty()) { |
3010 if (startedSubtest.isEmpty()) { |
2902 Util.showMessage(Constants.SUBTEST_NO_SUBTESTS); |
3011 Util.showMessage(Constants.SUBTEST_NO_SUBTESTS); |
2958 } |
3067 } |
2959 } |
3068 } |
2960 |
3069 |
2961 /** |
3070 /** |
2962 * When AnalyzeTool view tree model is collapsed. |
3071 * When AnalyzeTool view tree model is collapsed. |
2963 * |
3072 * |
2964 * @see org.eclipse.jface.viewers.ITreeViewerListener#treeCollapsed(org.eclipse.jface.viewers.TreeExpansionEvent) |
3073 * @see org.eclipse.jface.viewers.ITreeViewerListener#treeCollapsed(org.eclipse.jface.viewers.TreeExpansionEvent) |
2965 * |
3074 * |
2966 * @param event |
3075 * @param event |
2967 * Tree expansion event |
3076 * Tree expansion event |
2968 */ |
3077 */ |
2969 public void treeCollapsed(TreeExpansionEvent event) { |
3078 public void treeCollapsed(TreeExpansionEvent event) { |
2970 // MethodDeclaration/Block[count(BlockStatement) = 0 and |
3079 // MethodDeclaration/Block[count(BlockStatement) = 0 and |
2971 // @containsComment = 'false'] |
3080 // @containsComment = 'false'] |
2972 } |
3081 } |
2973 |
3082 |
2974 /** |
3083 /** |
2975 * When AnalyzeTool view tree model is expanded. |
3084 * When AnalyzeTool view tree model is expanded. |
2976 * |
3085 * |
2977 * @see org.eclipse.jface.viewers.ITreeViewerListener#treeExpanded(org.eclipse.jface.viewers.TreeExpansionEvent) |
3086 * @see org.eclipse.jface.viewers.ITreeViewerListener#treeExpanded(org.eclipse.jface.viewers.TreeExpansionEvent) |
2978 * |
3087 * |
2979 * @param event |
3088 * @param event |
2980 * Tree expansion event |
3089 * Tree expansion event |
2981 */ |
3090 */ |
2982 public void treeExpanded(TreeExpansionEvent event) { |
3091 public void treeExpanded(TreeExpansionEvent event) { |
2983 // MethodDeclaration/Block[count(BlockStatement) = 0 and |
3092 // MethodDeclaration/Block[count(BlockStatement) = 0 and |
2984 // @containsComment = 'false'] |
3093 // @containsComment = 'false'] |
2985 } |
3094 } |
2986 |
3095 |
2987 /** |
3096 /** |
2988 * Updates allocation count in the information label. |
3097 * Updates allocation count in the information label. |
2989 * |
3098 * |
2990 * The information layout is hard to modify so we need to manage information |
3099 * The information layout is hard to modify so we need to manage information |
2991 * label text |
3100 * label text |
2992 */ |
3101 */ |
2993 public final void updateAllocNumber() { |
3102 public final void updateAllocNumber() { |
2994 |
3103 |
3034 |
3143 |
3035 } |
3144 } |
3036 |
3145 |
3037 /** |
3146 /** |
3038 * Update build action icon and tooltip text. |
3147 * Update build action icon and tooltip text. |
3039 * |
3148 * |
3040 * @param projectRef |
3149 * @param projectRef |
3041 * Project reference |
3150 * Project reference |
3042 */ |
3151 */ |
3043 public final void updateBuildState(final IProject projectRef) { |
3152 public final void updateBuildState(final IProject projectRef) { |
3044 if (buildWithAtool == null) { |
3153 if (buildWithAtool == null) { |
3065 } |
3174 } |
3066 |
3175 |
3067 } |
3176 } |
3068 |
3177 |
3069 /** |
3178 /** |
3070 * Indicates the target (emulator/device) by inspecting the given projects build configuration. |
3179 * Indicates the target (emulator/device) by inspecting the given projects |
3071 * @param selectedProject the currently active project |
3180 * build configuration. |
3072 * @return "emulator" if the build configuration is WINSCW, "device" otherwise |
3181 * |
3182 * @param selectedProject |
|
3183 * the currently active project |
|
3184 * @return "emulator" if the build configuration is WINSCW, "device" |
|
3185 * otherwise |
|
3073 */ |
3186 */ |
3074 private static String getTraceTarget(final IProject selectedProject) { |
3187 private static String getTraceTarget(final IProject selectedProject) { |
3075 String target = ""; |
3188 String target = ""; |
3076 if (selectedProject != null && selectedProject.isOpen()) { |
3189 if (selectedProject != null && selectedProject.isOpen()) { |
3077 ICarbideProjectInfo info = CarbideBuilderPlugin.getBuildManager().getProjectInfo(selectedProject); |
3190 ICarbideProjectInfo info = CarbideBuilderPlugin.getBuildManager() |
3191 .getProjectInfo(selectedProject); |
|
3078 if (info != null) { |
3192 if (info != null) { |
3079 ICarbideBuildConfiguration config = info.getDefaultConfiguration(); |
3193 ICarbideBuildConfiguration config = info |
3194 .getDefaultConfiguration(); |
|
3080 target = config.getPlatformString().equals( |
3195 target = config.getPlatformString().equals( |
3081 Constants.BUILD_TARGET_WINSCW) ? Constants.INFO_TRACE_FROM_EMULATOR : Constants.INFO_TRACE_FROM_DEVICE; |
3196 Constants.BUILD_TARGET_WINSCW) ? Constants.INFO_TRACE_FROM_EMULATOR |
3197 : Constants.INFO_TRACE_FROM_DEVICE; |
|
3082 } |
3198 } |
3083 } |
3199 } |
3084 return target; |
3200 return target; |
3085 } |
3201 } |
3086 |
3202 |
3087 /** |
3203 /** |
3088 * Update change detail action state. |
3204 * Update change detail action state. |
3089 * |
3205 * |
3090 * @param projectRef |
3206 * @param projectRef |
3091 * Current project |
3207 * Current project |
3092 */ |
3208 */ |
3093 public final void updateChangeDetailState(final IProject projectRef) { |
3209 public final void updateChangeDetailState(final IProject projectRef) { |
3094 if (changeDetails == null) { |
3210 if (changeDetails == null) { |
3104 } else { |
3220 } else { |
3105 changeDetails.setEnabled(false); |
3221 changeDetails.setEnabled(false); |
3106 } |
3222 } |
3107 |
3223 |
3108 String dataFile = projectResults.getDataFileName(projectRef); |
3224 String dataFile = projectResults.getDataFileName(projectRef); |
3109 if( dataFile != null ) { |
3225 if (dataFile != null) { |
3110 int fileType = UseAtool.checkFileType(dataFile); |
3226 int fileType = UseAtool.checkFileType(dataFile); |
3111 if( fileType == Constants.DATAFILE_TRACE || fileType == Constants.DATAFILE_LOG ) { |
3227 if (fileType == Constants.DATAFILE_TRACE |
3228 || fileType == Constants.DATAFILE_LOG) { |
|
3112 refreshResults.setEnabled(true); |
3229 refreshResults.setEnabled(true); |
3113 } |
3230 } else { |
3114 else { |
|
3115 refreshResults.setEnabled(false); |
3231 refreshResults.setEnabled(false); |
3116 } |
3232 } |
3117 } |
3233 } else { |
3118 else { |
|
3119 refreshResults.setEnabled(false); |
3234 refreshResults.setEnabled(false); |
3120 } |
3235 } |
3121 } |
3236 } |
3122 |
3237 |
3123 /** |
3238 /** |
3124 * Sets information to the information label. |
3239 * Sets information to the information label. |
3125 * |
3240 * |
3126 * @param infoText |
3241 * @param infoText |
3127 * Info text |
3242 * Info text |
3128 */ |
3243 */ |
3129 private void updateInformationLabel(final String infoText) { |
3244 private void updateInformationLabel(final String infoText) { |
3130 // trace is active => do not update information label |
3245 // trace is active => do not update information label |
3143 }); |
3258 }); |
3144 } |
3259 } |
3145 |
3260 |
3146 /** |
3261 /** |
3147 * Updates label by given string. |
3262 * Updates label by given string. |
3148 * |
3263 * |
3149 * @param line |
3264 * @param line |
3150 * String to display |
3265 * String to display |
3151 */ |
3266 */ |
3152 public final void updateLabel(final String line) { |
3267 public final void updateLabel(final String line) { |
3153 |
3268 |
3165 |
3280 |
3166 } |
3281 } |
3167 |
3282 |
3168 /** |
3283 /** |
3169 * Updates Subtest info to the information label. |
3284 * Updates Subtest info to the information label. |
3170 * |
3285 * |
3171 * The information layout is hard to modify so we need to manage information |
3286 * The information layout is hard to modify so we need to manage information |
3172 * label text |
3287 * label text |
3173 * |
3288 * |
3174 * @param text |
3289 * @param text |
3175 * New label text |
3290 * New label text |
3176 */ |
3291 */ |
3177 private void updateSubtestInfoText(final String text) { |
3292 private void updateSubtestInfoText(final String text) { |
3178 final String newText = text; |
3293 final String newText = text; |
3219 cleanAnalyzeData(project); |
3334 cleanAnalyzeData(project); |
3220 clearCallstackViewContent(); |
3335 clearCallstackViewContent(); |
3221 traceStartedProjectRef = project; |
3336 traceStartedProjectRef = project; |
3222 |
3337 |
3223 // change icon and information text |
3338 // change icon and information text |
3224 traceAction |
3339 traceAction.setImageDescriptor(Activator |
3225 .setImageDescriptor(Activator |
3340 .getImageDescriptor((Constants.BUTTON_STOP))); |
3226 .getImageDescriptor((Constants.BUTTON_STOP))); |
3341 traceAction.setText(Constants.ACTION_STOP_TRACE); |
3227 traceAction |
3342 traceAction.setToolTipText(Constants.ACTION_STOP_TRACE); |
3228 .setText(Constants.ACTION_STOP_TRACE); |
|
3229 traceAction |
|
3230 .setToolTipText(Constants.ACTION_STOP_TRACE); |
|
3231 traceActive = true; |
3343 traceActive = true; |
3232 |
3344 |
3233 String fromTarget = getTraceTarget(traceStartedProjectRef); |
3345 String fromTarget = getTraceTarget(traceStartedProjectRef); |
3234 updateLabel(fromTarget.length()==0 ? Constants.INFO_TRACE_START : String.format(Constants.INFO_TRACE_FROM_TARGET_START, fromTarget)); |
3346 updateLabel(fromTarget.length() == 0 ? Constants.INFO_TRACE_START |
3347 : String.format(Constants.INFO_TRACE_FROM_TARGET_START, |
|
3348 fromTarget)); |
|
3235 // add2UserActionHistory( "Trace started for |
3349 // add2UserActionHistory( "Trace started for |
3236 // project: " |
3350 // project: " |
3237 // +project.getName() +" at "+ Util.getTime() ); |
3351 // +project.getName() +" at "+ Util.getTime() ); |
3238 |
3352 |
3239 // set start and stop subtest visible |
3353 // set start and stop subtest visible |
3246 updateAllocNumber(); |
3360 updateAllocNumber(); |
3247 } |
3361 } |
3248 |
3362 |
3249 /** |
3363 /** |
3250 * Overrided method to capture keyevents. |
3364 * Overrided method to capture keyevents. |
3251 * |
3365 * |
3252 * @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent) |
3366 * @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent) |
3253 */ |
3367 */ |
3254 public void keyPressed(KeyEvent e) { |
3368 public void keyPressed(KeyEvent e) { |
3255 |
3369 |
3256 // C key address(hex) |
3370 // C key address(hex) |
3263 boolean cPressed = (charValue == CTRL_C); // This should be enough |
3377 boolean cPressed = (charValue == CTRL_C); // This should be enough |
3264 |
3378 |
3265 // ctrl key pressed |
3379 // ctrl key pressed |
3266 boolean ctrlPressed = (e.stateMask & SWT.CTRL) != 0; |
3380 boolean ctrlPressed = (e.stateMask & SWT.CTRL) != 0; |
3267 |
3381 |
3268 //if ctrl and c key pressed => run copy action |
3382 // if ctrl and c key pressed => run copy action |
3269 if(ctrlPressed & cPressed){ |
3383 if (ctrlPressed & cPressed) { |
3270 // Triggering copy action |
3384 // Triggering copy action |
3271 copyAction.run(); |
3385 copyAction.run(); |
3272 } |
3386 } |
3273 |
3387 |
3274 } |
3388 } |
3275 |
3389 |
3276 /** |
3390 /** |
3277 * (non-Javadoc) |
3391 * (non-Javadoc) |
3392 * |
|
3278 * @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent) |
3393 * @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent) |
3279 */ |
3394 */ |
3280 public void keyReleased(KeyEvent e) { |
3395 public void keyReleased(KeyEvent e) { |
3281 // This method is overrided |
3396 // This method is overrided |
3282 } |
3397 } |
3398 |
|
3399 /** |
|
3400 * This job parses the .dat file and loads the graph |
|
3401 * |
|
3402 */ |
|
3403 class GraphLoadJob extends Job { |
|
3404 |
|
3405 /** Location of file to parse for graph model */ |
|
3406 private String datFileLocation; |
|
3407 |
|
3408 /** |
|
3409 * Constructor |
|
3410 * |
|
3411 * @param aDatFileLocation |
|
3412 * Location of file to parse for graph model |
|
3413 */ |
|
3414 public GraphLoadJob(String aDatFileLocation) { |
|
3415 super(Constants.GRAPH_LOAD_JOB_TITLE); |
|
3416 this.datFileLocation = aDatFileLocation; |
|
3417 } |
|
3418 |
|
3419 @Override |
|
3420 protected IStatus run(IProgressMonitor monitor) { |
|
3421 |
|
3422 monitor.beginTask(Constants.GRAPH_GENERATING_PROG_TITLE, |
|
3423 IProgressMonitor.UNKNOWN); |
|
3424 try { |
|
3425 ReadFile fileReader = new ReadFile(); |
|
3426 boolean success = fileReader.readFile(datFileLocation); |
|
3427 if (success) { |
|
3428 AbstractList<ProcessInfo> processes = fileReader |
|
3429 .getStatistic(); |
|
3430 IMemoryActivityModel model = new AnalyzeFactory() |
|
3431 .createModel(processes.size() == 0); |
|
3432 if (processes.size() > 0) { |
|
3433 model.setDeferredCallstackReading(fileReader |
|
3434 .hasDeferredCallstacks()); |
|
3435 if (model.isDeferredCallstackReading()) { |
|
3436 DeferredCallstackManager callstackManager = new DeferredCallstackManager( |
|
3437 datFileLocation); |
|
3438 callstackManager.setProcesses(processes); |
|
3439 model.setCallstackManager(callstackManager); |
|
3440 } else { |
|
3441 model.setCallstackManager(new SimpleCallstackManager()); |
|
3442 } |
|
3443 } |
|
3444 if (!monitor.isCanceled()) { |
|
3445 chart.setInput(project, model); |
|
3446 model.addProcesses(processes); |
|
3447 } |
|
3448 fileReader.finish(); |
|
3449 } |
|
3450 |
|
3451 } catch (OutOfMemoryError oome) { |
|
3452 Activator |
|
3453 .getDefault() |
|
3454 .logInfo(IStatus.ERROR, IStatus.ERROR, |
|
3455 "Can not allocate enough memory for the memory usage graph model."); |
|
3456 } catch (Exception e) { |
|
3457 Activator.getDefault().log(IStatus.ERROR, |
|
3458 "Error while generating graph model", e); |
|
3459 } |
|
3460 graphLoadJob = null; |
|
3461 return Status.OK_STATUS; |
|
3462 } |
|
3463 |
|
3464 } |
|
3283 } |
3465 } |