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
9 * Contributors: Alvaro Sanchez-Leon - Initial implementation
10 *******************************************************************************/
11 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.controlflow
;
13 import java
.util
.Vector
;
15 import org
.eclipse
.jface
.action
.Action
;
16 import org
.eclipse
.jface
.action
.IMenuListener
;
17 import org
.eclipse
.jface
.action
.IMenuManager
;
18 import org
.eclipse
.jface
.action
.IToolBarManager
;
19 import org
.eclipse
.jface
.action
.MenuManager
;
20 import org
.eclipse
.jface
.action
.Separator
;
21 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
22 import org
.eclipse
.jface
.viewers
.DoubleClickEvent
;
23 import org
.eclipse
.jface
.viewers
.IDoubleClickListener
;
24 import org
.eclipse
.jface
.viewers
.ISelection
;
25 import org
.eclipse
.jface
.viewers
.ISelectionChangedListener
;
26 import org
.eclipse
.jface
.viewers
.IStructuredContentProvider
;
27 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
28 import org
.eclipse
.jface
.viewers
.ITableLabelProvider
;
29 import org
.eclipse
.jface
.viewers
.LabelProvider
;
30 import org
.eclipse
.jface
.viewers
.SelectionChangedEvent
;
31 import org
.eclipse
.jface
.viewers
.StructuredViewer
;
32 import org
.eclipse
.jface
.viewers
.TableViewer
;
33 import org
.eclipse
.jface
.viewers
.Viewer
;
34 import org
.eclipse
.jface
.viewers
.ViewerFilter
;
35 import org
.eclipse
.linuxtools
.lttng
.control
.LttngCoreProviderFactory
;
36 import org
.eclipse
.linuxtools
.lttng
.event
.LttngTimestamp
;
37 import org
.eclipse
.linuxtools
.lttng
.request
.ILttngSyntEventRequest
;
38 import org
.eclipse
.linuxtools
.lttng
.state
.evProcessor
.ITransEventProcessor
;
39 import org
.eclipse
.linuxtools
.lttng
.ui
.TraceDebug
;
40 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.ItemContainer
;
41 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.TimeRangeEventProcess
;
42 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.TimeRangeViewerProvider
;
43 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.common
.AbsTimeUpdateView
;
44 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.common
.ParamsUpdater
;
45 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.controlflow
.evProcessor
.FlowEventToHandlerFactory
;
46 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.controlflow
.model
.FlowModelFactory
;
47 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
48 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimeRange
;
49 import org
.eclipse
.linuxtools
.tmf
.experiment
.TmfExperiment
;
50 import org
.eclipse
.linuxtools
.tmf
.request
.ITmfDataRequest
.ExecutionType
;
51 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfExperimentSelectedSignal
;
52 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfRangeSynchSignal
;
53 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfSignalHandler
;
54 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfTimeSynchSignal
;
55 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.TmfViewerFactory
;
56 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.ITmfTimeFilterSelectionListener
;
57 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.ITmfTimeScaleSelectionListener
;
58 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.ITmfTimeSelectionListener
;
59 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.TmfTimeFilterSelectionEvent
;
60 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.TmfTimeScaleSelectionEvent
;
61 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.TmfTimeSelectionEvent
;
62 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.model
.ITmfTimeAnalysisEntry
;
63 import org
.eclipse
.swt
.SWT
;
64 import org
.eclipse
.swt
.custom
.SashForm
;
65 import org
.eclipse
.swt
.custom
.ScrolledComposite
;
66 import org
.eclipse
.swt
.events
.KeyEvent
;
67 import org
.eclipse
.swt
.events
.KeyListener
;
68 import org
.eclipse
.swt
.graphics
.Image
;
69 import org
.eclipse
.swt
.graphics
.Point
;
70 import org
.eclipse
.swt
.graphics
.Rectangle
;
71 import org
.eclipse
.swt
.widgets
.Composite
;
72 import org
.eclipse
.swt
.widgets
.Display
;
73 import org
.eclipse
.swt
.widgets
.Menu
;
74 import org
.eclipse
.swt
.widgets
.ScrollBar
;
75 import org
.eclipse
.swt
.widgets
.Table
;
76 import org
.eclipse
.swt
.widgets
.TableColumn
;
77 import org
.eclipse
.swt
.widgets
.TableItem
;
78 import org
.eclipse
.ui
.IActionBars
;
79 import org
.eclipse
.ui
.IWorkbenchActionConstants
;
80 import org
.eclipse
.ui
.PlatformUI
;
81 import org
.eclipse
.ui
.plugin
.AbstractUIPlugin
;
84 * <b><u>ControlFlowView</u></b>
90 public class ControlFlowView
extends AbsTimeUpdateView
implements
91 ITmfTimeSelectionListener
, ITmfTimeScaleSelectionListener
,
92 ITmfTimeFilterSelectionListener
{
94 public static final String ID
= "org.eclipse.linuxtools.lttng.ui.views.controlflow"; //$NON-NLS-1$
96 // ========================================================================
98 // ========================================================================
100 private final String PROCESS_COLUMN
= Messages
.getString("ControlFlowView.processColumn"); //$NON-NLS-1$
101 private final String BRAND_COLUMN
= Messages
.getString("ControlFlowView.brandColumn"); //$NON-NLS-1$
102 private final String PID_COLUMN
= Messages
.getString("ControlFlowView.pidColumn"); //$NON-NLS-1$
103 private final String TGID_COLUMN
= Messages
.getString("ControlFlowView.tgidColumn"); //$NON-NLS-1$
104 private final String PPID_COLUMN
= Messages
.getString("ControlFlowView.ppidColumn"); //$NON-NLS-1$
105 private final String CPU_COLUMN
= Messages
.getString("ControlFlowView.cpuColumn"); //$NON-NLS-1$
106 private final String BIRTH_SEC_COLUMN
= Messages
.getString("ControlFlowView.birthSecColumn"); //$NON-NLS-1$
107 private final String BIRTH_NSEC_COLUMN
= Messages
.getString("ControlFlowView.birthNSecColumn"); //$NON-NLS-1$
108 private final String TRACE
= Messages
.getString("ControlFlowView.TraceNameColumn"); //$NON-NLS-1$
110 private final String
[] columnNames
= new String
[] { PROCESS_COLUMN
, /* */
116 BIRTH_SEC_COLUMN
,/* */
117 BIRTH_NSEC_COLUMN
,/* */
121 // ========================================================================
123 // ========================================================================
124 private TableViewer tableViewer
;
125 // private int totalNumItems = 0;
127 private Action doubleClickAction
;
128 private Action resetScale
;
129 private Action nextEvent
;
130 private Action prevEvent
;
131 private Action nextTrace
;
132 private Action prevTrace
;
133 private Action showLegend
;
134 private Action filterTraces
;
135 private Action zoomIn
;
136 private Action zoomOut
;
137 private Action zoomFilter
;
139 private ViewProcessFilter tableFilter
= null;
140 private ScrolledComposite scrollFrame
= null;
142 // private static SimpleDateFormat stimeformat = new SimpleDateFormat(
143 // "yy/MM/dd HH:mm:ss");
145 // private TraceModelImplFactory fact;
147 // ========================================================================
149 // ========================================================================
151 * The content provider class is responsible for providing objects to the
152 * view. It can wrap existing objects in adapters or simply return objects
153 * as-is. These objects may be sensitive to the current input of the view,
154 * or ignore it and always show the same content (like Task List, for
158 class ViewContentProvider
implements
159 /* ILazyContentProvider, */IStructuredContentProvider
{
160 private TableViewer cviewer
= null;
161 private ITmfTimeAnalysisEntry
[] elements
= null;
163 public ViewContentProvider(TableViewer v
) {
168 public void inputChanged(Viewer v
, Object oldInput
, Object newInput
) {
169 this.elements
= (ITmfTimeAnalysisEntry
[]) newInput
;
170 if (elements
!= null) {
171 TraceDebug
.debug("Total number of processes provided to Control Flow view: " + elements
.length
); //$NON-NLS-1$
173 TraceDebug
.debug("New input = null"); //$NON-NLS-1$
178 public void dispose() {
182 // Needed with the use of virtual tables in order to initialize items
183 // which were not initially visible.
184 public void updateElement(int index
) {
185 cviewer
.replace(elements
[index
], index
);
189 public Object
[] getElements(Object inputElement
) {
194 class ViewLabelProvider
extends LabelProvider
implements ITableLabelProvider
{
196 public String
getColumnText(Object obj
, int index
) {
197 String strRes
= ""; //$NON-NLS-1$
199 if (obj
instanceof TimeRangeEventProcess
) {
200 TimeRangeEventProcess process
= (TimeRangeEventProcess
) obj
;
203 strRes
= process
.getName();
206 strRes
= process
.getBrand();
209 strRes
= process
.getPid().toString();
212 strRes
= process
.getTgid().toString();
215 strRes
= process
.getPpid().toString();
218 strRes
= process
.getCpu().toString();
221 time
= new LttngTimestamp(process
.getCreationTime()
223 strRes
= time
.getSeconds();
226 time
= new LttngTimestamp(process
.getCreationTime()
228 strRes
= time
.getNanoSeconds();
231 strRes
= process
.getTraceID();
244 public Image
getColumnImage(Object obj
, int index
) {
245 return getImage(obj
);
249 public Image
getImage(Object obj
) {
250 // No image needed for the time being
251 // return PlatformUI.getWorkbench().getSharedImages().getImage(
252 // ISharedImages.IMG_OBJ_ELEMENT);
257 class ViewProcessFilter
extends ViewerFilter
{
259 private Vector
<ITmfTimeAnalysisEntry
> filteredSet
= new Vector
<ITmfTimeAnalysisEntry
>();
260 StructuredViewer viewer
;
262 public ViewProcessFilter(StructuredViewer rviewer
) {
263 this.viewer
= rviewer
;
266 public void setFilter(Vector
<ITmfTimeAnalysisEntry
> filtered
) {
267 if (filtered
!= null) {
268 this.filteredSet
= filtered
;
274 public boolean select(Viewer viewer
, Object parentElement
,
276 boolean filteredIn
= true;
277 if (element
instanceof ITmfTimeAnalysisEntry
) {
278 ITmfTimeAnalysisEntry process
= (ITmfTimeAnalysisEntry
) element
;
279 if (filteredSet
.contains(process
)) {
280 // The element is marked to be filtered out
284 TraceDebug
.debug("Unexpected type of filter element received: " //$NON-NLS-1$
285 + element
.toString());
287 // Compare element versus a list of filtered out
295 public ControlFlowView() {
300 * This is a callback that will allow us to create the viewer and initialize
307 * org.eclipse.linuxtools.tmf.ui.views.TmfView#createPartControl(org.eclipse
308 * .swt.widgets.Composite)
311 public void createPartControl(Composite parent
) {
313 scrollFrame
= new ScrolledComposite(parent
, SWT
.V_SCROLL
);
315 scrollFrame
.setExpandVertical(true);
316 scrollFrame
.setExpandHorizontal(true);
317 scrollFrame
.setAlwaysShowScrollBars(true);
319 SashForm sash
= new SashForm(scrollFrame
, SWT
.NONE
);
320 scrollFrame
.setContent(sash
);
322 tableViewer
= new TableViewer(sash
, SWT
.FULL_SELECTION
| SWT
.H_SCROLL
);
323 tableViewer
.setContentProvider(new ViewContentProvider(tableViewer
));
324 tableViewer
.setLabelProvider(new ViewLabelProvider());
325 Table table
= tableViewer
.getTable();
326 tableViewer
.addSelectionChangedListener(new ISelectionChangedListener() {
328 public void selectionChanged(SelectionChangedEvent event
) {
329 ISelection sel
= event
.getSelection();
330 if (!sel
.isEmpty()) {
331 Object firstSel
= null;
332 if (sel
instanceof IStructuredSelection
) {
333 firstSel
= ((IStructuredSelection
) sel
).getFirstElement();
335 // Make sure the selection is visible
336 updateScrollOrigin();
338 if (firstSel
instanceof ITmfTimeAnalysisEntry
) {
339 ITmfTimeAnalysisEntry trace
= (ITmfTimeAnalysisEntry
) firstSel
;
340 tsfviewer
.setSelectedTrace(trace
);
347 * Make sure the selected item is visible
349 private void updateScrollOrigin() {
350 Table table
= tableViewer
.getTable();
351 if (table
!= null && table
.getItemCount() > 0) {
352 TableItem item
= table
.getSelection()[0];
354 // no selected reference to go up or down
358 Rectangle itemRect
= item
.getBounds();
359 int step
= itemRect
.height
;
361 // calculate height of horizontal bar
363 ScrollBar hbar
= scrollFrame
.getHorizontalBar();
365 hscrolly
= hbar
.getSize().y
;
368 int visibleHeight
= scrollFrame
.getSize().y
- hscrolly
;
370 // the current scrollbar offset to adjust i.e. start
372 // the visible window
373 Point origin
= scrollFrame
.getOrigin();
374 // end of visible window
375 int endy
= origin
.y
+ visibleHeight
;
377 int itemStartPos
= itemRect
.y
+ table
.getHeaderHeight() + table
.getBorderWidth()
378 + table
.getParent().getBorderWidth();
381 int itemEndPos
= itemStartPos
+ step
;
383 // check if need to go up
384 if (origin
.y
>= step
&& itemStartPos
< origin
.y
) {
386 scrollFrame
.setOrigin(origin
.x
, origin
.y
- step
);
390 // check if it needs to go down
391 if (itemEndPos
> endy
) {
393 scrollFrame
.setOrigin(origin
.x
, origin
.y
+ step
);
400 // Listen to page up /down and Home / Enc keys
401 tableViewer
.getTable().addKeyListener(new KeyListener() {
403 public void keyPressed(KeyEvent e
) {
404 Table table
= tableViewer
.getTable();
405 Point origin
= scrollFrame
.getOrigin();
406 if (table
== null || table
.getItemCount() < 1) {
416 updateScrollPageDown();
423 count
= table
.getItemCount();
424 item
= table
.getItem(0);
426 scrollFrame
.setOrigin(origin
.x
, 0);
430 count
= table
.getItemCount();
431 item
= table
.getItem(count
- 1);
432 int itemStartPos
= item
.getBounds().y
;
434 scrollFrame
.setOrigin(origin
.x
, itemStartPos
);
442 public void keyReleased(KeyEvent e
) {
448 * Scroll one page down
450 private void updateScrollPageDown() {
451 // null protection before calling private method
452 Table table
= tableViewer
.getTable();
453 int step
= table
.getItemHeight();
456 ScrollBar hbar
= scrollFrame
.getHorizontalBar();
458 hscrolly
= hbar
.getSize().y
;
461 Point origin
= scrollFrame
.getOrigin();
462 int visibleHeight
= scrollFrame
.getSize().y
- hscrolly
;
463 int endy
= origin
.y
+ visibleHeight
;
465 scrollFrame
.setOrigin(origin
.x
, endy
- step
);
471 private void updateScrollUp() {
472 // null protection before calling private method
473 Table table
= tableViewer
.getTable();
474 int step
= table
.getItemHeight();
477 ScrollBar hbar
= scrollFrame
.getHorizontalBar();
479 hscrolly
= hbar
.getSize().y
;
482 Point origin
= scrollFrame
.getOrigin();
483 int visibleHeight
= scrollFrame
.getSize().y
- hscrolly
;
484 int pageUpPos
= origin
.y
- visibleHeight
+ step
;
485 pageUpPos
= pageUpPos
> 0 ? pageUpPos
: 0;
486 scrollFrame
.setOrigin(origin
.x
, pageUpPos
);
491 applyTableLayout(table
);
493 int borderWidth
= table
.getBorderWidth();
495 int itemHeight
= table
.getItemHeight() + checkForSWTBugItemHeightAdjustement();
496 int headerHeight
= table
.getHeaderHeight();
497 table
.getVerticalBar().setVisible(false);
499 tsfviewer
= TmfViewerFactory
.createViewer(sash
,
500 new TimeRangeViewerProvider(getParamsUpdater()));
502 tsfviewer
.addWidgetSelectionListner(this);
503 tsfviewer
.addWidgetTimeScaleSelectionListner(this);
505 // Traces shall not be grouped to allow synchronisation
506 tsfviewer
.groupTraces(false);
507 tsfviewer
.setItemHeight(itemHeight
);
508 tsfviewer
.setBorderWidth(borderWidth
);
509 tsfviewer
.setHeaderHeight(headerHeight
);
510 tsfviewer
.setVisibleVerticalScroll(false);
511 // Names provided by the table
512 tsfviewer
.setNameWidthPref(0);
513 tsfviewer
.setAcceptSelectionAPIcalls(true);
515 // Viewer to notify selection to this class
516 // This class will synchronise selections with table.
517 tsfviewer
.addWidgetSelectionListner(this);
518 tsfviewer
.addFilterSelectionListner(this);
519 tsfviewer
.addWidgetTimeScaleSelectionListner(this);
521 sash
.setWeights(new int[] { 1, 1 });
522 // Create the help context id for the viewer's control
523 // TODO: Associate with help system
524 PlatformUI
.getWorkbench().getHelpSystem().setHelp(
525 tableViewer
.getControl(),
526 "org.eclipse.linuxtools.lttnng.ui.views.flow.viewer"); //$NON-NLS-1$
530 hookDoubleClickAction();
531 contributeToActionBars();
533 // scrollFrame.addControlListener(new ControlAdapter() {
536 // public void controlResized(ControlEvent e) {
537 // tsfviewer.resizeControls();
538 // updateScrolls(scrollFrame);
542 // set the initial view parameter values
543 // Experiment start and end time
544 // as well as time space width in pixels, used by the time analysis
546 // Read relevant values
547 int timeSpaceWidth
= tsfviewer
.getTimeSpace();
548 if (timeSpaceWidth
< 0) {
549 timeSpaceWidth
= -timeSpaceWidth
;
552 TmfExperiment
<?
> experiment
= TmfExperiment
.getCurrentExperiment();
553 if (experiment
!= null) {
554 TmfTimeRange experimentTRange
= experiment
.getTimeRange();
556 // send request and received the adjusted time used
557 TmfTimeRange adjustedTimeRange
= initialExperimentDataRequest(this,
560 // initialize widget time boundaries and filtering parameters
561 ModelUpdateInit(experimentTRange
, adjustedTimeRange
, this);
563 TraceDebug
.debug("No selected experiment information available"); //$NON-NLS-1$
567 private void hookContextMenu() {
568 MenuManager menuMgr
= new MenuManager("#PopupMenu"); //$NON-NLS-1$
569 menuMgr
.setRemoveAllWhenShown(true);
570 menuMgr
.addMenuListener(new IMenuListener() {
572 public void menuAboutToShow(IMenuManager manager
) {
573 ControlFlowView
.this.fillContextMenu(manager
);
576 Menu menu
= menuMgr
.createContextMenu(tableViewer
.getControl());
577 tableViewer
.getControl().setMenu(menu
);
578 getSite().registerContextMenu(menuMgr
, tableViewer
);
581 private void contributeToActionBars() {
582 IActionBars bars
= getViewSite().getActionBars();
583 fillLocalPullDown(bars
.getMenuManager());
584 fillLocalToolBar(bars
.getToolBarManager());
587 private void fillLocalPullDown(IMenuManager manager
) {
588 manager
.add(new Separator());
589 // manager.add(showLegend);
590 manager
.add(new Separator());
591 manager
.add(resetScale
);
592 manager
.add(nextEvent
);
593 manager
.add(prevEvent
);
594 manager
.add(nextTrace
);
595 manager
.add(prevTrace
);
596 // manager.add(filterTraces);
598 manager
.add(zoomOut
);
599 manager
.add(zoomFilter
);
600 manager
.add(new Separator());
603 private void fillContextMenu(IMenuManager manager
) {
604 // manager.add(showLegend);
605 manager
.add(new Separator());
606 manager
.add(resetScale
);
607 manager
.add(nextEvent
);
608 manager
.add(prevEvent
);
609 manager
.add(nextTrace
);
610 manager
.add(prevTrace
);
611 // manager.add(showLegend);
612 // manager.add(filterTraces);
614 manager
.add(zoomOut
);
615 manager
.add(zoomFilter
);
616 manager
.add(new Separator());
617 manager
.add(new Separator(IWorkbenchActionConstants
.MB_ADDITIONS
));
620 private void fillLocalToolBar(IToolBarManager manager
) {
621 // manager.add(showLegend);
622 manager
.add(new Separator());
623 manager
.add(resetScale
);
624 manager
.add(nextEvent
);
625 manager
.add(prevEvent
);
626 manager
.add(nextTrace
);
627 manager
.add(prevTrace
);
628 // manager.add(filterTraces);
630 manager
.add(zoomOut
);
631 manager
.add(zoomFilter
);
632 manager
.add(new Separator());
635 private void makeActions() {
637 resetScale
= new Action() {
640 if (tsfviewer
!= null) {
641 tsfviewer
.resetStartFinishTime();
646 resetScale
.setText(Messages
.getString("ControlFlowView.Action.Reset")); //$NON-NLS-1$
647 resetScale
.setToolTipText(Messages
648 .getString("ControlFlowView.Action.Reset.ToolTip")); //$NON-NLS-1$
649 resetScale
.setImageDescriptor(AbstractUIPlugin
650 .imageDescriptorFromPlugin(Messages
651 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
652 "icons/elcl16/home_nav.gif")); //$NON-NLS-1$
655 nextEvent
= new Action() {
658 if (tsfviewer
!= null) {
659 tsfviewer
.selectNextEvent();
663 nextEvent
.setText(Messages
664 .getString("ControlFlowView.Action.NextEvent")); //$NON-NLS-1$
665 nextEvent
.setToolTipText(Messages
666 .getString("ControlFlowView.Action.NextEvent.Tooltip")); //$NON-NLS-1$
667 nextEvent
.setImageDescriptor(AbstractUIPlugin
668 .imageDescriptorFromPlugin(Messages
669 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
670 "icons/elcl16/next_event.gif")); //$NON-NLS-1$
673 prevEvent
= new Action() {
676 if (tsfviewer
!= null) {
677 tsfviewer
.selectPrevEvent();
681 prevEvent
.setText(Messages
682 .getString("ControlFlowView.Action.PrevEvent")); //$NON-NLS-1$
683 prevEvent
.setToolTipText(Messages
684 .getString("ControlFlowView.Action.PrevEvent.Tooltip")); //$NON-NLS-1$
685 prevEvent
.setImageDescriptor(AbstractUIPlugin
686 .imageDescriptorFromPlugin(Messages
687 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
688 "icons/elcl16/prev_event.gif")); //$NON-NLS-1$
691 nextTrace
= new Action() {
694 if (tsfviewer
!= null) {
695 tsfviewer
.selectNextTrace();
699 nextTrace
.setText(Messages
700 .getString("ControlFlowView.Action.NextProcess")); //$NON-NLS-1$
701 nextTrace
.setToolTipText(Messages
702 .getString("ControlFlowView.Action.NextProcess.ToolTip")); //$NON-NLS-1$
703 nextTrace
.setImageDescriptor(AbstractUIPlugin
704 .imageDescriptorFromPlugin(Messages
705 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
706 "icons/elcl16/next_item.gif")); //$NON-NLS-1$
709 prevTrace
= new Action() {
712 if (tsfviewer
!= null) {
713 tsfviewer
.selectPrevTrace();
717 prevTrace
.setText(Messages
718 .getString("ControlFlowView.Action.PreviousProcess")); //$NON-NLS-1$
719 prevTrace
.setToolTipText(Messages
720 .getString("ControlFlowView.Action.PreviousProcess.Tooltip")); //$NON-NLS-1$
721 prevTrace
.setImageDescriptor(AbstractUIPlugin
722 .imageDescriptorFromPlugin(Messages
723 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
724 "icons/elcl16/prev_item.gif")); //$NON-NLS-1$
727 showLegend
= new Action() {
730 if (tsfviewer
!= null) {
731 tsfviewer
.showLegend();
735 showLegend
.setText(Messages
.getString("ControlFlowView.Action.Legend")); //$NON-NLS-1$
736 showLegend
.setToolTipText(Messages
737 .getString("ControlFlowView.Action.Legend.ToolTip")); //$NON-NLS-1$
740 filterTraces
= new Action() {
743 if (tsfviewer
!= null) {
744 tsfviewer
.filterTraces();
748 filterTraces
.setText(Messages
749 .getString("ControlFlowView.Action.Filter")); //$NON-NLS-1$
750 filterTraces
.setToolTipText(Messages
751 .getString("ControlFlowView.Action.Filter.ToolTip")); //$NON-NLS-1$
752 filterTraces
.setImageDescriptor(AbstractUIPlugin
753 .imageDescriptorFromPlugin(Messages
754 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
755 "icons/elcl16/filter_items.gif")); //$NON-NLS-1$
758 zoomIn
= new Action() {
761 if (tsfviewer
!= null) {
766 zoomIn
.setText(Messages
.getString("ControlFlowView.Action.ZoomIn")); //$NON-NLS-1$
767 zoomIn
.setToolTipText(Messages
768 .getString("ControlFlowView.Action.ZoomIn.Tooltip")); //$NON-NLS-1$
769 zoomIn
.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(
770 Messages
.getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
771 "icons/elcl16/zoomin_nav.gif")); //$NON-NLS-1$
774 zoomOut
= new Action() {
777 if (tsfviewer
!= null) {
782 zoomOut
.setText(Messages
.getString("ControlFlowView.Action.ZoomOut")); //$NON-NLS-1$
783 zoomOut
.setToolTipText(Messages
784 .getString("ControlFlowView.Action.ZoomOut.tooltip")); //$NON-NLS-1$
785 zoomOut
.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(
786 Messages
.getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
787 "icons/elcl16/zoomout_nav.gif")); //$NON-NLS-1$
790 zoomFilter
= new Action() {
793 // Nothing to do, however the selection status is needed by the
797 zoomFilter
.setText(Messages
798 .getString("ControlFlowView.Action.ZoomFilter")); //$NON-NLS-1$
799 zoomFilter
.setToolTipText(Messages
800 .getString("ControlFlowView.Action.ZoomFilter.tooltip")); //$NON-NLS-1$
801 zoomFilter
.setImageDescriptor(AbstractUIPlugin
802 .imageDescriptorFromPlugin(Messages
803 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
804 "icons/elcl16/filter_items.gif")); //$NON-NLS-1$
805 zoomFilter
.setChecked(false);
807 // PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_SYNCED);
809 doubleClickAction
= new Action() {
812 ISelection selection
= tableViewer
.getSelection();
813 Object obj
= ((IStructuredSelection
) selection
)
815 showMessage("Double-click detected on " + obj
.toString()); //$NON-NLS-1$
820 private void hookDoubleClickAction() {
821 tableViewer
.addDoubleClickListener(new IDoubleClickListener() {
823 public void doubleClick(DoubleClickEvent event
) {
824 doubleClickAction
.run();
829 private void showMessage(String message
) {
830 MessageDialog
.openInformation(tableViewer
.getControl().getShell(),
831 Messages
.getString("ControlFlowView.msgSlogan"), message
); //$NON-NLS-1$
835 * Passing the focus request to the viewer's control.
838 public void setFocus() {
839 tableViewer
.getControl().setFocus();
845 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
846 * tsfTmProcessSelEvent
847 * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent
851 public void tsfTmProcessSelEvent(TmfTimeSelectionEvent event
) {
852 // common implementation
853 super.tsfTmProcessSelEvent(event
);
855 // Reselect the table viewer to widget selection
856 ISelection sel
= tsfviewer
.getSelectionTrace();
857 if (sel
!= null && !sel
.isEmpty()) {
858 tableViewer
.setSelection(sel
);
865 * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.
866 * ITmfTimeScaleSelectionListener
867 * #tsfTmProcessTimeScaleEvent(org.eclipse.linuxtools
868 * .tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent)
871 public void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event
) {
872 super.tsfTmProcessTimeScaleEvent(event
);
875 private void applyTableLayout(Table table
) {
876 for (int i
= 0; i
< columnNames
.length
; i
++) {
877 TableColumn tableColumn
= new TableColumn(table
, SWT
.LEFT
);
878 tableColumn
.setText(columnNames
[i
]);
881 table
.setHeaderVisible(true);
882 table
.setLinesVisible(true);
889 * org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#displayModel
890 * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.
891 * ITmfTimeAnalysisEntry[], long, long, boolean, long, long,
895 public void displayModel(final ITmfTimeAnalysisEntry
[] items
,
896 final long startBoundTime
, final long endBoundTime
,
897 final boolean updateTimeBounds
, final long startVisibleWindow
,
898 final long endVisibleWindow
, final Object source
) {
900 if(tableViewer
!= null) {
901 final Table table
= tableViewer
.getTable();
903 // Ignore update if widget is disposed
904 if (table
.isDisposed()) return;
906 Display display
= table
.getDisplay();
908 // Perform the updates on the UI thread)
909 display
.asyncExec(new Runnable() {
912 if (!table
.isDisposed()) {
913 tableViewer
.setInput(items
); // This shall be the minimal
915 tableFilter
= new ViewProcessFilter(tableViewer
);
916 tableViewer
.setFilters(new ViewerFilter
[] { tableFilter
});
918 resizeTableColumns(table
);
920 tableViewer
.refresh();
922 tsfviewer
.display(items
, startBoundTime
, endBoundTime
,
925 // validate visible boundaries
926 if (startVisibleWindow
> -1 && endVisibleWindow
> -1) {
927 tsfviewer
.setSelectVisTimeWindow(startVisibleWindow
,
928 endVisibleWindow
, source
);
931 tsfviewer
.resizeControls();
933 // Adjust asynchronously the size of the vertical scroll bar to fit the
935 tableViewer
.getTable().getDisplay().asyncExec(new Runnable() {
938 if ((scrollFrame
!= null) && (!scrollFrame
.isDisposed())) {
939 updateScrolls(scrollFrame
);
950 public void dispose() {
951 // dispose parent resources
954 tsfviewer
.removeFilterSelectionListner(this);
955 tsfviewer
.removeWidgetSelectionListner(this);
956 tsfviewer
.removeWidgetTimeScaleSelectionListner(this);
962 * @param tableComposite
965 private synchronized void resizeTableColumns(Table table
) {
967 Composite parent
= table
.getParent();
968 int tableWidthSum
= parent
.getBorderWidth();
970 TableColumn
[] columns
= table
.getColumns();
971 for (TableColumn column
: columns
) {
973 tableWidthSum
+= column
.getWidth();
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 // prepare time intervals in widget
1051 ModelUpdateInit(experimentTRange
, experimentTRange
, signal
1054 // request initial data
1055 initialExperimentDataRequest(signal
1056 .getSource(), experimentTRange
);
1062 * @param experimentTRange
1063 * @return Adjusted time window used for the request (smaller window to
1066 private TmfTimeRange
initialExperimentDataRequest(Object source
,
1067 TmfTimeRange experimentTRange
) {
1068 // Adjust the initial time window to a shorter interval to allow
1069 // user to select the interesting area based on the perspective
1070 TmfTimeRange initTimeWindow
= getInitTRange(experimentTRange
);
1072 dataRequest(initTimeWindow
, experimentTRange
, true, ExecutionType
.FOREGROUND
);
1073 if (TraceDebug
.isDEBUG()) {
1074 TraceDebug
.debug("Initialization request time range is: " //$NON-NLS-1$
1075 + initTimeWindow
.getStartTime().toString() + "-" //$NON-NLS-1$
1076 + initTimeWindow
.getEndTime().toString());
1079 return initTimeWindow
;
1086 public int checkForSWTBugItemHeightAdjustement() {
1087 int returnedAjustement
= 0;
1088 String desktopSessionName
= System
.getenv("DESKTOP_SESSION"); //$NON-NLS-1$
1090 // Gnome : most common case, no adjustement
1091 if ( desktopSessionName
.equals("gnome") ) { //$NON-NLS-1$
1092 returnedAjustement
= 0;
1094 // Kde : ajustement of 2 is needed
1095 else if ( desktopSessionName
.equals("kde") ) { //$NON-NLS-1$
1096 returnedAjustement
= 2;
1099 return returnedAjustement
;
1105 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1106 * getParamsUpdater()
1109 protected ParamsUpdater
getParamsUpdater() {
1110 return FlowModelFactory
.getParamsUpdater();
1116 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1117 * getItemContainer()
1120 protected ItemContainer
<?
> getItemContainer() {
1121 return FlowModelFactory
.getProcContainer();
1126 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#getProviderId()
1129 protected int getProviderId() {
1130 return LttngCoreProviderFactory
.CONTROL_FLOW_LTTNG_SYTH_EVENT_PROVIDER
;