|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 package com.nokia.s60tools.swmtanalyser.editors; |
|
18 |
|
19 import java.io.File; |
|
20 import java.lang.reflect.InvocationTargetException; |
|
21 import java.util.ArrayList; |
|
22 import java.util.Arrays; |
|
23 import java.util.Collections; |
|
24 import java.util.Iterator; |
|
25 import java.util.Random; |
|
26 import java.util.Map.Entry; |
|
27 |
|
28 import org.eclipse.core.resources.IMarker; |
|
29 import org.eclipse.core.runtime.IProgressMonitor; |
|
30 import org.eclipse.jface.dialogs.Dialog; |
|
31 import org.eclipse.jface.dialogs.IMessageProvider; |
|
32 import org.eclipse.jface.dialogs.MessageDialog; |
|
33 import org.eclipse.jface.dialogs.ProgressMonitorDialog; |
|
34 import org.eclipse.jface.operation.IRunnableWithProgress; |
|
35 import org.eclipse.jface.viewers.CheckStateChangedEvent; |
|
36 import org.eclipse.jface.viewers.CheckboxTableViewer; |
|
37 import org.eclipse.jface.wizard.WizardDialog; |
|
38 import org.eclipse.swt.SWT; |
|
39 import org.eclipse.swt.custom.SashForm; |
|
40 import org.eclipse.swt.events.MouseEvent; |
|
41 import org.eclipse.swt.events.MouseListener; |
|
42 import org.eclipse.swt.events.SelectionAdapter; |
|
43 import org.eclipse.swt.events.SelectionEvent; |
|
44 import org.eclipse.swt.events.SelectionListener; |
|
45 import org.eclipse.swt.graphics.Color; |
|
46 import org.eclipse.swt.graphics.Font; |
|
47 import org.eclipse.swt.graphics.GC; |
|
48 import org.eclipse.swt.graphics.Image; |
|
49 import org.eclipse.swt.graphics.ImageData; |
|
50 import org.eclipse.swt.graphics.ImageLoader; |
|
51 import org.eclipse.swt.layout.FillLayout; |
|
52 import org.eclipse.swt.layout.FormAttachment; |
|
53 import org.eclipse.swt.layout.FormData; |
|
54 import org.eclipse.swt.layout.FormLayout; |
|
55 import org.eclipse.swt.layout.GridData; |
|
56 import org.eclipse.swt.layout.GridLayout; |
|
57 import org.eclipse.swt.program.Program; |
|
58 import org.eclipse.swt.widgets.Button; |
|
59 import org.eclipse.swt.widgets.Combo; |
|
60 import org.eclipse.swt.widgets.Composite; |
|
61 import org.eclipse.swt.widgets.Display; |
|
62 import org.eclipse.swt.widgets.Event; |
|
63 import org.eclipse.swt.widgets.FileDialog; |
|
64 import org.eclipse.swt.widgets.Label; |
|
65 import org.eclipse.swt.widgets.List; |
|
66 import org.eclipse.swt.widgets.Menu; |
|
67 import org.eclipse.swt.widgets.MenuItem; |
|
68 import org.eclipse.swt.widgets.Sash; |
|
69 import org.eclipse.swt.widgets.Shell; |
|
70 import org.eclipse.swt.widgets.TabFolder; |
|
71 import org.eclipse.swt.widgets.TabItem; |
|
72 import org.eclipse.swt.widgets.Table; |
|
73 import org.eclipse.swt.widgets.TableColumn; |
|
74 import org.eclipse.swt.widgets.TableItem; |
|
75 import org.eclipse.swt.widgets.Tree; |
|
76 import org.eclipse.swt.widgets.TreeItem; |
|
77 import org.eclipse.ui.IEditorInput; |
|
78 import org.eclipse.ui.IEditorPart; |
|
79 import org.eclipse.ui.IEditorSite; |
|
80 import org.eclipse.ui.IWorkbench; |
|
81 import org.eclipse.ui.IWorkbenchWindow; |
|
82 import org.eclipse.ui.PartInitException; |
|
83 import org.eclipse.ui.PlatformUI; |
|
84 import org.eclipse.ui.forms.events.ExpansionAdapter; |
|
85 import org.eclipse.ui.forms.events.ExpansionEvent; |
|
86 import org.eclipse.ui.forms.widgets.FormToolkit; |
|
87 import org.eclipse.ui.forms.widgets.ScrolledForm; |
|
88 import org.eclipse.ui.forms.widgets.Section; |
|
89 import org.eclipse.ui.forms.widgets.TableWrapData; |
|
90 import org.eclipse.ui.forms.widgets.TableWrapLayout; |
|
91 import org.eclipse.ui.ide.IDE; |
|
92 import org.eclipse.ui.part.MultiPageEditorPart; |
|
93 |
|
94 import com.nokia.s60tools.swmtanalyser.SwmtAnalyserPlugin; |
|
95 import com.nokia.s60tools.swmtanalyser.analysers.AnalyserConstants; |
|
96 import com.nokia.s60tools.swmtanalyser.analysers.IAnalyser; |
|
97 import com.nokia.s60tools.swmtanalyser.analysers.ResultElements; |
|
98 import com.nokia.s60tools.swmtanalyser.analysers.ResultsParentNodes; |
|
99 import com.nokia.s60tools.swmtanalyser.data.CycleData; |
|
100 import com.nokia.s60tools.swmtanalyser.data.OverviewData; |
|
101 import com.nokia.s60tools.swmtanalyser.data.ParsedData; |
|
102 import com.nokia.s60tools.swmtanalyser.dialogs.AdvancedFilterDialog; |
|
103 import com.nokia.s60tools.swmtanalyser.dialogs.AdvancedFilterDialog.FilterInput; |
|
104 import com.nokia.s60tools.swmtanalyser.model.ExcelCreator; |
|
105 import com.nokia.s60tools.swmtanalyser.model.SWMTLogReaderUtils; |
|
106 import com.nokia.s60tools.swmtanalyser.ui.graphs.ChunksGraph; |
|
107 import com.nokia.s60tools.swmtanalyser.ui.graphs.DisksGraph; |
|
108 import com.nokia.s60tools.swmtanalyser.ui.graphs.GenericGraph; |
|
109 import com.nokia.s60tools.swmtanalyser.ui.graphs.GraphForAllEvents; |
|
110 import com.nokia.s60tools.swmtanalyser.ui.graphs.GraphsUtils; |
|
111 import com.nokia.s60tools.swmtanalyser.ui.graphs.IGraphTypeSelectionListener; |
|
112 import com.nokia.s60tools.swmtanalyser.ui.graphs.LinearIssuesGraph; |
|
113 import com.nokia.s60tools.swmtanalyser.ui.graphs.SwmtGraph; |
|
114 import com.nokia.s60tools.swmtanalyser.ui.graphs.SystemDataGraph; |
|
115 import com.nokia.s60tools.swmtanalyser.ui.graphs.ThreadsGraph; |
|
116 import com.nokia.s60tools.swmtanalyser.wizards.ReportGenerationWizard; |
|
117 |
|
118 /** |
|
119 * SWMT Analyser editor view |
|
120 * |
|
121 */ |
|
122 public class SWMTEditor extends MultiPageEditorPart implements SelectionListener, IGraphTypeSelectionListener{ |
|
123 |
|
124 // Overview Page Controls |
|
125 private ScrolledForm form; |
|
126 private Combo toCombo; |
|
127 private Button allBtn; |
|
128 private Button notAllBtn; |
|
129 private Button export; |
|
130 |
|
131 //Trace Page Controls |
|
132 private TabItem eventsTab; |
|
133 private Combo eventsCombo; |
|
134 private List eventList; |
|
135 private TabFolder innerTabFolder; |
|
136 private TabItem threadTab; |
|
137 private TabItem chunksTab; |
|
138 private TabItem diskTab; |
|
139 private TabItem sysInfoTab; |
|
140 private FilterTextTable threadTble; |
|
141 private FilterTextTable chunkTble; |
|
142 private FilterTextTable diskTble; |
|
143 private FilterTextTable sysinfoTble; |
|
144 |
|
145 private static enum CATEGORIES { All_events, Chunks, Disk, Files, Heap, HPAS, RAM, System_info }; |
|
146 private String[] CHUNKS_GRP = { "Global data size", "Non heap chunk size" }; |
|
147 private String[] DISK_GRP = { "Disk used", "Disk total" }; |
|
148 private String[] FILES_GRP = { "No of Files" }; |
|
149 private String[] HEAP_GRP = { "Max size", "Heap size", "Heap allocated space", "Heap free space", "Heap allocated cell count", "Heap free cell count", "Free slack" }; //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ |
|
150 private String[] HPAS_GRP = { "No of PS Handles" }; |
|
151 private String[] RAM_GRP = { "RAM used", "RAM total" }; |
|
152 private String[] SYSINFO_GRP = { "System Data" }; |
|
153 private String[] ALL_GRP = { "RAM used", "RAM total", "Global data size", "Non heap chunk size", "Disk used", "Disk total", "No of Files", "Max size", "Heap size", "Heap allocated space", "Heap free space", "Heap allocated cell count", "Heap free cell count", "Free slack", "No of PS Handles", "System Data" }; //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ |
|
154 |
|
155 //Stores overiew information to be displayed in the first page |
|
156 private OverviewData ov; |
|
157 |
|
158 // All cycles data |
|
159 private ParsedData parsedData = new ParsedData(); |
|
160 private ArrayList<String> threads = new ArrayList<String>(); |
|
161 private ArrayList<String> chunks = new ArrayList<String>(); |
|
162 private ArrayList<String> nonHeapChunks = new ArrayList<String>(); |
|
163 private ArrayList<String> disks = new ArrayList<String>(); |
|
164 |
|
165 //Four table viewer for 4 tabs in the Graphs tab |
|
166 private CheckboxTableViewer threadViewer; |
|
167 private CheckboxTableViewer chunksViewer; |
|
168 private CheckboxTableViewer disksViewer; |
|
169 private CheckboxTableViewer sysElemsViewer; |
|
170 |
|
171 private String lastSelectedEvent = RAM_GRP[0]; |
|
172 |
|
173 private SwmtGraph graph; |
|
174 private GraphForAllEvents allEventsGraph; |
|
175 |
|
176 private String selectedEvent; |
|
177 private CheckboxTableViewer graphedItemsViewer; |
|
178 private ArrayList<GraphedItemsInput> graphed = new ArrayList<GraphedItemsInput>(); |
|
179 private TabFolder mainTabFolder; |
|
180 private Label title; |
|
181 |
|
182 private Table issues_table; |
|
183 private Button viewAll_btn;; |
|
184 |
|
185 private int ANALYSIS_PAGE = -1; |
|
186 private int OVERVIEW_PAGE = -1; |
|
187 private int GRAPHS_PAGE = -1; |
|
188 private Tree issues_tree; |
|
189 private MenuItem analyse_menuItem; |
|
190 private Combo severity_combo; |
|
191 private Label severity_label; |
|
192 private IssuesFilter filter; |
|
193 private IssuesViewer viewer; |
|
194 private ArrayList<Object> analysis_results_obj = new ArrayList<Object>(); |
|
195 |
|
196 private static final String NO_ISSUES_MSG = "No Critical issues found."; |
|
197 private static final String GRAPHED_ITEMS_LABEL = "Graphed items"; |
|
198 private Button advanced_filter_button; |
|
199 private Button generate_report_btn; |
|
200 private SashForm graphSash; |
|
201 |
|
202 /** |
|
203 * Creates a multi-page editor. |
|
204 */ |
|
205 public SWMTEditor() { |
|
206 super(); |
|
207 } |
|
208 |
|
209 /** |
|
210 * Creates overview page of the SWMT Editor. |
|
211 */ |
|
212 private void createOverviewPage() { |
|
213 Composite composite = new Composite(getContainer(), SWT.NONE); |
|
214 FillLayout layoutF = new FillLayout(); |
|
215 composite.setLayout(layoutF); |
|
216 FormToolkit toolkit = new FormToolkit(composite.getDisplay()); |
|
217 form = toolkit.createScrolledForm(composite); |
|
218 form.setText("Overview:"); |
|
219 |
|
220 TableWrapLayout layout = new TableWrapLayout(); |
|
221 layout.leftMargin = 10; |
|
222 layout.rightMargin = 10; |
|
223 layout.numColumns = 2; |
|
224 form.getBody().setLayout(layout); |
|
225 form.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
|
226 |
|
227 if(parsedData.getNumberOfCycles() == 1 && parsedData.getLogData()[0].getCycleNumber() != 1) |
|
228 form.setMessage("This is a delta log file. It may not contain complete information. \nTo get complete information, selected logs must be in consecutive order starting from cycle 1.", IMessageProvider.WARNING); |
|
229 |
|
230 Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section.TITLE_BAR|Section.TWISTIE|Section.EXPANDED); |
|
231 TableWrapData td = new TableWrapData(TableWrapData.FILL); |
|
232 td.align = TableWrapData.FILL; |
|
233 td.grabHorizontal = true; |
|
234 |
|
235 section.setLayoutData(td); |
|
236 section.addExpansionListener(new ExpansionAdapter() { |
|
237 public void expansionStateChanged(ExpansionEvent e) { |
|
238 form.reflow(true); |
|
239 } |
|
240 }); |
|
241 section.setText("Properties"); |
|
242 section.setDescription("This section describes general information about log files"); |
|
243 Composite sectionClient = toolkit.createComposite(section); |
|
244 sectionClient.setLayout(new GridLayout()); |
|
245 toolkit.createLabel(sectionClient, "Number of Cycles : "+ov.noOfcycles); |
|
246 |
|
247 if(ov.noOfcycles > 1) |
|
248 toolkit.createLabel(sectionClient, "Time Period : "+ov.fromTime + " to " + ov.toTime); |
|
249 else if(ov.noOfcycles == 1){ |
|
250 toolkit.createLabel(sectionClient, "Time Period : "+ov.fromTime); |
|
251 } |
|
252 if(ov.duration >= 60) |
|
253 toolkit.createLabel(sectionClient, "Time Duration : "+ov.duration + " sec (" + ov.durationString +")"); //$NON-NLS-3$ |
|
254 else |
|
255 toolkit.createLabel(sectionClient, "Time Duration : "+ov.duration + " sec"); |
|
256 section.setClient(sectionClient); |
|
257 |
|
258 Section analysisSection = toolkit.createSection(form.getBody(), Section.TITLE_BAR|Section.TWISTIE|Section.EXPANDED); |
|
259 TableWrapData td3 = new TableWrapData(TableWrapData.FILL_GRAB); |
|
260 td3.rowspan = 3; |
|
261 td3.grabHorizontal = true; |
|
262 td3.grabVertical = true; |
|
263 analysisSection.setLayoutData(td3); |
|
264 analysisSection.setText("Analysis"); |
|
265 Composite analysisComp = toolkit.createComposite(analysisSection); |
|
266 analysisComp.setLayout(new GridLayout(1, false)); |
|
267 analysisComp.setLayoutData(new GridData(GridData.FILL)); |
|
268 |
|
269 toolkit.createLabel(analysisComp, "Top 5 issues:"); |
|
270 |
|
271 issues_table = toolkit.createTable(analysisComp, SWT.FULL_SELECTION|SWT.BORDER|SWT.SINGLE); |
|
272 GridData table_GD = new GridData(GridData.FILL_HORIZONTAL); |
|
273 //table_GD.heightHint = 200; |
|
274 issues_table.setLayoutData(table_GD); |
|
275 TableColumn col1 = new TableColumn(issues_table, SWT.NONE); |
|
276 col1.setWidth(250); |
|
277 col1.setText("Item"); |
|
278 TableColumn col2 = new TableColumn(issues_table, SWT.NONE); |
|
279 col2.setWidth(200); |
|
280 col2.setText("Event"); |
|
281 issues_table.pack(); |
|
282 issues_table.setHeaderVisible(true); |
|
283 issues_table.setToolTipText("Double click to analyse..."); |
|
284 |
|
285 issues_table.addSelectionListener(this); |
|
286 |
|
287 final Menu menuPopup = new Menu(issues_table); |
|
288 analyse_menuItem = new MenuItem(menuPopup, SWT.CASCADE); |
|
289 analyse_menuItem.setText("Analyse..."); |
|
290 analyse_menuItem.addSelectionListener(new SelectionAdapter() { |
|
291 public void widgetSelected(SelectionEvent e) { |
|
292 |
|
293 //Open Analysis tab |
|
294 setActivePage(ANALYSIS_PAGE); |
|
295 //If the issues viewer is in filtered state, then make it to show all the issues. |
|
296 filter.setFilterText(null); |
|
297 viewer.refresh(); |
|
298 |
|
299 //Find the TreeItem which matches the selection. |
|
300 TreeItem child_toBeSelected = null; |
|
301 TreeItem parent_toBeExpanded = null; |
|
302 for(TreeItem parent:issues_tree.getItems()) |
|
303 { |
|
304 parent.setExpanded(true); |
|
305 parent.notifyListeners(SWT.Expand, new Event()); |
|
306 for(TreeItem child:parent.getItems()) |
|
307 { |
|
308 if(child.getText(1).equals(issues_table.getSelection()[0].getText(0)) && child.getText(2).equals(issues_table.getSelection()[0].getText(1))) |
|
309 { |
|
310 parent_toBeExpanded = parent; |
|
311 child_toBeSelected = child; |
|
312 break; |
|
313 } |
|
314 } |
|
315 } |
|
316 |
|
317 //Select the matched Treeitem in viewer. |
|
318 if(child_toBeSelected!=null && parent_toBeExpanded !=null) |
|
319 { |
|
320 issues_tree.showItem(child_toBeSelected); |
|
321 issues_tree.select(child_toBeSelected); |
|
322 issues_tree.setFocus(); |
|
323 } |
|
324 } |
|
325 }); |
|
326 |
|
327 |
|
328 issues_table.setMenu(menuPopup); |
|
329 |
|
330 issues_table.addMouseListener(new MouseListener(){ |
|
331 public void mouseDoubleClick(MouseEvent e) { |
|
332 if(analyse_menuItem.isEnabled()) |
|
333 analyse_menuItem.notifyListeners(SWT.Selection, new Event()); |
|
334 } |
|
335 public void mouseDown(MouseEvent e) { |
|
336 } |
|
337 public void mouseUp(MouseEvent e) { |
|
338 } |
|
339 }); |
|
340 issues_table.pack(); |
|
341 |
|
342 viewAll_btn = toolkit.createButton(analysisComp, "View all issues...", SWT.PUSH); |
|
343 GridData viewAll_GD = new GridData(GridData.FILL); |
|
344 viewAll_GD.horizontalAlignment = GridData.END; |
|
345 viewAll_btn.setLayoutData(viewAll_GD); |
|
346 viewAll_btn.addSelectionListener(this); |
|
347 analysisSection.setClient(analysisComp); |
|
348 |
|
349 Section romDetails = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section.TITLE_BAR|Section.TWISTIE|Section.EXPANDED); |
|
350 TableWrapData tableData = new TableWrapData(TableWrapData.FILL); |
|
351 tableData.align = TableWrapData.FILL; |
|
352 tableData.grabHorizontal = true; |
|
353 |
|
354 romDetails.setLayoutData(tableData); |
|
355 romDetails.addExpansionListener(new ExpansionAdapter() { |
|
356 public void expansionStateChanged(ExpansionEvent e) { |
|
357 form.reflow(true); |
|
358 } |
|
359 }); |
|
360 romDetails.setText("ROM Details"); |
|
361 romDetails.setDescription("This section displays the ROM information from log files"); |
|
362 Composite romSection = toolkit.createComposite(romDetails); |
|
363 romSection.setLayout(new GridLayout()); |
|
364 |
|
365 CycleData firstCycle = parsedData.getLogData()[0]; |
|
366 |
|
367 toolkit.createLabel(romSection, "ROM Checksum : " + firstCycle.getRomCheckSum()); |
|
368 toolkit.createLabel(romSection, "ROM Version : " + firstCycle.getRomVersion()); |
|
369 romDetails.setClient(romSection); |
|
370 |
|
371 Section section2 = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section.TITLE_BAR|Section.TWISTIE|Section.EXPANDED); |
|
372 TableWrapData td2 = new TableWrapData(TableWrapData.FILL); |
|
373 section2.setLayoutData(td2); |
|
374 section2.addExpansionListener(new ExpansionAdapter() { |
|
375 public void expansionStateChanged(ExpansionEvent e) { |
|
376 form.reflow(true); |
|
377 } |
|
378 }); |
|
379 section2.setText("Export Options"); |
|
380 section2.setDescription("Specify the export options"); |
|
381 Composite sectionClient2 = toolkit.createComposite(section2); |
|
382 sectionClient2.setLayout(new GridLayout(4, false)); |
|
383 |
|
384 GridData gd1 = new GridData(); |
|
385 gd1.horizontalSpan = 4; |
|
386 allBtn = toolkit.createButton(sectionClient2, "All",SWT.RADIO); |
|
387 notAllBtn = toolkit.createButton(sectionClient2, "Selected log files",SWT.RADIO); |
|
388 allBtn.setLayoutData(gd1); |
|
389 allBtn.setSelection(true); |
|
390 allBtn.addSelectionListener(this); |
|
391 |
|
392 notAllBtn.setLayoutData(gd1); |
|
393 notAllBtn.addSelectionListener(this); |
|
394 |
|
395 toolkit.createLabel(sectionClient2, "From"); |
|
396 Label fromLabel = new Label(sectionClient2, SWT.NONE); |
|
397 |
|
398 toolkit.createLabel(sectionClient2, " To"); |
|
399 toCombo = new Combo(sectionClient2, SWT.DROP_DOWN|SWT.READ_ONLY); |
|
400 toCombo.setEnabled(false); |
|
401 toCombo.addSelectionListener(this); |
|
402 |
|
403 Composite exportComp = new Composite(sectionClient2,SWT.NONE); |
|
404 exportComp.setLayout(new GridLayout()); |
|
405 GridData exGD = new GridData(); |
|
406 exGD.horizontalSpan = 4; |
|
407 exportComp.setLayoutData(exGD); |
|
408 export = toolkit.createButton(exportComp, "Export as XLS...", SWT.PUSH); |
|
409 export.addSelectionListener(this); |
|
410 |
|
411 section2.setClient(sectionClient2); |
|
412 |
|
413 OVERVIEW_PAGE = addPage(composite); |
|
414 setPageText(OVERVIEW_PAGE, "Overview"); |
|
415 |
|
416 |
|
417 CycleData [] parsed_cycles = parsedData.getLogData(); |
|
418 |
|
419 if(parsedData.getNumberOfCycles() == 1) |
|
420 { |
|
421 int cycleNo = parsed_cycles[0].getCycleNumber(); |
|
422 fromLabel.setText(Integer.toString(cycleNo)); |
|
423 toCombo.add(Integer.toString(cycleNo)); |
|
424 } |
|
425 else |
|
426 { |
|
427 fromLabel.setText("1"); |
|
428 for (int i = 1 ; i <= parsed_cycles.length ; i++) |
|
429 { |
|
430 toCombo.add(Integer.toString(i)); |
|
431 } |
|
432 } |
|
433 |
|
434 toCombo.select(parsed_cycles.length -1); |
|
435 |
|
436 } |
|
437 |
|
438 /** |
|
439 * Creates Graphs page of the SWMT Editor. |
|
440 * |
|
441 */ |
|
442 private void createGraphsPage() |
|
443 { |
|
444 Composite parent = new Composite(getContainer(), SWT.NONE); |
|
445 parent.setLayout(new FormLayout()); |
|
446 |
|
447 Composite titleBar = new Composite(parent, SWT.NONE); |
|
448 Composite holder = new Composite(parent, SWT.NONE); |
|
449 |
|
450 title = new Label(titleBar, SWT.CENTER|SWT.BORDER); |
|
451 title.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_BLUE)); |
|
452 title.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE)); |
|
453 |
|
454 Font roman_8 = new Font(parent.getDisplay(), "Arial", 10, SWT.BOLD); |
|
455 title.setFont(roman_8); |
|
456 title.setText(""); |
|
457 |
|
458 FormData data = new FormData(); |
|
459 data.left = new FormAttachment(0); |
|
460 data.right = new FormAttachment(100); |
|
461 title.setLayoutData(data); |
|
462 |
|
463 FormData formData = new FormData(); |
|
464 formData.top = new FormAttachment(0); |
|
465 formData.left = new FormAttachment(0); |
|
466 formData.right = new FormAttachment(100); |
|
467 titleBar.setLayoutData(formData); |
|
468 titleBar.setLayout(new FormLayout()); |
|
469 |
|
470 // FormData for the overall holder composite |
|
471 formData = new FormData(); |
|
472 formData.top = new FormAttachment(titleBar); |
|
473 formData.bottom = new FormAttachment(100); |
|
474 formData.left = new FormAttachment(0); |
|
475 formData.right = new FormAttachment(100); |
|
476 holder.setLayoutData(formData); |
|
477 holder.setLayout(new FormLayout()); |
|
478 |
|
479 SashForm graphSash = new SashForm(holder, SWT.VERTICAL|SWT.SMOOTH|SWT.BORDER); |
|
480 graphSash.SASH_WIDTH = 5; |
|
481 graphSash.setLayout(new FillLayout()); |
|
482 |
|
483 Composite bottomComposite = new SashForm(holder, SWT.VERTICAL); |
|
484 final Sash acrossSash = new Sash(holder, SWT.HORIZONTAL); |
|
485 |
|
486 formData = new FormData(); |
|
487 formData.top = new FormAttachment(0); |
|
488 formData.bottom = new FormAttachment(acrossSash); |
|
489 formData.left = new FormAttachment(0); |
|
490 formData.right = new FormAttachment(100); |
|
491 graphSash.setLayoutData(formData); |
|
492 graphSash.setLayout(new FormLayout()); |
|
493 |
|
494 // FormData for bottom composite |
|
495 formData = new FormData(); |
|
496 formData.top = new FormAttachment(acrossSash); |
|
497 formData.bottom = new FormAttachment(100); |
|
498 formData.left = new FormAttachment(0); |
|
499 formData.right = new FormAttachment(100); |
|
500 bottomComposite.setLayoutData(formData); |
|
501 bottomComposite.setLayout(new FormLayout()); |
|
502 |
|
503 // FormData for acrossSash |
|
504 // Put it initially in the middle |
|
505 formData = new FormData(); |
|
506 formData.top = new FormAttachment(50); |
|
507 formData.left = new FormAttachment(0); |
|
508 formData.right = new FormAttachment(100); |
|
509 acrossSash.setLayoutData(formData); |
|
510 |
|
511 final FormData acrossSashData = formData; |
|
512 final Composite parentFinal = acrossSash.getParent(); |
|
513 acrossSash.addSelectionListener(new SelectionAdapter() { |
|
514 public void widgetSelected(SelectionEvent event) { |
|
515 if (event.detail != SWT.DRAG) { |
|
516 acrossSashData.top = new FormAttachment(0, event.y); |
|
517 parentFinal.layout(); |
|
518 } |
|
519 } |
|
520 }); |
|
521 graph = new SwmtGraph(graphSash); |
|
522 allEventsGraph = new GraphForAllEvents(graphSash); |
|
523 |
|
524 graph.setInputCyclesData(parsedData); |
|
525 allEventsGraph.setInputCyclesData(parsedData); |
|
526 |
|
527 graph.constructGraphArea(); |
|
528 |
|
529 mainTabFolder = new TabFolder(bottomComposite, SWT.NONE); |
|
530 mainTabFolder.setLayout(new FillLayout(2)); |
|
531 GridData tabGD=new GridData(GridData.FILL_HORIZONTAL); |
|
532 mainTabFolder.setLayoutData(tabGD); |
|
533 mainTabFolder.addSelectionListener(this); |
|
534 |
|
535 //Construct Events Tab |
|
536 constructEventTabsArea(mainTabFolder); |
|
537 //Construct Graphed Items Tab |
|
538 TabItem graphedItemsTab = new TabItem(mainTabFolder,SWT.NONE); |
|
539 graphedItemsTab.setText(GRAPHED_ITEMS_LABEL); |
|
540 |
|
541 GraphedItemsHelper graphedTabHelper = new GraphedItemsHelper(); |
|
542 graphedItemsViewer = graphedTabHelper.constructGraphedItemsViewer(graphedItemsTab, allEventsGraph); |
|
543 |
|
544 GRAPHS_PAGE = addPage(parent); |
|
545 setPageText(GRAPHS_PAGE, " Graphs "); |
|
546 |
|
547 if(threads != null) |
|
548 threadTble.setInput(threads); |
|
549 if(chunks != null) |
|
550 chunkTble.setInput(chunks); |
|
551 if(disks != null) |
|
552 diskTble.setInput(disks); |
|
553 |
|
554 sysinfoTble.setInput(GenericGraph.getGraphableKernels()); |
|
555 |
|
556 |
|
557 |
|
558 } |
|
559 |
|
560 /** |
|
561 * Creates Anlysis page in the SWMT Editor |
|
562 * |
|
563 */ |
|
564 private void createAnalysisPage() |
|
565 { |
|
566 Composite parentComposite = new Composite(getContainer(), SWT.NONE); |
|
567 parentComposite.setLayout(new FormLayout()); |
|
568 |
|
569 Composite titleBar = new Composite(parentComposite, SWT.NONE); |
|
570 Composite holder = new Composite(parentComposite, SWT.NONE); |
|
571 |
|
572 Label graph_title = new Label(titleBar, SWT.CENTER|SWT.BORDER); |
|
573 graph_title.setBackground(parentComposite.getDisplay().getSystemColor(SWT.COLOR_DARK_BLUE)); |
|
574 graph_title.setForeground(parentComposite.getDisplay().getSystemColor(SWT.COLOR_WHITE)); |
|
575 |
|
576 Font roman_8 = new Font(parentComposite.getDisplay(), "Arial", 10, SWT.BOLD); |
|
577 graph_title.setFont(roman_8); |
|
578 graph_title.setText(""); |
|
579 |
|
580 FormData formData = new FormData(); |
|
581 formData.top = new FormAttachment(0); |
|
582 formData.left = new FormAttachment(0); |
|
583 formData.right = new FormAttachment(100); |
|
584 titleBar.setLayoutData(formData); |
|
585 titleBar.setLayout(new FormLayout()); |
|
586 |
|
587 FormData data = new FormData(); |
|
588 data.left = new FormAttachment(0); |
|
589 data.right = new FormAttachment(100); |
|
590 graph_title.setLayoutData(data); |
|
591 |
|
592 // FormData for the overall holder composite |
|
593 formData = new FormData(); |
|
594 formData.top = new FormAttachment(titleBar); |
|
595 formData.bottom = new FormAttachment(100); |
|
596 formData.left = new FormAttachment(0); |
|
597 formData.right = new FormAttachment(100); |
|
598 holder.setLayoutData(formData); |
|
599 holder.setLayout(new FormLayout()); |
|
600 |
|
601 graphSash = new SashForm(holder, SWT.VERTICAL|SWT.SMOOTH|SWT.BORDER); |
|
602 graphSash.SASH_WIDTH = 5; |
|
603 graphSash.setLayout(new FillLayout()); |
|
604 |
|
605 Composite bottomComposite = new SashForm(holder, SWT.VERTICAL); |
|
606 final Sash acrossSash = new Sash(holder, SWT.HORIZONTAL); |
|
607 |
|
608 formData = new FormData(); |
|
609 formData.top = new FormAttachment(0); |
|
610 formData.bottom = new FormAttachment(acrossSash); |
|
611 formData.left = new FormAttachment(0); |
|
612 formData.right = new FormAttachment(100); |
|
613 graphSash.setLayoutData(formData); |
|
614 graphSash.setLayout(new FormLayout()); |
|
615 |
|
616 // FormData for bottom |
|
617 formData = new FormData(); |
|
618 formData.top = new FormAttachment(acrossSash); |
|
619 formData.bottom = new FormAttachment(100); |
|
620 formData.left = new FormAttachment(0); |
|
621 formData.right = new FormAttachment(100); |
|
622 bottomComposite.setLayoutData(formData); |
|
623 bottomComposite.setLayout(new FormLayout()); |
|
624 |
|
625 // FormData for acrossSash |
|
626 // Put it initially in the middle |
|
627 formData = new FormData(); |
|
628 formData.top = new FormAttachment(50); |
|
629 formData.width = 20; |
|
630 formData.left = new FormAttachment(0); |
|
631 formData.right = new FormAttachment(100); |
|
632 acrossSash.setLayoutData(formData); |
|
633 |
|
634 final FormData acrossSashData = formData; |
|
635 final Composite parentFinal = acrossSash.getParent(); |
|
636 acrossSash.addSelectionListener(new SelectionAdapter() { |
|
637 public void widgetSelected(SelectionEvent event) { |
|
638 if (event.detail != SWT.DRAG) { |
|
639 acrossSashData.top = new FormAttachment(0, event.y); |
|
640 parentFinal.layout(); |
|
641 } |
|
642 } |
|
643 }); |
|
644 |
|
645 Composite parent = new Composite(bottomComposite, SWT.NONE); |
|
646 parent.setLayout(new GridLayout(7, false)); |
|
647 parent.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
|
648 |
|
649 Label title = new Label(parent, SWT.WRAP); |
|
650 title.setText("Linear Analysis Results"); |
|
651 title.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
|
652 |
|
653 //Action button used for creation of report file. |
|
654 generate_report_btn = new Button(parent, SWT.PUSH); |
|
655 generate_report_btn.setText("Generate report..."); |
|
656 generate_report_btn.setToolTipText("Click here to generate pdf report for the selected issues."); |
|
657 generate_report_btn.addSelectionListener(this); |
|
658 |
|
659 Label separator = new Label(parent, SWT.SEPARATOR); |
|
660 GridData sepGD = new GridData(); |
|
661 sepGD.heightHint = 25; |
|
662 separator.setLayoutData(sepGD); |
|
663 |
|
664 Label severity = new Label(parent, SWT.NONE); |
|
665 severity.setText("Severity:"); |
|
666 |
|
667 severity_label = new Label(parent, SWT.WRAP); |
|
668 severity_label.setText(" "); |
|
669 GridData d = new GridData(GridData.FILL); |
|
670 d.heightHint = 20; |
|
671 severity_label.setLayoutData(d); |
|
672 |
|
673 severity_combo = new Combo(parent, SWT.BORDER|SWT.READ_ONLY); |
|
674 d = new GridData(); |
|
675 d.widthHint = 100; |
|
676 severity_combo.setLayoutData(d); |
|
677 severity_combo.setItems(new String[]{"All", AnalyserConstants.Priority.CRITICAL.name(), AnalyserConstants.Priority.HIGH.name(),AnalyserConstants.Priority.NORMAL.name(), "Custom filter"}); |
|
678 severity_combo.addSelectionListener(this); |
|
679 severity_combo.select(0); |
|
680 severity_combo.setToolTipText("Severity of an issue."); |
|
681 |
|
682 //Action button used to launch Custom filter dialog. |
|
683 advanced_filter_button = new Button(parent, SWT.PUSH); |
|
684 advanced_filter_button.setText("Set Custom filter..."); |
|
685 advanced_filter_button.addSelectionListener(this); |
|
686 advanced_filter_button.setToolTipText("Advanced settings to filter issues below."); |
|
687 advanced_filter_button.setEnabled(false); |
|
688 |
|
689 issues_tree = new Tree(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.CHECK); |
|
690 GridData gd = new GridData(GridData.FILL_BOTH); |
|
691 gd.horizontalSpan = 7; |
|
692 gd.grabExcessVerticalSpace = true; |
|
693 issues_tree.addSelectionListener(this); |
|
694 |
|
695 LinearIssuesGraph issue_graph = new LinearIssuesGraph(graphSash); |
|
696 issue_graph.setLogData(parsedData); |
|
697 |
|
698 //Creates issues viewer. |
|
699 viewer = new IssuesViewer(issues_tree, issue_graph); |
|
700 viewer.createIssuesViewerAndGraph(); |
|
701 viewer.setContentProvider(new IssuesTreeContentProvider()); |
|
702 viewer.setLabelProvider(new IssuesTreeLabelProvider()); |
|
703 filter = new IssuesFilter(); |
|
704 viewer.addFilter(filter); |
|
705 |
|
706 ANALYSIS_PAGE = addPage(parentComposite); |
|
707 setPageText(ANALYSIS_PAGE, " Analysis "); |
|
708 |
|
709 SWMTAnalysisRunnable start_analysis = new SWMTAnalysisRunnable(); |
|
710 IWorkbench wb = PlatformUI.getWorkbench(); |
|
711 IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); |
|
712 Shell shell = win != null ? win.getShell() : null; |
|
713 try { |
|
714 new ProgressMonitorDialog(shell).run(true, true, start_analysis); |
|
715 } catch (InvocationTargetException err) { |
|
716 err.printStackTrace(); |
|
717 } catch (InterruptedException err) { |
|
718 err.printStackTrace(); |
|
719 } |
|
720 viewer.setInput(analysis_results_obj); |
|
721 |
|
722 //Set top 5 issues in the overview tab |
|
723 setTopIssues(analysis_results_obj); |
|
724 |
|
725 issues_tree.setFocus(); |
|
726 } |
|
727 |
|
728 /** |
|
729 * Construts UI controls under Events Tab area. |
|
730 * @param mainTabFolder represents parent folder |
|
731 */ |
|
732 private void constructEventTabsArea(TabFolder mainTabFolder) |
|
733 { |
|
734 eventsTab = new TabItem(mainTabFolder,SWT.NONE); |
|
735 eventsTab.setText(" Events "); |
|
736 |
|
737 //Events Tab => events list and 4 inner tabs |
|
738 SashForm form=new SashForm(mainTabFolder, SWT.BORDER|SWT.HORIZONTAL|SWT.SMOOTH); |
|
739 form.setLayout(new GridLayout()); |
|
740 |
|
741 Composite eventC = new Composite(form, SWT.NONE); |
|
742 eventC.setLayout(new GridLayout(1,false)); |
|
743 eventC.setLayoutData(new GridData(GridData.FILL_BOTH)); |
|
744 |
|
745 eventsCombo = new Combo(eventC, SWT.BORDER|SWT.V_SCROLL | SWT.READ_ONLY); |
|
746 |
|
747 GridData comboGD = new GridData(GridData.FILL_HORIZONTAL); |
|
748 eventsCombo.setLayoutData(comboGD); |
|
749 for(CATEGORIES value : CATEGORIES.values()) |
|
750 eventsCombo.add(value.toString()); |
|
751 eventsCombo.addSelectionListener(this); |
|
752 |
|
753 |
|
754 eventList = new List(eventC, SWT.BORDER|SWT.SINGLE|SWT.V_SCROLL|SWT.H_SCROLL); |
|
755 GridData listGD = new GridData(GridData.FILL_BOTH); |
|
756 listGD.grabExcessVerticalSpace = true; |
|
757 eventList.setLayoutData(listGD); |
|
758 eventList.addSelectionListener(this); |
|
759 |
|
760 innerTabFolder = new TabFolder(form, SWT.NONE); |
|
761 innerTabFolder.setLayout(new GridLayout()); |
|
762 GridData innertabGD = new GridData(GridData.FILL_HORIZONTAL|GridData.FILL_VERTICAL); |
|
763 innertabGD.verticalSpan = 2; |
|
764 innerTabFolder.setLayoutData(innertabGD); |
|
765 innerTabFolder.addSelectionListener(this); |
|
766 |
|
767 threadTab = new TabItem(innerTabFolder,SWT.NONE); |
|
768 threadTab.setText(" Threads "); |
|
769 |
|
770 Composite compositeThrd = new Composite(innerTabFolder, SWT.NONE); |
|
771 compositeThrd.setLayout(new GridLayout(1, true)); |
|
772 threadTble = new FilterTextTable(this, compositeThrd, FilterTextTable.THREADS_TITLE); |
|
773 this.threadViewer = threadTble.getTableViewer(); |
|
774 |
|
775 GridData table_layout_data = new GridData(GridData.FILL_BOTH); |
|
776 table_layout_data.grabExcessVerticalSpace = true; |
|
777 |
|
778 compositeThrd.setLayoutData(table_layout_data); |
|
779 threadTab.setControl(compositeThrd); |
|
780 |
|
781 chunksTab = new TabItem(innerTabFolder,SWT.NONE); |
|
782 chunksTab.setText(" Chunks "); |
|
783 |
|
784 Composite compositeChnk = new Composite(innerTabFolder, SWT.NONE); |
|
785 compositeChnk.setLayout(new GridLayout(1, true)); |
|
786 chunkTble = new FilterTextTable(this, compositeChnk, FilterTextTable.CHUNKS_TITLE); |
|
787 compositeChnk.setLayoutData(table_layout_data); |
|
788 chunksTab.setControl(compositeChnk); |
|
789 this.chunksViewer = chunkTble.getTableViewer(); |
|
790 |
|
791 diskTab = new TabItem(innerTabFolder,SWT.NONE); |
|
792 diskTab.setText(" Disks "); |
|
793 |
|
794 Composite compositeDisk = new Composite(innerTabFolder, SWT.NONE); |
|
795 compositeDisk.setLayout(new GridLayout(1, false)); |
|
796 compositeDisk.setLayoutData(table_layout_data); |
|
797 diskTble = new FilterTextTable(this, compositeDisk, FilterTextTable.DISKS_TITLE); |
|
798 diskTab.setControl(compositeDisk); |
|
799 this.disksViewer = diskTble.getTableViewer(); |
|
800 |
|
801 sysInfoTab = new TabItem(innerTabFolder,SWT.NONE); |
|
802 sysInfoTab.setText(" System Data "); |
|
803 |
|
804 Composite compositeSysinfo = new Composite(innerTabFolder, SWT.NONE); |
|
805 compositeSysinfo.setLayout(new GridLayout(1, false)); |
|
806 compositeSysinfo.setLayoutData(table_layout_data); |
|
807 sysinfoTble = new FilterTextTable(this, compositeSysinfo, FilterTextTable.SYSTEM_DATA_TITLE); |
|
808 sysInfoTab.setControl(compositeSysinfo); |
|
809 this.sysElemsViewer = sysinfoTble.getTableViewer(); |
|
810 |
|
811 eventsCombo.select(0); |
|
812 eventsCombo.notifyListeners(SWT.Selection, new Event()); |
|
813 |
|
814 form.setWeights(new int[] {30,70}); |
|
815 form.SASH_WIDTH = 1; |
|
816 eventsTab.setControl(form); |
|
817 } |
|
818 |
|
819 /** |
|
820 * Creates the pages of the multi-page editor. |
|
821 */ |
|
822 protected void createPages() { |
|
823 |
|
824 if(parsedData == null || parsedData.getNumberOfCycles() == 0) |
|
825 return; |
|
826 |
|
827 createOverviewPage(); |
|
828 |
|
829 if(parsedData.getNumberOfCycles() > 1) |
|
830 { |
|
831 createGraphsPage(); |
|
832 createAnalysisPage(); |
|
833 } |
|
834 else |
|
835 { |
|
836 TableItem no_issues_item = new TableItem(issues_table,SWT.NONE); |
|
837 no_issues_item.setText(NO_ISSUES_MSG); |
|
838 viewAll_btn.setEnabled(false); |
|
839 } |
|
840 } |
|
841 |
|
842 /** |
|
843 * The method picks up the top 5 critical issues from the given list of issues |
|
844 * and displays them in the overview page. |
|
845 * @param issues_results |
|
846 */ |
|
847 public void setTopIssues(ArrayList<Object> issues_results) |
|
848 { |
|
849 if(issues_results.size() == 0) |
|
850 { |
|
851 TableItem item = new TableItem(issues_table,SWT.NONE); |
|
852 item.setText(NO_ISSUES_MSG); |
|
853 return; |
|
854 } |
|
855 |
|
856 ArrayList<ResultElements> critical_issues = new ArrayList<ResultElements>(); |
|
857 |
|
858 for(Object obj:issues_results) |
|
859 { |
|
860 if(obj instanceof ResultsParentNodes) |
|
861 { |
|
862 ResultsParentNodes parent = (ResultsParentNodes)obj; |
|
863 Object[] children = parent.getChildren(); |
|
864 |
|
865 for(Object issue:children) |
|
866 { |
|
867 if(issue instanceof ResultElements) |
|
868 { |
|
869 ResultElements issue_elem = (ResultElements)(issue); |
|
870 if(issue_elem.getPriority() == AnalyserConstants.Priority.CRITICAL) |
|
871 critical_issues.add(issue_elem); |
|
872 } |
|
873 } |
|
874 } |
|
875 } |
|
876 |
|
877 if(critical_issues.size() == 0) |
|
878 { |
|
879 TableItem item = new TableItem(issues_table,SWT.NONE); |
|
880 item.setText(NO_ISSUES_MSG); |
|
881 return; |
|
882 } |
|
883 else |
|
884 { |
|
885 Collections.sort(critical_issues); |
|
886 |
|
887 for(int index = critical_issues.size()-1, i=1; i <=5;i++,index--) |
|
888 { |
|
889 if(index < 0) |
|
890 break; |
|
891 |
|
892 ResultElements temp = critical_issues.get(index); |
|
893 TableItem item = new TableItem(issues_table,SWT.NONE); |
|
894 item.setText(new String[]{temp.getItemName(),temp.getEvent()}); |
|
895 } |
|
896 } |
|
897 |
|
898 } |
|
899 |
|
900 |
|
901 /* (non-Javadoc) |
|
902 * @see org.eclipse.ui.part.MultiPageEditorPart#dispose() |
|
903 */ |
|
904 public void dispose() { |
|
905 super.dispose(); |
|
906 } |
|
907 /* (non-Javadoc) |
|
908 * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor) |
|
909 */ |
|
910 public void doSave(IProgressMonitor monitor) { |
|
911 getEditor(0).doSave(monitor); |
|
912 } |
|
913 /** |
|
914 * Saves the multi-page editor's document as another file. |
|
915 * Also updates the text for page 0's tab, and updates this multi-page editor's input |
|
916 * to correspond to the nested editor's. |
|
917 * @see org.eclipse.ui.part.EditorPart#doSaveAs() |
|
918 */ |
|
919 public void doSaveAs() { |
|
920 IEditorPart editor = getEditor(0); |
|
921 editor.doSaveAs(); |
|
922 setPageText(0, editor.getTitle()); |
|
923 setInput(editor.getEditorInput()); |
|
924 } |
|
925 |
|
926 /** |
|
927 * Go to marker |
|
928 * @see IDE#gotoMarker(IEditorPart, IMarker) |
|
929 * @param marker |
|
930 */ |
|
931 public void gotoMarker(IMarker marker) { |
|
932 setActivePage(0); |
|
933 IDE.gotoMarker(getEditor(0), marker); |
|
934 } |
|
935 |
|
936 /* (non-Javadoc) |
|
937 * @see org.eclipse.ui.part.MultiPageEditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput) |
|
938 */ |
|
939 public void init(IEditorSite site, IEditorInput editorInput) |
|
940 throws PartInitException { |
|
941 if (!(editorInput instanceof SWMTEditorInput)) |
|
942 throw new PartInitException("Invalid Input: Must be SWMTEditorInput"); |
|
943 parsedData = ((SWMTEditorInput)editorInput).getParsedData(); |
|
944 ov = ((SWMTEditorInput)editorInput).getOverview(); |
|
945 |
|
946 SWMTLogReaderUtils util = new SWMTLogReaderUtils(); |
|
947 |
|
948 threads = util.getAllThreadNames(parsedData); |
|
949 if(threads != null) |
|
950 Collections.sort(threads); |
|
951 |
|
952 chunks = util.getAllGlobalChunkNames(parsedData); |
|
953 if(chunks != null) |
|
954 Collections.sort(chunks); |
|
955 |
|
956 nonHeapChunks = util.getAllNonHeapChunkNames(parsedData); |
|
957 if(nonHeapChunks != null) |
|
958 Collections.sort(nonHeapChunks); |
|
959 |
|
960 disks = util.getAllDiskNames(parsedData); |
|
961 if(disks != null) |
|
962 Collections.sort(disks); |
|
963 |
|
964 super.init(site, editorInput); |
|
965 } |
|
966 |
|
967 /* (non-Javadoc) |
|
968 * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed() |
|
969 */ |
|
970 public boolean isSaveAsAllowed() { |
|
971 return true; |
|
972 } |
|
973 |
|
974 /* (non-Javadoc) |
|
975 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) |
|
976 */ |
|
977 public void widgetDefaultSelected(SelectionEvent e) { |
|
978 } |
|
979 /* (non-Javadoc) |
|
980 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) |
|
981 */ |
|
982 public void widgetSelected(SelectionEvent e) { |
|
983 |
|
984 //When Export button is selected, data from given log files |
|
985 //will be exported to an excel file. |
|
986 if(e.widget == export) |
|
987 { |
|
988 FileDialog dlg = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE); |
|
989 dlg.setFilterExtensions(new String[]{"*.xls"}); |
|
990 String fileName = dlg.open(); |
|
991 if(fileName==null) |
|
992 return; |
|
993 |
|
994 SWMTExcelCreationRunnableWithProcess process = new SWMTExcelCreationRunnableWithProcess(fileName, parsedData, toCombo.getSelectionIndex()+1); |
|
995 IWorkbench wb = PlatformUI.getWorkbench(); |
|
996 IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); |
|
997 Shell shell = win != null ? win.getShell() : null; |
|
998 try { |
|
999 new ProgressMonitorDialog(shell).run(true, true, process); |
|
1000 } catch (InvocationTargetException err) { |
|
1001 err.printStackTrace(); |
|
1002 } catch (InterruptedException err) { |
|
1003 err.printStackTrace(); |
|
1004 } |
|
1005 } |
|
1006 else if(e.widget == allBtn) |
|
1007 { |
|
1008 toCombo.setEnabled(false); |
|
1009 } |
|
1010 else if(e.widget == notAllBtn) |
|
1011 { |
|
1012 toCombo.setEnabled(true); |
|
1013 } |
|
1014 else if(e.widget == viewAll_btn) |
|
1015 { |
|
1016 this.setActivePage(ANALYSIS_PAGE); |
|
1017 } |
|
1018 /* |
|
1019 * When Events list selection is changed, all previous selections should be cleared |
|
1020 * and they should be moved to Graphed items tab. |
|
1021 * Also, listeners of enabled tables should be notified. |
|
1022 */ |
|
1023 else if(e.widget == eventList) |
|
1024 { |
|
1025 selectedEvent = eventList.getSelection()[0]; |
|
1026 title.setText(selectedEvent); |
|
1027 updateGraphedItemsList(lastSelectedEvent); |
|
1028 |
|
1029 if(!selectedEvent.equals(lastSelectedEvent)) |
|
1030 { |
|
1031 chunkTble.cancelSelectionList(); |
|
1032 threadTble.cancelSelectionList(); |
|
1033 diskTble.cancelSelectionList(); |
|
1034 sysinfoTble.cancelSelectionList(); |
|
1035 } |
|
1036 |
|
1037 if(!selectedEvent.equals(lastSelectedEvent) && graph != null) |
|
1038 graph.clearGraph(); |
|
1039 |
|
1040 if(Arrays.asList(RAM_GRP).contains(selectedEvent)) |
|
1041 { |
|
1042 threadTble.setEnabled(false); |
|
1043 chunkTble.setEnabled(false); |
|
1044 diskTble.setEnabled(false); |
|
1045 sysinfoTble.setEnabled(false); |
|
1046 |
|
1047 DisksGraph diskGraph = new DisksGraph(); |
|
1048 GenericGraph.EventTypes eventType = GraphsUtils.getMappedEvent(selectedEvent); |
|
1049 diskGraph.setEvent(eventType); |
|
1050 diskGraph.setCyclesData(parsedData); |
|
1051 |
|
1052 if(graph != null) |
|
1053 graph.redraw(diskGraph); |
|
1054 } |
|
1055 else |
|
1056 { |
|
1057 if(Arrays.asList(CHUNKS_GRP).contains(selectedEvent)) |
|
1058 { |
|
1059 if(Arrays.asList(CHUNKS_GRP).indexOf(selectedEvent)==0 && !selectedEvent.equals(lastSelectedEvent)) |
|
1060 chunkTble.setInput(chunks); |
|
1061 else if(Arrays.asList(CHUNKS_GRP).indexOf(selectedEvent)==1 && !selectedEvent.equals(lastSelectedEvent)) |
|
1062 chunkTble.setInput(nonHeapChunks); |
|
1063 innerTabFolder.setSelection(chunksTab); |
|
1064 |
|
1065 CheckStateChangedEvent event = new CheckStateChangedEvent(chunksViewer, null, false); |
|
1066 |
|
1067 if(chunkTble.getCheckStateListener() != null) |
|
1068 chunkTble.getCheckStateListener().checkStateChanged(event); |
|
1069 } |
|
1070 else if(Arrays.asList(HEAP_GRP).contains(selectedEvent) || Arrays.asList(FILES_GRP).contains(selectedEvent) || Arrays.asList(HPAS_GRP).contains(selectedEvent)) |
|
1071 { |
|
1072 innerTabFolder.setSelection(threadTab); |
|
1073 |
|
1074 CheckStateChangedEvent event = new CheckStateChangedEvent(threadViewer, null, false); |
|
1075 if(threadTble.getCheckStateListener() != null) |
|
1076 threadTble.getCheckStateListener().checkStateChanged(event); |
|
1077 } |
|
1078 else if(Arrays.asList(DISK_GRP).contains(selectedEvent)) |
|
1079 { |
|
1080 innerTabFolder.setSelection(diskTab); |
|
1081 |
|
1082 CheckStateChangedEvent event = new CheckStateChangedEvent(disksViewer, null, false); |
|
1083 if(diskTble.getCheckStateListener() != null) |
|
1084 diskTble.getCheckStateListener().checkStateChanged(event); |
|
1085 } |
|
1086 else if(Arrays.asList(SYSINFO_GRP).contains(selectedEvent)) |
|
1087 { |
|
1088 innerTabFolder.setSelection(sysInfoTab); |
|
1089 |
|
1090 CheckStateChangedEvent event = new CheckStateChangedEvent(sysElemsViewer, null, false); |
|
1091 |
|
1092 if(sysinfoTble.getCheckStateListener() != null) |
|
1093 sysinfoTble.getCheckStateListener().checkStateChanged(event); |
|
1094 } |
|
1095 |
|
1096 threadTble.setEnabled(innerTabFolder.getItem(innerTabFolder.getSelectionIndex())==threadTab); |
|
1097 chunkTble.setEnabled(innerTabFolder.getItem(innerTabFolder.getSelectionIndex())==chunksTab); |
|
1098 diskTble.setEnabled(innerTabFolder.getItem(innerTabFolder.getSelectionIndex())==diskTab); |
|
1099 sysinfoTble.setEnabled(innerTabFolder.getItem(innerTabFolder.getSelectionIndex())==sysInfoTab); |
|
1100 |
|
1101 } |
|
1102 |
|
1103 lastSelectedEvent = selectedEvent; |
|
1104 } |
|
1105 //Events list will be modified based on the selection of |
|
1106 //event category from the drop down box. |
|
1107 else if(e.widget == eventsCombo) |
|
1108 { |
|
1109 eventList.removeAll(); |
|
1110 CATEGORIES index = CATEGORIES.valueOf(eventsCombo.getText()); |
|
1111 switch(index) |
|
1112 { |
|
1113 case All_events: |
|
1114 eventList.setItems(ALL_GRP); |
|
1115 break; |
|
1116 case Chunks: |
|
1117 eventList.setItems(CHUNKS_GRP); |
|
1118 break; |
|
1119 case Disk: |
|
1120 eventList.setItems(DISK_GRP); |
|
1121 break; |
|
1122 case Files: |
|
1123 eventList.setItems(FILES_GRP); |
|
1124 break; |
|
1125 case Heap: |
|
1126 eventList.setItems(HEAP_GRP); |
|
1127 break; |
|
1128 case HPAS: |
|
1129 eventList.setItems(HPAS_GRP); |
|
1130 break; |
|
1131 case RAM: |
|
1132 eventList.setItems(RAM_GRP); |
|
1133 break; |
|
1134 case System_info: |
|
1135 eventList.setItems(SYSINFO_GRP); |
|
1136 break; |
|
1137 } |
|
1138 eventList.select(0); |
|
1139 |
|
1140 if(eventList.getItemCount() > 0) |
|
1141 { |
|
1142 eventList.notifyListeners(SWT.Selection, new Event()); |
|
1143 } |
|
1144 } |
|
1145 else if(e.widget == mainTabFolder && mainTabFolder.getSelectionIndex() != -1 && |
|
1146 mainTabFolder.getSelection()[0].getText().trim().equalsIgnoreCase(GRAPHED_ITEMS_LABEL)) |
|
1147 { |
|
1148 selectedEvent = eventList.getSelection()[0]; |
|
1149 updateGraphedItemsList(selectedEvent); |
|
1150 |
|
1151 title.setText("Graphed Items"); |
|
1152 |
|
1153 Object [] checkedElems = graphedItemsViewer.getCheckedElements(); |
|
1154 ArrayList<GraphedItemsInput> selectedItems = new ArrayList<GraphedItemsInput>(); |
|
1155 |
|
1156 for(Object obj:checkedElems) |
|
1157 { |
|
1158 GraphedItemsInput graphInput = (GraphedItemsInput)obj; |
|
1159 selectedItems.add(graphInput); |
|
1160 } |
|
1161 |
|
1162 allEventsGraph.setGraphedItemsInput(selectedItems); |
|
1163 allEventsGraph.constructGraphArea(); |
|
1164 |
|
1165 } |
|
1166 else if(e.widget == mainTabFolder && mainTabFolder.getSelectionIndex() != -1 && mainTabFolder.getSelection()[0] == eventsTab) |
|
1167 { |
|
1168 if(graphedItemsViewer.getInput() == null) |
|
1169 { |
|
1170 graphed.clear(); |
|
1171 } |
|
1172 graph.constructGraphArea(); |
|
1173 |
|
1174 if(eventList.getSelectionIndex() != -1){ |
|
1175 title.setText(eventList.getItem(eventList.getSelectionIndex())); |
|
1176 eventList.notifyListeners(SWT.Selection, new Event()); |
|
1177 } |
|
1178 else |
|
1179 title.setText(""); |
|
1180 |
|
1181 } |
|
1182 |
|
1183 //Issues list gets modified based on the selection of Severity |
|
1184 //from the drop down box. |
|
1185 else if(e.widget == severity_combo) |
|
1186 { |
|
1187 advanced_filter_button.setEnabled(false); |
|
1188 filter.setAdvancedSearchOptions(null); |
|
1189 Image img = null; |
|
1190 String icon_name = ""; |
|
1191 switch(severity_combo.getSelectionIndex()) |
|
1192 { |
|
1193 case 1: |
|
1194 icon_name = "\\red.png"; |
|
1195 filter.setFilterText(AnalyserConstants.Priority.CRITICAL.name()); |
|
1196 break; |
|
1197 case 2: |
|
1198 icon_name = "\\yellow.png"; |
|
1199 filter.setFilterText(AnalyserConstants.Priority.HIGH.name()); |
|
1200 break; |
|
1201 case 3: |
|
1202 icon_name = "\\green.png"; |
|
1203 filter.setFilterText(AnalyserConstants.Priority.NORMAL.name()); |
|
1204 break; |
|
1205 case 4: |
|
1206 advanced_filter_button.setEnabled(true); |
|
1207 default: |
|
1208 icon_name = null; |
|
1209 filter.setFilterText(null); |
|
1210 break; |
|
1211 } |
|
1212 if(icon_name!=null) |
|
1213 { |
|
1214 try { |
|
1215 img = new Image( Display.getCurrent(), SwmtAnalyserPlugin.getPluginInstallPath() + "\\icons" + icon_name); |
|
1216 } catch (RuntimeException e1) { |
|
1217 e1.printStackTrace(); |
|
1218 } |
|
1219 } |
|
1220 severity_label.setImage(img); |
|
1221 issues_tree.setFocus(); |
|
1222 viewer.refresh(); |
|
1223 } |
|
1224 else if(e.widget == issues_table) |
|
1225 { |
|
1226 analyse_menuItem.setEnabled(!issues_table.getSelection()[0].getText(0).startsWith(NO_ISSUES_MSG)); |
|
1227 } |
|
1228 else if(e.widget == advanced_filter_button) |
|
1229 { |
|
1230 AdvancedFilterDialog dlg = new AdvancedFilterDialog(Display.getCurrent().getActiveShell()); |
|
1231 int status = dlg.open(); |
|
1232 if(status == Dialog.OK) |
|
1233 { |
|
1234 FilterInput input = dlg.getFilterOptions(); |
|
1235 filter.setAdvancedSearchOptions(input); |
|
1236 issues_tree.setFocus(); |
|
1237 viewer.refresh(); |
|
1238 } |
|
1239 } |
|
1240 else if(e.widget == generate_report_btn) |
|
1241 { |
|
1242 //Save graph in temporary location |
|
1243 GC gc = new GC(graphSash); |
|
1244 Image image = new Image(Display.getCurrent(), graphSash.getClientArea().width, graphSash.getClientArea().height); |
|
1245 graphSash.setFocus(); |
|
1246 gc.copyArea(image, 0, 0); |
|
1247 gc.dispose(); |
|
1248 ImageData data = image.getImageData(); |
|
1249 ImageLoader loader = new ImageLoader(); |
|
1250 loader.data = new ImageData[] {data}; |
|
1251 loader.save(SwmtAnalyserPlugin.getPluginInstallPath()+"\\swmt_graph.bmp", SWT.IMAGE_BMP); |
|
1252 image.dispose(); |
|
1253 |
|
1254 // Now open the wizard |
|
1255 Runnable showWizardRunnable = new Runnable(){ |
|
1256 public void run(){ |
|
1257 WizardDialog wizDialog; |
|
1258 ReportGenerationWizard wiz = new ReportGenerationWizard(ov, parsedData.getLogData()[0].getRomCheckSum(), parsedData.getLogData()[0].getRomVersion(), issues_tree); |
|
1259 wizDialog = new WizardDialog(Display.getCurrent().getActiveShell(), wiz); |
|
1260 wizDialog.create(); |
|
1261 wizDialog.getShell().setSize(400, 500); |
|
1262 wizDialog.addPageChangedListener(wiz); |
|
1263 wizDialog.open(); |
|
1264 } |
|
1265 }; |
|
1266 Display.getDefault().asyncExec(showWizardRunnable); |
|
1267 } |
|
1268 } |
|
1269 |
|
1270 /** |
|
1271 * SWMT specific runnable process for creating excel. |
|
1272 * |
|
1273 */ |
|
1274 private class SWMTExcelCreationRunnableWithProcess implements IRunnableWithProgress |
|
1275 { |
|
1276 private String fileName; |
|
1277 private CycleData [] data = new CycleData [0]; |
|
1278 private int exportFilesNo; |
|
1279 private OverviewData ovData; |
|
1280 public SWMTExcelCreationRunnableWithProcess(String fileName, ParsedData parsedData,int exportFiles) { |
|
1281 this.data = parsedData.getLogData(); |
|
1282 this.fileName = fileName; |
|
1283 this.exportFilesNo = exportFiles; |
|
1284 } |
|
1285 |
|
1286 public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { |
|
1287 createExcel(monitor); |
|
1288 } |
|
1289 |
|
1290 private void createExcel(IProgressMonitor monitor) |
|
1291 { |
|
1292 monitor.beginTask("Parsing log files...", 10); |
|
1293 ExcelCreator creator = new ExcelCreator(fileName); |
|
1294 ovData = (new SWMTLogReaderUtils()).getOverviewInformationFromCyclesData(data, this.exportFilesNo); |
|
1295 creator.setOverviewPageInput(ovData); |
|
1296 |
|
1297 ArrayList<CycleData> exportedCycles = new ArrayList<CycleData>(); |
|
1298 |
|
1299 if(this.exportFilesNo >= 255) |
|
1300 { |
|
1301 int extras = this.exportFilesNo - 254; |
|
1302 ArrayList<Integer> series = new ArrayList<Integer>(extras); |
|
1303 |
|
1304 if(extras ==1) |
|
1305 { |
|
1306 series.add(this.exportFilesNo/2); |
|
1307 creator.setSkipFileConstant(series); |
|
1308 } |
|
1309 else |
|
1310 { |
|
1311 int temp = this.exportFilesNo; |
|
1312 while(series.size()!=extras) |
|
1313 { |
|
1314 temp = temp/2; |
|
1315 for(int i=2; i<this.exportFilesNo; i++) |
|
1316 { |
|
1317 if(i%temp == 0) |
|
1318 { |
|
1319 if(!series.contains(i)) |
|
1320 series.add(i); |
|
1321 if(series.size() == extras) |
|
1322 break; |
|
1323 } |
|
1324 } |
|
1325 } |
|
1326 creator.setSkipFileConstant(series); |
|
1327 } |
|
1328 } |
|
1329 |
|
1330 for(int i=0; i<exportFilesNo; i++) |
|
1331 { |
|
1332 CycleData cycle = data[i]; |
|
1333 exportedCycles.add(cycle); |
|
1334 } |
|
1335 monitor.worked(3); |
|
1336 |
|
1337 ParsedData exportedData = new ParsedData(); |
|
1338 exportedData.setParsedData(exportedCycles); |
|
1339 |
|
1340 creator.setInputCyclesData(exportedData); |
|
1341 |
|
1342 if(creator.createExcel(monitor)) |
|
1343 { |
|
1344 monitor.done(); |
|
1345 Runnable p = new Runnable(){ |
|
1346 |
|
1347 public void run() { |
|
1348 if(MessageDialog.openQuestion(Display.getCurrent().getActiveShell(),"Confirmation","Would you like to open the saved file?")) |
|
1349 { |
|
1350 Program p=Program.findProgram(".xls"); |
|
1351 if(p!=null) |
|
1352 p.execute(fileName); |
|
1353 } |
|
1354 } |
|
1355 |
|
1356 }; |
|
1357 Display.getDefault().asyncExec(p); |
|
1358 } |
|
1359 else |
|
1360 { |
|
1361 File file = new File(fileName); |
|
1362 file.delete(); |
|
1363 } |
|
1364 } |
|
1365 } |
|
1366 |
|
1367 /** |
|
1368 * Runnable class to run analysis in new thread. |
|
1369 * |
|
1370 */ |
|
1371 public class SWMTAnalysisRunnable implements IRunnableWithProgress |
|
1372 { |
|
1373 |
|
1374 public SWMTAnalysisRunnable() { |
|
1375 } |
|
1376 |
|
1377 public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { |
|
1378 monitor.beginTask("Analysing data...", 10); |
|
1379 int worked = 0; |
|
1380 for(IAnalyser analyser:SwmtAnalyserPlugin.getDefault().getRegisteredAnalysers()) |
|
1381 { |
|
1382 analyser.analyse(parsedData); |
|
1383 analysis_results_obj.addAll(Arrays.asList(analyser.getResults())); |
|
1384 worked = worked + 10/(SwmtAnalyserPlugin.getDefault().getRegisteredAnalysers().length) ; |
|
1385 monitor.worked(worked); |
|
1386 } |
|
1387 monitor.done(); |
|
1388 } |
|
1389 } |
|
1390 |
|
1391 /* (non-Javadoc) |
|
1392 * @see com.nokia.s60tools.swmtanalyser.ui.graphs.IGraphTypeSelectionListener#notifyThreadsSelection() |
|
1393 */ |
|
1394 public void notifyThreadsSelection() |
|
1395 { |
|
1396 Object [] checkedElements = this.threadViewer.getCheckedElements(); |
|
1397 |
|
1398 ArrayList<String> threadNames = new ArrayList<String>(); |
|
1399 ArrayList<Color> threadColors = new ArrayList<Color>(); |
|
1400 |
|
1401 for(Object obj: checkedElements) |
|
1402 { |
|
1403 if(obj instanceof TableViewerInputObject) |
|
1404 { |
|
1405 TableViewerInputObject checkedItem = (TableViewerInputObject)obj; |
|
1406 |
|
1407 threadNames.add(checkedItem.getName()); |
|
1408 threadColors.add(checkedItem.getColor()); |
|
1409 } |
|
1410 } |
|
1411 |
|
1412 //Graph class will be informed about the selected event and selected threads. |
|
1413 ThreadsGraph thGraph = new ThreadsGraph(); |
|
1414 GenericGraph.EventTypes eventType = GraphsUtils.getMappedEvent(selectedEvent); |
|
1415 thGraph.setEvent(eventType); |
|
1416 thGraph.setUserSelectedItems(threadNames); |
|
1417 thGraph.setCyclesData(parsedData); |
|
1418 thGraph.setColors(threadColors); |
|
1419 |
|
1420 graph.redraw(thGraph); |
|
1421 } |
|
1422 |
|
1423 /* (non-Javadoc) |
|
1424 * @see com.nokia.s60tools.swmtanalyser.ui.graphs.IGraphTypeSelectionListener#notifyChunksSelection() |
|
1425 */ |
|
1426 public void notifyChunksSelection() |
|
1427 { |
|
1428 Object [] checkedElements = this.chunksViewer.getCheckedElements(); |
|
1429 |
|
1430 ArrayList<String> chunkNames = new ArrayList<String>(); |
|
1431 ArrayList<Color> chunkColors = new ArrayList<Color>(); |
|
1432 |
|
1433 for(Object obj: checkedElements) |
|
1434 { |
|
1435 if(obj instanceof TableViewerInputObject) |
|
1436 { |
|
1437 TableViewerInputObject checkedItem = (TableViewerInputObject)obj; |
|
1438 |
|
1439 chunkNames.add(checkedItem.getName()); |
|
1440 chunkColors.add(checkedItem.getColor()); |
|
1441 } |
|
1442 } |
|
1443 |
|
1444 //Graph class will be informed about the selected event and selected chunks. |
|
1445 ChunksGraph chnkGraph = new ChunksGraph(); |
|
1446 GenericGraph.EventTypes eventType = GraphsUtils.getMappedEvent(selectedEvent); |
|
1447 chnkGraph.setEvent(eventType); |
|
1448 chnkGraph.setUserSelectedItems(chunkNames); |
|
1449 chnkGraph.setCyclesData(parsedData); |
|
1450 chnkGraph.setColors(chunkColors); |
|
1451 |
|
1452 graph.redraw(chnkGraph); |
|
1453 } |
|
1454 |
|
1455 /* (non-Javadoc) |
|
1456 * @see com.nokia.s60tools.swmtanalyser.ui.graphs.IGraphTypeSelectionListener#notifyDisksSelection() |
|
1457 */ |
|
1458 public void notifyDisksSelection() |
|
1459 { |
|
1460 Object [] checkedElements = this.disksViewer.getCheckedElements(); |
|
1461 |
|
1462 ArrayList<String> diskNames = new ArrayList<String>(); |
|
1463 ArrayList<Color> diskColors = new ArrayList<Color>(); |
|
1464 |
|
1465 for(Object obj: checkedElements) |
|
1466 { |
|
1467 if(obj instanceof TableViewerInputObject) |
|
1468 { |
|
1469 TableViewerInputObject checkedItem = (TableViewerInputObject)obj; |
|
1470 |
|
1471 diskNames.add(checkedItem.getName()); |
|
1472 diskColors.add(checkedItem.getColor()); |
|
1473 } |
|
1474 } |
|
1475 //Graph class will be informed about the selected event and selected disks. |
|
1476 DisksGraph diskGraph = new DisksGraph(); |
|
1477 GenericGraph.EventTypes eventType = GraphsUtils.getMappedEvent(selectedEvent); |
|
1478 diskGraph.setEvent(eventType); |
|
1479 diskGraph.setUserSelectedItems(diskNames); |
|
1480 diskGraph.setCyclesData(parsedData); |
|
1481 diskGraph.setColors(diskColors); |
|
1482 |
|
1483 this.setGraphTitle(selectedEvent); |
|
1484 graph.redraw(diskGraph); |
|
1485 } |
|
1486 |
|
1487 /* (non-Javadoc) |
|
1488 * @see com.nokia.s60tools.swmtanalyser.ui.graphs.IGraphTypeSelectionListener#notifySysElementsSelection() |
|
1489 */ |
|
1490 public void notifySysElementsSelection() |
|
1491 { |
|
1492 Object [] checkedElements = this.sysElemsViewer.getCheckedElements(); |
|
1493 |
|
1494 ArrayList<String> sysElemNames = new ArrayList<String>(); |
|
1495 ArrayList<Color> sysElemColors = new ArrayList<Color>(); |
|
1496 |
|
1497 for(Object obj: checkedElements) |
|
1498 { |
|
1499 if(obj instanceof TableViewerInputObject) |
|
1500 { |
|
1501 TableViewerInputObject checkedItem = (TableViewerInputObject)obj; |
|
1502 |
|
1503 sysElemNames.add(checkedItem.getName()); |
|
1504 sysElemColors.add(checkedItem.getColor()); |
|
1505 } |
|
1506 } |
|
1507 |
|
1508 //Graph class will be informed about the selected event and selected system elements. |
|
1509 SystemDataGraph sysDataGraph = new SystemDataGraph(); |
|
1510 GenericGraph.EventTypes eventType = GraphsUtils.getMappedEvent(selectedEvent); |
|
1511 sysDataGraph.setEvent(eventType); |
|
1512 sysDataGraph.setUserSelectedItems(sysElemNames); |
|
1513 sysDataGraph.setCyclesData(parsedData); |
|
1514 sysDataGraph.setColors(sysElemColors); |
|
1515 |
|
1516 graph.redraw(sysDataGraph); |
|
1517 } |
|
1518 |
|
1519 /** |
|
1520 * Changes the graph title with the given name |
|
1521 * @param name graph name to be set |
|
1522 */ |
|
1523 private void setGraphTitle(String name) |
|
1524 { |
|
1525 if(this.title != null) |
|
1526 title.setText(name); |
|
1527 } |
|
1528 |
|
1529 /** |
|
1530 * WHen Graphed items tab is selected, the items selected in the events tab will be moved |
|
1531 * to Graphed items tab. |
|
1532 * @param event |
|
1533 */ |
|
1534 public void updateGraphedItemsList(String event) |
|
1535 { |
|
1536 if(threadTble.getEnabled()) |
|
1537 { |
|
1538 Iterator<Entry<String, Color>> itr = threadTble.checked.entrySet().iterator(); |
|
1539 while(itr.hasNext()) |
|
1540 { |
|
1541 Entry<String, Color> entry = itr.next(); |
|
1542 GraphedItemsInput item = new GraphedItemsInput(); |
|
1543 graph.storeClearedEventValues(entry.getKey(), allEventsGraph); |
|
1544 |
|
1545 item.setName(entry.getKey()); |
|
1546 item.setEvent(event); |
|
1547 item.setColor(entry.getValue()); |
|
1548 item.setType("Thread"); |
|
1549 if(!checkItemInTheList(item,graphed)) |
|
1550 graphed.add(item); |
|
1551 } |
|
1552 } |
|
1553 else if(chunkTble.getEnabled()) |
|
1554 { |
|
1555 Iterator<Entry<String, Color>> itr = chunkTble.checked.entrySet().iterator(); |
|
1556 while(itr.hasNext()) |
|
1557 { |
|
1558 Entry<String, Color> entry = itr.next(); |
|
1559 GraphedItemsInput item = new GraphedItemsInput(); |
|
1560 graph.storeClearedEventValues(entry.getKey(), allEventsGraph); |
|
1561 |
|
1562 item.setName(entry.getKey()); |
|
1563 item.setColor(entry.getValue()); |
|
1564 item.setEvent(event); |
|
1565 item.setType("Chunk"); |
|
1566 if(!checkItemInTheList(item,graphed)) |
|
1567 graphed.add(item); |
|
1568 } |
|
1569 } |
|
1570 else if(diskTble.getEnabled()) |
|
1571 { |
|
1572 Iterator<Entry<String, Color>> itr = diskTble.checked.entrySet().iterator(); |
|
1573 while(itr.hasNext()) |
|
1574 { |
|
1575 Entry<String, Color> entry = itr.next(); |
|
1576 GraphedItemsInput item = new GraphedItemsInput(); |
|
1577 graph.storeClearedEventValues(entry.getKey(), allEventsGraph); |
|
1578 |
|
1579 item.setName(entry.getKey()); |
|
1580 item.setColor(entry.getValue()); |
|
1581 item.setEvent(event); |
|
1582 item.setType("Disk"); |
|
1583 if(!checkItemInTheList(item,graphed)) |
|
1584 graphed.add(item); |
|
1585 } |
|
1586 } |
|
1587 else if(sysinfoTble.getEnabled()) |
|
1588 { |
|
1589 Iterator<Entry<String, Color>> itr = sysinfoTble.checked.entrySet().iterator(); |
|
1590 while(itr.hasNext()) |
|
1591 { |
|
1592 Entry<String, Color> entry = itr.next(); |
|
1593 GraphedItemsInput item = new GraphedItemsInput(); |
|
1594 graph.storeClearedEventValues(entry.getKey(), allEventsGraph); |
|
1595 |
|
1596 item.setName(entry.getKey()); |
|
1597 item.setColor(entry.getValue()); |
|
1598 item.setEvent(event); |
|
1599 item.setType("System Data"); |
|
1600 if(!checkItemInTheList(item,graphed)) |
|
1601 graphed.add(item); |
|
1602 } |
|
1603 } |
|
1604 else if(Arrays.asList(RAM_GRP).contains(event)) |
|
1605 { |
|
1606 GraphedItemsInput item = new GraphedItemsInput(); |
|
1607 graph.storeClearedEventValues(event, allEventsGraph); |
|
1608 |
|
1609 item.setName(event); |
|
1610 item.setEvent(event); |
|
1611 item.setType("Memory"); |
|
1612 if(!checkItemInTheList(item,graphed)) |
|
1613 graphed.add(item); |
|
1614 } |
|
1615 |
|
1616 if(graphed.size()>0) |
|
1617 { |
|
1618 graphedItemsViewer.setInput(graphed); |
|
1619 graphedItemsViewer.setAllChecked(true); |
|
1620 for(Object obj : graphedItemsViewer.getCheckedElements()) |
|
1621 { |
|
1622 GraphedItemsInput item = (GraphedItemsInput)obj; |
|
1623 if(item.getColor() == null) |
|
1624 item.setColor(getRandomColor()); |
|
1625 graphedItemsViewer.update(item, null); |
|
1626 } |
|
1627 } |
|
1628 } |
|
1629 |
|
1630 /** |
|
1631 * The given item from the given list is checked. |
|
1632 * @param item |
|
1633 * @param list |
|
1634 * @return |
|
1635 */ |
|
1636 public boolean checkItemInTheList(GraphedItemsInput item, ArrayList<GraphedItemsInput> list) |
|
1637 { |
|
1638 for(GraphedItemsInput obj: list) |
|
1639 { |
|
1640 if(item.getEvent().equals(obj.getEvent()) && item.getName().equals(obj.getName()) && item.getType().equals(obj.getType())) |
|
1641 return true; |
|
1642 } |
|
1643 return false; |
|
1644 } |
|
1645 |
|
1646 /** |
|
1647 * Generates random color. |
|
1648 * @return a random color |
|
1649 */ |
|
1650 public Color getRandomColor() |
|
1651 { |
|
1652 Random rand = new Random(); |
|
1653 int r = rand.nextInt(255); |
|
1654 int g = rand.nextInt(255); |
|
1655 int b = rand.nextInt(255); |
|
1656 return new Color(Display.getCurrent(), r, g,b); |
|
1657 } |
|
1658 |
|
1659 |
|
1660 |
|
1661 } |