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 | |
6e512b93 | 12 | *******************************************************************************/ |
8b29a712 | 13 | package org.eclipse.linuxtools.lttng.ui.views.controlflow; |
6e512b93 | 14 | |
dfaf8391 FC |
15 | import java.util.Vector; |
16 | ||
17 | import org.eclipse.jface.action.Action; | |
18 | import org.eclipse.jface.action.IMenuListener; | |
19 | import org.eclipse.jface.action.IMenuManager; | |
20 | import org.eclipse.jface.action.IToolBarManager; | |
21 | import org.eclipse.jface.action.MenuManager; | |
22 | import org.eclipse.jface.action.Separator; | |
23 | import org.eclipse.jface.dialogs.MessageDialog; | |
24 | import org.eclipse.jface.viewers.DoubleClickEvent; | |
25 | import org.eclipse.jface.viewers.IDoubleClickListener; | |
26 | import org.eclipse.jface.viewers.ISelection; | |
27 | import org.eclipse.jface.viewers.ISelectionChangedListener; | |
28 | import org.eclipse.jface.viewers.IStructuredContentProvider; | |
29 | import org.eclipse.jface.viewers.IStructuredSelection; | |
30 | import org.eclipse.jface.viewers.ITableLabelProvider; | |
31 | import org.eclipse.jface.viewers.LabelProvider; | |
32 | import org.eclipse.jface.viewers.SelectionChangedEvent; | |
33 | import org.eclipse.jface.viewers.StructuredViewer; | |
34 | import org.eclipse.jface.viewers.TableViewer; | |
35 | import org.eclipse.jface.viewers.Viewer; | |
36 | import org.eclipse.jface.viewers.ViewerFilter; | |
c1c69938 | 37 | import org.eclipse.linuxtools.lttng.control.LttngCoreProviderFactory; |
dfaf8391 | 38 | import org.eclipse.linuxtools.lttng.event.LttngTimestamp; |
8827c197 FC |
39 | import org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest; |
40 | import org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor; | |
dfaf8391 | 41 | import org.eclipse.linuxtools.lttng.ui.TraceDebug; |
8827c197 | 42 | import org.eclipse.linuxtools.lttng.ui.model.trange.ItemContainer; |
dfaf8391 FC |
43 | import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventProcess; |
44 | import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeViewerProvider; | |
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; |
8827c197 | 49 | import org.eclipse.linuxtools.tmf.event.TmfEvent; |
dfaf8391 | 50 | import org.eclipse.linuxtools.tmf.event.TmfTimeRange; |
8827c197 | 51 | import org.eclipse.linuxtools.tmf.experiment.TmfExperiment; |
9b635e61 | 52 | import org.eclipse.linuxtools.tmf.request.ITmfDataRequest.ExecutionType; |
8827c197 FC |
53 | import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal; |
54 | import org.eclipse.linuxtools.tmf.signal.TmfRangeSynchSignal; | |
dfaf8391 | 55 | import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler; |
dfaf8391 FC |
56 | import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal; |
57 | import org.eclipse.linuxtools.tmf.ui.viewers.TmfViewerFactory; | |
dfaf8391 FC |
58 | import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeFilterSelectionListener; |
59 | import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeScaleSelectionListener; | |
60 | import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeSelectionListener; | |
61 | import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeFilterSelectionEvent; | |
62 | import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent; | |
63 | import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent; | |
64 | import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry; | |
dfaf8391 FC |
65 | import org.eclipse.swt.SWT; |
66 | import org.eclipse.swt.custom.SashForm; | |
67 | import org.eclipse.swt.custom.ScrolledComposite; | |
dfaf8391 FC |
68 | import org.eclipse.swt.events.KeyEvent; |
69 | import org.eclipse.swt.events.KeyListener; | |
70 | import org.eclipse.swt.graphics.Image; | |
71 | import org.eclipse.swt.graphics.Point; | |
72 | import org.eclipse.swt.graphics.Rectangle; | |
6e512b93 | 73 | import org.eclipse.swt.widgets.Composite; |
dfaf8391 FC |
74 | import org.eclipse.swt.widgets.Display; |
75 | import org.eclipse.swt.widgets.Menu; | |
76 | import org.eclipse.swt.widgets.ScrollBar; | |
77 | import org.eclipse.swt.widgets.Table; | |
78 | import org.eclipse.swt.widgets.TableColumn; | |
79 | import org.eclipse.swt.widgets.TableItem; | |
80 | import org.eclipse.ui.IActionBars; | |
81 | import org.eclipse.ui.IWorkbenchActionConstants; | |
82 | import org.eclipse.ui.PlatformUI; | |
83 | import org.eclipse.ui.plugin.AbstractUIPlugin; | |
6e512b93 ASL |
84 | |
85 | /** | |
86 | * <b><u>ControlFlowView</u></b> | |
87 | */ | |
41dc35d0 FC |
88 | /** |
89 | * @author alvaro | |
90 | * | |
91 | */ | |
92 | public class ControlFlowView extends AbsTimeUpdateView implements | |
dfaf8391 | 93 | ITmfTimeSelectionListener, ITmfTimeScaleSelectionListener, |
41dc35d0 | 94 | ITmfTimeFilterSelectionListener { |
6e512b93 | 95 | |
3b38ea61 | 96 | public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.controlflow"; //$NON-NLS-1$ |
41dc35d0 | 97 | |
dfaf8391 FC |
98 | // ======================================================================== |
99 | // Table data | |
100 | // ======================================================================== | |
3b38ea61 FC |
101 | |
102 | private final String PROCESS_COLUMN = Messages.getString("ControlFlowView.processColumn"); //$NON-NLS-1$ | |
103 | private final String BRAND_COLUMN = Messages.getString("ControlFlowView.brandColumn"); //$NON-NLS-1$ | |
104 | private final String PID_COLUMN = Messages.getString("ControlFlowView.pidColumn"); //$NON-NLS-1$ | |
105 | private final String TGID_COLUMN = Messages.getString("ControlFlowView.tgidColumn"); //$NON-NLS-1$ | |
106 | private final String PPID_COLUMN = Messages.getString("ControlFlowView.ppidColumn"); //$NON-NLS-1$ | |
107 | private final String CPU_COLUMN = Messages.getString("ControlFlowView.cpuColumn"); //$NON-NLS-1$ | |
108 | private final String BIRTH_SEC_COLUMN = Messages.getString("ControlFlowView.birthSecColumn"); //$NON-NLS-1$ | |
109 | private final String BIRTH_NSEC_COLUMN = Messages.getString("ControlFlowView.birthNSecColumn"); //$NON-NLS-1$ | |
110 | private final String TRACE = Messages.getString("ControlFlowView.TraceNameColumn"); //$NON-NLS-1$ | |
dfaf8391 FC |
111 | |
112 | private final String[] columnNames = new String[] { PROCESS_COLUMN, /* */ | |
113 | BRAND_COLUMN,/* */ | |
114 | PID_COLUMN,/* */ | |
115 | TGID_COLUMN,/* */ | |
116 | PPID_COLUMN,/* */ | |
117 | CPU_COLUMN, /* */ | |
118 | BIRTH_SEC_COLUMN,/* */ | |
119 | BIRTH_NSEC_COLUMN,/* */ | |
120 | TRACE /* */ | |
121 | }; | |
122 | ||
123 | // ======================================================================== | |
124 | // Data | |
125 | // ======================================================================== | |
dfaf8391 FC |
126 | private TableViewer tableViewer; |
127 | // private int totalNumItems = 0; | |
128 | // Actions | |
129 | private Action doubleClickAction; | |
130 | private Action resetScale; | |
131 | private Action nextEvent; | |
132 | private Action prevEvent; | |
133 | private Action nextTrace; | |
134 | private Action prevTrace; | |
135 | private Action showLegend; | |
136 | private Action filterTraces; | |
137 | private Action zoomIn; | |
138 | private Action zoomOut; | |
8827c197 | 139 | private Action zoomFilter; |
dfaf8391 | 140 | |
dfaf8391 FC |
141 | private ViewProcessFilter tableFilter = null; |
142 | private ScrolledComposite scrollFrame = null; | |
dfaf8391 FC |
143 | |
144 | // private static SimpleDateFormat stimeformat = new SimpleDateFormat( | |
145 | // "yy/MM/dd HH:mm:ss"); | |
146 | ||
147 | // private TraceModelImplFactory fact; | |
148 | ||
149 | // ======================================================================== | |
150 | // Methods | |
151 | // ======================================================================== | |
152 | /* | |
153 | * The content provider class is responsible for providing objects to the | |
154 | * view. It can wrap existing objects in adapters or simply return objects | |
155 | * as-is. These objects may be sensitive to the current input of the view, | |
156 | * or ignore it and always show the same content (like Task List, for | |
157 | * example). | |
158 | */ | |
159 | ||
160 | class ViewContentProvider implements | |
161 | /* ILazyContentProvider, */IStructuredContentProvider { | |
162 | private TableViewer cviewer = null; | |
163 | private ITmfTimeAnalysisEntry[] elements = null; | |
164 | ||
165 | public ViewContentProvider(TableViewer v) { | |
166 | cviewer = v; | |
167 | } | |
168 | ||
d4011df2 | 169 | @Override |
dfaf8391 FC |
170 | public void inputChanged(Viewer v, Object oldInput, Object newInput) { |
171 | this.elements = (ITmfTimeAnalysisEntry[]) newInput; | |
172 | if (elements != null) { | |
3b38ea61 | 173 | TraceDebug.debug("Total number of processes provided to Control Flow view: " + elements.length); //$NON-NLS-1$ |
dfaf8391 | 174 | } else { |
3b38ea61 | 175 | TraceDebug.debug("New input = null"); //$NON-NLS-1$ |
dfaf8391 FC |
176 | } |
177 | } | |
178 | ||
d4011df2 | 179 | @Override |
dfaf8391 FC |
180 | public void dispose() { |
181 | ||
182 | } | |
183 | ||
184 | // Needed with the use of virtual tables in order to initialize items | |
185 | // which were not initially visible. | |
186 | public void updateElement(int index) { | |
187 | cviewer.replace(elements[index], index); | |
188 | } | |
189 | ||
d4011df2 | 190 | @Override |
dfaf8391 | 191 | public Object[] getElements(Object inputElement) { |
dfaf8391 FC |
192 | return elements; |
193 | } | |
194 | } | |
195 | ||
d4011df2 FC |
196 | class ViewLabelProvider extends LabelProvider implements ITableLabelProvider { |
197 | @Override | |
dfaf8391 FC |
198 | public String getColumnText(Object obj, int index) { |
199 | String strRes = ""; //$NON-NLS-1$ | |
200 | LttngTimestamp time; | |
201 | if (obj instanceof TimeRangeEventProcess) { | |
202 | TimeRangeEventProcess process = (TimeRangeEventProcess) obj; | |
203 | switch (index) { | |
204 | case 0: | |
205 | strRes = process.getName(); | |
206 | break; | |
207 | case 1: | |
208 | strRes = process.getBrand(); | |
209 | break; | |
210 | case 2: | |
211 | strRes = process.getPid().toString(); | |
212 | break; | |
213 | case 3: | |
214 | strRes = process.getTgid().toString(); | |
215 | break; | |
216 | case 4: | |
217 | strRes = process.getPpid().toString(); | |
218 | break; | |
219 | case 5: | |
220 | strRes = process.getCpu().toString(); | |
221 | break; | |
222 | case 6: | |
223 | time = new LttngTimestamp(process.getCreationTime() | |
224 | .longValue()); | |
225 | strRes = time.getSeconds(); | |
226 | break; | |
227 | case 7: | |
228 | time = new LttngTimestamp(process.getCreationTime() | |
229 | .longValue()); | |
230 | strRes = time.getNanoSeconds(); | |
231 | break; | |
232 | case 8: | |
233 | strRes = process.getTraceID(); | |
234 | break; | |
235 | default: | |
236 | break; | |
237 | } | |
238 | } else { | |
239 | return getText(obj); | |
240 | } | |
241 | ||
242 | return strRes; | |
243 | } | |
244 | ||
d4011df2 | 245 | @Override |
dfaf8391 FC |
246 | public Image getColumnImage(Object obj, int index) { |
247 | return getImage(obj); | |
248 | } | |
249 | ||
250 | @Override | |
251 | public Image getImage(Object obj) { | |
252 | // No image needed for the time being | |
253 | // return PlatformUI.getWorkbench().getSharedImages().getImage( | |
254 | // ISharedImages.IMG_OBJ_ELEMENT); | |
255 | return null; | |
256 | } | |
257 | } | |
258 | ||
259 | class ViewProcessFilter extends ViewerFilter { | |
260 | ||
261 | private Vector<ITmfTimeAnalysisEntry> filteredSet = new Vector<ITmfTimeAnalysisEntry>(); | |
262 | StructuredViewer viewer; | |
263 | ||
264 | public ViewProcessFilter(StructuredViewer rviewer) { | |
265 | this.viewer = rviewer; | |
266 | } | |
267 | ||
268 | public void setFilter(Vector<ITmfTimeAnalysisEntry> filtered) { | |
269 | if (filtered != null) { | |
270 | this.filteredSet = filtered; | |
271 | viewer.refresh(); | |
272 | } | |
273 | } | |
274 | ||
275 | @Override | |
276 | public boolean select(Viewer viewer, Object parentElement, | |
277 | Object element) { | |
278 | boolean filteredIn = true; | |
279 | if (element instanceof ITmfTimeAnalysisEntry) { | |
280 | ITmfTimeAnalysisEntry process = (ITmfTimeAnalysisEntry) element; | |
281 | if (filteredSet.contains(process)) { | |
282 | // The element is marked to be filtered out | |
283 | return false; | |
284 | } | |
285 | } else { | |
3b38ea61 | 286 | TraceDebug.debug("Unexpected type of filter element received: " //$NON-NLS-1$ |
dfaf8391 FC |
287 | + element.toString()); |
288 | } | |
289 | // Compare element versus a list of filtered out | |
290 | return filteredIn; | |
291 | } | |
292 | } | |
293 | ||
6e512b93 | 294 | /** |
dfaf8391 | 295 | * The constructor. |
6e512b93 ASL |
296 | */ |
297 | public ControlFlowView() { | |
41dc35d0 | 298 | super(ID); |
6e512b93 ASL |
299 | } |
300 | ||
dfaf8391 FC |
301 | /** |
302 | * This is a callback that will allow us to create the viewer and initialize | |
303 | * it. | |
6e512b93 | 304 | */ |
8827c197 FC |
305 | /* |
306 | * (non-Javadoc) | |
307 | * | |
308 | * @see | |
309 | * org.eclipse.linuxtools.tmf.ui.views.TmfView#createPartControl(org.eclipse | |
310 | * .swt.widgets.Composite) | |
311 | */ | |
6e512b93 ASL |
312 | @Override |
313 | public void createPartControl(Composite parent) { | |
dfaf8391 | 314 | |
8827c197 FC |
315 | scrollFrame = new ScrolledComposite(parent, SWT.V_SCROLL); |
316 | ||
dfaf8391 FC |
317 | scrollFrame.setExpandVertical(true); |
318 | scrollFrame.setExpandHorizontal(true); | |
dfaf8391 | 319 | scrollFrame.setAlwaysShowScrollBars(true); |
8827c197 FC |
320 | |
321 | SashForm sash = new SashForm(scrollFrame, SWT.NONE); | |
322 | scrollFrame.setContent(sash); | |
323 | ||
324 | tableViewer = new TableViewer(sash, SWT.FULL_SELECTION | SWT.H_SCROLL); | |
dfaf8391 FC |
325 | tableViewer.setContentProvider(new ViewContentProvider(tableViewer)); |
326 | tableViewer.setLabelProvider(new ViewLabelProvider()); | |
327 | Table table = tableViewer.getTable(); | |
8827c197 | 328 | tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { |
d4011df2 | 329 | @Override |
8827c197 FC |
330 | public void selectionChanged(SelectionChangedEvent event) { |
331 | ISelection sel = event.getSelection(); | |
332 | if (!sel.isEmpty()) { | |
333 | Object firstSel = null; | |
334 | if (sel instanceof IStructuredSelection) { | |
335 | firstSel = ((IStructuredSelection) sel).getFirstElement(); | |
336 | ||
337 | // Make sure the selection is visible | |
338 | updateScrollOrigin(); | |
339 | ||
340 | if (firstSel instanceof ITmfTimeAnalysisEntry) { | |
341 | ITmfTimeAnalysisEntry trace = (ITmfTimeAnalysisEntry) firstSel; | |
342 | tsfviewer.setSelectedTrace(trace); | |
dfaf8391 FC |
343 | } |
344 | } | |
8827c197 FC |
345 | } |
346 | } | |
dfaf8391 | 347 | |
8827c197 FC |
348 | /** |
349 | * Make sure the selected item is visible | |
350 | */ | |
351 | private void updateScrollOrigin() { | |
352 | Table table = tableViewer.getTable(); | |
353 | if (table != null && table.getItemCount() > 0) { | |
354 | TableItem item = table.getSelection()[0]; | |
355 | if (item == null) { | |
356 | // no selected reference to go up or down | |
357 | return; | |
358 | } | |
dfaf8391 | 359 | |
8827c197 FC |
360 | Rectangle itemRect = item.getBounds(); |
361 | int step = itemRect.height; | |
dfaf8391 | 362 | |
8827c197 FC |
363 | // calculate height of horizontal bar |
364 | int hscrolly = 0; | |
365 | ScrollBar hbar = scrollFrame.getHorizontalBar(); | |
366 | if (hbar != null) { | |
367 | hscrolly = hbar.getSize().y; | |
368 | } | |
dfaf8391 | 369 | |
8827c197 | 370 | int visibleHeight = scrollFrame.getSize().y - hscrolly; |
dfaf8391 | 371 | |
8827c197 FC |
372 | // the current scrollbar offset to adjust i.e. start |
373 | // of | |
374 | // the visible window | |
375 | Point origin = scrollFrame.getOrigin(); | |
376 | // end of visible window | |
377 | int endy = origin.y + visibleHeight; | |
dfaf8391 | 378 | |
8827c197 FC |
379 | int itemStartPos = itemRect.y + table.getHeaderHeight() + table.getBorderWidth() |
380 | + table.getParent().getBorderWidth(); | |
dfaf8391 | 381 | |
8827c197 FC |
382 | // Item End Position |
383 | int itemEndPos = itemStartPos + step; | |
dfaf8391 | 384 | |
8827c197 FC |
385 | // check if need to go up |
386 | if (origin.y >= step && itemStartPos < origin.y) { | |
387 | // one step up | |
388 | scrollFrame.setOrigin(origin.x, origin.y - step); | |
8035003b | 389 | |
8827c197 | 390 | } |
dfaf8391 FC |
391 | |
392 | // check if it needs to go down | |
8827c197 FC |
393 | if (itemEndPos > endy) { |
394 | // one step down | |
395 | scrollFrame.setOrigin(origin.x, origin.y + step); | |
dfaf8391 FC |
396 | |
397 | } | |
8827c197 FC |
398 | } |
399 | } | |
400 | }); | |
401 | ||
dfaf8391 FC |
402 | // Listen to page up /down and Home / Enc keys |
403 | tableViewer.getTable().addKeyListener(new KeyListener() { | |
d4011df2 | 404 | @Override |
dfaf8391 FC |
405 | public void keyPressed(KeyEvent e) { |
406 | Table table = tableViewer.getTable(); | |
407 | Point origin = scrollFrame.getOrigin(); | |
408 | if (table == null || table.getItemCount() < 1) { | |
409 | // nothing to page | |
410 | return; | |
411 | } | |
412 | ||
413 | TableItem item; | |
414 | int count; | |
415 | ||
416 | switch (e.keyCode) { | |
417 | case SWT.PAGE_DOWN: | |
418 | updateScrollPageDown(); | |
419 | break; | |
420 | case SWT.PAGE_UP: | |
421 | updateScrollUp(); | |
422 | break; | |
423 | case SWT.HOME: | |
424 | // Home | |
425 | count = table.getItemCount(); | |
426 | item = table.getItem(0); | |
427 | // Go to the top | |
428 | scrollFrame.setOrigin(origin.x, 0); | |
429 | break; | |
430 | case SWT.END: | |
431 | // End Selected | |
432 | count = table.getItemCount(); | |
433 | item = table.getItem(count - 1); | |
434 | int itemStartPos = item.getBounds().y; | |
435 | // Get to the bottom | |
436 | scrollFrame.setOrigin(origin.x, itemStartPos); | |
437 | break; | |
438 | default: | |
439 | break; | |
440 | } | |
441 | } | |
442 | ||
d4011df2 | 443 | @Override |
dfaf8391 FC |
444 | public void keyReleased(KeyEvent e) { |
445 | // Nothing to do | |
446 | ||
447 | } | |
448 | ||
449 | /** | |
450 | * Scroll one page down | |
451 | */ | |
452 | private void updateScrollPageDown() { | |
453 | // null protection before calling private method | |
454 | Table table = tableViewer.getTable(); | |
455 | int step = table.getItemHeight(); | |
456 | ||
457 | int hscrolly = 0; | |
458 | ScrollBar hbar = scrollFrame.getHorizontalBar(); | |
459 | if (hbar != null) { | |
460 | hscrolly = hbar.getSize().y; | |
461 | } | |
462 | ||
463 | Point origin = scrollFrame.getOrigin(); | |
464 | int visibleHeight = scrollFrame.getSize().y - hscrolly; | |
465 | int endy = origin.y + visibleHeight; | |
466 | ||
467 | scrollFrame.setOrigin(origin.x, endy - step); | |
468 | } | |
469 | ||
470 | /** | |
471 | * Scroll one page up | |
472 | */ | |
473 | private void updateScrollUp() { | |
474 | // null protection before calling private method | |
475 | Table table = tableViewer.getTable(); | |
476 | int step = table.getItemHeight(); | |
477 | ||
478 | int hscrolly = 0; | |
479 | ScrollBar hbar = scrollFrame.getHorizontalBar(); | |
480 | if (hbar != null) { | |
481 | hscrolly = hbar.getSize().y; | |
482 | } | |
483 | ||
484 | Point origin = scrollFrame.getOrigin(); | |
485 | int visibleHeight = scrollFrame.getSize().y - hscrolly; | |
486 | int pageUpPos = origin.y - visibleHeight + step; | |
487 | pageUpPos = pageUpPos > 0 ? pageUpPos : 0; | |
488 | scrollFrame.setOrigin(origin.x, pageUpPos); | |
489 | } | |
490 | ||
491 | }); | |
492 | // Describe table | |
493 | applyTableLayout(table); | |
494 | ||
495 | int borderWidth = table.getBorderWidth(); | |
496 | ||
162eeb24 | 497 | int itemHeight = table.getItemHeight() + getTableItemHeightAdjustement(); |
dfaf8391 FC |
498 | int headerHeight = table.getHeaderHeight(); |
499 | table.getVerticalBar().setVisible(false); | |
500 | ||
97a888f0 | 501 | tsfviewer = TmfViewerFactory.createViewer(sash, new TimeRangeViewerProvider(getParamsUpdater())); |
dfaf8391 | 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 { | |
3b38ea61 | 561 | TraceDebug.debug("No selected experiment information available"); //$NON-NLS-1$ |
8827c197 | 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 | |
3b38ea61 | 649 | .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$ |
7e71a0d6 | 650 | "icons/elcl16/home_nav.gif")); //$NON-NLS-1$ |
dfaf8391 | 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 | |
3b38ea61 | 667 | .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$ |
7e71a0d6 | 668 | "icons/elcl16/next_event.gif")); //$NON-NLS-1$ |
dfaf8391 | 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 | |
3b38ea61 | 685 | .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$ |
7e71a0d6 | 686 | "icons/elcl16/prev_event.gif")); //$NON-NLS-1$ |
dfaf8391 | 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 | |
3b38ea61 | 703 | .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$ |
7e71a0d6 | 704 | "icons/elcl16/next_item.gif")); //$NON-NLS-1$ |
dfaf8391 | 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 | |
3b38ea61 | 721 | .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$ |
7e71a0d6 | 722 | "icons/elcl16/prev_item.gif")); //$NON-NLS-1$ |
dfaf8391 | 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 | |
3b38ea61 | 752 | .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$ |
7e71a0d6 | 753 | "icons/elcl16/filter_items.gif")); //$NON-NLS-1$ |
dfaf8391 | 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( | |
3b38ea61 | 768 | Messages.getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$ |
7e71a0d6 | 769 | "icons/elcl16/zoomin_nav.gif")); //$NON-NLS-1$ |
dfaf8391 | 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( | |
3b38ea61 | 784 | Messages.getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$ |
7e71a0d6 | 785 | "icons/elcl16/zoomout_nav.gif")); //$NON-NLS-1$ |
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 | |
3b38ea61 | 801 | .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$ |
7e71a0d6 | 802 | "icons/elcl16/filter_items.gif")); //$NON-NLS-1$ |
8827c197 FC |
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 |
c1c69938 | 869 | public void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event) { |
8827c197 | 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 | ||
15beb3f1 FC |
931 | // Adjust asynchronously the size of the vertical scroll bar to fit the |
932 | // contents | |
933 | tableViewer.getTable().getDisplay().asyncExec(new Runnable() { | |
934 | @Override | |
935 | public void run() { | |
b12f4544 | 936 | if ((scrollFrame != null) && (!scrollFrame.isDisposed())) { |
15beb3f1 FC |
937 | updateScrolls(scrollFrame); |
938 | } | |
939 | } | |
940 | }); | |
3e9fdb8b | 941 | } |
dfaf8391 | 942 | } |
3e9fdb8b FC |
943 | }); |
944 | } | |
dfaf8391 FC |
945 | } |
946 | ||
947 | @Override | |
948 | public void dispose() { | |
949 | // dispose parent resources | |
950 | super.dispose(); | |
dfaf8391 | 951 | |
dfaf8391 FC |
952 | tsfviewer.removeFilterSelectionListner(this); |
953 | tsfviewer.removeWidgetSelectionListner(this); | |
954 | tsfviewer.removeWidgetTimeScaleSelectionListner(this); | |
955 | tableViewer = null; | |
956 | tsfviewer = null; | |
957 | } | |
958 | ||
959 | /** | |
960 | * @param tableComposite | |
961 | * @param table | |
962 | */ | |
963 | private synchronized void resizeTableColumns(Table table) { | |
964 | if (table != null) { | |
965 | Composite parent = table.getParent(); | |
966 | int tableWidthSum = parent.getBorderWidth(); | |
967 | ||
968 | TableColumn[] columns = table.getColumns(); | |
969 | for (TableColumn column : columns) { | |
970 | column.pack(); | |
971 | tableWidthSum += column.getWidth(); | |
972 | } | |
973 | } | |
974 | } | |
975 | ||
d4011df2 | 976 | @Override |
dfaf8391 FC |
977 | public void tmfTaProcessFilterSelection(TmfTimeFilterSelectionEvent event) { |
978 | if (tableFilter != null) { | |
979 | Vector<ITmfTimeAnalysisEntry> filteredout = event.getFilteredOut(); | |
980 | if (filteredout != null) { | |
981 | tableFilter.setFilter(filteredout); | |
982 | } else { | |
983 | tableFilter.setFilter(new Vector<ITmfTimeAnalysisEntry>()); | |
984 | } | |
985 | tableViewer.refresh(); | |
986 | } | |
987 | } | |
988 | ||
dfaf8391 FC |
989 | /** |
990 | * @param scrollFrame | |
991 | * @param wrapper | |
992 | */ | |
8827c197 FC |
993 | private void updateScrolls(final ScrolledComposite scrollFrame) { |
994 | scrollFrame.setMinSize(tableViewer.getTable().computeSize(SWT.DEFAULT, SWT.DEFAULT)); | |
dfaf8391 FC |
995 | } |
996 | ||
997 | /** | |
8827c197 | 998 | * Registers as listener of time selection from other views |
dfaf8391 | 999 | * |
8827c197 | 1000 | * @param signal |
dfaf8391 | 1001 | */ |
550d787e | 1002 | @Override |
8827c197 FC |
1003 | @TmfSignalHandler |
1004 | public void synchToTime(TmfTimeSynchSignal signal) { | |
1005 | super.synchToTime(signal); | |
dfaf8391 FC |
1006 | } |
1007 | ||
1008 | /** | |
8827c197 FC |
1009 | * Annotation Registers as listener of time range selection from other views |
1010 | * The implementation handles the entry of the signal. | |
dfaf8391 FC |
1011 | * |
1012 | * @param signal | |
1013 | */ | |
1014 | @TmfSignalHandler | |
8827c197 FC |
1015 | public void synchToTimeRange(TmfRangeSynchSignal signal) { |
1016 | if (zoomFilter != null) { | |
1017 | synchToTimeRange(signal, zoomFilter.isChecked()); | |
dfaf8391 | 1018 | } |
6e512b93 ASL |
1019 | } |
1020 | ||
39332b5c | 1021 | @Override |
8827c197 FC |
1022 | public void modelIncomplete(ILttngSyntEventRequest request) { |
1023 | // Nothing to do | |
1024 | // The data will be refreshed on the next request | |
41dc35d0 FC |
1025 | } |
1026 | ||
1027 | /* | |
1028 | * (non-Javadoc) | |
1029 | * | |
8827c197 FC |
1030 | * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# |
1031 | * getEventProcessor() | |
41dc35d0 | 1032 | */ |
39332b5c | 1033 | @Override |
8827c197 FC |
1034 | public ITransEventProcessor getEventProcessor() { |
1035 | return FlowEventToHandlerFactory.getInstance(); | |
1036 | } | |
d712a5f3 | 1037 | |
8827c197 FC |
1038 | /** |
1039 | * @param signal | |
1040 | */ | |
1041 | @TmfSignalHandler | |
1042 | public void experimentSelected( | |
1043 | TmfExperimentSelectedSignal<? extends TmfEvent> signal) { | |
1044 | if (signal != null) { | |
1045 | TmfTimeRange experimentTRange = signal.getExperiment() | |
1046 | .getTimeRange(); | |
1047 | ||
1048 | // prepare time intervals in widget | |
1049 | ModelUpdateInit(experimentTRange, experimentTRange, signal | |
1050 | .getSource()); | |
1051 | ||
1052 | // request initial data | |
1053 | initialExperimentDataRequest(signal | |
1054 | .getSource(), experimentTRange); | |
d712a5f3 | 1055 | } |
41dc35d0 FC |
1056 | } |
1057 | ||
8827c197 FC |
1058 | /** |
1059 | * @param source | |
1060 | * @param experimentTRange | |
1061 | * @return Adjusted time window used for the request (smaller window to | |
1062 | * initialize view) | |
41dc35d0 | 1063 | */ |
8827c197 FC |
1064 | private TmfTimeRange initialExperimentDataRequest(Object source, |
1065 | TmfTimeRange experimentTRange) { | |
1066 | // Adjust the initial time window to a shorter interval to allow | |
1067 | // user to select the interesting area based on the perspective | |
1068 | TmfTimeRange initTimeWindow = getInitTRange(experimentTRange); | |
41dc35d0 | 1069 | |
f6b14ce2 | 1070 | dataRequest(initTimeWindow, experimentTRange, true, ExecutionType.FOREGROUND); |
41dc35d0 | 1071 | if (TraceDebug.isDEBUG()) { |
3b38ea61 FC |
1072 | TraceDebug.debug("Initialization request time range is: " //$NON-NLS-1$ |
1073 | + initTimeWindow.getStartTime().toString() + "-" //$NON-NLS-1$ | |
8827c197 | 1074 | + initTimeWindow.getEndTime().toString()); |
41dc35d0 | 1075 | } |
8827c197 FC |
1076 | |
1077 | return initTimeWindow; | |
41dc35d0 | 1078 | } |
542c8a2e | 1079 | |
162eeb24 FC |
1080 | /* |
1081 | * SWT doesn't seem to report correctly the table item height, at least in | |
1082 | * the case of KDE. | |
1083 | * | |
1084 | * This method provides an adjustment term according to the desktop session. | |
1085 | * | |
1086 | * @return Height adjustment | |
1087 | */ | |
1088 | private int getTableItemHeightAdjustement() { | |
1089 | int ajustement = 0; | |
1090 | String desktopSession = System.getenv("DESKTOP_SESSION"); //$NON-NLS-1$ | |
1091 | ||
1092 | if (desktopSession != null) { | |
1093 | if (desktopSession.equals("kde")) { //$NON-NLS-1$ | |
1094 | ajustement = 2; | |
1095 | } | |
542c8a2e | 1096 | } |
162eeb24 FC |
1097 | |
1098 | return ajustement; | |
542c8a2e | 1099 | } |
542c8a2e | 1100 | |
8827c197 FC |
1101 | /* |
1102 | * (non-Javadoc) | |
1103 | * | |
1104 | * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# | |
1105 | * getParamsUpdater() | |
1106 | */ | |
1107 | @Override | |
1108 | protected ParamsUpdater getParamsUpdater() { | |
1109 | return FlowModelFactory.getParamsUpdater(); | |
1110 | } | |
1111 | ||
1112 | /* | |
1113 | * (non-Javadoc) | |
1114 | * | |
1115 | * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# | |
1116 | * getItemContainer() | |
1117 | */ | |
1118 | @Override | |
1119 | protected ItemContainer<?> getItemContainer() { | |
1120 | return FlowModelFactory.getProcContainer(); | |
1121 | } | |
c1c69938 FC |
1122 | |
1123 | /* | |
1124 | * (non-Javadoc) | |
1125 | * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#getProviderId() | |
1126 | */ | |
1127 | @Override | |
1128 | protected int getProviderId() { | |
1129 | return LttngCoreProviderFactory.CONTROL_FLOW_LTTNG_SYTH_EVENT_PROVIDER; | |
1130 | } | |
8827c197 | 1131 | } |