1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 Ericsson
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
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Alvaro Sanchez-Leon - Initial implementation
11 * Michel Dagenais (michel.dagenais@polymtl.ca) - Reference C implementation, used with permission
12 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.controlflow
;
15 import java
.util
.Vector
;
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
;
37 import org
.eclipse
.linuxtools
.lttng
.control
.LttngCoreProviderFactory
;
38 import org
.eclipse
.linuxtools
.lttng
.event
.LttngTimestamp
;
39 import org
.eclipse
.linuxtools
.lttng
.request
.ILttngSyntEventRequest
;
40 import org
.eclipse
.linuxtools
.lttng
.state
.evProcessor
.ITransEventProcessor
;
41 import org
.eclipse
.linuxtools
.lttng
.ui
.TraceDebug
;
42 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.ItemContainer
;
43 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.TimeRangeEventProcess
;
44 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.TimeRangeViewerProvider
;
45 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.common
.AbsTimeUpdateView
;
46 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.common
.ParamsUpdater
;
47 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.controlflow
.evProcessor
.FlowEventToHandlerFactory
;
48 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.controlflow
.model
.FlowModelFactory
;
49 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
50 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimeRange
;
51 import org
.eclipse
.linuxtools
.tmf
.experiment
.TmfExperiment
;
52 import org
.eclipse
.linuxtools
.tmf
.request
.ITmfDataRequest
.ExecutionType
;
53 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfExperimentSelectedSignal
;
54 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfRangeSynchSignal
;
55 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfSignalHandler
;
56 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfTimeSynchSignal
;
57 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.TmfViewerFactory
;
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
;
65 import org
.eclipse
.swt
.SWT
;
66 import org
.eclipse
.swt
.custom
.SashForm
;
67 import org
.eclipse
.swt
.custom
.ScrolledComposite
;
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
;
73 import org
.eclipse
.swt
.widgets
.Composite
;
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
;
86 * <b><u>ControlFlowView</u></b>
92 public class ControlFlowView
extends AbsTimeUpdateView
implements
93 ITmfTimeSelectionListener
, ITmfTimeScaleSelectionListener
,
94 ITmfTimeFilterSelectionListener
{
96 public static final String ID
= "org.eclipse.linuxtools.lttng.ui.views.controlflow"; //$NON-NLS-1$
98 // ========================================================================
100 // ========================================================================
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$
112 private final String
[] columnNames
= new String
[] { PROCESS_COLUMN
, /* */
118 BIRTH_SEC_COLUMN
,/* */
119 BIRTH_NSEC_COLUMN
,/* */
123 // ========================================================================
125 // ========================================================================
126 private TableViewer tableViewer
;
127 // private int totalNumItems = 0;
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
;
139 private Action zoomFilter
;
141 private ViewProcessFilter tableFilter
= null;
142 private ScrolledComposite scrollFrame
= null;
144 // private static SimpleDateFormat stimeformat = new SimpleDateFormat(
145 // "yy/MM/dd HH:mm:ss");
147 // private TraceModelImplFactory fact;
149 // ========================================================================
151 // ========================================================================
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
160 class ViewContentProvider
implements
161 /* ILazyContentProvider, */IStructuredContentProvider
{
162 private TableViewer cviewer
= null;
163 private ITmfTimeAnalysisEntry
[] elements
= null;
165 public ViewContentProvider(TableViewer v
) {
170 public void inputChanged(Viewer v
, Object oldInput
, Object newInput
) {
171 this.elements
= (ITmfTimeAnalysisEntry
[]) newInput
;
172 if (elements
!= null) {
173 TraceDebug
.debug("Total number of processes provided to Control Flow view: " + elements
.length
); //$NON-NLS-1$
175 TraceDebug
.debug("New input = null"); //$NON-NLS-1$
180 public void dispose() {
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
);
191 public Object
[] getElements(Object inputElement
) {
196 class ViewLabelProvider
extends LabelProvider
implements ITableLabelProvider
{
198 public String
getColumnText(Object obj
, int index
) {
199 String strRes
= ""; //$NON-NLS-1$
201 if (obj
instanceof TimeRangeEventProcess
) {
202 TimeRangeEventProcess process
= (TimeRangeEventProcess
) obj
;
205 strRes
= process
.getName();
208 strRes
= process
.getBrand();
211 strRes
= process
.getPid().toString();
214 strRes
= process
.getTgid().toString();
217 strRes
= process
.getPpid().toString();
220 strRes
= process
.getCpu().toString();
223 time
= new LttngTimestamp(process
.getCreationTime()
225 strRes
= time
.getSeconds();
228 time
= new LttngTimestamp(process
.getCreationTime()
230 strRes
= time
.getNanoSeconds();
233 strRes
= process
.getTraceID();
246 public Image
getColumnImage(Object obj
, int index
) {
247 return getImage(obj
);
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);
259 class ViewProcessFilter
extends ViewerFilter
{
261 private Vector
<ITmfTimeAnalysisEntry
> filteredSet
= new Vector
<ITmfTimeAnalysisEntry
>();
262 StructuredViewer viewer
;
264 public ViewProcessFilter(StructuredViewer rviewer
) {
265 this.viewer
= rviewer
;
268 public void setFilter(Vector
<ITmfTimeAnalysisEntry
> filtered
) {
269 if (filtered
!= null) {
270 this.filteredSet
= filtered
;
276 public boolean select(Viewer viewer
, Object parentElement
,
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
286 TraceDebug
.debug("Unexpected type of filter element received: " //$NON-NLS-1$
287 + element
.toString());
289 // Compare element versus a list of filtered out
297 public ControlFlowView() {
302 * This is a callback that will allow us to create the viewer and initialize
309 * org.eclipse.linuxtools.tmf.ui.views.TmfView#createPartControl(org.eclipse
310 * .swt.widgets.Composite)
313 public void createPartControl(Composite parent
) {
315 scrollFrame
= new ScrolledComposite(parent
, SWT
.V_SCROLL
);
317 scrollFrame
.setExpandVertical(true);
318 scrollFrame
.setExpandHorizontal(true);
319 scrollFrame
.setAlwaysShowScrollBars(true);
321 SashForm sash
= new SashForm(scrollFrame
, SWT
.NONE
);
322 scrollFrame
.setContent(sash
);
324 tableViewer
= new TableViewer(sash
, SWT
.FULL_SELECTION
| SWT
.H_SCROLL
);
325 tableViewer
.setContentProvider(new ViewContentProvider(tableViewer
));
326 tableViewer
.setLabelProvider(new ViewLabelProvider());
327 Table table
= tableViewer
.getTable();
328 tableViewer
.addSelectionChangedListener(new ISelectionChangedListener() {
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();
337 // Make sure the selection is visible
338 updateScrollOrigin();
340 if (firstSel
instanceof ITmfTimeAnalysisEntry
) {
341 ITmfTimeAnalysisEntry trace
= (ITmfTimeAnalysisEntry
) firstSel
;
342 tsfviewer
.setSelectedTrace(trace
);
349 * Make sure the selected item is visible
351 private void updateScrollOrigin() {
352 Table table
= tableViewer
.getTable();
353 if (table
!= null && table
.getItemCount() > 0) {
354 TableItem item
= table
.getSelection()[0];
356 // no selected reference to go up or down
360 Rectangle itemRect
= item
.getBounds();
361 int step
= itemRect
.height
;
363 // calculate height of horizontal bar
365 ScrollBar hbar
= scrollFrame
.getHorizontalBar();
367 hscrolly
= hbar
.getSize().y
;
370 int visibleHeight
= scrollFrame
.getSize().y
- hscrolly
;
372 // the current scrollbar offset to adjust i.e. start
374 // the visible window
375 Point origin
= scrollFrame
.getOrigin();
376 // end of visible window
377 int endy
= origin
.y
+ visibleHeight
;
379 int itemStartPos
= itemRect
.y
+ table
.getHeaderHeight() + table
.getBorderWidth()
380 + table
.getParent().getBorderWidth();
383 int itemEndPos
= itemStartPos
+ step
;
385 // check if need to go up
386 if (origin
.y
>= step
&& itemStartPos
< origin
.y
) {
388 scrollFrame
.setOrigin(origin
.x
, origin
.y
- step
);
392 // check if it needs to go down
393 if (itemEndPos
> endy
) {
395 scrollFrame
.setOrigin(origin
.x
, origin
.y
+ step
);
402 // Listen to page up /down and Home / Enc keys
403 tableViewer
.getTable().addKeyListener(new KeyListener() {
405 public void keyPressed(KeyEvent e
) {
406 Table table
= tableViewer
.getTable();
407 Point origin
= scrollFrame
.getOrigin();
408 if (table
== null || table
.getItemCount() < 1) {
418 updateScrollPageDown();
425 count
= table
.getItemCount();
426 item
= table
.getItem(0);
428 scrollFrame
.setOrigin(origin
.x
, 0);
432 count
= table
.getItemCount();
433 item
= table
.getItem(count
- 1);
434 int itemStartPos
= item
.getBounds().y
;
436 scrollFrame
.setOrigin(origin
.x
, itemStartPos
);
444 public void keyReleased(KeyEvent e
) {
450 * Scroll one page down
452 private void updateScrollPageDown() {
453 // null protection before calling private method
454 Table table
= tableViewer
.getTable();
455 int step
= table
.getItemHeight();
458 ScrollBar hbar
= scrollFrame
.getHorizontalBar();
460 hscrolly
= hbar
.getSize().y
;
463 Point origin
= scrollFrame
.getOrigin();
464 int visibleHeight
= scrollFrame
.getSize().y
- hscrolly
;
465 int endy
= origin
.y
+ visibleHeight
;
467 scrollFrame
.setOrigin(origin
.x
, endy
- step
);
473 private void updateScrollUp() {
474 // null protection before calling private method
475 Table table
= tableViewer
.getTable();
476 int step
= table
.getItemHeight();
479 ScrollBar hbar
= scrollFrame
.getHorizontalBar();
481 hscrolly
= hbar
.getSize().y
;
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
);
493 applyTableLayout(table
);
495 int borderWidth
= table
.getBorderWidth();
497 int itemHeight
= table
.getItemHeight() + getTableItemHeightAdjustement();
498 int headerHeight
= table
.getHeaderHeight();
499 table
.getVerticalBar().setVisible(false);
501 tsfviewer
= TmfViewerFactory
.createViewer(sash
, new TimeRangeViewerProvider(getParamsUpdater()));
503 // Traces shall not be grouped to allow synchronisation
504 tsfviewer
.groupTraces(false);
505 tsfviewer
.setItemHeight(itemHeight
);
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);
513 // Viewer to notify selection to this class
514 // This class will synchronise selections with table.
515 tsfviewer
.addWidgetSelectionListner(this);
516 tsfviewer
.addFilterSelectionListner(this);
517 tsfviewer
.addWidgetTimeScaleSelectionListner(this);
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$
528 hookDoubleClickAction();
529 contributeToActionBars();
531 // scrollFrame.addControlListener(new ControlAdapter() {
534 // public void controlResized(ControlEvent e) {
535 // tsfviewer.resizeControls();
536 // updateScrolls(scrollFrame);
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
544 // Read relevant values
545 int timeSpaceWidth
= tsfviewer
.getTimeSpace();
546 if (timeSpaceWidth
< 0) {
547 timeSpaceWidth
= -timeSpaceWidth
;
550 TmfExperiment
<?
> experiment
= TmfExperiment
.getCurrentExperiment();
551 if (experiment
!= null) {
552 TmfTimeRange experimentTRange
= experiment
.getTimeRange();
554 // send request and received the adjusted time used
555 TmfTimeRange adjustedTimeRange
= initialExperimentDataRequest(this,
558 // initialize widget time boundaries and filtering parameters
559 ModelUpdateInit(experimentTRange
, adjustedTimeRange
, this);
561 TraceDebug
.debug("No selected experiment information available"); //$NON-NLS-1$
565 private void hookContextMenu() {
566 MenuManager menuMgr
= new MenuManager("#PopupMenu"); //$NON-NLS-1$
567 menuMgr
.setRemoveAllWhenShown(true);
568 menuMgr
.addMenuListener(new IMenuListener() {
570 public void menuAboutToShow(IMenuManager manager
) {
571 ControlFlowView
.this.fillContextMenu(manager
);
574 Menu menu
= menuMgr
.createContextMenu(tableViewer
.getControl());
575 tableViewer
.getControl().setMenu(menu
);
576 getSite().registerContextMenu(menuMgr
, tableViewer
);
579 private void contributeToActionBars() {
580 IActionBars bars
= getViewSite().getActionBars();
581 fillLocalPullDown(bars
.getMenuManager());
582 fillLocalToolBar(bars
.getToolBarManager());
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);
596 manager
.add(zoomOut
);
597 manager
.add(zoomFilter
);
598 manager
.add(new Separator());
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);
612 manager
.add(zoomOut
);
613 manager
.add(zoomFilter
);
614 manager
.add(new Separator());
615 manager
.add(new Separator(IWorkbenchActionConstants
.MB_ADDITIONS
));
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);
628 manager
.add(zoomOut
);
629 manager
.add(zoomFilter
);
630 manager
.add(new Separator());
633 private void makeActions() {
635 resetScale
= new Action() {
638 if (tsfviewer
!= null) {
639 tsfviewer
.resetStartFinishTime();
644 resetScale
.setText(Messages
.getString("ControlFlowView.Action.Reset")); //$NON-NLS-1$
645 resetScale
.setToolTipText(Messages
646 .getString("ControlFlowView.Action.Reset.ToolTip")); //$NON-NLS-1$
647 resetScale
.setImageDescriptor(AbstractUIPlugin
648 .imageDescriptorFromPlugin(Messages
649 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
650 "icons/elcl16/home_nav.gif")); //$NON-NLS-1$
653 nextEvent
= new Action() {
656 if (tsfviewer
!= null) {
657 tsfviewer
.selectNextEvent();
661 nextEvent
.setText(Messages
662 .getString("ControlFlowView.Action.NextEvent")); //$NON-NLS-1$
663 nextEvent
.setToolTipText(Messages
664 .getString("ControlFlowView.Action.NextEvent.Tooltip")); //$NON-NLS-1$
665 nextEvent
.setImageDescriptor(AbstractUIPlugin
666 .imageDescriptorFromPlugin(Messages
667 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
668 "icons/elcl16/next_event.gif")); //$NON-NLS-1$
671 prevEvent
= new Action() {
674 if (tsfviewer
!= null) {
675 tsfviewer
.selectPrevEvent();
679 prevEvent
.setText(Messages
680 .getString("ControlFlowView.Action.PrevEvent")); //$NON-NLS-1$
681 prevEvent
.setToolTipText(Messages
682 .getString("ControlFlowView.Action.PrevEvent.Tooltip")); //$NON-NLS-1$
683 prevEvent
.setImageDescriptor(AbstractUIPlugin
684 .imageDescriptorFromPlugin(Messages
685 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
686 "icons/elcl16/prev_event.gif")); //$NON-NLS-1$
689 nextTrace
= new Action() {
692 if (tsfviewer
!= null) {
693 tsfviewer
.selectNextTrace();
697 nextTrace
.setText(Messages
698 .getString("ControlFlowView.Action.NextProcess")); //$NON-NLS-1$
699 nextTrace
.setToolTipText(Messages
700 .getString("ControlFlowView.Action.NextProcess.ToolTip")); //$NON-NLS-1$
701 nextTrace
.setImageDescriptor(AbstractUIPlugin
702 .imageDescriptorFromPlugin(Messages
703 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
704 "icons/elcl16/next_item.gif")); //$NON-NLS-1$
707 prevTrace
= new Action() {
710 if (tsfviewer
!= null) {
711 tsfviewer
.selectPrevTrace();
715 prevTrace
.setText(Messages
716 .getString("ControlFlowView.Action.PreviousProcess")); //$NON-NLS-1$
717 prevTrace
.setToolTipText(Messages
718 .getString("ControlFlowView.Action.PreviousProcess.Tooltip")); //$NON-NLS-1$
719 prevTrace
.setImageDescriptor(AbstractUIPlugin
720 .imageDescriptorFromPlugin(Messages
721 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
722 "icons/elcl16/prev_item.gif")); //$NON-NLS-1$
725 showLegend
= new Action() {
728 if (tsfviewer
!= null) {
729 tsfviewer
.showLegend();
733 showLegend
.setText(Messages
.getString("ControlFlowView.Action.Legend")); //$NON-NLS-1$
734 showLegend
.setToolTipText(Messages
735 .getString("ControlFlowView.Action.Legend.ToolTip")); //$NON-NLS-1$
738 filterTraces
= new Action() {
741 if (tsfviewer
!= null) {
742 tsfviewer
.filterTraces();
746 filterTraces
.setText(Messages
747 .getString("ControlFlowView.Action.Filter")); //$NON-NLS-1$
748 filterTraces
.setToolTipText(Messages
749 .getString("ControlFlowView.Action.Filter.ToolTip")); //$NON-NLS-1$
750 filterTraces
.setImageDescriptor(AbstractUIPlugin
751 .imageDescriptorFromPlugin(Messages
752 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
753 "icons/elcl16/filter_items.gif")); //$NON-NLS-1$
756 zoomIn
= new Action() {
759 if (tsfviewer
!= null) {
764 zoomIn
.setText(Messages
.getString("ControlFlowView.Action.ZoomIn")); //$NON-NLS-1$
765 zoomIn
.setToolTipText(Messages
766 .getString("ControlFlowView.Action.ZoomIn.Tooltip")); //$NON-NLS-1$
767 zoomIn
.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(
768 Messages
.getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
769 "icons/elcl16/zoomin_nav.gif")); //$NON-NLS-1$
772 zoomOut
= new Action() {
775 if (tsfviewer
!= null) {
780 zoomOut
.setText(Messages
.getString("ControlFlowView.Action.ZoomOut")); //$NON-NLS-1$
781 zoomOut
.setToolTipText(Messages
782 .getString("ControlFlowView.Action.ZoomOut.tooltip")); //$NON-NLS-1$
783 zoomOut
.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(
784 Messages
.getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
785 "icons/elcl16/zoomout_nav.gif")); //$NON-NLS-1$
788 zoomFilter
= new Action() {
791 // Nothing to do, however the selection status is needed by the
795 zoomFilter
.setText(Messages
796 .getString("ControlFlowView.Action.ZoomFilter")); //$NON-NLS-1$
797 zoomFilter
.setToolTipText(Messages
798 .getString("ControlFlowView.Action.ZoomFilter.tooltip")); //$NON-NLS-1$
799 zoomFilter
.setImageDescriptor(AbstractUIPlugin
800 .imageDescriptorFromPlugin(Messages
801 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
802 "icons/elcl16/filter_items.gif")); //$NON-NLS-1$
803 zoomFilter
.setChecked(false);
805 // PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_SYNCED);
807 doubleClickAction
= new Action() {
810 ISelection selection
= tableViewer
.getSelection();
811 Object obj
= ((IStructuredSelection
) selection
)
813 showMessage("Double-click detected on " + obj
.toString()); //$NON-NLS-1$
818 private void hookDoubleClickAction() {
819 tableViewer
.addDoubleClickListener(new IDoubleClickListener() {
821 public void doubleClick(DoubleClickEvent event
) {
822 doubleClickAction
.run();
827 private void showMessage(String message
) {
828 MessageDialog
.openInformation(tableViewer
.getControl().getShell(),
829 Messages
.getString("ControlFlowView.msgSlogan"), message
); //$NON-NLS-1$
833 * Passing the focus request to the viewer's control.
836 public void setFocus() {
837 tableViewer
.getControl().setFocus();
843 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
844 * tsfTmProcessSelEvent
845 * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent
849 public void tsfTmProcessSelEvent(TmfTimeSelectionEvent event
) {
850 // common implementation
851 super.tsfTmProcessSelEvent(event
);
853 // Reselect the table viewer to widget selection
854 ISelection sel
= tsfviewer
.getSelectionTrace();
855 if (sel
!= null && !sel
.isEmpty()) {
856 tableViewer
.setSelection(sel
);
863 * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.
864 * ITmfTimeScaleSelectionListener
865 * #tsfTmProcessTimeScaleEvent(org.eclipse.linuxtools
866 * .tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent)
869 public void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event
) {
870 super.tsfTmProcessTimeScaleEvent(event
);
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
]);
879 table
.setHeaderVisible(true);
880 table
.setLinesVisible(true);
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,
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
) {
898 if(tableViewer
!= null) {
899 final Table table
= tableViewer
.getTable();
901 // Ignore update if widget is disposed
902 if (table
.isDisposed()) return;
904 Display display
= table
.getDisplay();
906 // Perform the updates on the UI thread)
907 display
.asyncExec(new Runnable() {
910 if (!table
.isDisposed()) {
911 tableViewer
.setInput(items
); // This shall be the minimal
913 tableFilter
= new ViewProcessFilter(tableViewer
);
914 tableViewer
.setFilters(new ViewerFilter
[] { tableFilter
});
916 resizeTableColumns(table
);
918 tableViewer
.refresh();
920 tsfviewer
.display(items
, startBoundTime
, endBoundTime
,
923 // validate visible boundaries
924 if (startVisibleWindow
> -1 && endVisibleWindow
> -1) {
925 tsfviewer
.setSelectVisTimeWindow(startVisibleWindow
,
926 endVisibleWindow
, source
);
929 tsfviewer
.resizeControls();
931 // Adjust asynchronously the size of the vertical scroll bar to fit the
933 tableViewer
.getTable().getDisplay().asyncExec(new Runnable() {
936 if ((scrollFrame
!= null) && (!scrollFrame
.isDisposed())) {
937 updateScrolls(scrollFrame
);
948 public void dispose() {
949 // dispose parent resources
952 tsfviewer
.removeFilterSelectionListner(this);
953 tsfviewer
.removeWidgetSelectionListner(this);
954 tsfviewer
.removeWidgetTimeScaleSelectionListner(this);
960 * @param tableComposite
963 private synchronized void resizeTableColumns(Table table
) {
965 Composite parent
= table
.getParent();
966 int tableWidthSum
= parent
.getBorderWidth();
968 TableColumn
[] columns
= table
.getColumns();
969 for (TableColumn column
: columns
) {
971 tableWidthSum
+= column
.getWidth();
977 public void tmfTaProcessFilterSelection(TmfTimeFilterSelectionEvent event
) {
978 if (tableFilter
!= null) {
979 Vector
<ITmfTimeAnalysisEntry
> filteredout
= event
.getFilteredOut();
980 if (filteredout
!= null) {
981 tableFilter
.setFilter(filteredout
);
983 tableFilter
.setFilter(new Vector
<ITmfTimeAnalysisEntry
>());
985 tableViewer
.refresh();
993 private void updateScrolls(final ScrolledComposite scrollFrame
) {
994 scrollFrame
.setMinSize(tableViewer
.getTable().computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
));
998 * Registers as listener of time selection from other views
1004 public void synchToTime(TmfTimeSynchSignal signal
) {
1005 super.synchToTime(signal
);
1009 * Annotation Registers as listener of time range selection from other views
1010 * The implementation handles the entry of the signal.
1015 public void synchToTimeRange(TmfRangeSynchSignal signal
) {
1016 if (zoomFilter
!= null) {
1017 synchToTimeRange(signal
, zoomFilter
.isChecked());
1022 public void modelIncomplete(ILttngSyntEventRequest request
) {
1024 // The data will be refreshed on the next request
1030 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1031 * getEventProcessor()
1034 public ITransEventProcessor
getEventProcessor() {
1035 return FlowEventToHandlerFactory
.getInstance();
1042 public void experimentSelected(
1043 TmfExperimentSelectedSignal
<?
extends TmfEvent
> signal
) {
1044 if (signal
!= null) {
1045 TmfTimeRange experimentTRange
= signal
.getExperiment()
1048 // prepare time intervals in widget
1049 ModelUpdateInit(experimentTRange
, experimentTRange
, signal
1052 // request initial data
1053 initialExperimentDataRequest(signal
1054 .getSource(), experimentTRange
);
1060 * @param experimentTRange
1061 * @return Adjusted time window used for the request (smaller window to
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
);
1070 dataRequest(initTimeWindow
, experimentTRange
, true, ExecutionType
.FOREGROUND
);
1071 if (TraceDebug
.isDEBUG()) {
1072 TraceDebug
.debug("Initialization request time range is: " //$NON-NLS-1$
1073 + initTimeWindow
.getStartTime().toString() + "-" //$NON-NLS-1$
1074 + initTimeWindow
.getEndTime().toString());
1077 return initTimeWindow
;
1081 * SWT doesn't seem to report correctly the table item height, at least in
1084 * This method provides an adjustment term according to the desktop session.
1086 * @return Height adjustment
1088 private int getTableItemHeightAdjustement() {
1090 String desktopSession
= System
.getenv("DESKTOP_SESSION"); //$NON-NLS-1$
1092 if (desktopSession
!= null) {
1093 if (desktopSession
.equals("kde")) { //$NON-NLS-1$
1104 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1105 * getParamsUpdater()
1108 protected ParamsUpdater
getParamsUpdater() {
1109 return FlowModelFactory
.getParamsUpdater();
1115 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1116 * getItemContainer()
1119 protected ItemContainer
<?
> getItemContainer() {
1120 return FlowModelFactory
.getProcContainer();
1125 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#getProviderId()
1128 protected int getProviderId() {
1129 return LttngCoreProviderFactory
.CONTROL_FLOW_LTTNG_SYTH_EVENT_PROVIDER
;