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
, new TimeRangeViewerProvider(getParamsUpdater()));
501 // Traces shall not be grouped to allow synchronisation
502 tsfviewer
.groupTraces(false);
503 tsfviewer
.setItemHeight(itemHeight
);
504 tsfviewer
.setBorderWidth(borderWidth
);
505 tsfviewer
.setHeaderHeight(headerHeight
);
506 tsfviewer
.setVisibleVerticalScroll(false);
507 // Names provided by the table
508 tsfviewer
.setNameWidthPref(0);
509 tsfviewer
.setAcceptSelectionAPIcalls(true);
511 // Viewer to notify selection to this class
512 // This class will synchronise selections with table.
513 tsfviewer
.addWidgetSelectionListner(this);
514 tsfviewer
.addFilterSelectionListner(this);
515 tsfviewer
.addWidgetTimeScaleSelectionListner(this);
517 sash
.setWeights(new int[] { 1, 1 });
518 // Create the help context id for the viewer's control
519 // TODO: Associate with help system
520 PlatformUI
.getWorkbench().getHelpSystem().setHelp(
521 tableViewer
.getControl(),
522 "org.eclipse.linuxtools.lttnng.ui.views.flow.viewer"); //$NON-NLS-1$
526 hookDoubleClickAction();
527 contributeToActionBars();
529 // scrollFrame.addControlListener(new ControlAdapter() {
532 // public void controlResized(ControlEvent e) {
533 // tsfviewer.resizeControls();
534 // updateScrolls(scrollFrame);
538 // set the initial view parameter values
539 // Experiment start and end time
540 // as well as time space width in pixels, used by the time analysis
542 // Read relevant values
543 int timeSpaceWidth
= tsfviewer
.getTimeSpace();
544 if (timeSpaceWidth
< 0) {
545 timeSpaceWidth
= -timeSpaceWidth
;
548 TmfExperiment
<?
> experiment
= TmfExperiment
.getCurrentExperiment();
549 if (experiment
!= null) {
550 TmfTimeRange experimentTRange
= experiment
.getTimeRange();
552 // send request and received the adjusted time used
553 TmfTimeRange adjustedTimeRange
= initialExperimentDataRequest(this,
556 // initialize widget time boundaries and filtering parameters
557 ModelUpdateInit(experimentTRange
, adjustedTimeRange
, this);
559 TraceDebug
.debug("No selected experiment information available"); //$NON-NLS-1$
563 private void hookContextMenu() {
564 MenuManager menuMgr
= new MenuManager("#PopupMenu"); //$NON-NLS-1$
565 menuMgr
.setRemoveAllWhenShown(true);
566 menuMgr
.addMenuListener(new IMenuListener() {
568 public void menuAboutToShow(IMenuManager manager
) {
569 ControlFlowView
.this.fillContextMenu(manager
);
572 Menu menu
= menuMgr
.createContextMenu(tableViewer
.getControl());
573 tableViewer
.getControl().setMenu(menu
);
574 getSite().registerContextMenu(menuMgr
, tableViewer
);
577 private void contributeToActionBars() {
578 IActionBars bars
= getViewSite().getActionBars();
579 fillLocalPullDown(bars
.getMenuManager());
580 fillLocalToolBar(bars
.getToolBarManager());
583 private void fillLocalPullDown(IMenuManager manager
) {
584 manager
.add(new Separator());
585 // manager.add(showLegend);
586 manager
.add(new Separator());
587 manager
.add(resetScale
);
588 manager
.add(nextEvent
);
589 manager
.add(prevEvent
);
590 manager
.add(nextTrace
);
591 manager
.add(prevTrace
);
592 // manager.add(filterTraces);
594 manager
.add(zoomOut
);
595 manager
.add(zoomFilter
);
596 manager
.add(new Separator());
599 private void fillContextMenu(IMenuManager manager
) {
600 // manager.add(showLegend);
601 manager
.add(new Separator());
602 manager
.add(resetScale
);
603 manager
.add(nextEvent
);
604 manager
.add(prevEvent
);
605 manager
.add(nextTrace
);
606 manager
.add(prevTrace
);
607 // manager.add(showLegend);
608 // manager.add(filterTraces);
610 manager
.add(zoomOut
);
611 manager
.add(zoomFilter
);
612 manager
.add(new Separator());
613 manager
.add(new Separator(IWorkbenchActionConstants
.MB_ADDITIONS
));
616 private void fillLocalToolBar(IToolBarManager manager
) {
617 // manager.add(showLegend);
618 manager
.add(new Separator());
619 manager
.add(resetScale
);
620 manager
.add(nextEvent
);
621 manager
.add(prevEvent
);
622 manager
.add(nextTrace
);
623 manager
.add(prevTrace
);
624 // manager.add(filterTraces);
626 manager
.add(zoomOut
);
627 manager
.add(zoomFilter
);
628 manager
.add(new Separator());
631 private void makeActions() {
633 resetScale
= new Action() {
636 if (tsfviewer
!= null) {
637 tsfviewer
.resetStartFinishTime();
642 resetScale
.setText(Messages
.getString("ControlFlowView.Action.Reset")); //$NON-NLS-1$
643 resetScale
.setToolTipText(Messages
644 .getString("ControlFlowView.Action.Reset.ToolTip")); //$NON-NLS-1$
645 resetScale
.setImageDescriptor(AbstractUIPlugin
646 .imageDescriptorFromPlugin(Messages
647 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
648 "icons/elcl16/home_nav.gif")); //$NON-NLS-1$
651 nextEvent
= new Action() {
654 if (tsfviewer
!= null) {
655 tsfviewer
.selectNextEvent();
659 nextEvent
.setText(Messages
660 .getString("ControlFlowView.Action.NextEvent")); //$NON-NLS-1$
661 nextEvent
.setToolTipText(Messages
662 .getString("ControlFlowView.Action.NextEvent.Tooltip")); //$NON-NLS-1$
663 nextEvent
.setImageDescriptor(AbstractUIPlugin
664 .imageDescriptorFromPlugin(Messages
665 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
666 "icons/elcl16/next_event.gif")); //$NON-NLS-1$
669 prevEvent
= new Action() {
672 if (tsfviewer
!= null) {
673 tsfviewer
.selectPrevEvent();
677 prevEvent
.setText(Messages
678 .getString("ControlFlowView.Action.PrevEvent")); //$NON-NLS-1$
679 prevEvent
.setToolTipText(Messages
680 .getString("ControlFlowView.Action.PrevEvent.Tooltip")); //$NON-NLS-1$
681 prevEvent
.setImageDescriptor(AbstractUIPlugin
682 .imageDescriptorFromPlugin(Messages
683 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
684 "icons/elcl16/prev_event.gif")); //$NON-NLS-1$
687 nextTrace
= new Action() {
690 if (tsfviewer
!= null) {
691 tsfviewer
.selectNextTrace();
695 nextTrace
.setText(Messages
696 .getString("ControlFlowView.Action.NextProcess")); //$NON-NLS-1$
697 nextTrace
.setToolTipText(Messages
698 .getString("ControlFlowView.Action.NextProcess.ToolTip")); //$NON-NLS-1$
699 nextTrace
.setImageDescriptor(AbstractUIPlugin
700 .imageDescriptorFromPlugin(Messages
701 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
702 "icons/elcl16/next_item.gif")); //$NON-NLS-1$
705 prevTrace
= new Action() {
708 if (tsfviewer
!= null) {
709 tsfviewer
.selectPrevTrace();
713 prevTrace
.setText(Messages
714 .getString("ControlFlowView.Action.PreviousProcess")); //$NON-NLS-1$
715 prevTrace
.setToolTipText(Messages
716 .getString("ControlFlowView.Action.PreviousProcess.Tooltip")); //$NON-NLS-1$
717 prevTrace
.setImageDescriptor(AbstractUIPlugin
718 .imageDescriptorFromPlugin(Messages
719 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
720 "icons/elcl16/prev_item.gif")); //$NON-NLS-1$
723 showLegend
= new Action() {
726 if (tsfviewer
!= null) {
727 tsfviewer
.showLegend();
731 showLegend
.setText(Messages
.getString("ControlFlowView.Action.Legend")); //$NON-NLS-1$
732 showLegend
.setToolTipText(Messages
733 .getString("ControlFlowView.Action.Legend.ToolTip")); //$NON-NLS-1$
736 filterTraces
= new Action() {
739 if (tsfviewer
!= null) {
740 tsfviewer
.filterTraces();
744 filterTraces
.setText(Messages
745 .getString("ControlFlowView.Action.Filter")); //$NON-NLS-1$
746 filterTraces
.setToolTipText(Messages
747 .getString("ControlFlowView.Action.Filter.ToolTip")); //$NON-NLS-1$
748 filterTraces
.setImageDescriptor(AbstractUIPlugin
749 .imageDescriptorFromPlugin(Messages
750 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
751 "icons/elcl16/filter_items.gif")); //$NON-NLS-1$
754 zoomIn
= new Action() {
757 if (tsfviewer
!= null) {
762 zoomIn
.setText(Messages
.getString("ControlFlowView.Action.ZoomIn")); //$NON-NLS-1$
763 zoomIn
.setToolTipText(Messages
764 .getString("ControlFlowView.Action.ZoomIn.Tooltip")); //$NON-NLS-1$
765 zoomIn
.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(
766 Messages
.getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
767 "icons/elcl16/zoomin_nav.gif")); //$NON-NLS-1$
770 zoomOut
= new Action() {
773 if (tsfviewer
!= null) {
778 zoomOut
.setText(Messages
.getString("ControlFlowView.Action.ZoomOut")); //$NON-NLS-1$
779 zoomOut
.setToolTipText(Messages
780 .getString("ControlFlowView.Action.ZoomOut.tooltip")); //$NON-NLS-1$
781 zoomOut
.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(
782 Messages
.getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
783 "icons/elcl16/zoomout_nav.gif")); //$NON-NLS-1$
786 zoomFilter
= new Action() {
789 // Nothing to do, however the selection status is needed by the
793 zoomFilter
.setText(Messages
794 .getString("ControlFlowView.Action.ZoomFilter")); //$NON-NLS-1$
795 zoomFilter
.setToolTipText(Messages
796 .getString("ControlFlowView.Action.ZoomFilter.tooltip")); //$NON-NLS-1$
797 zoomFilter
.setImageDescriptor(AbstractUIPlugin
798 .imageDescriptorFromPlugin(Messages
799 .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
800 "icons/elcl16/filter_items.gif")); //$NON-NLS-1$
801 zoomFilter
.setChecked(false);
803 // PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_SYNCED);
805 doubleClickAction
= new Action() {
808 ISelection selection
= tableViewer
.getSelection();
809 Object obj
= ((IStructuredSelection
) selection
)
811 showMessage("Double-click detected on " + obj
.toString()); //$NON-NLS-1$
816 private void hookDoubleClickAction() {
817 tableViewer
.addDoubleClickListener(new IDoubleClickListener() {
819 public void doubleClick(DoubleClickEvent event
) {
820 doubleClickAction
.run();
825 private void showMessage(String message
) {
826 MessageDialog
.openInformation(tableViewer
.getControl().getShell(),
827 Messages
.getString("ControlFlowView.msgSlogan"), message
); //$NON-NLS-1$
831 * Passing the focus request to the viewer's control.
834 public void setFocus() {
835 tableViewer
.getControl().setFocus();
841 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
842 * tsfTmProcessSelEvent
843 * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent
847 public void tsfTmProcessSelEvent(TmfTimeSelectionEvent event
) {
848 // common implementation
849 super.tsfTmProcessSelEvent(event
);
851 // Reselect the table viewer to widget selection
852 ISelection sel
= tsfviewer
.getSelectionTrace();
853 if (sel
!= null && !sel
.isEmpty()) {
854 tableViewer
.setSelection(sel
);
861 * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.
862 * ITmfTimeScaleSelectionListener
863 * #tsfTmProcessTimeScaleEvent(org.eclipse.linuxtools
864 * .tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent)
867 public void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event
) {
868 super.tsfTmProcessTimeScaleEvent(event
);
871 private void applyTableLayout(Table table
) {
872 for (int i
= 0; i
< columnNames
.length
; i
++) {
873 TableColumn tableColumn
= new TableColumn(table
, SWT
.LEFT
);
874 tableColumn
.setText(columnNames
[i
]);
877 table
.setHeaderVisible(true);
878 table
.setLinesVisible(true);
885 * org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#displayModel
886 * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.
887 * ITmfTimeAnalysisEntry[], long, long, boolean, long, long,
891 public void displayModel(final ITmfTimeAnalysisEntry
[] items
,
892 final long startBoundTime
, final long endBoundTime
,
893 final boolean updateTimeBounds
, final long startVisibleWindow
,
894 final long endVisibleWindow
, final Object source
) {
896 if(tableViewer
!= null) {
897 final Table table
= tableViewer
.getTable();
899 // Ignore update if widget is disposed
900 if (table
.isDisposed()) return;
902 Display display
= table
.getDisplay();
904 // Perform the updates on the UI thread)
905 display
.asyncExec(new Runnable() {
908 if (!table
.isDisposed()) {
909 tableViewer
.setInput(items
); // This shall be the minimal
911 tableFilter
= new ViewProcessFilter(tableViewer
);
912 tableViewer
.setFilters(new ViewerFilter
[] { tableFilter
});
914 resizeTableColumns(table
);
916 tableViewer
.refresh();
918 tsfviewer
.display(items
, startBoundTime
, endBoundTime
,
921 // validate visible boundaries
922 if (startVisibleWindow
> -1 && endVisibleWindow
> -1) {
923 tsfviewer
.setSelectVisTimeWindow(startVisibleWindow
,
924 endVisibleWindow
, source
);
927 tsfviewer
.resizeControls();
929 // Adjust asynchronously the size of the vertical scroll bar to fit the
931 tableViewer
.getTable().getDisplay().asyncExec(new Runnable() {
934 if ((scrollFrame
!= null) && (!scrollFrame
.isDisposed())) {
935 updateScrolls(scrollFrame
);
946 public void dispose() {
947 // dispose parent resources
950 tsfviewer
.removeFilterSelectionListner(this);
951 tsfviewer
.removeWidgetSelectionListner(this);
952 tsfviewer
.removeWidgetTimeScaleSelectionListner(this);
958 * @param tableComposite
961 private synchronized void resizeTableColumns(Table table
) {
963 Composite parent
= table
.getParent();
964 int tableWidthSum
= parent
.getBorderWidth();
966 TableColumn
[] columns
= table
.getColumns();
967 for (TableColumn column
: columns
) {
969 tableWidthSum
+= column
.getWidth();
975 public void tmfTaProcessFilterSelection(TmfTimeFilterSelectionEvent event
) {
976 if (tableFilter
!= null) {
977 Vector
<ITmfTimeAnalysisEntry
> filteredout
= event
.getFilteredOut();
978 if (filteredout
!= null) {
979 tableFilter
.setFilter(filteredout
);
981 tableFilter
.setFilter(new Vector
<ITmfTimeAnalysisEntry
>());
983 tableViewer
.refresh();
991 private void updateScrolls(final ScrolledComposite scrollFrame
) {
992 scrollFrame
.setMinSize(tableViewer
.getTable().computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
));
996 * Registers as listener of time selection from other views
1002 public void synchToTime(TmfTimeSynchSignal signal
) {
1003 super.synchToTime(signal
);
1007 * Annotation Registers as listener of time range selection from other views
1008 * The implementation handles the entry of the signal.
1013 public void synchToTimeRange(TmfRangeSynchSignal signal
) {
1014 if (zoomFilter
!= null) {
1015 synchToTimeRange(signal
, zoomFilter
.isChecked());
1020 public void modelIncomplete(ILttngSyntEventRequest request
) {
1022 // The data will be refreshed on the next request
1028 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1029 * getEventProcessor()
1032 public ITransEventProcessor
getEventProcessor() {
1033 return FlowEventToHandlerFactory
.getInstance();
1040 public void experimentSelected(
1041 TmfExperimentSelectedSignal
<?
extends TmfEvent
> signal
) {
1042 if (signal
!= null) {
1043 TmfTimeRange experimentTRange
= signal
.getExperiment()
1046 // prepare time intervals in widget
1047 ModelUpdateInit(experimentTRange
, experimentTRange
, signal
1050 // request initial data
1051 initialExperimentDataRequest(signal
1052 .getSource(), experimentTRange
);
1058 * @param experimentTRange
1059 * @return Adjusted time window used for the request (smaller window to
1062 private TmfTimeRange
initialExperimentDataRequest(Object source
,
1063 TmfTimeRange experimentTRange
) {
1064 // Adjust the initial time window to a shorter interval to allow
1065 // user to select the interesting area based on the perspective
1066 TmfTimeRange initTimeWindow
= getInitTRange(experimentTRange
);
1068 dataRequest(initTimeWindow
, experimentTRange
, true, ExecutionType
.FOREGROUND
);
1069 if (TraceDebug
.isDEBUG()) {
1070 TraceDebug
.debug("Initialization request time range is: " //$NON-NLS-1$
1071 + initTimeWindow
.getStartTime().toString() + "-" //$NON-NLS-1$
1072 + initTimeWindow
.getEndTime().toString());
1075 return initTimeWindow
;
1082 public int checkForSWTBugItemHeightAdjustement() {
1083 int returnedAjustement
= 0;
1084 String desktopSessionName
= System
.getenv("DESKTOP_SESSION"); //$NON-NLS-1$
1086 // Gnome : most common case, no adjustement
1087 if ( desktopSessionName
.equals("gnome") ) { //$NON-NLS-1$
1088 returnedAjustement
= 0;
1090 // Kde : ajustement of 2 is needed
1091 else if ( desktopSessionName
.equals("kde") ) { //$NON-NLS-1$
1092 returnedAjustement
= 2;
1095 return returnedAjustement
;
1101 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1102 * getParamsUpdater()
1105 protected ParamsUpdater
getParamsUpdater() {
1106 return FlowModelFactory
.getParamsUpdater();
1112 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1113 * getItemContainer()
1116 protected ItemContainer
<?
> getItemContainer() {
1117 return FlowModelFactory
.getProcContainer();
1122 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#getProviderId()
1125 protected int getProviderId() {
1126 return LttngCoreProviderFactory
.CONTROL_FLOW_LTTNG_SYTH_EVENT_PROVIDER
;