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