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";
96 // ========================================================================
98 // ========================================================================
99 private final String PROCESS_COLUMN
= "Process";
100 private final String BRAND_COLUMN
= "Brand";
101 private final String PID_COLUMN
= "PID";
102 private final String TGID_COLUMN
= "TGID";
103 private final String PPID_COLUMN
= "PPID";
104 private final String CPU_COLUMN
= "CPU";
105 private final String BIRTH_SEC_COLUMN
= "Birth sec";
106 private final String BIRTH_NSEC_COLUMN
= "Birth nsec";
107 private final String TRACE
= "TRACE";
109 private final String
[] columnNames
= new String
[] { PROCESS_COLUMN
, /* */
115 BIRTH_SEC_COLUMN
,/* */
116 BIRTH_NSEC_COLUMN
,/* */
120 // ========================================================================
122 // ========================================================================
123 private TableViewer tableViewer
;
124 // private int totalNumItems = 0;
126 private Action doubleClickAction
;
127 private Action resetScale
;
128 private Action nextEvent
;
129 private Action prevEvent
;
130 private Action nextTrace
;
131 private Action prevTrace
;
132 private Action showLegend
;
133 private Action filterTraces
;
134 private Action zoomIn
;
135 private Action zoomOut
;
136 private Action zoomFilter
;
138 private ViewProcessFilter tableFilter
= null;
139 private ScrolledComposite scrollFrame
= null;
141 // private static SimpleDateFormat stimeformat = new SimpleDateFormat(
142 // "yy/MM/dd HH:mm:ss");
144 // private TraceModelImplFactory fact;
146 // ========================================================================
148 // ========================================================================
150 * The content provider class is responsible for providing objects to the
151 * view. It can wrap existing objects in adapters or simply return objects
152 * as-is. These objects may be sensitive to the current input of the view,
153 * or ignore it and always show the same content (like Task List, for
157 class ViewContentProvider
implements
158 /* ILazyContentProvider, */IStructuredContentProvider
{
159 private TableViewer cviewer
= null;
160 private ITmfTimeAnalysisEntry
[] elements
= null;
162 public ViewContentProvider(TableViewer v
) {
167 public void inputChanged(Viewer v
, Object oldInput
, Object newInput
) {
168 this.elements
= (ITmfTimeAnalysisEntry
[]) newInput
;
169 if (elements
!= null) {
170 TraceDebug
.debug("Total number of processes provided to Control Flow view: " + elements
.length
);
172 TraceDebug
.debug("New input = null");
177 public void dispose() {
181 // Needed with the use of virtual tables in order to initialize items
182 // which were not initially visible.
183 public void updateElement(int index
) {
184 cviewer
.replace(elements
[index
], index
);
188 public Object
[] getElements(Object inputElement
) {
193 class ViewLabelProvider
extends LabelProvider
implements ITableLabelProvider
{
195 public String
getColumnText(Object obj
, int index
) {
196 String strRes
= ""; //$NON-NLS-1$
198 if (obj
instanceof TimeRangeEventProcess
) {
199 TimeRangeEventProcess process
= (TimeRangeEventProcess
) obj
;
202 strRes
= process
.getName();
205 strRes
= process
.getBrand();
208 strRes
= process
.getPid().toString();
211 strRes
= process
.getTgid().toString();
214 strRes
= process
.getPpid().toString();
217 strRes
= process
.getCpu().toString();
220 time
= new LttngTimestamp(process
.getCreationTime()
222 strRes
= time
.getSeconds();
225 time
= new LttngTimestamp(process
.getCreationTime()
227 strRes
= time
.getNanoSeconds();
230 strRes
= process
.getTraceID();
243 public Image
getColumnImage(Object obj
, int index
) {
244 return getImage(obj
);
248 public Image
getImage(Object obj
) {
249 // No image needed for the time being
250 // return PlatformUI.getWorkbench().getSharedImages().getImage(
251 // ISharedImages.IMG_OBJ_ELEMENT);
256 class ViewProcessFilter
extends ViewerFilter
{
258 private Vector
<ITmfTimeAnalysisEntry
> filteredSet
= new Vector
<ITmfTimeAnalysisEntry
>();
259 StructuredViewer viewer
;
261 public ViewProcessFilter(StructuredViewer rviewer
) {
262 this.viewer
= rviewer
;
265 public void setFilter(Vector
<ITmfTimeAnalysisEntry
> filtered
) {
266 if (filtered
!= null) {
267 this.filteredSet
= filtered
;
273 public boolean select(Viewer viewer
, Object parentElement
,
275 boolean filteredIn
= true;
276 if (element
instanceof ITmfTimeAnalysisEntry
) {
277 ITmfTimeAnalysisEntry process
= (ITmfTimeAnalysisEntry
) element
;
278 if (filteredSet
.contains(process
)) {
279 // The element is marked to be filtered out
283 TraceDebug
.debug("Unexpected type of filter element received: "
284 + element
.toString());
286 // Compare element versus a list of filtered out
294 public ControlFlowView() {
299 * This is a callback that will allow us to create the viewer and initialize
306 * org.eclipse.linuxtools.tmf.ui.views.TmfView#createPartControl(org.eclipse
307 * .swt.widgets.Composite)
310 public void createPartControl(Composite parent
) {
312 scrollFrame
= new ScrolledComposite(parent
, SWT
.V_SCROLL
);
314 scrollFrame
.setExpandVertical(true);
315 scrollFrame
.setExpandHorizontal(true);
316 scrollFrame
.setAlwaysShowScrollBars(true);
318 SashForm sash
= new SashForm(scrollFrame
, SWT
.NONE
);
319 scrollFrame
.setContent(sash
);
321 tableViewer
= new TableViewer(sash
, SWT
.FULL_SELECTION
| SWT
.H_SCROLL
);
322 tableViewer
.setContentProvider(new ViewContentProvider(tableViewer
));
323 tableViewer
.setLabelProvider(new ViewLabelProvider());
324 Table table
= tableViewer
.getTable();
325 tableViewer
.addSelectionChangedListener(new ISelectionChangedListener() {
327 public void selectionChanged(SelectionChangedEvent event
) {
328 ISelection sel
= event
.getSelection();
329 if (!sel
.isEmpty()) {
330 Object firstSel
= null;
331 if (sel
instanceof IStructuredSelection
) {
332 firstSel
= ((IStructuredSelection
) sel
).getFirstElement();
334 // Make sure the selection is visible
335 updateScrollOrigin();
337 if (firstSel
instanceof ITmfTimeAnalysisEntry
) {
338 ITmfTimeAnalysisEntry trace
= (ITmfTimeAnalysisEntry
) firstSel
;
339 tsfviewer
.setSelectedTrace(trace
);
346 * Make sure the selected item is visible
348 private void updateScrollOrigin() {
349 Table table
= tableViewer
.getTable();
350 if (table
!= null && table
.getItemCount() > 0) {
351 TableItem item
= table
.getSelection()[0];
353 // no selected reference to go up or down
357 Rectangle itemRect
= item
.getBounds();
358 int step
= itemRect
.height
;
360 // calculate height of horizontal bar
362 ScrollBar hbar
= scrollFrame
.getHorizontalBar();
364 hscrolly
= hbar
.getSize().y
;
367 int visibleHeight
= scrollFrame
.getSize().y
- hscrolly
;
369 // the current scrollbar offset to adjust i.e. start
371 // the visible window
372 Point origin
= scrollFrame
.getOrigin();
373 // end of visible window
374 int endy
= origin
.y
+ visibleHeight
;
376 int itemStartPos
= itemRect
.y
+ table
.getHeaderHeight() + table
.getBorderWidth()
377 + table
.getParent().getBorderWidth();
380 int itemEndPos
= itemStartPos
+ step
;
382 // check if need to go up
383 if (origin
.y
>= step
&& itemStartPos
< origin
.y
) {
385 scrollFrame
.setOrigin(origin
.x
, origin
.y
- step
);
389 // check if it needs to go down
390 if (itemEndPos
> endy
) {
392 scrollFrame
.setOrigin(origin
.x
, origin
.y
+ step
);
399 // Listen to page up /down and Home / Enc keys
400 tableViewer
.getTable().addKeyListener(new KeyListener() {
402 public void keyPressed(KeyEvent e
) {
403 Table table
= tableViewer
.getTable();
404 Point origin
= scrollFrame
.getOrigin();
405 if (table
== null || table
.getItemCount() < 1) {
415 updateScrollPageDown();
422 count
= table
.getItemCount();
423 item
= table
.getItem(0);
425 scrollFrame
.setOrigin(origin
.x
, 0);
429 count
= table
.getItemCount();
430 item
= table
.getItem(count
- 1);
431 int itemStartPos
= item
.getBounds().y
;
433 scrollFrame
.setOrigin(origin
.x
, itemStartPos
);
441 public void keyReleased(KeyEvent e
) {
447 * Scroll one page down
449 private void updateScrollPageDown() {
450 // null protection before calling private method
451 Table table
= tableViewer
.getTable();
452 int step
= table
.getItemHeight();
455 ScrollBar hbar
= scrollFrame
.getHorizontalBar();
457 hscrolly
= hbar
.getSize().y
;
460 Point origin
= scrollFrame
.getOrigin();
461 int visibleHeight
= scrollFrame
.getSize().y
- hscrolly
;
462 int endy
= origin
.y
+ visibleHeight
;
464 scrollFrame
.setOrigin(origin
.x
, endy
- step
);
470 private void updateScrollUp() {
471 // null protection before calling private method
472 Table table
= tableViewer
.getTable();
473 int step
= table
.getItemHeight();
476 ScrollBar hbar
= scrollFrame
.getHorizontalBar();
478 hscrolly
= hbar
.getSize().y
;
481 Point origin
= scrollFrame
.getOrigin();
482 int visibleHeight
= scrollFrame
.getSize().y
- hscrolly
;
483 int pageUpPos
= origin
.y
- visibleHeight
+ step
;
484 pageUpPos
= pageUpPos
> 0 ? pageUpPos
: 0;
485 scrollFrame
.setOrigin(origin
.x
, pageUpPos
);
490 applyTableLayout(table
);
492 int borderWidth
= table
.getBorderWidth();
494 int itemHeight
= table
.getItemHeight() + checkForSWTBugItemHeightAdjustement();
495 int headerHeight
= table
.getHeaderHeight();
496 table
.getVerticalBar().setVisible(false);
498 tsfviewer
= TmfViewerFactory
.createViewer(sash
,
499 new TimeRangeViewerProvider(getParamsUpdater()));
501 tsfviewer
.addWidgetSelectionListner(this);
502 tsfviewer
.addWidgetTimeScaleSelectionListner(this);
504 // Traces shall not be grouped to allow synchronisation
505 tsfviewer
.groupTraces(false);
506 tsfviewer
.setItemHeight(itemHeight
);
507 tsfviewer
.setBorderWidth(borderWidth
);
508 tsfviewer
.setHeaderHeight(headerHeight
);
509 tsfviewer
.setVisibleVerticalScroll(false);
510 // Names provided by the table
511 tsfviewer
.setNameWidthPref(0);
512 tsfviewer
.setAcceptSelectionAPIcalls(true);
514 // Viewer to notify selection to this class
515 // This class will synchronise selections with table.
516 tsfviewer
.addWidgetSelectionListner(this);
517 tsfviewer
.addFilterSelectionListner(this);
518 tsfviewer
.addWidgetTimeScaleSelectionListner(this);
520 sash
.setWeights(new int[] { 1, 1 });
521 // Create the help context id for the viewer's control
522 // TODO: Associate with help system
523 PlatformUI
.getWorkbench().getHelpSystem().setHelp(
524 tableViewer
.getControl(),
525 "org.eclipse.linuxtools.lttnng.ui.views.flow.viewer"); //$NON-NLS-1$
529 hookDoubleClickAction();
530 contributeToActionBars();
532 // scrollFrame.addControlListener(new ControlAdapter() {
535 // public void controlResized(ControlEvent e) {
536 // tsfviewer.resizeControls();
537 // updateScrolls(scrollFrame);
541 // set the initial view parameter values
542 // Experiment start and end time
543 // as well as time space width in pixels, used by the time analysis
545 // Read relevant values
546 int timeSpaceWidth
= tsfviewer
.getTimeSpace();
547 if (timeSpaceWidth
< 0) {
548 timeSpaceWidth
= -timeSpaceWidth
;
551 TmfExperiment
<?
> experiment
= TmfExperiment
.getCurrentExperiment();
552 if (experiment
!= null) {
553 TmfTimeRange experimentTRange
= experiment
.getTimeRange();
555 // send request and received the adjusted time used
556 TmfTimeRange adjustedTimeRange
= initialExperimentDataRequest(this,
559 // initialize widget time boundaries and filtering parameters
560 ModelUpdateInit(experimentTRange
, adjustedTimeRange
, this);
562 TraceDebug
.debug("No selected experiment information available");
566 private void hookContextMenu() {
567 MenuManager menuMgr
= new MenuManager("#PopupMenu"); //$NON-NLS-1$
568 menuMgr
.setRemoveAllWhenShown(true);
569 menuMgr
.addMenuListener(new IMenuListener() {
571 public void menuAboutToShow(IMenuManager manager
) {
572 ControlFlowView
.this.fillContextMenu(manager
);
575 Menu menu
= menuMgr
.createContextMenu(tableViewer
.getControl());
576 tableViewer
.getControl().setMenu(menu
);
577 getSite().registerContextMenu(menuMgr
, tableViewer
);
580 private void contributeToActionBars() {
581 IActionBars bars
= getViewSite().getActionBars();
582 fillLocalPullDown(bars
.getMenuManager());
583 fillLocalToolBar(bars
.getToolBarManager());
586 private void fillLocalPullDown(IMenuManager manager
) {
587 manager
.add(new Separator());
588 // manager.add(showLegend);
589 manager
.add(new Separator());
590 manager
.add(resetScale
);
591 manager
.add(nextEvent
);
592 manager
.add(prevEvent
);
593 manager
.add(nextTrace
);
594 manager
.add(prevTrace
);
595 // manager.add(filterTraces);
597 manager
.add(zoomOut
);
598 manager
.add(zoomFilter
);
599 manager
.add(new Separator());
602 private void fillContextMenu(IMenuManager manager
) {
603 // manager.add(showLegend);
604 manager
.add(new Separator());
605 manager
.add(resetScale
);
606 manager
.add(nextEvent
);
607 manager
.add(prevEvent
);
608 manager
.add(nextTrace
);
609 manager
.add(prevTrace
);
610 // manager.add(showLegend);
611 // manager.add(filterTraces);
613 manager
.add(zoomOut
);
614 manager
.add(zoomFilter
);
615 manager
.add(new Separator());
616 manager
.add(new Separator(IWorkbenchActionConstants
.MB_ADDITIONS
));
619 private void fillLocalToolBar(IToolBarManager manager
) {
620 // manager.add(showLegend);
621 manager
.add(new Separator());
622 manager
.add(resetScale
);
623 manager
.add(nextEvent
);
624 manager
.add(prevEvent
);
625 manager
.add(nextTrace
);
626 manager
.add(prevTrace
);
627 // manager.add(filterTraces);
629 manager
.add(zoomOut
);
630 manager
.add(zoomFilter
);
631 manager
.add(new Separator());
634 private void makeActions() {
636 resetScale
= new Action() {
639 if (tsfviewer
!= null) {
640 tsfviewer
.resetStartFinishTime();
645 resetScale
.setText(Messages
.getString("ControlFlowView.Action.Reset")); //$NON-NLS-1$
646 resetScale
.setToolTipText(Messages
647 .getString("ControlFlowView.Action.Reset.ToolTip")); //$NON-NLS-1$
648 resetScale
.setImageDescriptor(AbstractUIPlugin
649 .imageDescriptorFromPlugin(Messages
650 .getString("ControlFlowView.tmf.UI"),
651 "icons/home_nav.gif"));
654 nextEvent
= new Action() {
657 if (tsfviewer
!= null) {
658 tsfviewer
.selectNextEvent();
662 nextEvent
.setText(Messages
663 .getString("ControlFlowView.Action.NextEvent")); //$NON-NLS-1$
664 nextEvent
.setToolTipText(Messages
665 .getString("ControlFlowView.Action.NextEvent.Tooltip")); //$NON-NLS-1$
666 nextEvent
.setImageDescriptor(AbstractUIPlugin
667 .imageDescriptorFromPlugin(Messages
668 .getString("ControlFlowView.tmf.UI"),
669 "icons/next_event.gif"));
672 prevEvent
= new Action() {
675 if (tsfviewer
!= null) {
676 tsfviewer
.selectPrevEvent();
680 prevEvent
.setText(Messages
681 .getString("ControlFlowView.Action.PrevEvent")); //$NON-NLS-1$
682 prevEvent
.setToolTipText(Messages
683 .getString("ControlFlowView.Action.PrevEvent.Tooltip")); //$NON-NLS-1$
684 prevEvent
.setImageDescriptor(AbstractUIPlugin
685 .imageDescriptorFromPlugin(Messages
686 .getString("ControlFlowView.tmf.UI"),
687 "icons/prev_event.gif"));
690 nextTrace
= new Action() {
693 if (tsfviewer
!= null) {
694 tsfviewer
.selectNextTrace();
698 nextTrace
.setText(Messages
699 .getString("ControlFlowView.Action.NextProcess")); //$NON-NLS-1$
700 nextTrace
.setToolTipText(Messages
701 .getString("ControlFlowView.Action.NextProcess.ToolTip")); //$NON-NLS-1$
702 nextTrace
.setImageDescriptor(AbstractUIPlugin
703 .imageDescriptorFromPlugin(Messages
704 .getString("ControlFlowView.tmf.UI"),
705 "icons/next_item.gif"));
708 prevTrace
= new Action() {
711 if (tsfviewer
!= null) {
712 tsfviewer
.selectPrevTrace();
716 prevTrace
.setText(Messages
717 .getString("ControlFlowView.Action.PreviousProcess")); //$NON-NLS-1$
718 prevTrace
.setToolTipText(Messages
719 .getString("ControlFlowView.Action.PreviousProcess.Tooltip")); //$NON-NLS-1$
720 prevTrace
.setImageDescriptor(AbstractUIPlugin
721 .imageDescriptorFromPlugin(Messages
722 .getString("ControlFlowView.tmf.UI"),
723 "icons/prev_item.gif"));
726 showLegend
= new Action() {
729 if (tsfviewer
!= null) {
730 tsfviewer
.showLegend();
734 showLegend
.setText(Messages
.getString("ControlFlowView.Action.Legend")); //$NON-NLS-1$
735 showLegend
.setToolTipText(Messages
736 .getString("ControlFlowView.Action.Legend.ToolTip")); //$NON-NLS-1$
739 filterTraces
= new Action() {
742 if (tsfviewer
!= null) {
743 tsfviewer
.filterTraces();
747 filterTraces
.setText(Messages
748 .getString("ControlFlowView.Action.Filter")); //$NON-NLS-1$
749 filterTraces
.setToolTipText(Messages
750 .getString("ControlFlowView.Action.Filter.ToolTip")); //$NON-NLS-1$
751 filterTraces
.setImageDescriptor(AbstractUIPlugin
752 .imageDescriptorFromPlugin(Messages
753 .getString("ControlFlowView.tmf.UI"),
754 "icons/filter_items.gif"));
757 zoomIn
= new Action() {
760 if (tsfviewer
!= null) {
765 zoomIn
.setText(Messages
.getString("ControlFlowView.Action.ZoomIn")); //$NON-NLS-1$
766 zoomIn
.setToolTipText(Messages
767 .getString("ControlFlowView.Action.ZoomIn.Tooltip")); //$NON-NLS-1$
768 zoomIn
.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(
769 Messages
.getString("ControlFlowView.tmf.UI"),
770 "icons/zoomin_nav.gif"));
773 zoomOut
= new Action() {
776 if (tsfviewer
!= null) {
781 zoomOut
.setText(Messages
.getString("ControlFlowView.Action.ZoomOut")); //$NON-NLS-1$
782 zoomOut
.setToolTipText(Messages
783 .getString("ControlFlowView.Action.ZoomOut.tooltip")); //$NON-NLS-1$
784 zoomOut
.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(
785 Messages
.getString("ControlFlowView.tmf.UI"),
786 "icons/zoomout_nav.gif"));
789 zoomFilter
= new Action() {
792 // Nothing to do, however the selection status is needed by the
796 zoomFilter
.setText(Messages
797 .getString("ControlFlowView.Action.ZoomFilter")); //$NON-NLS-1$
798 zoomFilter
.setToolTipText(Messages
799 .getString("ControlFlowView.Action.ZoomFilter.tooltip")); //$NON-NLS-1$
800 zoomFilter
.setImageDescriptor(AbstractUIPlugin
801 .imageDescriptorFromPlugin(Messages
802 .getString("ControlFlowView.tmf.UI"),
803 "icons/filter_items.gif"));
804 zoomFilter
.setChecked(false);
806 // PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_SYNCED);
808 doubleClickAction
= new Action() {
811 ISelection selection
= tableViewer
.getSelection();
812 Object obj
= ((IStructuredSelection
) selection
)
814 showMessage("Double-click detected on " + obj
.toString()); //$NON-NLS-1$
819 private void hookDoubleClickAction() {
820 tableViewer
.addDoubleClickListener(new IDoubleClickListener() {
822 public void doubleClick(DoubleClickEvent event
) {
823 doubleClickAction
.run();
828 private void showMessage(String message
) {
829 MessageDialog
.openInformation(tableViewer
.getControl().getShell(),
830 Messages
.getString("ControlFlowView.msgSlogan"), message
); //$NON-NLS-1$
834 * Passing the focus request to the viewer's control.
837 public void setFocus() {
838 tableViewer
.getControl().setFocus();
844 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
845 * tsfTmProcessSelEvent
846 * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent
850 public void tsfTmProcessSelEvent(TmfTimeSelectionEvent event
) {
851 // common implementation
852 super.tsfTmProcessSelEvent(event
);
854 // Reselect the table viewer to widget selection
855 ISelection sel
= tsfviewer
.getSelectionTrace();
856 if (sel
!= null && !sel
.isEmpty()) {
857 tableViewer
.setSelection(sel
);
864 * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.
865 * ITmfTimeScaleSelectionListener
866 * #tsfTmProcessTimeScaleEvent(org.eclipse.linuxtools
867 * .tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent)
870 public void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event
) {
871 super.tsfTmProcessTimeScaleEvent(event
);
874 private void applyTableLayout(Table table
) {
875 for (int i
= 0; i
< columnNames
.length
; i
++) {
876 TableColumn tableColumn
= new TableColumn(table
, SWT
.LEFT
);
877 tableColumn
.setText(columnNames
[i
]);
880 table
.setHeaderVisible(true);
881 table
.setLinesVisible(true);
888 * org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#displayModel
889 * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.
890 * ITmfTimeAnalysisEntry[], long, long, boolean, long, long,
894 public void displayModel(final ITmfTimeAnalysisEntry
[] items
,
895 final long startBoundTime
, final long endBoundTime
,
896 final boolean updateTimeBounds
, final long startVisibleWindow
,
897 final long endVisibleWindow
, final Object source
) {
899 if(tableViewer
!= null) {
900 final Table table
= tableViewer
.getTable();
902 // Ignore update if widget is disposed
903 if (table
.isDisposed()) return;
905 Display display
= table
.getDisplay();
907 // Perform the updates on the UI thread)
908 display
.asyncExec(new Runnable() {
911 if (!table
.isDisposed()) {
912 tableViewer
.setInput(items
); // This shall be the minimal
914 tableFilter
= new ViewProcessFilter(tableViewer
);
915 tableViewer
.setFilters(new ViewerFilter
[] { tableFilter
});
917 resizeTableColumns(table
);
919 tableViewer
.refresh();
921 tsfviewer
.display(items
, startBoundTime
, endBoundTime
,
924 // validate visible boundaries
925 if (startVisibleWindow
> -1 && endVisibleWindow
> -1) {
926 tsfviewer
.setSelectVisTimeWindow(startVisibleWindow
,
927 endVisibleWindow
, source
);
930 tsfviewer
.resizeControls();
932 // Adjust the size of the vertical scroll bar to fit the
934 if (scrollFrame
!= null) {
935 updateScrolls(scrollFrame
);
944 public void dispose() {
945 // dispose parent resources
948 tsfviewer
.removeFilterSelectionListner(this);
949 tsfviewer
.removeWidgetSelectionListner(this);
950 tsfviewer
.removeWidgetTimeScaleSelectionListner(this);
956 * @param tableComposite
959 private synchronized void resizeTableColumns(Table table
) {
961 Composite parent
= table
.getParent();
962 int tableWidthSum
= parent
.getBorderWidth();
964 TableColumn
[] columns
= table
.getColumns();
965 for (TableColumn column
: columns
) {
967 tableWidthSum
+= column
.getWidth();
973 public void tmfTaProcessFilterSelection(TmfTimeFilterSelectionEvent event
) {
974 if (tableFilter
!= null) {
975 Vector
<ITmfTimeAnalysisEntry
> filteredout
= event
.getFilteredOut();
976 if (filteredout
!= null) {
977 tableFilter
.setFilter(filteredout
);
979 tableFilter
.setFilter(new Vector
<ITmfTimeAnalysisEntry
>());
981 tableViewer
.refresh();
989 private void updateScrolls(final ScrolledComposite scrollFrame
) {
990 scrollFrame
.setMinSize(tableViewer
.getTable().computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
));
994 * Registers as listener of time selection from other views
1000 public void synchToTime(TmfTimeSynchSignal signal
) {
1001 super.synchToTime(signal
);
1005 * Annotation Registers as listener of time range selection from other views
1006 * The implementation handles the entry of the signal.
1011 public void synchToTimeRange(TmfRangeSynchSignal signal
) {
1012 if (zoomFilter
!= null) {
1013 synchToTimeRange(signal
, zoomFilter
.isChecked());
1018 public void modelIncomplete(ILttngSyntEventRequest request
) {
1020 // The data will be refreshed on the next request
1026 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1027 * getEventProcessor()
1030 public ITransEventProcessor
getEventProcessor() {
1031 return FlowEventToHandlerFactory
.getInstance();
1038 public void experimentSelected(
1039 TmfExperimentSelectedSignal
<?
extends TmfEvent
> signal
) {
1040 if (signal
!= null) {
1041 TmfTimeRange experimentTRange
= signal
.getExperiment()
1044 // prepare time intervals in widget
1045 ModelUpdateInit(experimentTRange
, experimentTRange
, signal
1048 // request initial data
1049 initialExperimentDataRequest(signal
1050 .getSource(), experimentTRange
);
1056 * @param experimentTRange
1057 * @return Adjusted time window used for the request (smaller window to
1060 private TmfTimeRange
initialExperimentDataRequest(Object source
,
1061 TmfTimeRange experimentTRange
) {
1062 // Adjust the initial time window to a shorter interval to allow
1063 // user to select the interesting area based on the perspective
1064 TmfTimeRange initTimeWindow
= getInitTRange(experimentTRange
);
1066 dataRequest(initTimeWindow
, experimentTRange
, true, ExecutionType
.FOREGROUND
);
1067 if (TraceDebug
.isDEBUG()) {
1068 TraceDebug
.debug("Initialization request time range is: "
1069 + initTimeWindow
.getStartTime().toString() + "-"
1070 + initTimeWindow
.getEndTime().toString());
1073 return initTimeWindow
;
1080 public int checkForSWTBugItemHeightAdjustement() {
1081 int returnedAjustement
= 0;
1082 String desktopSessionName
= System
.getenv("DESKTOP_SESSION");
1084 // Gnome : most common case, no adjustement
1085 if ( desktopSessionName
.equals("gnome") ) {
1086 returnedAjustement
= 0;
1088 // Kde : ajustement of 2 is needed
1089 else if ( desktopSessionName
.equals("kde") ) {
1090 returnedAjustement
= 2;
1093 return returnedAjustement
;
1099 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1100 * getParamsUpdater()
1103 protected ParamsUpdater
getParamsUpdater() {
1104 return FlowModelFactory
.getParamsUpdater();
1110 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1111 * getItemContainer()
1114 protected ItemContainer
<?
> getItemContainer() {
1115 return FlowModelFactory
.getProcContainer();
1120 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#getProviderId()
1123 protected int getProviderId() {
1124 return LttngCoreProviderFactory
.CONTROL_FLOW_LTTNG_SYTH_EVENT_PROVIDER
;