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 * Bernd Hufmann - Bug fixes
13 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.controlflow
;
16 import java
.util
.Vector
;
18 import org
.eclipse
.jface
.action
.Action
;
19 import org
.eclipse
.jface
.action
.IMenuListener
;
20 import org
.eclipse
.jface
.action
.IMenuManager
;
21 import org
.eclipse
.jface
.action
.IToolBarManager
;
22 import org
.eclipse
.jface
.action
.MenuManager
;
23 import org
.eclipse
.jface
.action
.Separator
;
24 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
25 import org
.eclipse
.jface
.viewers
.DoubleClickEvent
;
26 import org
.eclipse
.jface
.viewers
.IDoubleClickListener
;
27 import org
.eclipse
.jface
.viewers
.ISelection
;
28 import org
.eclipse
.jface
.viewers
.ISelectionChangedListener
;
29 import org
.eclipse
.jface
.viewers
.IStructuredContentProvider
;
30 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
31 import org
.eclipse
.jface
.viewers
.ITableLabelProvider
;
32 import org
.eclipse
.jface
.viewers
.LabelProvider
;
33 import org
.eclipse
.jface
.viewers
.SelectionChangedEvent
;
34 import org
.eclipse
.jface
.viewers
.StructuredViewer
;
35 import org
.eclipse
.jface
.viewers
.TableViewer
;
36 import org
.eclipse
.jface
.viewers
.Viewer
;
37 import org
.eclipse
.jface
.viewers
.ViewerFilter
;
38 import org
.eclipse
.linuxtools
.lttng
.control
.LttngCoreProviderFactory
;
39 import org
.eclipse
.linuxtools
.lttng
.event
.LttngTimestamp
;
40 import org
.eclipse
.linuxtools
.lttng
.request
.ILttngSyntEventRequest
;
41 import org
.eclipse
.linuxtools
.lttng
.state
.evProcessor
.ITransEventProcessor
;
42 import org
.eclipse
.linuxtools
.lttng
.ui
.TraceDebug
;
43 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.ItemContainer
;
44 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.TimeRangeEventProcess
;
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
.lttng
.ui
.views
.controlflow
.model
.FlowTimeRangeViewerProvider
;
50 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
51 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimeRange
;
52 import org
.eclipse
.linuxtools
.tmf
.experiment
.TmfExperiment
;
53 import org
.eclipse
.linuxtools
.tmf
.request
.ITmfDataRequest
.ExecutionType
;
54 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfExperimentRangeUpdatedSignal
;
55 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfExperimentSelectedSignal
;
56 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfRangeSynchSignal
;
57 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfSignalHandler
;
58 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfTimeSynchSignal
;
59 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.TmfViewerFactory
;
60 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.ITmfTimeFilterSelectionListener
;
61 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.ITmfTimeScaleSelectionListener
;
62 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.ITmfTimeSelectionListener
;
63 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.TmfTimeFilterSelectionEvent
;
64 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.TmfTimeScaleSelectionEvent
;
65 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.TmfTimeSelectionEvent
;
66 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.model
.ITmfTimeAnalysisEntry
;
67 import org
.eclipse
.swt
.SWT
;
68 import org
.eclipse
.swt
.custom
.SashForm
;
69 import org
.eclipse
.swt
.custom
.ScrolledComposite
;
70 import org
.eclipse
.swt
.events
.KeyEvent
;
71 import org
.eclipse
.swt
.events
.KeyListener
;
72 import org
.eclipse
.swt
.graphics
.Image
;
73 import org
.eclipse
.swt
.graphics
.Point
;
74 import org
.eclipse
.swt
.graphics
.Rectangle
;
75 import org
.eclipse
.swt
.widgets
.Composite
;
76 import org
.eclipse
.swt
.widgets
.Display
;
77 import org
.eclipse
.swt
.widgets
.Menu
;
78 import org
.eclipse
.swt
.widgets
.ScrollBar
;
79 import org
.eclipse
.swt
.widgets
.Table
;
80 import org
.eclipse
.swt
.widgets
.TableColumn
;
81 import org
.eclipse
.swt
.widgets
.TableItem
;
82 import org
.eclipse
.ui
.IActionBars
;
83 import org
.eclipse
.ui
.IWorkbenchActionConstants
;
84 import org
.eclipse
.ui
.PlatformUI
;
85 import org
.eclipse
.ui
.plugin
.AbstractUIPlugin
;
88 * <b><u>ControlFlowView</u></b>
94 public class ControlFlowView
extends AbsTimeUpdateView
implements
95 ITmfTimeSelectionListener
, ITmfTimeScaleSelectionListener
,
96 ITmfTimeFilterSelectionListener
{
98 public static final String ID
= "org.eclipse.linuxtools.lttng.ui.views.controlflow"; //$NON-NLS-1$
100 // ========================================================================
102 // ========================================================================
104 private final String PROCESS_COLUMN
= Messages
.getString("ControlFlowView.processColumn"); //$NON-NLS-1$
105 private final String BRAND_COLUMN
= Messages
.getString("ControlFlowView.brandColumn"); //$NON-NLS-1$
106 private final String PID_COLUMN
= Messages
.getString("ControlFlowView.pidColumn"); //$NON-NLS-1$
107 private final String TGID_COLUMN
= Messages
.getString("ControlFlowView.tgidColumn"); //$NON-NLS-1$
108 private final String PPID_COLUMN
= Messages
.getString("ControlFlowView.ppidColumn"); //$NON-NLS-1$
109 private final String CPU_COLUMN
= Messages
.getString("ControlFlowView.cpuColumn"); //$NON-NLS-1$
110 private final String BIRTH_SEC_COLUMN
= Messages
.getString("ControlFlowView.birthSecColumn"); //$NON-NLS-1$
111 private final String BIRTH_NSEC_COLUMN
= Messages
.getString("ControlFlowView.birthNSecColumn"); //$NON-NLS-1$
112 private final String TRACE
= Messages
.getString("ControlFlowView.TraceNameColumn"); //$NON-NLS-1$
114 private final String
[] columnNames
= new String
[] { PROCESS_COLUMN
, /* */
120 BIRTH_SEC_COLUMN
,/* */
121 BIRTH_NSEC_COLUMN
,/* */
125 // ========================================================================
127 // ========================================================================
128 private TableViewer tableViewer
;
129 // private int totalNumItems = 0;
131 private Action doubleClickAction
;
132 private Action resetScale
;
133 private Action nextEvent
;
134 private Action prevEvent
;
135 private Action nextTrace
;
136 private Action prevTrace
;
137 private Action showLegend
;
138 private Action filterTraces
;
139 private Action zoomIn
;
140 private Action zoomOut
;
141 private Action zoomFilter
;
143 private ViewProcessFilter tableFilter
= null;
144 private ScrolledComposite scrollFrame
= null;
146 private TmfTimeRange initTimeRange
= TmfTimeRange
.Null
;
148 // private static SimpleDateFormat stimeformat = new SimpleDateFormat(
149 // "yy/MM/dd HH:mm:ss");
151 // private TraceModelImplFactory fact;
153 // ========================================================================
155 // ========================================================================
157 * The content provider class is responsible for providing objects to the
158 * view. It can wrap existing objects in adapters or simply return objects
159 * as-is. These objects may be sensitive to the current input of the view,
160 * or ignore it and always show the same content (like Task List, for
164 class ViewContentProvider
implements
165 /* ILazyContentProvider, */IStructuredContentProvider
{
166 private TableViewer cviewer
= null;
167 private ITmfTimeAnalysisEntry
[] elements
= null;
169 public ViewContentProvider(TableViewer v
) {
174 public void inputChanged(Viewer v
, Object oldInput
, Object newInput
) {
175 this.elements
= (ITmfTimeAnalysisEntry
[]) newInput
;
176 if (elements
!= null) {
177 TraceDebug
.debug("Total number of processes provided to Control Flow view: " + elements
.length
); //$NON-NLS-1$
179 TraceDebug
.debug("New input = null"); //$NON-NLS-1$
184 public void dispose() {
188 // Needed with the use of virtual tables in order to initialize items
189 // which were not initially visible.
190 public void updateElement(int index
) {
191 cviewer
.replace(elements
[index
], index
);
195 public Object
[] getElements(Object inputElement
) {
200 class ViewLabelProvider
extends LabelProvider
implements ITableLabelProvider
{
202 public String
getColumnText(Object obj
, int index
) {
203 String strRes
= ""; //$NON-NLS-1$
205 if (obj
instanceof TimeRangeEventProcess
) {
206 TimeRangeEventProcess process
= (TimeRangeEventProcess
) obj
;
209 strRes
= process
.getName();
212 strRes
= process
.getBrand();
215 strRes
= process
.getPid().toString();
218 strRes
= process
.getTgid().toString();
221 strRes
= process
.getPpid().toString();
224 strRes
= process
.getCpu().toString();
227 time
= new LttngTimestamp(process
.getCreationTime()
229 strRes
= time
.getSeconds();
232 time
= new LttngTimestamp(process
.getCreationTime()
234 strRes
= time
.getNanoSeconds();
237 strRes
= process
.getTraceID();
250 public Image
getColumnImage(Object obj
, int index
) {
251 return getImage(obj
);
255 public Image
getImage(Object obj
) {
256 // No image needed for the time being
257 // return PlatformUI.getWorkbench().getSharedImages().getImage(
258 // ISharedImages.IMG_OBJ_ELEMENT);
263 class ViewProcessFilter
extends ViewerFilter
{
265 private Vector
<ITmfTimeAnalysisEntry
> filteredSet
= new Vector
<ITmfTimeAnalysisEntry
>();
266 StructuredViewer viewer
;
268 public ViewProcessFilter(StructuredViewer rviewer
) {
269 this.viewer
= rviewer
;
272 public void setFilter(Vector
<ITmfTimeAnalysisEntry
> filtered
) {
273 if (filtered
!= null) {
274 this.filteredSet
= filtered
;
280 public boolean select(Viewer viewer
, Object parentElement
,
282 boolean filteredIn
= true;
283 if (element
instanceof ITmfTimeAnalysisEntry
) {
284 ITmfTimeAnalysisEntry process
= (ITmfTimeAnalysisEntry
) element
;
285 if (filteredSet
.contains(process
)) {
286 // The element is marked to be filtered out
290 TraceDebug
.debug("Unexpected type of filter element received: " //$NON-NLS-1$
291 + element
.toString());
293 // Compare element versus a list of filtered out
301 public ControlFlowView() {
306 * This is a callback that will allow us to create the viewer and initialize
313 * org.eclipse.linuxtools.tmf.ui.views.TmfView#createPartControl(org.eclipse
314 * .swt.widgets.Composite)
317 public void createPartControl(Composite parent
) {
319 scrollFrame
= new ScrolledComposite(parent
, SWT
.V_SCROLL
);
321 scrollFrame
.setExpandVertical(true);
322 scrollFrame
.setExpandHorizontal(true);
323 scrollFrame
.setAlwaysShowScrollBars(true);
325 SashForm sash
= new SashForm(scrollFrame
, SWT
.NONE
);
326 scrollFrame
.setContent(sash
);
328 tableViewer
= new TableViewer(sash
, SWT
.FULL_SELECTION
| SWT
.H_SCROLL
);
329 tableViewer
.setContentProvider(new ViewContentProvider(tableViewer
));
330 tableViewer
.setLabelProvider(new ViewLabelProvider());
331 Table table
= tableViewer
.getTable();
332 tableViewer
.addSelectionChangedListener(new ISelectionChangedListener() {
334 public void selectionChanged(SelectionChangedEvent event
) {
335 ISelection sel
= event
.getSelection();
336 if (!sel
.isEmpty()) {
337 Object firstSel
= null;
338 if (sel
instanceof IStructuredSelection
) {
339 firstSel
= ((IStructuredSelection
) sel
).getFirstElement();
341 // Make sure the selection is visible
342 updateScrollOrigin();
344 if (firstSel
instanceof ITmfTimeAnalysisEntry
) {
345 ITmfTimeAnalysisEntry trace
= (ITmfTimeAnalysisEntry
) firstSel
;
346 tsfviewer
.setSelectedTrace(trace
);
353 * Make sure the selected item is visible
355 private void updateScrollOrigin() {
356 Table table
= tableViewer
.getTable();
357 if (table
!= null && table
.getItemCount() > 0) {
358 TableItem item
= table
.getSelection()[0];
360 // no selected reference to go up or down
364 Rectangle itemRect
= item
.getBounds();
365 int step
= itemRect
.height
;
367 // calculate height of horizontal bar
369 ScrollBar hbar
= scrollFrame
.getHorizontalBar();
371 hscrolly
= hbar
.getSize().y
;
374 int visibleHeight
= scrollFrame
.getSize().y
- hscrolly
;
376 // the current scrollbar offset to adjust i.e. start
378 // the visible window
379 Point origin
= scrollFrame
.getOrigin();
380 // end of visible window
381 int endy
= origin
.y
+ visibleHeight
;
383 int itemStartPos
= itemRect
.y
+ table
.getHeaderHeight() + table
.getBorderWidth()
384 + table
.getParent().getBorderWidth();
387 int itemEndPos
= itemStartPos
+ step
;
389 // check if need to go up
390 if (origin
.y
>= step
&& itemStartPos
< origin
.y
) {
392 scrollFrame
.setOrigin(origin
.x
, origin
.y
- step
);
396 // check if it needs to go down
397 if (itemEndPos
> endy
) {
399 scrollFrame
.setOrigin(origin
.x
, origin
.y
+ step
);
406 // Listen to page up /down and Home / Enc keys
407 tableViewer
.getTable().addKeyListener(new KeyListener() {
409 public void keyPressed(KeyEvent e
) {
410 Table table
= tableViewer
.getTable();
411 Point origin
= scrollFrame
.getOrigin();
412 if (table
== null || table
.getItemCount() < 1) {
422 updateScrollPageDown();
429 count
= table
.getItemCount();
430 item
= table
.getItem(0);
432 scrollFrame
.setOrigin(origin
.x
, 0);
436 count
= table
.getItemCount();
437 item
= table
.getItem(count
- 1);
438 int itemStartPos
= item
.getBounds().y
;
440 scrollFrame
.setOrigin(origin
.x
, itemStartPos
);
448 public void keyReleased(KeyEvent e
) {
454 * Scroll one page down
456 private void updateScrollPageDown() {
457 // null protection before calling private method
458 Table table
= tableViewer
.getTable();
459 int step
= table
.getItemHeight();
462 ScrollBar hbar
= scrollFrame
.getHorizontalBar();
464 hscrolly
= hbar
.getSize().y
;
467 Point origin
= scrollFrame
.getOrigin();
468 int visibleHeight
= scrollFrame
.getSize().y
- hscrolly
;
469 int endy
= origin
.y
+ visibleHeight
;
471 scrollFrame
.setOrigin(origin
.x
, endy
- step
);
477 private void updateScrollUp() {
478 // null protection before calling private method
479 Table table
= tableViewer
.getTable();
480 int step
= table
.getItemHeight();
483 ScrollBar hbar
= scrollFrame
.getHorizontalBar();
485 hscrolly
= hbar
.getSize().y
;
488 Point origin
= scrollFrame
.getOrigin();
489 int visibleHeight
= scrollFrame
.getSize().y
- hscrolly
;
490 int pageUpPos
= origin
.y
- visibleHeight
+ step
;
491 pageUpPos
= pageUpPos
> 0 ? pageUpPos
: 0;
492 scrollFrame
.setOrigin(origin
.x
, pageUpPos
);
497 applyTableLayout(table
);
499 int borderWidth
= table
.getBorderWidth();
501 int itemHeight
= table
.getItemHeight() + getTableItemHeightAdjustement();
502 int headerHeight
= table
.getHeaderHeight();
503 table
.getVerticalBar().setVisible(false);
505 tsfviewer
= TmfViewerFactory
.createViewer(sash
, new FlowTimeRangeViewerProvider(getParamsUpdater()));
507 // Traces shall not be grouped to allow synchronisation
508 tsfviewer
.groupTraces(false);
509 tsfviewer
.setItemHeight(itemHeight
);
510 tsfviewer
.setBorderWidth(borderWidth
);
511 tsfviewer
.setHeaderHeight(headerHeight
);
512 tsfviewer
.setVisibleVerticalScroll(false);
513 // Names provided by the table
514 tsfviewer
.setNameWidthPref(0);
515 tsfviewer
.setAcceptSelectionAPIcalls(true);
517 // Viewer to notify selection to this class
518 // This class will synchronise selections with table.
519 tsfviewer
.addWidgetSelectionListner(this);
520 tsfviewer
.addFilterSelectionListner(this);
521 tsfviewer
.addWidgetTimeScaleSelectionListner(this);
523 sash
.setWeights(new int[] { 1, 1 });
524 // Create the help context id for the viewer's control
525 // TODO: Associate with help system
526 PlatformUI
.getWorkbench().getHelpSystem().setHelp(
527 tableViewer
.getControl(),
528 "org.eclipse.linuxtools.lttnng.ui.views.flow.viewer"); //$NON-NLS-1$
532 hookDoubleClickAction();
533 contributeToActionBars();
535 // scrollFrame.addControlListener(new ControlAdapter() {
538 // public void controlResized(ControlEvent e) {
539 // tsfviewer.resizeControls();
540 // updateScrolls(scrollFrame);
544 // set the initial view parameter values
545 // Experiment start and end time
546 // as well as time space width in pixels, used by the time analysis
548 // Read relevant values
549 int timeSpaceWidth
= tsfviewer
.getTimeSpace();
550 if (timeSpaceWidth
< 0) {
551 timeSpaceWidth
= -timeSpaceWidth
;
554 TmfExperiment
<?
> experiment
= TmfExperiment
.getCurrentExperiment();
555 if (experiment
!= null) {
556 TmfTimeRange experimentTRange
= experiment
.getTimeRange();
558 if (experimentTRange
!= TmfTimeRange
.Null
) {
559 // send request and received the adjusted time used
560 TmfTimeRange adjustedTimeRange
= initialExperimentDataRequest(this,
563 // initialize widget time boundaries and filtering parameters
564 ModelUpdateInit(experimentTRange
, adjustedTimeRange
, this);
567 TraceDebug
.debug("No selected experiment information available"); //$NON-NLS-1$
571 private void hookContextMenu() {
572 MenuManager menuMgr
= new MenuManager("#PopupMenu"); //$NON-NLS-1$
573 menuMgr
.setRemoveAllWhenShown(true);
574 menuMgr
.addMenuListener(new IMenuListener() {
576 public void menuAboutToShow(IMenuManager manager
) {
577 ControlFlowView
.this.fillContextMenu(manager
);
580 Menu menu
= menuMgr
.createContextMenu(tableViewer
.getControl());
581 tableViewer
.getControl().setMenu(menu
);
582 getSite().registerContextMenu(menuMgr
, tableViewer
);
585 private void contributeToActionBars() {
586 IActionBars bars
= getViewSite().getActionBars();
587 fillLocalPullDown(bars
.getMenuManager());
588 fillLocalToolBar(bars
.getToolBarManager());
591 private void fillLocalPullDown(IMenuManager manager
) {
592 manager
.add(new Separator());
593 manager
.add(showLegend
);
594 manager
.add(new Separator());
595 manager
.add(resetScale
);
596 manager
.add(nextEvent
);
597 manager
.add(prevEvent
);
598 manager
.add(nextTrace
);
599 manager
.add(prevTrace
);
600 // manager.add(filterTraces);
602 manager
.add(zoomOut
);
603 manager
.add(zoomFilter
);
604 manager
.add(new Separator());
607 private void fillContextMenu(IMenuManager manager
) {
608 manager
.add(showLegend
);
609 manager
.add(new Separator());
610 manager
.add(resetScale
);
611 manager
.add(nextEvent
);
612 manager
.add(prevEvent
);
613 manager
.add(nextTrace
);
614 manager
.add(prevTrace
);
615 manager
.add(showLegend
);
616 // manager.add(filterTraces);
618 manager
.add(zoomOut
);
619 manager
.add(zoomFilter
);
620 manager
.add(new Separator());
621 manager
.add(new Separator(IWorkbenchActionConstants
.MB_ADDITIONS
));
624 private void fillLocalToolBar(IToolBarManager manager
) {
625 manager
.add(showLegend
);
626 manager
.add(new Separator());
627 manager
.add(resetScale
);
628 manager
.add(nextEvent
);
629 manager
.add(prevEvent
);
630 manager
.add(nextTrace
);
631 manager
.add(prevTrace
);
632 // manager.add(filterTraces);
634 manager
.add(zoomOut
);
635 manager
.add(zoomFilter
);
636 manager
.add(new Separator());
639 private void makeActions() {
641 resetScale
= new Action() {
644 if (tsfviewer
!= null) {
645 tsfviewer
.resetStartFinishTime();
650 resetScale
.setText(Messages
.getString("ControlFlowView.Action.Reset")); //$NON-NLS-1$
651 resetScale
.setToolTipText(Messages
652 .getString("ControlFlowView.Action.Reset.ToolTip")); //$NON-NLS-1$
653 resetScale
.setImageDescriptor(AbstractUIPlugin
654 .imageDescriptorFromPlugin(Messages
655 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
656 "icons/elcl16/home_nav.gif")); //$NON-NLS-1$
659 nextEvent
= new Action() {
662 if (tsfviewer
!= null) {
663 tsfviewer
.selectNextEvent();
667 nextEvent
.setText(Messages
668 .getString("ControlFlowView.Action.NextEvent")); //$NON-NLS-1$
669 nextEvent
.setToolTipText(Messages
670 .getString("ControlFlowView.Action.NextEvent.Tooltip")); //$NON-NLS-1$
671 nextEvent
.setImageDescriptor(AbstractUIPlugin
672 .imageDescriptorFromPlugin(Messages
673 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
674 "icons/elcl16/next_event.gif")); //$NON-NLS-1$
677 prevEvent
= new Action() {
680 if (tsfviewer
!= null) {
681 tsfviewer
.selectPrevEvent();
685 prevEvent
.setText(Messages
686 .getString("ControlFlowView.Action.PrevEvent")); //$NON-NLS-1$
687 prevEvent
.setToolTipText(Messages
688 .getString("ControlFlowView.Action.PrevEvent.Tooltip")); //$NON-NLS-1$
689 prevEvent
.setImageDescriptor(AbstractUIPlugin
690 .imageDescriptorFromPlugin(Messages
691 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
692 "icons/elcl16/prev_event.gif")); //$NON-NLS-1$
695 nextTrace
= new Action() {
698 if (tsfviewer
!= null) {
699 tsfviewer
.selectNextTrace();
703 nextTrace
.setText(Messages
704 .getString("ControlFlowView.Action.NextProcess")); //$NON-NLS-1$
705 nextTrace
.setToolTipText(Messages
706 .getString("ControlFlowView.Action.NextProcess.ToolTip")); //$NON-NLS-1$
707 nextTrace
.setImageDescriptor(AbstractUIPlugin
708 .imageDescriptorFromPlugin(Messages
709 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
710 "icons/elcl16/next_item.gif")); //$NON-NLS-1$
713 prevTrace
= new Action() {
716 if (tsfviewer
!= null) {
717 tsfviewer
.selectPrevTrace();
721 prevTrace
.setText(Messages
722 .getString("ControlFlowView.Action.PreviousProcess")); //$NON-NLS-1$
723 prevTrace
.setToolTipText(Messages
724 .getString("ControlFlowView.Action.PreviousProcess.Tooltip")); //$NON-NLS-1$
725 prevTrace
.setImageDescriptor(AbstractUIPlugin
726 .imageDescriptorFromPlugin(Messages
727 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
728 "icons/elcl16/prev_item.gif")); //$NON-NLS-1$
731 showLegend
= new Action() {
734 if (tsfviewer
!= null) {
735 tsfviewer
.showLegend();
739 showLegend
.setText(Messages
.getString("ControlFlowView.Action.Legend")); //$NON-NLS-1$
740 showLegend
.setToolTipText(Messages
741 .getString("ControlFlowView.Action.Legend.ToolTip")); //$NON-NLS-1$
744 filterTraces
= new Action() {
747 if (tsfviewer
!= null) {
748 tsfviewer
.filterTraces();
752 filterTraces
.setText(Messages
753 .getString("ControlFlowView.Action.Filter")); //$NON-NLS-1$
754 filterTraces
.setToolTipText(Messages
755 .getString("ControlFlowView.Action.Filter.ToolTip")); //$NON-NLS-1$
756 filterTraces
.setImageDescriptor(AbstractUIPlugin
757 .imageDescriptorFromPlugin(Messages
758 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
759 "icons/elcl16/filter_items.gif")); //$NON-NLS-1$
762 zoomIn
= new Action() {
765 if (tsfviewer
!= null) {
770 zoomIn
.setText(Messages
.getString("ControlFlowView.Action.ZoomIn")); //$NON-NLS-1$
771 zoomIn
.setToolTipText(Messages
772 .getString("ControlFlowView.Action.ZoomIn.Tooltip")); //$NON-NLS-1$
773 zoomIn
.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(
774 Messages
.getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
775 "icons/elcl16/zoomin_nav.gif")); //$NON-NLS-1$
778 zoomOut
= new Action() {
781 if (tsfviewer
!= null) {
786 zoomOut
.setText(Messages
.getString("ControlFlowView.Action.ZoomOut")); //$NON-NLS-1$
787 zoomOut
.setToolTipText(Messages
788 .getString("ControlFlowView.Action.ZoomOut.tooltip")); //$NON-NLS-1$
789 zoomOut
.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(
790 Messages
.getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
791 "icons/elcl16/zoomout_nav.gif")); //$NON-NLS-1$
794 zoomFilter
= new Action() {
797 // Nothing to do, however the selection status is needed by the
801 zoomFilter
.setText(Messages
802 .getString("ControlFlowView.Action.ZoomFilter")); //$NON-NLS-1$
803 zoomFilter
.setToolTipText(Messages
804 .getString("ControlFlowView.Action.ZoomFilter.tooltip")); //$NON-NLS-1$
805 zoomFilter
.setImageDescriptor(AbstractUIPlugin
806 .imageDescriptorFromPlugin(Messages
807 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
808 "icons/elcl16/filter_items.gif")); //$NON-NLS-1$
809 zoomFilter
.setChecked(false);
811 // PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_SYNCED);
813 doubleClickAction
= new Action() {
816 ISelection selection
= tableViewer
.getSelection();
817 Object obj
= ((IStructuredSelection
) selection
)
819 showMessage("Double-click detected on " + obj
.toString()); //$NON-NLS-1$
824 private void hookDoubleClickAction() {
825 tableViewer
.addDoubleClickListener(new IDoubleClickListener() {
827 public void doubleClick(DoubleClickEvent event
) {
828 doubleClickAction
.run();
833 private void showMessage(String message
) {
834 MessageDialog
.openInformation(tableViewer
.getControl().getShell(),
835 Messages
.getString("ControlFlowView.msgSlogan"), message
); //$NON-NLS-1$
839 * Passing the focus request to the viewer's control.
842 public void setFocus() {
843 tableViewer
.getControl().setFocus();
849 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
850 * tsfTmProcessSelEvent
851 * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent
855 public void tsfTmProcessSelEvent(TmfTimeSelectionEvent event
) {
856 // common implementation
857 super.tsfTmProcessSelEvent(event
);
859 // Reselect the table viewer to widget selection
860 ISelection sel
= tsfviewer
.getSelectionTrace();
861 if (sel
!= null && !sel
.isEmpty()) {
862 tableViewer
.setSelection(sel
);
869 * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.
870 * ITmfTimeScaleSelectionListener
871 * #tsfTmProcessTimeScaleEvent(org.eclipse.linuxtools
872 * .tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent)
875 public void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event
) {
876 super.tsfTmProcessTimeScaleEvent(event
);
879 private void applyTableLayout(Table table
) {
880 for (int i
= 0; i
< columnNames
.length
; i
++) {
881 TableColumn tableColumn
= new TableColumn(table
, SWT
.LEFT
);
882 tableColumn
.setText(columnNames
[i
]);
885 table
.setHeaderVisible(true);
886 table
.setLinesVisible(true);
893 * org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#displayModel
894 * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.
895 * ITmfTimeAnalysisEntry[], long, long, boolean, long, long,
899 public void displayModel(final ITmfTimeAnalysisEntry
[] items
,
900 final long startBoundTime
, final long endBoundTime
,
901 final boolean updateTimeBounds
, final long startVisibleWindow
,
902 final long endVisibleWindow
, final Object source
) {
904 if(tableViewer
!= null) {
905 final Table table
= tableViewer
.getTable();
907 // Ignore update if widget is disposed
908 if (table
.isDisposed()) return;
910 Display display
= table
.getDisplay();
912 // Perform the updates on the UI thread)
913 display
.asyncExec(new Runnable() {
916 if (!table
.isDisposed()) {
917 tableViewer
.setInput(items
); // This shall be the minimal
919 tableFilter
= new ViewProcessFilter(tableViewer
);
920 tableViewer
.setFilters(new ViewerFilter
[] { tableFilter
});
922 resizeTableColumns(table
);
924 tableViewer
.refresh();
926 tsfviewer
.display(items
, startBoundTime
, endBoundTime
,
929 // validate visible boundaries
930 if (startVisibleWindow
> -1 && endVisibleWindow
> -1) {
931 tsfviewer
.setSelectVisTimeWindow(startVisibleWindow
,
932 endVisibleWindow
, source
);
935 tsfviewer
.resizeControls();
937 // Adjust asynchronously the size of the vertical scroll bar to fit the
939 tableViewer
.getTable().getDisplay().asyncExec(new Runnable() {
942 if ((scrollFrame
!= null) && (!scrollFrame
.isDisposed())) {
943 updateScrolls(scrollFrame
);
954 public void dispose() {
955 // dispose parent resources
958 tsfviewer
.removeFilterSelectionListner(this);
959 tsfviewer
.removeWidgetSelectionListner(this);
960 tsfviewer
.removeWidgetTimeScaleSelectionListner(this);
966 * @param tableComposite
969 private synchronized void resizeTableColumns(Table table
) {
971 TableColumn
[] columns
= table
.getColumns();
972 for (TableColumn column
: columns
) {
979 public void tmfTaProcessFilterSelection(TmfTimeFilterSelectionEvent event
) {
980 if (tableFilter
!= null) {
981 Vector
<ITmfTimeAnalysisEntry
> filteredout
= event
.getFilteredOut();
982 if (filteredout
!= null) {
983 tableFilter
.setFilter(filteredout
);
985 tableFilter
.setFilter(new Vector
<ITmfTimeAnalysisEntry
>());
987 tableViewer
.refresh();
995 private void updateScrolls(final ScrolledComposite scrollFrame
) {
996 scrollFrame
.setMinSize(tableViewer
.getTable().computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
));
1000 * Registers as listener of time selection from other views
1006 public void synchToTime(TmfTimeSynchSignal signal
) {
1007 super.synchToTime(signal
);
1011 * Annotation Registers as listener of time range selection from other views
1012 * The implementation handles the entry of the signal.
1017 public void synchToTimeRange(TmfRangeSynchSignal signal
) {
1018 if (zoomFilter
!= null) {
1019 synchToTimeRange(signal
, zoomFilter
.isChecked());
1024 public void modelIncomplete(ILttngSyntEventRequest request
) {
1026 // The data will be refreshed on the next request
1032 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1033 * getEventProcessor()
1036 public ITransEventProcessor
getEventProcessor() {
1037 return FlowEventToHandlerFactory
.getInstance();
1044 public void experimentSelected(
1045 TmfExperimentSelectedSignal
<?
extends TmfEvent
> signal
) {
1046 if (signal
!= null) {
1047 TmfTimeRange experimentTRange
= signal
.getExperiment()
1050 initTimeRange
= TmfTimeRange
.Null
;
1051 if (experimentTRange
!= TmfTimeRange
.Null
) {
1052 // prepare time intervals in widget
1053 ModelUpdateInit(experimentTRange
, experimentTRange
, signal
1056 // request initial data
1057 initialExperimentDataRequest(signal
1058 .getSource(), experimentTRange
);
1064 public void experimentRangeUpdated(TmfExperimentRangeUpdatedSignal signal
) {
1065 if (initTimeRange
== TmfTimeRange
.Null
&& signal
.getExperiment().equals(TmfExperiment
.getCurrentExperiment())) {
1066 TmfTimeRange experimentTRange
= signal
.getRange();
1068 if (experimentTRange
!= TmfTimeRange
.Null
) {
1069 // prepare time intervals in widget
1070 ModelUpdateInit(experimentTRange
, experimentTRange
, signal
.getSource());
1072 // request initial data
1073 initialExperimentDataRequest(signal
.getSource(), experimentTRange
);
1080 * @param experimentTRange
1081 * @return Adjusted time window used for the request (smaller window to
1084 private TmfTimeRange
initialExperimentDataRequest(Object source
,
1085 TmfTimeRange experimentTRange
) {
1086 // Adjust the initial time window to a shorter interval to allow
1087 // user to select the interesting area based on the perspective
1088 TmfTimeRange initTimeWindow
= getInitTRange(experimentTRange
);
1090 eventRequest(initTimeWindow
, experimentTRange
, true, ExecutionType
.FOREGROUND
);
1091 if (TraceDebug
.isDEBUG()) {
1092 TraceDebug
.debug("Initialization request time range is: " //$NON-NLS-1$
1093 + initTimeWindow
.getStartTime().toString() + "-" //$NON-NLS-1$
1094 + initTimeWindow
.getEndTime().toString());
1097 initTimeRange
= initTimeWindow
;
1098 return initTimeWindow
;
1102 * SWT doesn't seem to report correctly the table item height, at least in
1105 * This method provides an adjustment term according to the desktop session.
1107 * @return Height adjustment
1109 private int getTableItemHeightAdjustement() {
1111 String desktopSession
= System
.getenv("DESKTOP_SESSION"); //$NON-NLS-1$
1113 if (desktopSession
!= null) {
1114 if (desktopSession
.equals("kde")) { //$NON-NLS-1$
1125 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1126 * getParamsUpdater()
1129 protected ParamsUpdater
getParamsUpdater() {
1130 return FlowModelFactory
.getParamsUpdater();
1136 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1137 * getItemContainer()
1140 protected ItemContainer
<?
> getItemContainer() {
1141 return FlowModelFactory
.getProcContainer();
1146 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#getProviderId()
1149 protected int getProviderId() {
1150 return LttngCoreProviderFactory
.CONTROL_FLOW_LTTNG_SYTH_EVENT_PROVIDER
;