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
.views
.common
.AbsTimeUpdateView
;
45 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.common
.ParamsUpdater
;
46 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.controlflow
.evProcessor
.FlowEventToHandlerFactory
;
47 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.controlflow
.model
.FlowModelFactory
;
48 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.controlflow
.model
.FlowTimeRangeViewerProvider
;
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
.TmfExperimentRangeUpdatedSignal
;
54 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfExperimentSelectedSignal
;
55 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfRangeSynchSignal
;
56 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfSignalHandler
;
57 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfTimeSynchSignal
;
58 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.TmfViewerFactory
;
59 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.ITmfTimeFilterSelectionListener
;
60 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.ITmfTimeScaleSelectionListener
;
61 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.ITmfTimeSelectionListener
;
62 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.TmfTimeFilterSelectionEvent
;
63 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.TmfTimeScaleSelectionEvent
;
64 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.TmfTimeSelectionEvent
;
65 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.model
.ITmfTimeAnalysisEntry
;
66 import org
.eclipse
.swt
.SWT
;
67 import org
.eclipse
.swt
.custom
.SashForm
;
68 import org
.eclipse
.swt
.custom
.ScrolledComposite
;
69 import org
.eclipse
.swt
.events
.KeyEvent
;
70 import org
.eclipse
.swt
.events
.KeyListener
;
71 import org
.eclipse
.swt
.graphics
.Image
;
72 import org
.eclipse
.swt
.graphics
.Point
;
73 import org
.eclipse
.swt
.graphics
.Rectangle
;
74 import org
.eclipse
.swt
.widgets
.Composite
;
75 import org
.eclipse
.swt
.widgets
.Display
;
76 import org
.eclipse
.swt
.widgets
.Menu
;
77 import org
.eclipse
.swt
.widgets
.ScrollBar
;
78 import org
.eclipse
.swt
.widgets
.Table
;
79 import org
.eclipse
.swt
.widgets
.TableColumn
;
80 import org
.eclipse
.swt
.widgets
.TableItem
;
81 import org
.eclipse
.ui
.IActionBars
;
82 import org
.eclipse
.ui
.IWorkbenchActionConstants
;
83 import org
.eclipse
.ui
.PlatformUI
;
84 import org
.eclipse
.ui
.plugin
.AbstractUIPlugin
;
87 * <b><u>ControlFlowView</u></b>
93 public class ControlFlowView
extends AbsTimeUpdateView
implements
94 ITmfTimeSelectionListener
, ITmfTimeScaleSelectionListener
,
95 ITmfTimeFilterSelectionListener
{
97 public static final String ID
= "org.eclipse.linuxtools.lttng.ui.views.controlflow"; //$NON-NLS-1$
99 // ========================================================================
101 // ========================================================================
103 private final String PROCESS_COLUMN
= Messages
.getString("ControlFlowView.processColumn"); //$NON-NLS-1$
104 private final String BRAND_COLUMN
= Messages
.getString("ControlFlowView.brandColumn"); //$NON-NLS-1$
105 private final String PID_COLUMN
= Messages
.getString("ControlFlowView.pidColumn"); //$NON-NLS-1$
106 private final String TGID_COLUMN
= Messages
.getString("ControlFlowView.tgidColumn"); //$NON-NLS-1$
107 private final String PPID_COLUMN
= Messages
.getString("ControlFlowView.ppidColumn"); //$NON-NLS-1$
108 private final String CPU_COLUMN
= Messages
.getString("ControlFlowView.cpuColumn"); //$NON-NLS-1$
109 private final String BIRTH_SEC_COLUMN
= Messages
.getString("ControlFlowView.birthSecColumn"); //$NON-NLS-1$
110 private final String BIRTH_NSEC_COLUMN
= Messages
.getString("ControlFlowView.birthNSecColumn"); //$NON-NLS-1$
111 private final String TRACE
= Messages
.getString("ControlFlowView.TraceNameColumn"); //$NON-NLS-1$
113 private final String
[] columnNames
= new String
[] { PROCESS_COLUMN
, /* */
119 BIRTH_SEC_COLUMN
,/* */
120 BIRTH_NSEC_COLUMN
,/* */
124 // ========================================================================
126 // ========================================================================
127 private TableViewer tableViewer
;
128 // private int totalNumItems = 0;
130 private Action doubleClickAction
;
131 private Action resetScale
;
132 private Action nextEvent
;
133 private Action prevEvent
;
134 private Action nextTrace
;
135 private Action prevTrace
;
136 private Action showLegend
;
137 private Action filterTraces
;
138 private Action zoomIn
;
139 private Action zoomOut
;
140 private Action zoomFilter
;
142 private ViewProcessFilter tableFilter
= null;
143 private ScrolledComposite scrollFrame
= null;
145 private TmfTimeRange initTimeRange
= TmfTimeRange
.Null
;
147 // private static SimpleDateFormat stimeformat = new SimpleDateFormat(
148 // "yy/MM/dd HH:mm:ss");
150 // private TraceModelImplFactory fact;
152 // ========================================================================
154 // ========================================================================
156 * The content provider class is responsible for providing objects to the
157 * view. It can wrap existing objects in adapters or simply return objects
158 * as-is. These objects may be sensitive to the current input of the view,
159 * or ignore it and always show the same content (like Task List, for
163 class ViewContentProvider
implements
164 /* ILazyContentProvider, */IStructuredContentProvider
{
165 private TableViewer cviewer
= null;
166 private ITmfTimeAnalysisEntry
[] elements
= null;
168 public ViewContentProvider(TableViewer v
) {
173 public void inputChanged(Viewer v
, Object oldInput
, Object newInput
) {
174 this.elements
= (ITmfTimeAnalysisEntry
[]) newInput
;
175 if (elements
!= null) {
176 TraceDebug
.debug("Total number of processes provided to Control Flow view: " + elements
.length
); //$NON-NLS-1$
178 TraceDebug
.debug("New input = null"); //$NON-NLS-1$
183 public void dispose() {
187 // Needed with the use of virtual tables in order to initialize items
188 // which were not initially visible.
189 public void updateElement(int index
) {
190 cviewer
.replace(elements
[index
], index
);
194 public Object
[] getElements(Object inputElement
) {
199 class ViewLabelProvider
extends LabelProvider
implements ITableLabelProvider
{
201 public String
getColumnText(Object obj
, int index
) {
202 String strRes
= ""; //$NON-NLS-1$
204 if (obj
instanceof TimeRangeEventProcess
) {
205 TimeRangeEventProcess process
= (TimeRangeEventProcess
) obj
;
208 strRes
= process
.getName();
211 strRes
= process
.getBrand();
214 strRes
= process
.getPid().toString();
217 strRes
= process
.getTgid().toString();
220 strRes
= process
.getPpid().toString();
223 strRes
= process
.getCpu().toString();
226 time
= new LttngTimestamp(process
.getCreationTime()
228 strRes
= time
.getSeconds();
231 time
= new LttngTimestamp(process
.getCreationTime()
233 strRes
= time
.getNanoSeconds();
236 strRes
= process
.getTraceID();
249 public Image
getColumnImage(Object obj
, int index
) {
250 return getImage(obj
);
254 public Image
getImage(Object obj
) {
255 // No image needed for the time being
256 // return PlatformUI.getWorkbench().getSharedImages().getImage(
257 // ISharedImages.IMG_OBJ_ELEMENT);
262 class ViewProcessFilter
extends ViewerFilter
{
264 private Vector
<ITmfTimeAnalysisEntry
> filteredSet
= new Vector
<ITmfTimeAnalysisEntry
>();
265 StructuredViewer viewer
;
267 public ViewProcessFilter(StructuredViewer rviewer
) {
268 this.viewer
= rviewer
;
271 public void setFilter(Vector
<ITmfTimeAnalysisEntry
> filtered
) {
272 if (filtered
!= null) {
273 this.filteredSet
= filtered
;
279 public boolean select(Viewer viewer
, Object parentElement
,
281 boolean filteredIn
= true;
282 if (element
instanceof ITmfTimeAnalysisEntry
) {
283 ITmfTimeAnalysisEntry process
= (ITmfTimeAnalysisEntry
) element
;
284 if (filteredSet
.contains(process
)) {
285 // The element is marked to be filtered out
289 TraceDebug
.debug("Unexpected type of filter element received: " //$NON-NLS-1$
290 + element
.toString());
292 // Compare element versus a list of filtered out
300 public ControlFlowView() {
305 * This is a callback that will allow us to create the viewer and initialize
312 * org.eclipse.linuxtools.tmf.ui.views.TmfView#createPartControl(org.eclipse
313 * .swt.widgets.Composite)
316 public void createPartControl(Composite parent
) {
318 scrollFrame
= new ScrolledComposite(parent
, SWT
.V_SCROLL
);
320 scrollFrame
.setExpandVertical(true);
321 scrollFrame
.setExpandHorizontal(true);
322 scrollFrame
.setAlwaysShowScrollBars(true);
324 SashForm sash
= new SashForm(scrollFrame
, SWT
.NONE
);
325 scrollFrame
.setContent(sash
);
327 tableViewer
= new TableViewer(sash
, SWT
.FULL_SELECTION
| SWT
.H_SCROLL
);
328 tableViewer
.setContentProvider(new ViewContentProvider(tableViewer
));
329 tableViewer
.setLabelProvider(new ViewLabelProvider());
330 Table table
= tableViewer
.getTable();
331 tableViewer
.addSelectionChangedListener(new ISelectionChangedListener() {
333 public void selectionChanged(SelectionChangedEvent event
) {
334 ISelection sel
= event
.getSelection();
335 if (!sel
.isEmpty()) {
336 Object firstSel
= null;
337 if (sel
instanceof IStructuredSelection
) {
338 firstSel
= ((IStructuredSelection
) sel
).getFirstElement();
340 // Make sure the selection is visible
341 updateScrollOrigin();
343 if (firstSel
instanceof ITmfTimeAnalysisEntry
) {
344 ITmfTimeAnalysisEntry trace
= (ITmfTimeAnalysisEntry
) firstSel
;
345 tsfviewer
.setSelectedTrace(trace
);
352 * Make sure the selected item is visible
354 private void updateScrollOrigin() {
355 Table table
= tableViewer
.getTable();
356 if (table
!= null && table
.getItemCount() > 0) {
357 TableItem item
= table
.getSelection()[0];
359 // no selected reference to go up or down
363 Rectangle itemRect
= item
.getBounds();
364 int step
= itemRect
.height
;
366 // calculate height of horizontal bar
368 ScrollBar hbar
= scrollFrame
.getHorizontalBar();
370 hscrolly
= hbar
.getSize().y
;
373 int visibleHeight
= scrollFrame
.getSize().y
- hscrolly
;
375 // the current scrollbar offset to adjust i.e. start
377 // the visible window
378 Point origin
= scrollFrame
.getOrigin();
379 // end of visible window
380 int endy
= origin
.y
+ visibleHeight
;
382 int itemStartPos
= itemRect
.y
+ table
.getHeaderHeight() + table
.getBorderWidth()
383 + table
.getParent().getBorderWidth();
386 int itemEndPos
= itemStartPos
+ step
;
388 // check if need to go up
389 if (origin
.y
>= step
&& itemStartPos
< origin
.y
) {
391 scrollFrame
.setOrigin(origin
.x
, origin
.y
- step
);
395 // check if it needs to go down
396 if (itemEndPos
> endy
) {
398 scrollFrame
.setOrigin(origin
.x
, origin
.y
+ step
);
405 // Listen to page up /down and Home / Enc keys
406 tableViewer
.getTable().addKeyListener(new KeyListener() {
408 public void keyPressed(KeyEvent e
) {
409 Table table
= tableViewer
.getTable();
410 Point origin
= scrollFrame
.getOrigin();
411 if (table
== null || table
.getItemCount() < 1) {
421 updateScrollPageDown();
428 count
= table
.getItemCount();
429 item
= table
.getItem(0);
431 scrollFrame
.setOrigin(origin
.x
, 0);
435 count
= table
.getItemCount();
436 item
= table
.getItem(count
- 1);
437 int itemStartPos
= item
.getBounds().y
;
439 scrollFrame
.setOrigin(origin
.x
, itemStartPos
);
447 public void keyReleased(KeyEvent e
) {
453 * Scroll one page down
455 private void updateScrollPageDown() {
456 // null protection before calling private method
457 Table table
= tableViewer
.getTable();
458 int step
= table
.getItemHeight();
461 ScrollBar hbar
= scrollFrame
.getHorizontalBar();
463 hscrolly
= hbar
.getSize().y
;
466 Point origin
= scrollFrame
.getOrigin();
467 int visibleHeight
= scrollFrame
.getSize().y
- hscrolly
;
468 int endy
= origin
.y
+ visibleHeight
;
470 scrollFrame
.setOrigin(origin
.x
, endy
- step
);
476 private void updateScrollUp() {
477 // null protection before calling private method
478 Table table
= tableViewer
.getTable();
479 int step
= table
.getItemHeight();
482 ScrollBar hbar
= scrollFrame
.getHorizontalBar();
484 hscrolly
= hbar
.getSize().y
;
487 Point origin
= scrollFrame
.getOrigin();
488 int visibleHeight
= scrollFrame
.getSize().y
- hscrolly
;
489 int pageUpPos
= origin
.y
- visibleHeight
+ step
;
490 pageUpPos
= pageUpPos
> 0 ? pageUpPos
: 0;
491 scrollFrame
.setOrigin(origin
.x
, pageUpPos
);
496 applyTableLayout(table
);
498 int borderWidth
= table
.getBorderWidth();
500 int itemHeight
= table
.getItemHeight() + getTableItemHeightAdjustement();
501 int headerHeight
= table
.getHeaderHeight();
502 table
.getVerticalBar().setVisible(false);
504 tsfviewer
= TmfViewerFactory
.createViewer(sash
, new FlowTimeRangeViewerProvider(getParamsUpdater()));
506 // Traces shall not be grouped to allow synchronisation
507 tsfviewer
.groupTraces(false);
508 tsfviewer
.setItemHeight(itemHeight
);
509 tsfviewer
.setBorderWidth(borderWidth
);
510 tsfviewer
.setHeaderHeight(headerHeight
);
511 tsfviewer
.setVisibleVerticalScroll(false);
512 // Names provided by the table
513 tsfviewer
.setNameWidthPref(0);
514 tsfviewer
.setAcceptSelectionAPIcalls(true);
516 // Viewer to notify selection to this class
517 // This class will synchronise selections with table.
518 tsfviewer
.addWidgetSelectionListner(this);
519 tsfviewer
.addFilterSelectionListner(this);
520 tsfviewer
.addWidgetTimeScaleSelectionListner(this);
522 sash
.setWeights(new int[] { 1, 1 });
523 // Create the help context id for the viewer's control
524 // TODO: Associate with help system
525 PlatformUI
.getWorkbench().getHelpSystem().setHelp(
526 tableViewer
.getControl(),
527 "org.eclipse.linuxtools.lttnng.ui.views.flow.viewer"); //$NON-NLS-1$
531 hookDoubleClickAction();
532 contributeToActionBars();
534 // scrollFrame.addControlListener(new ControlAdapter() {
537 // public void controlResized(ControlEvent e) {
538 // tsfviewer.resizeControls();
539 // updateScrolls(scrollFrame);
543 // set the initial view parameter values
544 // Experiment start and end time
545 // as well as time space width in pixels, used by the time analysis
547 // Read relevant values
548 int timeSpaceWidth
= tsfviewer
.getTimeSpace();
549 if (timeSpaceWidth
< 0) {
550 timeSpaceWidth
= -timeSpaceWidth
;
553 TmfExperiment
<?
> experiment
= TmfExperiment
.getCurrentExperiment();
554 if (experiment
!= null) {
555 TmfTimeRange experimentTRange
= experiment
.getTimeRange();
557 if (experimentTRange
!= TmfTimeRange
.Null
) {
558 // send request and received the adjusted time used
559 TmfTimeRange adjustedTimeRange
= initialExperimentDataRequest(this,
562 // initialize widget time boundaries and filtering parameters
563 ModelUpdateInit(experimentTRange
, adjustedTimeRange
, this);
566 TraceDebug
.debug("No selected experiment information available"); //$NON-NLS-1$
570 private void hookContextMenu() {
571 MenuManager menuMgr
= new MenuManager("#PopupMenu"); //$NON-NLS-1$
572 menuMgr
.setRemoveAllWhenShown(true);
573 menuMgr
.addMenuListener(new IMenuListener() {
575 public void menuAboutToShow(IMenuManager manager
) {
576 ControlFlowView
.this.fillContextMenu(manager
);
579 Menu menu
= menuMgr
.createContextMenu(tableViewer
.getControl());
580 tableViewer
.getControl().setMenu(menu
);
581 getSite().registerContextMenu(menuMgr
, tableViewer
);
584 private void contributeToActionBars() {
585 IActionBars bars
= getViewSite().getActionBars();
586 fillLocalPullDown(bars
.getMenuManager());
587 fillLocalToolBar(bars
.getToolBarManager());
590 private void fillLocalPullDown(IMenuManager manager
) {
591 manager
.add(new Separator());
592 manager
.add(showLegend
);
593 manager
.add(new Separator());
594 manager
.add(resetScale
);
595 manager
.add(nextEvent
);
596 manager
.add(prevEvent
);
597 manager
.add(nextTrace
);
598 manager
.add(prevTrace
);
599 // manager.add(filterTraces);
601 manager
.add(zoomOut
);
602 manager
.add(zoomFilter
);
603 manager
.add(new Separator());
606 private void fillContextMenu(IMenuManager manager
) {
607 manager
.add(showLegend
);
608 manager
.add(new Separator());
609 manager
.add(resetScale
);
610 manager
.add(nextEvent
);
611 manager
.add(prevEvent
);
612 manager
.add(nextTrace
);
613 manager
.add(prevTrace
);
614 manager
.add(showLegend
);
615 // manager.add(filterTraces);
617 manager
.add(zoomOut
);
618 manager
.add(zoomFilter
);
619 manager
.add(new Separator());
620 manager
.add(new Separator(IWorkbenchActionConstants
.MB_ADDITIONS
));
623 private void fillLocalToolBar(IToolBarManager manager
) {
624 manager
.add(showLegend
);
625 manager
.add(new Separator());
626 manager
.add(resetScale
);
627 manager
.add(nextEvent
);
628 manager
.add(prevEvent
);
629 manager
.add(nextTrace
);
630 manager
.add(prevTrace
);
631 // manager.add(filterTraces);
633 manager
.add(zoomOut
);
634 manager
.add(zoomFilter
);
635 manager
.add(new Separator());
638 private void makeActions() {
640 resetScale
= new Action() {
643 if (tsfviewer
!= null) {
644 tsfviewer
.resetStartFinishTime();
649 resetScale
.setText(Messages
.getString("ControlFlowView.Action.Reset")); //$NON-NLS-1$
650 resetScale
.setToolTipText(Messages
651 .getString("ControlFlowView.Action.Reset.ToolTip")); //$NON-NLS-1$
652 resetScale
.setImageDescriptor(AbstractUIPlugin
653 .imageDescriptorFromPlugin(Messages
654 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
655 "icons/elcl16/home_nav.gif")); //$NON-NLS-1$
658 nextEvent
= new Action() {
661 if (tsfviewer
!= null) {
662 tsfviewer
.selectNextEvent();
666 nextEvent
.setText(Messages
667 .getString("ControlFlowView.Action.NextEvent")); //$NON-NLS-1$
668 nextEvent
.setToolTipText(Messages
669 .getString("ControlFlowView.Action.NextEvent.Tooltip")); //$NON-NLS-1$
670 nextEvent
.setImageDescriptor(AbstractUIPlugin
671 .imageDescriptorFromPlugin(Messages
672 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
673 "icons/elcl16/next_event.gif")); //$NON-NLS-1$
676 prevEvent
= new Action() {
679 if (tsfviewer
!= null) {
680 tsfviewer
.selectPrevEvent();
684 prevEvent
.setText(Messages
685 .getString("ControlFlowView.Action.PrevEvent")); //$NON-NLS-1$
686 prevEvent
.setToolTipText(Messages
687 .getString("ControlFlowView.Action.PrevEvent.Tooltip")); //$NON-NLS-1$
688 prevEvent
.setImageDescriptor(AbstractUIPlugin
689 .imageDescriptorFromPlugin(Messages
690 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
691 "icons/elcl16/prev_event.gif")); //$NON-NLS-1$
694 nextTrace
= new Action() {
697 if (tsfviewer
!= null) {
698 tsfviewer
.selectNextTrace();
702 nextTrace
.setText(Messages
703 .getString("ControlFlowView.Action.NextProcess")); //$NON-NLS-1$
704 nextTrace
.setToolTipText(Messages
705 .getString("ControlFlowView.Action.NextProcess.ToolTip")); //$NON-NLS-1$
706 nextTrace
.setImageDescriptor(AbstractUIPlugin
707 .imageDescriptorFromPlugin(Messages
708 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
709 "icons/elcl16/next_item.gif")); //$NON-NLS-1$
712 prevTrace
= new Action() {
715 if (tsfviewer
!= null) {
716 tsfviewer
.selectPrevTrace();
720 prevTrace
.setText(Messages
721 .getString("ControlFlowView.Action.PreviousProcess")); //$NON-NLS-1$
722 prevTrace
.setToolTipText(Messages
723 .getString("ControlFlowView.Action.PreviousProcess.Tooltip")); //$NON-NLS-1$
724 prevTrace
.setImageDescriptor(AbstractUIPlugin
725 .imageDescriptorFromPlugin(Messages
726 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
727 "icons/elcl16/prev_item.gif")); //$NON-NLS-1$
730 showLegend
= new Action() {
733 if (tsfviewer
!= null) {
734 tsfviewer
.showLegend();
738 showLegend
.setText(Messages
.getString("ControlFlowView.Action.Legend")); //$NON-NLS-1$
739 showLegend
.setToolTipText(Messages
740 .getString("ControlFlowView.Action.Legend.ToolTip")); //$NON-NLS-1$
743 filterTraces
= new Action() {
746 if (tsfviewer
!= null) {
747 tsfviewer
.filterTraces();
751 filterTraces
.setText(Messages
752 .getString("ControlFlowView.Action.Filter")); //$NON-NLS-1$
753 filterTraces
.setToolTipText(Messages
754 .getString("ControlFlowView.Action.Filter.ToolTip")); //$NON-NLS-1$
755 filterTraces
.setImageDescriptor(AbstractUIPlugin
756 .imageDescriptorFromPlugin(Messages
757 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
758 "icons/elcl16/filter_items.gif")); //$NON-NLS-1$
761 zoomIn
= new Action() {
764 if (tsfviewer
!= null) {
769 zoomIn
.setText(Messages
.getString("ControlFlowView.Action.ZoomIn")); //$NON-NLS-1$
770 zoomIn
.setToolTipText(Messages
771 .getString("ControlFlowView.Action.ZoomIn.Tooltip")); //$NON-NLS-1$
772 zoomIn
.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(
773 Messages
.getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
774 "icons/elcl16/zoomin_nav.gif")); //$NON-NLS-1$
777 zoomOut
= new Action() {
780 if (tsfviewer
!= null) {
785 zoomOut
.setText(Messages
.getString("ControlFlowView.Action.ZoomOut")); //$NON-NLS-1$
786 zoomOut
.setToolTipText(Messages
787 .getString("ControlFlowView.Action.ZoomOut.tooltip")); //$NON-NLS-1$
788 zoomOut
.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(
789 Messages
.getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
790 "icons/elcl16/zoomout_nav.gif")); //$NON-NLS-1$
793 zoomFilter
= new Action() {
796 // Nothing to do, however the selection status is needed by the
800 zoomFilter
.setText(Messages
801 .getString("ControlFlowView.Action.ZoomFilter")); //$NON-NLS-1$
802 zoomFilter
.setToolTipText(Messages
803 .getString("ControlFlowView.Action.ZoomFilter.tooltip")); //$NON-NLS-1$
804 zoomFilter
.setImageDescriptor(AbstractUIPlugin
805 .imageDescriptorFromPlugin(Messages
806 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
807 "icons/elcl16/filter_items.gif")); //$NON-NLS-1$
808 zoomFilter
.setChecked(false);
810 // PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_SYNCED);
812 doubleClickAction
= new Action() {
815 ISelection selection
= tableViewer
.getSelection();
816 Object obj
= ((IStructuredSelection
) selection
)
818 showMessage("Double-click detected on " + obj
.toString()); //$NON-NLS-1$
823 private void hookDoubleClickAction() {
824 tableViewer
.addDoubleClickListener(new IDoubleClickListener() {
826 public void doubleClick(DoubleClickEvent event
) {
827 doubleClickAction
.run();
832 private void showMessage(String message
) {
833 MessageDialog
.openInformation(tableViewer
.getControl().getShell(),
834 Messages
.getString("ControlFlowView.msgSlogan"), message
); //$NON-NLS-1$
838 * Passing the focus request to the viewer's control.
841 public void setFocus() {
842 tableViewer
.getControl().setFocus();
848 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
849 * tsfTmProcessSelEvent
850 * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent
854 public void tsfTmProcessSelEvent(TmfTimeSelectionEvent event
) {
855 // common implementation
856 super.tsfTmProcessSelEvent(event
);
858 // Reselect the table viewer to widget selection
859 ISelection sel
= tsfviewer
.getSelectionTrace();
860 if (sel
!= null && !sel
.isEmpty()) {
861 tableViewer
.setSelection(sel
);
868 * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.
869 * ITmfTimeScaleSelectionListener
870 * #tsfTmProcessTimeScaleEvent(org.eclipse.linuxtools
871 * .tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent)
874 public void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event
) {
875 super.tsfTmProcessTimeScaleEvent(event
);
878 private void applyTableLayout(Table table
) {
879 for (int i
= 0; i
< columnNames
.length
; i
++) {
880 TableColumn tableColumn
= new TableColumn(table
, SWT
.LEFT
);
881 tableColumn
.setText(columnNames
[i
]);
884 table
.setHeaderVisible(true);
885 table
.setLinesVisible(true);
892 * org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#displayModel
893 * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.
894 * ITmfTimeAnalysisEntry[], long, long, boolean, long, long,
898 public void displayModel(final ITmfTimeAnalysisEntry
[] items
,
899 final long startBoundTime
, final long endBoundTime
,
900 final boolean updateTimeBounds
, final long startVisibleWindow
,
901 final long endVisibleWindow
, final Object source
) {
903 if(tableViewer
!= null) {
904 final Table table
= tableViewer
.getTable();
906 // Ignore update if widget is disposed
907 if (table
.isDisposed()) return;
909 Display display
= table
.getDisplay();
911 // Perform the updates on the UI thread)
912 display
.asyncExec(new Runnable() {
915 if (!table
.isDisposed()) {
916 tableViewer
.setInput(items
); // This shall be the minimal
918 tableFilter
= new ViewProcessFilter(tableViewer
);
919 tableViewer
.setFilters(new ViewerFilter
[] { tableFilter
});
921 resizeTableColumns(table
);
923 tableViewer
.refresh();
925 tsfviewer
.display(items
, startBoundTime
, endBoundTime
,
928 // validate visible boundaries
929 if (startVisibleWindow
> -1 && endVisibleWindow
> -1) {
930 tsfviewer
.setSelectVisTimeWindow(startVisibleWindow
,
931 endVisibleWindow
, source
);
934 tsfviewer
.resizeControls();
936 // Adjust asynchronously the size of the vertical scroll bar to fit the
938 tableViewer
.getTable().getDisplay().asyncExec(new Runnable() {
941 if ((scrollFrame
!= null) && (!scrollFrame
.isDisposed())) {
942 updateScrolls(scrollFrame
);
953 public void dispose() {
954 // dispose parent resources
957 tsfviewer
.removeFilterSelectionListner(this);
958 tsfviewer
.removeWidgetSelectionListner(this);
959 tsfviewer
.removeWidgetTimeScaleSelectionListner(this);
965 * @param tableComposite
968 private synchronized void resizeTableColumns(Table table
) {
970 Composite parent
= table
.getParent();
971 int tableWidthSum
= parent
.getBorderWidth();
973 TableColumn
[] columns
= table
.getColumns();
974 for (TableColumn column
: columns
) {
976 tableWidthSum
+= column
.getWidth();
982 public void tmfTaProcessFilterSelection(TmfTimeFilterSelectionEvent event
) {
983 if (tableFilter
!= null) {
984 Vector
<ITmfTimeAnalysisEntry
> filteredout
= event
.getFilteredOut();
985 if (filteredout
!= null) {
986 tableFilter
.setFilter(filteredout
);
988 tableFilter
.setFilter(new Vector
<ITmfTimeAnalysisEntry
>());
990 tableViewer
.refresh();
998 private void updateScrolls(final ScrolledComposite scrollFrame
) {
999 scrollFrame
.setMinSize(tableViewer
.getTable().computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
));
1003 * Registers as listener of time selection from other views
1009 public void synchToTime(TmfTimeSynchSignal signal
) {
1010 super.synchToTime(signal
);
1014 * Annotation Registers as listener of time range selection from other views
1015 * The implementation handles the entry of the signal.
1020 public void synchToTimeRange(TmfRangeSynchSignal signal
) {
1021 if (zoomFilter
!= null) {
1022 synchToTimeRange(signal
, zoomFilter
.isChecked());
1027 public void modelIncomplete(ILttngSyntEventRequest request
) {
1029 // The data will be refreshed on the next request
1035 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1036 * getEventProcessor()
1039 public ITransEventProcessor
getEventProcessor() {
1040 return FlowEventToHandlerFactory
.getInstance();
1047 public void experimentSelected(
1048 TmfExperimentSelectedSignal
<?
extends TmfEvent
> signal
) {
1049 if (signal
!= null) {
1050 TmfTimeRange experimentTRange
= signal
.getExperiment()
1053 initTimeRange
= TmfTimeRange
.Null
;
1054 if (experimentTRange
!= TmfTimeRange
.Null
) {
1055 // prepare time intervals in widget
1056 ModelUpdateInit(experimentTRange
, experimentTRange
, signal
1059 // request initial data
1060 initialExperimentDataRequest(signal
1061 .getSource(), experimentTRange
);
1067 public void experimentRangeUpdated(TmfExperimentRangeUpdatedSignal signal
) {
1068 if (initTimeRange
== TmfTimeRange
.Null
&& signal
.getExperiment().equals(TmfExperiment
.getCurrentExperiment())) {
1069 TmfTimeRange experimentTRange
= signal
.getRange();
1071 if (experimentTRange
!= TmfTimeRange
.Null
) {
1072 // prepare time intervals in widget
1073 ModelUpdateInit(experimentTRange
, experimentTRange
, signal
.getSource());
1075 // request initial data
1076 initialExperimentDataRequest(signal
.getSource(), experimentTRange
);
1083 * @param experimentTRange
1084 * @return Adjusted time window used for the request (smaller window to
1087 private TmfTimeRange
initialExperimentDataRequest(Object source
,
1088 TmfTimeRange experimentTRange
) {
1089 // Adjust the initial time window to a shorter interval to allow
1090 // user to select the interesting area based on the perspective
1091 TmfTimeRange initTimeWindow
= getInitTRange(experimentTRange
);
1093 eventRequest(initTimeWindow
, experimentTRange
, true, ExecutionType
.FOREGROUND
);
1094 if (TraceDebug
.isDEBUG()) {
1095 TraceDebug
.debug("Initialization request time range is: " //$NON-NLS-1$
1096 + initTimeWindow
.getStartTime().toString() + "-" //$NON-NLS-1$
1097 + initTimeWindow
.getEndTime().toString());
1100 initTimeRange
= initTimeWindow
;
1101 return initTimeWindow
;
1105 * SWT doesn't seem to report correctly the table item height, at least in
1108 * This method provides an adjustment term according to the desktop session.
1110 * @return Height adjustment
1112 private int getTableItemHeightAdjustement() {
1114 String desktopSession
= System
.getenv("DESKTOP_SESSION"); //$NON-NLS-1$
1116 if (desktopSession
!= null) {
1117 if (desktopSession
.equals("kde")) { //$NON-NLS-1$
1128 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1129 * getParamsUpdater()
1132 protected ParamsUpdater
getParamsUpdater() {
1133 return FlowModelFactory
.getParamsUpdater();
1139 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1140 * getItemContainer()
1143 protected ItemContainer
<?
> getItemContainer() {
1144 return FlowModelFactory
.getProcContainer();
1149 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#getProviderId()
1152 protected int getProviderId() {
1153 return LttngCoreProviderFactory
.CONTROL_FLOW_LTTNG_SYTH_EVENT_PROVIDER
;