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