Commit | Line | Data |
---|---|---|
6e512b93 | 1 | /******************************************************************************* |
8827c197 | 2 | * Copyright (c) 2009, 2010 Ericsson |
6e512b93 | 3 | * |
dfaf8391 FC |
4 | * All rights reserved. This program and the accompanying materials are made |
5 | * available under the terms of the Eclipse Public License v1.0 which | |
6e512b93 ASL |
6 | * accompanies this distribution, and is available at |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
dfaf8391 | 9 | * Contributors: Alvaro Sanchez-Leon - Initial implementation |
6e512b93 | 10 | *******************************************************************************/ |
8b29a712 | 11 | package org.eclipse.linuxtools.lttng.ui.views.controlflow; |
6e512b93 | 12 | |
dfaf8391 FC |
13 | import java.util.Vector; |
14 | ||
15 | import org.eclipse.jface.action.Action; | |
16 | import org.eclipse.jface.action.IMenuListener; | |
17 | import org.eclipse.jface.action.IMenuManager; | |
18 | import org.eclipse.jface.action.IToolBarManager; | |
19 | import org.eclipse.jface.action.MenuManager; | |
20 | import org.eclipse.jface.action.Separator; | |
21 | import org.eclipse.jface.dialogs.MessageDialog; | |
22 | import org.eclipse.jface.viewers.DoubleClickEvent; | |
23 | import org.eclipse.jface.viewers.IDoubleClickListener; | |
24 | import org.eclipse.jface.viewers.ISelection; | |
25 | import org.eclipse.jface.viewers.ISelectionChangedListener; | |
26 | import org.eclipse.jface.viewers.IStructuredContentProvider; | |
27 | import org.eclipse.jface.viewers.IStructuredSelection; | |
28 | import org.eclipse.jface.viewers.ITableLabelProvider; | |
29 | import org.eclipse.jface.viewers.LabelProvider; | |
30 | import org.eclipse.jface.viewers.SelectionChangedEvent; | |
31 | import org.eclipse.jface.viewers.StructuredViewer; | |
32 | import org.eclipse.jface.viewers.TableViewer; | |
33 | import org.eclipse.jface.viewers.Viewer; | |
34 | import org.eclipse.jface.viewers.ViewerFilter; | |
35 | import org.eclipse.linuxtools.lttng.event.LttngTimestamp; | |
8827c197 FC |
36 | import org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest; |
37 | import org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor; | |
dfaf8391 | 38 | import org.eclipse.linuxtools.lttng.ui.TraceDebug; |
8827c197 | 39 | import org.eclipse.linuxtools.lttng.ui.model.trange.ItemContainer; |
dfaf8391 FC |
40 | import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventProcess; |
41 | import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeViewerProvider; | |
41dc35d0 | 42 | import org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView; |
dfaf8391 | 43 | import org.eclipse.linuxtools.lttng.ui.views.common.ParamsUpdater; |
8827c197 | 44 | import org.eclipse.linuxtools.lttng.ui.views.controlflow.evProcessor.FlowEventToHandlerFactory; |
dfaf8391 | 45 | import org.eclipse.linuxtools.lttng.ui.views.controlflow.model.FlowModelFactory; |
8827c197 | 46 | import org.eclipse.linuxtools.tmf.event.TmfEvent; |
dfaf8391 | 47 | import org.eclipse.linuxtools.tmf.event.TmfTimeRange; |
8827c197 | 48 | import org.eclipse.linuxtools.tmf.experiment.TmfExperiment; |
9b635e61 | 49 | import org.eclipse.linuxtools.tmf.request.ITmfDataRequest.ExecutionType; |
8827c197 FC |
50 | import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal; |
51 | import org.eclipse.linuxtools.tmf.signal.TmfRangeSynchSignal; | |
dfaf8391 | 52 | import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler; |
dfaf8391 FC |
53 | import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal; |
54 | import org.eclipse.linuxtools.tmf.ui.viewers.TmfViewerFactory; | |
dfaf8391 FC |
55 | import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeFilterSelectionListener; |
56 | import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeScaleSelectionListener; | |
57 | import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeSelectionListener; | |
58 | import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeFilterSelectionEvent; | |
59 | import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent; | |
60 | import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent; | |
61 | import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry; | |
dfaf8391 FC |
62 | import org.eclipse.swt.SWT; |
63 | import org.eclipse.swt.custom.SashForm; | |
64 | import org.eclipse.swt.custom.ScrolledComposite; | |
dfaf8391 FC |
65 | import org.eclipse.swt.events.KeyEvent; |
66 | import org.eclipse.swt.events.KeyListener; | |
67 | import org.eclipse.swt.graphics.Image; | |
68 | import org.eclipse.swt.graphics.Point; | |
69 | import org.eclipse.swt.graphics.Rectangle; | |
6e512b93 | 70 | import org.eclipse.swt.widgets.Composite; |
dfaf8391 FC |
71 | import org.eclipse.swt.widgets.Display; |
72 | import org.eclipse.swt.widgets.Menu; | |
73 | import org.eclipse.swt.widgets.ScrollBar; | |
74 | import org.eclipse.swt.widgets.Table; | |
75 | import org.eclipse.swt.widgets.TableColumn; | |
76 | import org.eclipse.swt.widgets.TableItem; | |
77 | import org.eclipse.ui.IActionBars; | |
78 | import org.eclipse.ui.IWorkbenchActionConstants; | |
79 | import org.eclipse.ui.PlatformUI; | |
80 | import org.eclipse.ui.plugin.AbstractUIPlugin; | |
6e512b93 ASL |
81 | |
82 | /** | |
83 | * <b><u>ControlFlowView</u></b> | |
84 | */ | |
41dc35d0 FC |
85 | /** |
86 | * @author alvaro | |
87 | * | |
88 | */ | |
89 | public class ControlFlowView extends AbsTimeUpdateView implements | |
dfaf8391 | 90 | ITmfTimeSelectionListener, ITmfTimeScaleSelectionListener, |
41dc35d0 | 91 | ITmfTimeFilterSelectionListener { |
6e512b93 | 92 | |
62d1696a | 93 | public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.controlflow"; |
41dc35d0 | 94 | |
dfaf8391 FC |
95 | // ======================================================================== |
96 | // Table data | |
97 | // ======================================================================== | |
98 | private final String PROCESS_COLUMN = "Process"; | |
99 | private final String BRAND_COLUMN = "Brand"; | |
100 | private final String PID_COLUMN = "PID"; | |
101 | private final String TGID_COLUMN = "TGID"; | |
102 | private final String PPID_COLUMN = "PPID"; | |
103 | private final String CPU_COLUMN = "CPU"; | |
104 | private final String BIRTH_SEC_COLUMN = "Birth sec"; | |
105 | private final String BIRTH_NSEC_COLUMN = "Birth nsec"; | |
106 | private final String TRACE = "TRACE"; | |
107 | ||
108 | private final String[] columnNames = new String[] { PROCESS_COLUMN, /* */ | |
109 | BRAND_COLUMN,/* */ | |
110 | PID_COLUMN,/* */ | |
111 | TGID_COLUMN,/* */ | |
112 | PPID_COLUMN,/* */ | |
113 | CPU_COLUMN, /* */ | |
114 | BIRTH_SEC_COLUMN,/* */ | |
115 | BIRTH_NSEC_COLUMN,/* */ | |
116 | TRACE /* */ | |
117 | }; | |
118 | ||
119 | // ======================================================================== | |
120 | // Data | |
121 | // ======================================================================== | |
dfaf8391 FC |
122 | private TableViewer tableViewer; |
123 | // private int totalNumItems = 0; | |
124 | // Actions | |
125 | private Action doubleClickAction; | |
126 | private Action resetScale; | |
127 | private Action nextEvent; | |
128 | private Action prevEvent; | |
129 | private Action nextTrace; | |
130 | private Action prevTrace; | |
131 | private Action showLegend; | |
132 | private Action filterTraces; | |
133 | private Action zoomIn; | |
134 | private Action zoomOut; | |
8827c197 | 135 | private Action zoomFilter; |
dfaf8391 | 136 | |
dfaf8391 FC |
137 | private ViewProcessFilter tableFilter = null; |
138 | private ScrolledComposite scrollFrame = null; | |
dfaf8391 FC |
139 | |
140 | // private static SimpleDateFormat stimeformat = new SimpleDateFormat( | |
141 | // "yy/MM/dd HH:mm:ss"); | |
142 | ||
143 | // private TraceModelImplFactory fact; | |
144 | ||
145 | // ======================================================================== | |
146 | // Methods | |
147 | // ======================================================================== | |
148 | /* | |
149 | * The content provider class is responsible for providing objects to the | |
150 | * view. It can wrap existing objects in adapters or simply return objects | |
151 | * as-is. These objects may be sensitive to the current input of the view, | |
152 | * or ignore it and always show the same content (like Task List, for | |
153 | * example). | |
154 | */ | |
155 | ||
156 | class ViewContentProvider implements | |
157 | /* ILazyContentProvider, */IStructuredContentProvider { | |
158 | private TableViewer cviewer = null; | |
159 | private ITmfTimeAnalysisEntry[] elements = null; | |
160 | ||
161 | public ViewContentProvider(TableViewer v) { | |
162 | cviewer = v; | |
163 | } | |
164 | ||
d4011df2 | 165 | @Override |
dfaf8391 FC |
166 | public void inputChanged(Viewer v, Object oldInput, Object newInput) { |
167 | this.elements = (ITmfTimeAnalysisEntry[]) newInput; | |
168 | if (elements != null) { | |
8827c197 | 169 | TraceDebug.debug("Total number of processes provided to Control Flow view: " + elements.length); |
dfaf8391 FC |
170 | } else { |
171 | TraceDebug.debug("New input = null"); | |
172 | } | |
173 | } | |
174 | ||
d4011df2 | 175 | @Override |
dfaf8391 FC |
176 | public void dispose() { |
177 | ||
178 | } | |
179 | ||
180 | // Needed with the use of virtual tables in order to initialize items | |
181 | // which were not initially visible. | |
182 | public void updateElement(int index) { | |
183 | cviewer.replace(elements[index], index); | |
184 | } | |
185 | ||
d4011df2 | 186 | @Override |
dfaf8391 | 187 | public Object[] getElements(Object inputElement) { |
dfaf8391 FC |
188 | return elements; |
189 | } | |
190 | } | |
191 | ||
d4011df2 FC |
192 | class ViewLabelProvider extends LabelProvider implements ITableLabelProvider { |
193 | @Override | |
dfaf8391 FC |
194 | public String getColumnText(Object obj, int index) { |
195 | String strRes = ""; //$NON-NLS-1$ | |
196 | LttngTimestamp time; | |
197 | if (obj instanceof TimeRangeEventProcess) { | |
198 | TimeRangeEventProcess process = (TimeRangeEventProcess) obj; | |
199 | switch (index) { | |
200 | case 0: | |
201 | strRes = process.getName(); | |
202 | break; | |
203 | case 1: | |
204 | strRes = process.getBrand(); | |
205 | break; | |
206 | case 2: | |
207 | strRes = process.getPid().toString(); | |
208 | break; | |
209 | case 3: | |
210 | strRes = process.getTgid().toString(); | |
211 | break; | |
212 | case 4: | |
213 | strRes = process.getPpid().toString(); | |
214 | break; | |
215 | case 5: | |
216 | strRes = process.getCpu().toString(); | |
217 | break; | |
218 | case 6: | |
219 | time = new LttngTimestamp(process.getCreationTime() | |
220 | .longValue()); | |
221 | strRes = time.getSeconds(); | |
222 | break; | |
223 | case 7: | |
224 | time = new LttngTimestamp(process.getCreationTime() | |
225 | .longValue()); | |
226 | strRes = time.getNanoSeconds(); | |
227 | break; | |
228 | case 8: | |
229 | strRes = process.getTraceID(); | |
230 | break; | |
231 | default: | |
232 | break; | |
233 | } | |
234 | } else { | |
235 | return getText(obj); | |
236 | } | |
237 | ||
238 | return strRes; | |
239 | } | |
240 | ||
d4011df2 | 241 | @Override |
dfaf8391 FC |
242 | public Image getColumnImage(Object obj, int index) { |
243 | return getImage(obj); | |
244 | } | |
245 | ||
246 | @Override | |
247 | public Image getImage(Object obj) { | |
248 | // No image needed for the time being | |
249 | // return PlatformUI.getWorkbench().getSharedImages().getImage( | |
250 | // ISharedImages.IMG_OBJ_ELEMENT); | |
251 | return null; | |
252 | } | |
253 | } | |
254 | ||
255 | class ViewProcessFilter extends ViewerFilter { | |
256 | ||
257 | private Vector<ITmfTimeAnalysisEntry> filteredSet = new Vector<ITmfTimeAnalysisEntry>(); | |
258 | StructuredViewer viewer; | |
259 | ||
260 | public ViewProcessFilter(StructuredViewer rviewer) { | |
261 | this.viewer = rviewer; | |
262 | } | |
263 | ||
264 | public void setFilter(Vector<ITmfTimeAnalysisEntry> filtered) { | |
265 | if (filtered != null) { | |
266 | this.filteredSet = filtered; | |
267 | viewer.refresh(); | |
268 | } | |
269 | } | |
270 | ||
271 | @Override | |
272 | public boolean select(Viewer viewer, Object parentElement, | |
273 | Object element) { | |
274 | boolean filteredIn = true; | |
275 | if (element instanceof ITmfTimeAnalysisEntry) { | |
276 | ITmfTimeAnalysisEntry process = (ITmfTimeAnalysisEntry) element; | |
277 | if (filteredSet.contains(process)) { | |
278 | // The element is marked to be filtered out | |
279 | return false; | |
280 | } | |
281 | } else { | |
282 | TraceDebug.debug("Unexpected type of filter element received: " | |
283 | + element.toString()); | |
284 | } | |
285 | // Compare element versus a list of filtered out | |
286 | return filteredIn; | |
287 | } | |
288 | } | |
289 | ||
6e512b93 | 290 | /** |
dfaf8391 | 291 | * The constructor. |
6e512b93 ASL |
292 | */ |
293 | public ControlFlowView() { | |
41dc35d0 | 294 | super(ID); |
6e512b93 ASL |
295 | } |
296 | ||
dfaf8391 FC |
297 | /** |
298 | * This is a callback that will allow us to create the viewer and initialize | |
299 | * it. | |
6e512b93 | 300 | */ |
8827c197 FC |
301 | /* |
302 | * (non-Javadoc) | |
303 | * | |
304 | * @see | |
305 | * org.eclipse.linuxtools.tmf.ui.views.TmfView#createPartControl(org.eclipse | |
306 | * .swt.widgets.Composite) | |
307 | */ | |
6e512b93 ASL |
308 | @Override |
309 | public void createPartControl(Composite parent) { | |
dfaf8391 | 310 | |
8827c197 FC |
311 | scrollFrame = new ScrolledComposite(parent, SWT.V_SCROLL); |
312 | ||
dfaf8391 FC |
313 | scrollFrame.setExpandVertical(true); |
314 | scrollFrame.setExpandHorizontal(true); | |
dfaf8391 | 315 | scrollFrame.setAlwaysShowScrollBars(true); |
8827c197 FC |
316 | |
317 | SashForm sash = new SashForm(scrollFrame, SWT.NONE); | |
318 | scrollFrame.setContent(sash); | |
319 | ||
320 | tableViewer = new TableViewer(sash, SWT.FULL_SELECTION | SWT.H_SCROLL); | |
dfaf8391 FC |
321 | tableViewer.setContentProvider(new ViewContentProvider(tableViewer)); |
322 | tableViewer.setLabelProvider(new ViewLabelProvider()); | |
323 | Table table = tableViewer.getTable(); | |
8827c197 | 324 | tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { |
d4011df2 | 325 | @Override |
8827c197 FC |
326 | public void selectionChanged(SelectionChangedEvent event) { |
327 | ISelection sel = event.getSelection(); | |
328 | if (!sel.isEmpty()) { | |
329 | Object firstSel = null; | |
330 | if (sel instanceof IStructuredSelection) { | |
331 | firstSel = ((IStructuredSelection) sel).getFirstElement(); | |
332 | ||
333 | // Make sure the selection is visible | |
334 | updateScrollOrigin(); | |
335 | ||
336 | if (firstSel instanceof ITmfTimeAnalysisEntry) { | |
337 | ITmfTimeAnalysisEntry trace = (ITmfTimeAnalysisEntry) firstSel; | |
338 | tsfviewer.setSelectedTrace(trace); | |
dfaf8391 FC |
339 | } |
340 | } | |
8827c197 FC |
341 | } |
342 | } | |
dfaf8391 | 343 | |
8827c197 FC |
344 | /** |
345 | * Make sure the selected item is visible | |
346 | */ | |
347 | private void updateScrollOrigin() { | |
348 | Table table = tableViewer.getTable(); | |
349 | if (table != null && table.getItemCount() > 0) { | |
350 | TableItem item = table.getSelection()[0]; | |
351 | if (item == null) { | |
352 | // no selected reference to go up or down | |
353 | return; | |
354 | } | |
dfaf8391 | 355 | |
8827c197 FC |
356 | Rectangle itemRect = item.getBounds(); |
357 | int step = itemRect.height; | |
dfaf8391 | 358 | |
8827c197 FC |
359 | // calculate height of horizontal bar |
360 | int hscrolly = 0; | |
361 | ScrollBar hbar = scrollFrame.getHorizontalBar(); | |
362 | if (hbar != null) { | |
363 | hscrolly = hbar.getSize().y; | |
364 | } | |
dfaf8391 | 365 | |
8827c197 | 366 | int visibleHeight = scrollFrame.getSize().y - hscrolly; |
dfaf8391 | 367 | |
8827c197 FC |
368 | // the current scrollbar offset to adjust i.e. start |
369 | // of | |
370 | // the visible window | |
371 | Point origin = scrollFrame.getOrigin(); | |
372 | // end of visible window | |
373 | int endy = origin.y + visibleHeight; | |
dfaf8391 | 374 | |
8827c197 FC |
375 | int itemStartPos = itemRect.y + table.getHeaderHeight() + table.getBorderWidth() |
376 | + table.getParent().getBorderWidth(); | |
dfaf8391 | 377 | |
8827c197 FC |
378 | // Item End Position |
379 | int itemEndPos = itemStartPos + step; | |
dfaf8391 | 380 | |
8827c197 FC |
381 | // check if need to go up |
382 | if (origin.y >= step && itemStartPos < origin.y) { | |
383 | // one step up | |
384 | scrollFrame.setOrigin(origin.x, origin.y - step); | |
8035003b | 385 | |
8827c197 | 386 | } |
dfaf8391 FC |
387 | |
388 | // check if it needs to go down | |
8827c197 FC |
389 | if (itemEndPos > endy) { |
390 | // one step down | |
391 | scrollFrame.setOrigin(origin.x, origin.y + step); | |
dfaf8391 FC |
392 | |
393 | } | |
8827c197 FC |
394 | } |
395 | } | |
396 | }); | |
397 | ||
dfaf8391 FC |
398 | // Listen to page up /down and Home / Enc keys |
399 | tableViewer.getTable().addKeyListener(new KeyListener() { | |
d4011df2 | 400 | @Override |
dfaf8391 FC |
401 | public void keyPressed(KeyEvent e) { |
402 | Table table = tableViewer.getTable(); | |
403 | Point origin = scrollFrame.getOrigin(); | |
404 | if (table == null || table.getItemCount() < 1) { | |
405 | // nothing to page | |
406 | return; | |
407 | } | |
408 | ||
409 | TableItem item; | |
410 | int count; | |
411 | ||
412 | switch (e.keyCode) { | |
413 | case SWT.PAGE_DOWN: | |
414 | updateScrollPageDown(); | |
415 | break; | |
416 | case SWT.PAGE_UP: | |
417 | updateScrollUp(); | |
418 | break; | |
419 | case SWT.HOME: | |
420 | // Home | |
421 | count = table.getItemCount(); | |
422 | item = table.getItem(0); | |
423 | // Go to the top | |
424 | scrollFrame.setOrigin(origin.x, 0); | |
425 | break; | |
426 | case SWT.END: | |
427 | // End Selected | |
428 | count = table.getItemCount(); | |
429 | item = table.getItem(count - 1); | |
430 | int itemStartPos = item.getBounds().y; | |
431 | // Get to the bottom | |
432 | scrollFrame.setOrigin(origin.x, itemStartPos); | |
433 | break; | |
434 | default: | |
435 | break; | |
436 | } | |
437 | } | |
438 | ||
d4011df2 | 439 | @Override |
dfaf8391 FC |
440 | public void keyReleased(KeyEvent e) { |
441 | // Nothing to do | |
442 | ||
443 | } | |
444 | ||
445 | /** | |
446 | * Scroll one page down | |
447 | */ | |
448 | private void updateScrollPageDown() { | |
449 | // null protection before calling private method | |
450 | Table table = tableViewer.getTable(); | |
451 | int step = table.getItemHeight(); | |
452 | ||
453 | int hscrolly = 0; | |
454 | ScrollBar hbar = scrollFrame.getHorizontalBar(); | |
455 | if (hbar != null) { | |
456 | hscrolly = hbar.getSize().y; | |
457 | } | |
458 | ||
459 | Point origin = scrollFrame.getOrigin(); | |
460 | int visibleHeight = scrollFrame.getSize().y - hscrolly; | |
461 | int endy = origin.y + visibleHeight; | |
462 | ||
463 | scrollFrame.setOrigin(origin.x, endy - step); | |
464 | } | |
465 | ||
466 | /** | |
467 | * Scroll one page up | |
468 | */ | |
469 | private void updateScrollUp() { | |
470 | // null protection before calling private method | |
471 | Table table = tableViewer.getTable(); | |
472 | int step = table.getItemHeight(); | |
473 | ||
474 | int hscrolly = 0; | |
475 | ScrollBar hbar = scrollFrame.getHorizontalBar(); | |
476 | if (hbar != null) { | |
477 | hscrolly = hbar.getSize().y; | |
478 | } | |
479 | ||
480 | Point origin = scrollFrame.getOrigin(); | |
481 | int visibleHeight = scrollFrame.getSize().y - hscrolly; | |
482 | int pageUpPos = origin.y - visibleHeight + step; | |
483 | pageUpPos = pageUpPos > 0 ? pageUpPos : 0; | |
484 | scrollFrame.setOrigin(origin.x, pageUpPos); | |
485 | } | |
486 | ||
487 | }); | |
488 | // Describe table | |
489 | applyTableLayout(table); | |
490 | ||
491 | int borderWidth = table.getBorderWidth(); | |
492 | ||
8827c197 | 493 | int itemHeight = table.getItemHeight() + checkForSWTBugItemHeightAdjustement(); |
dfaf8391 FC |
494 | int headerHeight = table.getHeaderHeight(); |
495 | table.getVerticalBar().setVisible(false); | |
496 | ||
497 | tsfviewer = TmfViewerFactory.createViewer(sash, | |
a72a38d9 | 498 | new TimeRangeViewerProvider(getParamsUpdater())); |
dfaf8391 FC |
499 | |
500 | tsfviewer.addWidgetSelectionListner(this); | |
501 | tsfviewer.addWidgetTimeScaleSelectionListner(this); | |
502 | ||
41dc35d0 | 503 | // Traces shall not be grouped to allow synchronisation |
dfaf8391 | 504 | tsfviewer.groupTraces(false); |
8827c197 | 505 | tsfviewer.setItemHeight(itemHeight); |
dfaf8391 FC |
506 | tsfviewer.setBorderWidth(borderWidth); |
507 | tsfviewer.setHeaderHeight(headerHeight); | |
508 | tsfviewer.setVisibleVerticalScroll(false); | |
509 | // Names provided by the table | |
510 | tsfviewer.setNameWidthPref(0); | |
511 | tsfviewer.setAcceptSelectionAPIcalls(true); | |
512 | ||
513 | // Viewer to notify selection to this class | |
41dc35d0 | 514 | // This class will synchronise selections with table. |
dfaf8391 FC |
515 | tsfviewer.addWidgetSelectionListner(this); |
516 | tsfviewer.addFilterSelectionListner(this); | |
517 | tsfviewer.addWidgetTimeScaleSelectionListner(this); | |
518 | ||
519 | sash.setWeights(new int[] { 1, 1 }); | |
520 | // Create the help context id for the viewer's control | |
521 | // TODO: Associate with help system | |
522 | PlatformUI.getWorkbench().getHelpSystem().setHelp( | |
523 | tableViewer.getControl(), | |
524 | "org.eclipse.linuxtools.lttnng.ui.views.flow.viewer"); //$NON-NLS-1$ | |
525 | ||
526 | makeActions(); | |
527 | hookContextMenu(); | |
528 | hookDoubleClickAction(); | |
529 | contributeToActionBars(); | |
530 | ||
8827c197 FC |
531 | // scrollFrame.addControlListener(new ControlAdapter() { |
532 | // | |
533 | // @Override | |
534 | // public void controlResized(ControlEvent e) { | |
535 | // tsfviewer.resizeControls(); | |
536 | // updateScrolls(scrollFrame); | |
537 | // } | |
538 | // }); | |
dfaf8391 FC |
539 | |
540 | // set the initial view parameter values | |
541 | // Experiment start and end time | |
542 | // as well as time space width in pixels, used by the time analysis | |
543 | // widget | |
dfaf8391 FC |
544 | // Read relevant values |
545 | int timeSpaceWidth = tsfviewer.getTimeSpace(); | |
8827c197 FC |
546 | if (timeSpaceWidth < 0) { |
547 | timeSpaceWidth = -timeSpaceWidth; | |
dfaf8391 FC |
548 | } |
549 | ||
8827c197 FC |
550 | TmfExperiment<?> experiment = TmfExperiment.getCurrentExperiment(); |
551 | if (experiment != null) { | |
552 | TmfTimeRange experimentTRange = experiment.getTimeRange(); | |
553 | ||
554 | // send request and received the adjusted time used | |
555 | TmfTimeRange adjustedTimeRange = initialExperimentDataRequest(this, | |
556 | experimentTRange); | |
557 | ||
558 | // initialize widget time boundaries and filtering parameters | |
559 | ModelUpdateInit(experimentTRange, adjustedTimeRange, this); | |
560 | } else { | |
561 | TraceDebug.debug("No selected experiment information available"); | |
562 | } | |
6e512b93 ASL |
563 | } |
564 | ||
dfaf8391 FC |
565 | private void hookContextMenu() { |
566 | MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$ | |
567 | menuMgr.setRemoveAllWhenShown(true); | |
568 | menuMgr.addMenuListener(new IMenuListener() { | |
d4011df2 | 569 | @Override |
dfaf8391 FC |
570 | public void menuAboutToShow(IMenuManager manager) { |
571 | ControlFlowView.this.fillContextMenu(manager); | |
572 | } | |
573 | }); | |
574 | Menu menu = menuMgr.createContextMenu(tableViewer.getControl()); | |
575 | tableViewer.getControl().setMenu(menu); | |
576 | getSite().registerContextMenu(menuMgr, tableViewer); | |
577 | } | |
578 | ||
579 | private void contributeToActionBars() { | |
580 | IActionBars bars = getViewSite().getActionBars(); | |
581 | fillLocalPullDown(bars.getMenuManager()); | |
582 | fillLocalToolBar(bars.getToolBarManager()); | |
583 | } | |
584 | ||
585 | private void fillLocalPullDown(IMenuManager manager) { | |
586 | manager.add(new Separator()); | |
587 | // manager.add(showLegend); | |
588 | manager.add(new Separator()); | |
589 | manager.add(resetScale); | |
590 | manager.add(nextEvent); | |
591 | manager.add(prevEvent); | |
592 | manager.add(nextTrace); | |
593 | manager.add(prevTrace); | |
594 | // manager.add(filterTraces); | |
595 | manager.add(zoomIn); | |
596 | manager.add(zoomOut); | |
8827c197 | 597 | manager.add(zoomFilter); |
dfaf8391 FC |
598 | manager.add(new Separator()); |
599 | } | |
600 | ||
601 | private void fillContextMenu(IMenuManager manager) { | |
602 | // manager.add(showLegend); | |
603 | manager.add(new Separator()); | |
604 | manager.add(resetScale); | |
605 | manager.add(nextEvent); | |
606 | manager.add(prevEvent); | |
607 | manager.add(nextTrace); | |
608 | manager.add(prevTrace); | |
609 | // manager.add(showLegend); | |
610 | // manager.add(filterTraces); | |
611 | manager.add(zoomIn); | |
612 | manager.add(zoomOut); | |
8827c197 | 613 | manager.add(zoomFilter); |
dfaf8391 FC |
614 | manager.add(new Separator()); |
615 | manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); | |
616 | } | |
617 | ||
618 | private void fillLocalToolBar(IToolBarManager manager) { | |
619 | // manager.add(showLegend); | |
620 | manager.add(new Separator()); | |
621 | manager.add(resetScale); | |
622 | manager.add(nextEvent); | |
623 | manager.add(prevEvent); | |
624 | manager.add(nextTrace); | |
625 | manager.add(prevTrace); | |
626 | // manager.add(filterTraces); | |
627 | manager.add(zoomIn); | |
628 | manager.add(zoomOut); | |
8827c197 | 629 | manager.add(zoomFilter); |
dfaf8391 FC |
630 | manager.add(new Separator()); |
631 | } | |
632 | ||
633 | private void makeActions() { | |
f1eb6a6b | 634 | // resetScale |
dfaf8391 FC |
635 | resetScale = new Action() { |
636 | @Override | |
637 | public void run() { | |
638 | if (tsfviewer != null) { | |
639 | tsfviewer.resetStartFinishTime(); | |
640 | } | |
641 | ||
642 | } | |
643 | }; | |
644 | resetScale.setText(Messages.getString("ControlFlowView.Action.Reset")); //$NON-NLS-1$ | |
645 | resetScale.setToolTipText(Messages | |
646 | .getString("ControlFlowView.Action.Reset.ToolTip")); //$NON-NLS-1$ | |
647 | resetScale.setImageDescriptor(AbstractUIPlugin | |
648 | .imageDescriptorFromPlugin(Messages | |
649 | .getString("ControlFlowView.tmf.UI"), | |
650 | "icons/home_nav.gif")); | |
651 | ||
f1eb6a6b | 652 | // nextEvent |
dfaf8391 FC |
653 | nextEvent = new Action() { |
654 | @Override | |
655 | public void run() { | |
656 | if (tsfviewer != null) { | |
657 | tsfviewer.selectNextEvent(); | |
658 | } | |
659 | } | |
660 | }; | |
661 | nextEvent.setText(Messages | |
662 | .getString("ControlFlowView.Action.NextEvent")); //$NON-NLS-1$ | |
663 | nextEvent.setToolTipText(Messages | |
664 | .getString("ControlFlowView.Action.NextEvent.Tooltip")); //$NON-NLS-1$ | |
665 | nextEvent.setImageDescriptor(AbstractUIPlugin | |
666 | .imageDescriptorFromPlugin(Messages | |
667 | .getString("ControlFlowView.tmf.UI"), | |
668 | "icons/next_event.gif")); | |
669 | ||
f1eb6a6b | 670 | // prevEvent |
dfaf8391 | 671 | prevEvent = new Action() { |
41dc35d0 FC |
672 | @Override |
673 | public void run() { | |
dfaf8391 FC |
674 | if (tsfviewer != null) { |
675 | tsfviewer.selectPrevEvent(); | |
676 | } | |
677 | } | |
678 | }; | |
679 | prevEvent.setText(Messages | |
680 | .getString("ControlFlowView.Action.PrevEvent")); //$NON-NLS-1$ | |
681 | prevEvent.setToolTipText(Messages | |
682 | .getString("ControlFlowView.Action.PrevEvent.Tooltip")); //$NON-NLS-1$ | |
683 | prevEvent.setImageDescriptor(AbstractUIPlugin | |
684 | .imageDescriptorFromPlugin(Messages | |
685 | .getString("ControlFlowView.tmf.UI"), | |
686 | "icons/prev_event.gif")); | |
687 | ||
f1eb6a6b | 688 | // nextTrace |
dfaf8391 FC |
689 | nextTrace = new Action() { |
690 | @Override | |
691 | public void run() { | |
692 | if (tsfviewer != null) { | |
693 | tsfviewer.selectNextTrace(); | |
694 | } | |
695 | } | |
696 | }; | |
697 | nextTrace.setText(Messages | |
698 | .getString("ControlFlowView.Action.NextProcess")); //$NON-NLS-1$ | |
699 | nextTrace.setToolTipText(Messages | |
700 | .getString("ControlFlowView.Action.NextProcess.ToolTip")); //$NON-NLS-1$ | |
701 | nextTrace.setImageDescriptor(AbstractUIPlugin | |
702 | .imageDescriptorFromPlugin(Messages | |
703 | .getString("ControlFlowView.tmf.UI"), | |
704 | "icons/next_item.gif")); | |
705 | ||
f1eb6a6b | 706 | // prevTrace |
dfaf8391 FC |
707 | prevTrace = new Action() { |
708 | @Override | |
709 | public void run() { | |
710 | if (tsfviewer != null) { | |
711 | tsfviewer.selectPrevTrace(); | |
712 | } | |
713 | } | |
714 | }; | |
715 | prevTrace.setText(Messages | |
716 | .getString("ControlFlowView.Action.PreviousProcess")); //$NON-NLS-1$ | |
717 | prevTrace.setToolTipText(Messages | |
718 | .getString("ControlFlowView.Action.PreviousProcess.Tooltip")); //$NON-NLS-1$ | |
719 | prevTrace.setImageDescriptor(AbstractUIPlugin | |
720 | .imageDescriptorFromPlugin(Messages | |
721 | .getString("ControlFlowView.tmf.UI"), | |
722 | "icons/prev_item.gif")); | |
723 | ||
f1eb6a6b | 724 | // showLegend |
dfaf8391 FC |
725 | showLegend = new Action() { |
726 | @Override | |
727 | public void run() { | |
728 | if (tsfviewer != null) { | |
729 | tsfviewer.showLegend(); | |
730 | } | |
731 | } | |
732 | }; | |
733 | showLegend.setText(Messages.getString("ControlFlowView.Action.Legend")); //$NON-NLS-1$ | |
734 | showLegend.setToolTipText(Messages | |
735 | .getString("ControlFlowView.Action.Legend.ToolTip")); //$NON-NLS-1$ | |
736 | ||
f1eb6a6b | 737 | // filterTraces |
dfaf8391 FC |
738 | filterTraces = new Action() { |
739 | @Override | |
740 | public void run() { | |
741 | if (tsfviewer != null) { | |
742 | tsfviewer.filterTraces(); | |
743 | } | |
744 | } | |
745 | }; | |
746 | filterTraces.setText(Messages | |
747 | .getString("ControlFlowView.Action.Filter")); //$NON-NLS-1$ | |
748 | filterTraces.setToolTipText(Messages | |
749 | .getString("ControlFlowView.Action.Filter.ToolTip")); //$NON-NLS-1$ | |
750 | filterTraces.setImageDescriptor(AbstractUIPlugin | |
751 | .imageDescriptorFromPlugin(Messages | |
752 | .getString("ControlFlowView.tmf.UI"), | |
753 | "icons/filter_items.gif")); | |
754 | ||
f1eb6a6b | 755 | // zoomIn |
dfaf8391 FC |
756 | zoomIn = new Action() { |
757 | @Override | |
758 | public void run() { | |
759 | if (tsfviewer != null) { | |
760 | tsfviewer.zoomIn(); | |
761 | } | |
762 | } | |
763 | }; | |
764 | zoomIn.setText(Messages.getString("ControlFlowView.Action.ZoomIn")); //$NON-NLS-1$ | |
765 | zoomIn.setToolTipText(Messages | |
766 | .getString("ControlFlowView.Action.ZoomIn.Tooltip")); //$NON-NLS-1$ | |
767 | zoomIn.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin( | |
768 | Messages.getString("ControlFlowView.tmf.UI"), | |
769 | "icons/zoomin_nav.gif")); | |
770 | ||
f1eb6a6b | 771 | // zoomOut |
dfaf8391 FC |
772 | zoomOut = new Action() { |
773 | @Override | |
774 | public void run() { | |
775 | if (tsfviewer != null) { | |
776 | tsfviewer.zoomOut(); | |
777 | } | |
778 | } | |
779 | }; | |
780 | zoomOut.setText(Messages.getString("ControlFlowView.Action.ZoomOut")); //$NON-NLS-1$ | |
781 | zoomOut.setToolTipText(Messages | |
782 | .getString("ControlFlowView.Action.ZoomOut.tooltip")); //$NON-NLS-1$ | |
783 | zoomOut.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin( | |
784 | Messages.getString("ControlFlowView.tmf.UI"), | |
785 | "icons/zoomout_nav.gif")); | |
8827c197 FC |
786 | |
787 | // zoomFilter | |
788 | zoomFilter = new Action() { | |
dfaf8391 FC |
789 | @Override |
790 | public void run() { | |
8827c197 FC |
791 | // Nothing to do, however the selection status is needed by the |
792 | // application | |
dfaf8391 FC |
793 | } |
794 | }; | |
8827c197 FC |
795 | zoomFilter.setText(Messages |
796 | .getString("ControlFlowView.Action.ZoomFilter")); //$NON-NLS-1$ | |
797 | zoomFilter.setToolTipText(Messages | |
798 | .getString("ControlFlowView.Action.ZoomFilter.tooltip")); //$NON-NLS-1$ | |
799 | zoomFilter.setImageDescriptor(AbstractUIPlugin | |
800 | .imageDescriptorFromPlugin(Messages | |
801 | .getString("ControlFlowView.tmf.UI"), | |
802 | "icons/filter_items.gif")); | |
803 | zoomFilter.setChecked(false); | |
804 | ||
dfaf8391 FC |
805 | // PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_SYNCED); |
806 | ||
807 | doubleClickAction = new Action() { | |
808 | @Override | |
809 | public void run() { | |
810 | ISelection selection = tableViewer.getSelection(); | |
811 | Object obj = ((IStructuredSelection) selection) | |
812 | .getFirstElement(); | |
813 | showMessage("Double-click detected on " + obj.toString()); //$NON-NLS-1$ | |
814 | } | |
815 | }; | |
816 | } | |
817 | ||
818 | private void hookDoubleClickAction() { | |
819 | tableViewer.addDoubleClickListener(new IDoubleClickListener() { | |
d4011df2 | 820 | @Override |
dfaf8391 FC |
821 | public void doubleClick(DoubleClickEvent event) { |
822 | doubleClickAction.run(); | |
823 | } | |
824 | }); | |
825 | } | |
826 | ||
827 | private void showMessage(String message) { | |
828 | MessageDialog.openInformation(tableViewer.getControl().getShell(), | |
829 | Messages.getString("ControlFlowView.msgSlogan"), message); //$NON-NLS-1$ | |
830 | } | |
831 | ||
832 | /** | |
833 | * Passing the focus request to the viewer's control. | |
6e512b93 ASL |
834 | */ |
835 | @Override | |
836 | public void setFocus() { | |
dfaf8391 FC |
837 | tableViewer.getControl().setFocus(); |
838 | } | |
839 | ||
8827c197 FC |
840 | /* |
841 | * (non-Javadoc) | |
842 | * | |
843 | * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# | |
844 | * tsfTmProcessSelEvent | |
845 | * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent | |
846 | * ) | |
847 | */ | |
550d787e | 848 | @Override |
dfaf8391 | 849 | public void tsfTmProcessSelEvent(TmfTimeSelectionEvent event) { |
8827c197 FC |
850 | // common implementation |
851 | super.tsfTmProcessSelEvent(event); | |
dfaf8391 FC |
852 | |
853 | // Reselect the table viewer to widget selection | |
854 | ISelection sel = tsfviewer.getSelectionTrace(); | |
855 | if (sel != null && !sel.isEmpty()) { | |
856 | tableViewer.setSelection(sel); | |
857 | } | |
dfaf8391 FC |
858 | } |
859 | ||
8827c197 FC |
860 | /* |
861 | * (non-Javadoc) | |
dfaf8391 | 862 | * |
8827c197 FC |
863 | * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis. |
864 | * ITmfTimeScaleSelectionListener | |
865 | * #tsfTmProcessTimeScaleEvent(org.eclipse.linuxtools | |
866 | * .tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent) | |
dfaf8391 | 867 | */ |
550d787e | 868 | @Override |
8827c197 FC |
869 | public synchronized void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event) { |
870 | super.tsfTmProcessTimeScaleEvent(event); | |
dfaf8391 | 871 | } |
8035003b | 872 | |
dfaf8391 FC |
873 | private void applyTableLayout(Table table) { |
874 | for (int i = 0; i < columnNames.length; i++) { | |
875 | TableColumn tableColumn = new TableColumn(table, SWT.LEFT); | |
876 | tableColumn.setText(columnNames[i]); | |
877 | tableColumn.pack(); | |
878 | } | |
879 | table.setHeaderVisible(true); | |
880 | table.setLinesVisible(true); | |
881 | } | |
882 | ||
8827c197 FC |
883 | /* |
884 | * (non-Javadoc) | |
885 | * | |
886 | * @see | |
887 | * org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#displayModel | |
888 | * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model. | |
889 | * ITmfTimeAnalysisEntry[], long, long, boolean, long, long, | |
890 | * java.lang.Object) | |
d712a5f3 | 891 | */ |
550d787e | 892 | @Override |
8827c197 FC |
893 | public void displayModel(final ITmfTimeAnalysisEntry[] items, |
894 | final long startBoundTime, final long endBoundTime, | |
895 | final boolean updateTimeBounds, final long startVisibleWindow, | |
896 | final long endVisibleWindow, final Object source) { | |
3e9fdb8b FC |
897 | |
898 | if(tableViewer != null) { | |
899 | final Table table = tableViewer.getTable(); | |
db1ea19b FC |
900 | |
901 | // Ignore update if widget is disposed | |
902 | if (table.isDisposed()) return; | |
903 | ||
3e9fdb8b | 904 | Display display = table.getDisplay(); |
db1ea19b | 905 | |
3e9fdb8b FC |
906 | // Perform the updates on the UI thread) |
907 | display.asyncExec(new Runnable() { | |
d4011df2 | 908 | @Override |
3e9fdb8b | 909 | public void run() { |
db1ea19b FC |
910 | if (!table.isDisposed()) { |
911 | tableViewer.setInput(items); // This shall be the minimal | |
912 | // initial | |
913 | tableFilter = new ViewProcessFilter(tableViewer); | |
914 | tableViewer.setFilters(new ViewerFilter[] { tableFilter }); | |
915 | ||
916 | resizeTableColumns(table); | |
917 | table.update(); | |
918 | tableViewer.refresh(); | |
919 | ||
920 | tsfviewer.display(items, startBoundTime, endBoundTime, | |
921 | updateTimeBounds); | |
922 | ||
923 | // validate visible boundaries | |
924 | if (startVisibleWindow > -1 && endVisibleWindow > -1) { | |
925 | tsfviewer.setSelectVisTimeWindow(startVisibleWindow, | |
926 | endVisibleWindow, source); | |
927 | } | |
928 | ||
929 | tsfviewer.resizeControls(); | |
930 | ||
931 | // Adjust the size of the vertical scroll bar to fit the | |
932 | // contents | |
933 | if (scrollFrame != null) { | |
934 | updateScrolls(scrollFrame); | |
935 | } | |
3e9fdb8b | 936 | } |
dfaf8391 | 937 | } |
3e9fdb8b FC |
938 | }); |
939 | } | |
dfaf8391 FC |
940 | } |
941 | ||
942 | @Override | |
943 | public void dispose() { | |
944 | // dispose parent resources | |
945 | super.dispose(); | |
dfaf8391 | 946 | |
dfaf8391 FC |
947 | tsfviewer.removeFilterSelectionListner(this); |
948 | tsfviewer.removeWidgetSelectionListner(this); | |
949 | tsfviewer.removeWidgetTimeScaleSelectionListner(this); | |
950 | tableViewer = null; | |
951 | tsfviewer = null; | |
952 | } | |
953 | ||
954 | /** | |
955 | * @param tableComposite | |
956 | * @param table | |
957 | */ | |
958 | private synchronized void resizeTableColumns(Table table) { | |
959 | if (table != null) { | |
960 | Composite parent = table.getParent(); | |
961 | int tableWidthSum = parent.getBorderWidth(); | |
962 | ||
963 | TableColumn[] columns = table.getColumns(); | |
964 | for (TableColumn column : columns) { | |
965 | column.pack(); | |
966 | tableWidthSum += column.getWidth(); | |
967 | } | |
968 | } | |
969 | } | |
970 | ||
d4011df2 | 971 | @Override |
dfaf8391 FC |
972 | public void tmfTaProcessFilterSelection(TmfTimeFilterSelectionEvent event) { |
973 | if (tableFilter != null) { | |
974 | Vector<ITmfTimeAnalysisEntry> filteredout = event.getFilteredOut(); | |
975 | if (filteredout != null) { | |
976 | tableFilter.setFilter(filteredout); | |
977 | } else { | |
978 | tableFilter.setFilter(new Vector<ITmfTimeAnalysisEntry>()); | |
979 | } | |
980 | tableViewer.refresh(); | |
981 | } | |
982 | } | |
983 | ||
dfaf8391 FC |
984 | /** |
985 | * @param scrollFrame | |
986 | * @param wrapper | |
987 | */ | |
8827c197 FC |
988 | private void updateScrolls(final ScrolledComposite scrollFrame) { |
989 | scrollFrame.setMinSize(tableViewer.getTable().computeSize(SWT.DEFAULT, SWT.DEFAULT)); | |
dfaf8391 FC |
990 | } |
991 | ||
992 | /** | |
8827c197 | 993 | * Registers as listener of time selection from other views |
dfaf8391 | 994 | * |
8827c197 | 995 | * @param signal |
dfaf8391 | 996 | */ |
550d787e | 997 | @Override |
8827c197 FC |
998 | @TmfSignalHandler |
999 | public void synchToTime(TmfTimeSynchSignal signal) { | |
1000 | super.synchToTime(signal); | |
dfaf8391 FC |
1001 | } |
1002 | ||
1003 | /** | |
8827c197 FC |
1004 | * Annotation Registers as listener of time range selection from other views |
1005 | * The implementation handles the entry of the signal. | |
dfaf8391 FC |
1006 | * |
1007 | * @param signal | |
1008 | */ | |
1009 | @TmfSignalHandler | |
8827c197 FC |
1010 | public void synchToTimeRange(TmfRangeSynchSignal signal) { |
1011 | if (zoomFilter != null) { | |
1012 | synchToTimeRange(signal, zoomFilter.isChecked()); | |
dfaf8391 | 1013 | } |
6e512b93 ASL |
1014 | } |
1015 | ||
39332b5c | 1016 | @Override |
8827c197 FC |
1017 | public void modelIncomplete(ILttngSyntEventRequest request) { |
1018 | // Nothing to do | |
1019 | // The data will be refreshed on the next request | |
41dc35d0 FC |
1020 | } |
1021 | ||
1022 | /* | |
1023 | * (non-Javadoc) | |
1024 | * | |
8827c197 FC |
1025 | * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# |
1026 | * getEventProcessor() | |
41dc35d0 | 1027 | */ |
39332b5c | 1028 | @Override |
8827c197 FC |
1029 | public ITransEventProcessor getEventProcessor() { |
1030 | return FlowEventToHandlerFactory.getInstance(); | |
1031 | } | |
d712a5f3 | 1032 | |
8827c197 FC |
1033 | /** |
1034 | * @param signal | |
1035 | */ | |
1036 | @TmfSignalHandler | |
1037 | public void experimentSelected( | |
1038 | TmfExperimentSelectedSignal<? extends TmfEvent> signal) { | |
1039 | if (signal != null) { | |
1040 | TmfTimeRange experimentTRange = signal.getExperiment() | |
1041 | .getTimeRange(); | |
1042 | ||
1043 | // prepare time intervals in widget | |
1044 | ModelUpdateInit(experimentTRange, experimentTRange, signal | |
1045 | .getSource()); | |
1046 | ||
1047 | // request initial data | |
1048 | initialExperimentDataRequest(signal | |
1049 | .getSource(), experimentTRange); | |
d712a5f3 | 1050 | } |
41dc35d0 FC |
1051 | } |
1052 | ||
8827c197 FC |
1053 | /** |
1054 | * @param source | |
1055 | * @param experimentTRange | |
1056 | * @return Adjusted time window used for the request (smaller window to | |
1057 | * initialize view) | |
41dc35d0 | 1058 | */ |
8827c197 FC |
1059 | private TmfTimeRange initialExperimentDataRequest(Object source, |
1060 | TmfTimeRange experimentTRange) { | |
1061 | // Adjust the initial time window to a shorter interval to allow | |
1062 | // user to select the interesting area based on the perspective | |
1063 | TmfTimeRange initTimeWindow = getInitTRange(experimentTRange); | |
41dc35d0 | 1064 | |
f6b14ce2 | 1065 | dataRequest(initTimeWindow, experimentTRange, true, ExecutionType.FOREGROUND); |
41dc35d0 | 1066 | if (TraceDebug.isDEBUG()) { |
8827c197 FC |
1067 | TraceDebug.debug("Initialization request time range is: " |
1068 | + initTimeWindow.getStartTime().toString() + "-" | |
1069 | + initTimeWindow.getEndTime().toString()); | |
41dc35d0 | 1070 | } |
8827c197 FC |
1071 | |
1072 | return initTimeWindow; | |
41dc35d0 | 1073 | } |
542c8a2e WB |
1074 | |
1075 | // *** HACK *** | |
1076 | // | |
1077 | // | |
1078 | // | |
1079 | public int checkForSWTBugItemHeightAdjustement() { | |
1080 | int returnedAjustement = 0; | |
1081 | String desktopSessionName = System.getenv("DESKTOP_SESSION"); | |
1082 | ||
1083 | // Gnome : most common case, no adjustement | |
1084 | if ( desktopSessionName.equals("gnome") ) { | |
1085 | returnedAjustement = 0; | |
1086 | } | |
1087 | // Kde : ajustement of 2 is needed | |
1088 | else if ( desktopSessionName.equals("kde") ) { | |
1089 | returnedAjustement = 2; | |
1090 | } | |
1091 | ||
1092 | return returnedAjustement; | |
1093 | } | |
542c8a2e | 1094 | |
8827c197 FC |
1095 | /* |
1096 | * (non-Javadoc) | |
1097 | * | |
1098 | * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# | |
1099 | * getParamsUpdater() | |
1100 | */ | |
1101 | @Override | |
1102 | protected ParamsUpdater getParamsUpdater() { | |
1103 | return FlowModelFactory.getParamsUpdater(); | |
1104 | } | |
1105 | ||
1106 | /* | |
1107 | * (non-Javadoc) | |
1108 | * | |
1109 | * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# | |
1110 | * getItemContainer() | |
1111 | */ | |
1112 | @Override | |
1113 | protected ItemContainer<?> getItemContainer() { | |
1114 | return FlowModelFactory.getProcContainer(); | |
1115 | } | |
1116 | } |