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
.event
.LttngTimestamp
;
36 import org
.eclipse
.linuxtools
.lttng
.request
.ILttngSyntEventRequest
;
37 import org
.eclipse
.linuxtools
.lttng
.state
.evProcessor
.ITransEventProcessor
;
38 import org
.eclipse
.linuxtools
.lttng
.ui
.TraceDebug
;
39 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.ItemContainer
;
40 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.TimeRangeEventProcess
;
41 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.TimeRangeViewerProvider
;
42 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.common
.AbsTimeUpdateView
;
43 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.common
.ParamsUpdater
;
44 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.controlflow
.evProcessor
.FlowEventToHandlerFactory
;
45 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.controlflow
.model
.FlowModelFactory
;
46 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
47 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimeRange
;
48 import org
.eclipse
.linuxtools
.tmf
.experiment
.TmfExperiment
;
49 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfExperimentSelectedSignal
;
50 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfRangeSynchSignal
;
51 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfSignalHandler
;
52 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfTimeSynchSignal
;
53 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.TmfViewerFactory
;
54 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.ITmfTimeFilterSelectionListener
;
55 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.ITmfTimeScaleSelectionListener
;
56 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.ITmfTimeSelectionListener
;
57 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.TmfTimeFilterSelectionEvent
;
58 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.TmfTimeScaleSelectionEvent
;
59 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.TmfTimeSelectionEvent
;
60 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.model
.ITmfTimeAnalysisEntry
;
61 import org
.eclipse
.swt
.SWT
;
62 import org
.eclipse
.swt
.custom
.SashForm
;
63 import org
.eclipse
.swt
.custom
.ScrolledComposite
;
64 import org
.eclipse
.swt
.events
.KeyEvent
;
65 import org
.eclipse
.swt
.events
.KeyListener
;
66 import org
.eclipse
.swt
.graphics
.Image
;
67 import org
.eclipse
.swt
.graphics
.Point
;
68 import org
.eclipse
.swt
.graphics
.Rectangle
;
69 import org
.eclipse
.swt
.widgets
.Composite
;
70 import org
.eclipse
.swt
.widgets
.Display
;
71 import org
.eclipse
.swt
.widgets
.Menu
;
72 import org
.eclipse
.swt
.widgets
.ScrollBar
;
73 import org
.eclipse
.swt
.widgets
.Table
;
74 import org
.eclipse
.swt
.widgets
.TableColumn
;
75 import org
.eclipse
.swt
.widgets
.TableItem
;
76 import org
.eclipse
.ui
.IActionBars
;
77 import org
.eclipse
.ui
.IWorkbenchActionConstants
;
78 import org
.eclipse
.ui
.PlatformUI
;
79 import org
.eclipse
.ui
.plugin
.AbstractUIPlugin
;
82 * <b><u>ControlFlowView</u></b>
88 public class ControlFlowView
extends AbsTimeUpdateView
implements
89 ITmfTimeSelectionListener
, ITmfTimeScaleSelectionListener
,
90 ITmfTimeFilterSelectionListener
{
92 public static final String ID
= "org.eclipse.linuxtools.lttng.ui.views.controlflow";
94 // ========================================================================
96 // ========================================================================
97 private final String PROCESS_COLUMN
= "Process";
98 private final String BRAND_COLUMN
= "Brand";
99 private final String PID_COLUMN
= "PID";
100 private final String TGID_COLUMN
= "TGID";
101 private final String PPID_COLUMN
= "PPID";
102 private final String CPU_COLUMN
= "CPU";
103 private final String BIRTH_SEC_COLUMN
= "Birth sec";
104 private final String BIRTH_NSEC_COLUMN
= "Birth nsec";
105 private final String TRACE
= "TRACE";
107 private final String
[] columnNames
= new String
[] { PROCESS_COLUMN
, /* */
113 BIRTH_SEC_COLUMN
,/* */
114 BIRTH_NSEC_COLUMN
,/* */
118 // ========================================================================
120 // ========================================================================
121 private TableViewer tableViewer
;
122 // private int totalNumItems = 0;
124 private Action doubleClickAction
;
125 private Action resetScale
;
126 private Action nextEvent
;
127 private Action prevEvent
;
128 private Action nextTrace
;
129 private Action prevTrace
;
130 private Action showLegend
;
131 private Action filterTraces
;
132 private Action zoomIn
;
133 private Action zoomOut
;
134 private Action zoomFilter
;
136 private ViewProcessFilter tableFilter
= null;
137 private ScrolledComposite scrollFrame
= null;
139 // private static SimpleDateFormat stimeformat = new SimpleDateFormat(
140 // "yy/MM/dd HH:mm:ss");
142 // private TraceModelImplFactory fact;
144 // ========================================================================
146 // ========================================================================
148 * The content provider class is responsible for providing objects to the
149 * view. It can wrap existing objects in adapters or simply return objects
150 * as-is. These objects may be sensitive to the current input of the view,
151 * or ignore it and always show the same content (like Task List, for
155 class ViewContentProvider
implements
156 /* ILazyContentProvider, */IStructuredContentProvider
{
157 private TableViewer cviewer
= null;
158 private ITmfTimeAnalysisEntry
[] elements
= null;
160 public ViewContentProvider(TableViewer v
) {
164 public void inputChanged(Viewer v
, Object oldInput
, Object newInput
) {
165 this.elements
= (ITmfTimeAnalysisEntry
[]) newInput
;
166 if (elements
!= null) {
167 TraceDebug
.debug("Total number of processes provided to Control Flow view: " + elements
.length
);
169 TraceDebug
.debug("New input = null");
173 public void dispose() {
177 // Needed with the use of virtual tables in order to initialize items
178 // which were not initially visible.
179 public void updateElement(int index
) {
180 cviewer
.replace(elements
[index
], index
);
184 public Object
[] getElements(Object inputElement
) {
189 class ViewLabelProvider
extends LabelProvider
implements
190 ITableLabelProvider
{
191 public String
getColumnText(Object obj
, int index
) {
192 String strRes
= ""; //$NON-NLS-1$
194 if (obj
instanceof TimeRangeEventProcess
) {
195 TimeRangeEventProcess process
= (TimeRangeEventProcess
) obj
;
198 strRes
= process
.getName();
201 strRes
= process
.getBrand();
204 strRes
= process
.getPid().toString();
207 strRes
= process
.getTgid().toString();
210 strRes
= process
.getPpid().toString();
213 strRes
= process
.getCpu().toString();
216 time
= new LttngTimestamp(process
.getCreationTime()
218 strRes
= time
.getSeconds();
221 time
= new LttngTimestamp(process
.getCreationTime()
223 strRes
= time
.getNanoSeconds();
226 strRes
= process
.getTraceID();
238 public Image
getColumnImage(Object obj
, int index
) {
239 return getImage(obj
);
243 public Image
getImage(Object obj
) {
244 // No image needed for the time being
245 // return PlatformUI.getWorkbench().getSharedImages().getImage(
246 // ISharedImages.IMG_OBJ_ELEMENT);
251 class ViewProcessFilter
extends ViewerFilter
{
253 private Vector
<ITmfTimeAnalysisEntry
> filteredSet
= new Vector
<ITmfTimeAnalysisEntry
>();
254 StructuredViewer viewer
;
256 public ViewProcessFilter(StructuredViewer rviewer
) {
257 this.viewer
= rviewer
;
260 public void setFilter(Vector
<ITmfTimeAnalysisEntry
> filtered
) {
261 if (filtered
!= null) {
262 this.filteredSet
= filtered
;
268 public boolean select(Viewer viewer
, Object parentElement
,
270 boolean filteredIn
= true;
271 if (element
instanceof ITmfTimeAnalysisEntry
) {
272 ITmfTimeAnalysisEntry process
= (ITmfTimeAnalysisEntry
) element
;
273 if (filteredSet
.contains(process
)) {
274 // The element is marked to be filtered out
278 TraceDebug
.debug("Unexpected type of filter element received: "
279 + element
.toString());
281 // Compare element versus a list of filtered out
289 public ControlFlowView() {
294 * This is a callback that will allow us to create the viewer and initialize
301 * org.eclipse.linuxtools.tmf.ui.views.TmfView#createPartControl(org.eclipse
302 * .swt.widgets.Composite)
305 public void createPartControl(Composite parent
) {
307 scrollFrame
= new ScrolledComposite(parent
, SWT
.V_SCROLL
);
309 scrollFrame
.setExpandVertical(true);
310 scrollFrame
.setExpandHorizontal(true);
311 scrollFrame
.setAlwaysShowScrollBars(true);
313 SashForm sash
= new SashForm(scrollFrame
, SWT
.NONE
);
314 scrollFrame
.setContent(sash
);
316 tableViewer
= new TableViewer(sash
, SWT
.FULL_SELECTION
| SWT
.H_SCROLL
);
317 tableViewer
.setContentProvider(new ViewContentProvider(tableViewer
));
318 tableViewer
.setLabelProvider(new ViewLabelProvider());
319 Table table
= tableViewer
.getTable();
320 tableViewer
.addSelectionChangedListener(new ISelectionChangedListener() {
321 public void selectionChanged(SelectionChangedEvent event
) {
322 ISelection sel
= event
.getSelection();
323 if (!sel
.isEmpty()) {
324 Object firstSel
= null;
325 if (sel
instanceof IStructuredSelection
) {
326 firstSel
= ((IStructuredSelection
) sel
).getFirstElement();
328 // Make sure the selection is visible
329 updateScrollOrigin();
331 if (firstSel
instanceof ITmfTimeAnalysisEntry
) {
332 ITmfTimeAnalysisEntry trace
= (ITmfTimeAnalysisEntry
) firstSel
;
333 tsfviewer
.setSelectedTrace(trace
);
340 * Make sure the selected item is visible
342 private void updateScrollOrigin() {
343 Table table
= tableViewer
.getTable();
344 if (table
!= null && table
.getItemCount() > 0) {
345 TableItem item
= table
.getSelection()[0];
347 // no selected reference to go up or down
351 Rectangle itemRect
= item
.getBounds();
352 int step
= itemRect
.height
;
354 // calculate height of horizontal bar
356 ScrollBar hbar
= scrollFrame
.getHorizontalBar();
358 hscrolly
= hbar
.getSize().y
;
361 int visibleHeight
= scrollFrame
.getSize().y
- hscrolly
;
363 // the current scrollbar offset to adjust i.e. start
365 // the visible window
366 Point origin
= scrollFrame
.getOrigin();
367 // end of visible window
368 int endy
= origin
.y
+ visibleHeight
;
370 int itemStartPos
= itemRect
.y
+ table
.getHeaderHeight() + table
.getBorderWidth()
371 + table
.getParent().getBorderWidth();
374 int itemEndPos
= itemStartPos
+ step
;
376 // check if need to go up
377 if (origin
.y
>= step
&& itemStartPos
< origin
.y
) {
379 scrollFrame
.setOrigin(origin
.x
, origin
.y
- step
);
383 // check if it needs to go down
384 if (itemEndPos
> endy
) {
386 scrollFrame
.setOrigin(origin
.x
, origin
.y
+ step
);
393 // Listen to page up /down and Home / Enc keys
394 tableViewer
.getTable().addKeyListener(new KeyListener() {
395 public void keyPressed(KeyEvent e
) {
396 Table table
= tableViewer
.getTable();
397 Point origin
= scrollFrame
.getOrigin();
398 if (table
== null || table
.getItemCount() < 1) {
408 updateScrollPageDown();
415 count
= table
.getItemCount();
416 item
= table
.getItem(0);
418 scrollFrame
.setOrigin(origin
.x
, 0);
422 count
= table
.getItemCount();
423 item
= table
.getItem(count
- 1);
424 int itemStartPos
= item
.getBounds().y
;
426 scrollFrame
.setOrigin(origin
.x
, itemStartPos
);
433 public void keyReleased(KeyEvent e
) {
439 * Scroll one page down
441 private void updateScrollPageDown() {
442 // null protection before calling private method
443 Table table
= tableViewer
.getTable();
444 int step
= table
.getItemHeight();
447 ScrollBar hbar
= scrollFrame
.getHorizontalBar();
449 hscrolly
= hbar
.getSize().y
;
452 Point origin
= scrollFrame
.getOrigin();
453 int visibleHeight
= scrollFrame
.getSize().y
- hscrolly
;
454 int endy
= origin
.y
+ visibleHeight
;
456 scrollFrame
.setOrigin(origin
.x
, endy
- step
);
462 private void updateScrollUp() {
463 // null protection before calling private method
464 Table table
= tableViewer
.getTable();
465 int step
= table
.getItemHeight();
468 ScrollBar hbar
= scrollFrame
.getHorizontalBar();
470 hscrolly
= hbar
.getSize().y
;
473 Point origin
= scrollFrame
.getOrigin();
474 int visibleHeight
= scrollFrame
.getSize().y
- hscrolly
;
475 int pageUpPos
= origin
.y
- visibleHeight
+ step
;
476 pageUpPos
= pageUpPos
> 0 ? pageUpPos
: 0;
477 scrollFrame
.setOrigin(origin
.x
, pageUpPos
);
482 applyTableLayout(table
);
484 int borderWidth
= table
.getBorderWidth();
486 int itemHeight
= table
.getItemHeight() + checkForSWTBugItemHeightAdjustement();
487 int headerHeight
= table
.getHeaderHeight();
488 table
.getVerticalBar().setVisible(false);
490 tsfviewer
= TmfViewerFactory
.createViewer(sash
,
491 new TimeRangeViewerProvider());
493 tsfviewer
.addWidgetSelectionListner(this);
494 tsfviewer
.addWidgetTimeScaleSelectionListner(this);
496 // Traces shall not be grouped to allow synchronisation
497 tsfviewer
.groupTraces(false);
498 tsfviewer
.setItemHeight(itemHeight
);
499 tsfviewer
.setBorderWidth(borderWidth
);
500 tsfviewer
.setHeaderHeight(headerHeight
);
501 tsfviewer
.setVisibleVerticalScroll(false);
502 // Names provided by the table
503 tsfviewer
.setNameWidthPref(0);
504 tsfviewer
.setAcceptSelectionAPIcalls(true);
506 // Viewer to notify selection to this class
507 // This class will synchronise selections with table.
508 tsfviewer
.addWidgetSelectionListner(this);
509 tsfviewer
.addFilterSelectionListner(this);
510 tsfviewer
.addWidgetTimeScaleSelectionListner(this);
512 sash
.setWeights(new int[] { 1, 1 });
513 // Create the help context id for the viewer's control
514 // TODO: Associate with help system
515 PlatformUI
.getWorkbench().getHelpSystem().setHelp(
516 tableViewer
.getControl(),
517 "org.eclipse.linuxtools.lttnng.ui.views.flow.viewer"); //$NON-NLS-1$
521 hookDoubleClickAction();
522 contributeToActionBars();
524 // scrollFrame.addControlListener(new ControlAdapter() {
527 // public void controlResized(ControlEvent e) {
528 // tsfviewer.resizeControls();
529 // updateScrolls(scrollFrame);
533 // set the initial view parameter values
534 // Experiment start and end time
535 // as well as time space width in pixels, used by the time analysis
537 // Read relevant values
538 int timeSpaceWidth
= tsfviewer
.getTimeSpace();
539 if (timeSpaceWidth
< 0) {
540 timeSpaceWidth
= -timeSpaceWidth
;
543 TmfExperiment
<?
> experiment
= TmfExperiment
.getCurrentExperiment();
544 if (experiment
!= null) {
545 TmfTimeRange experimentTRange
= experiment
.getTimeRange();
547 // send request and received the adjusted time used
548 TmfTimeRange adjustedTimeRange
= initialExperimentDataRequest(this,
551 // initialize widget time boundaries and filtering parameters
552 ModelUpdateInit(experimentTRange
, adjustedTimeRange
, this);
554 TraceDebug
.debug("No selected experiment information available");
558 private void hookContextMenu() {
559 MenuManager menuMgr
= new MenuManager("#PopupMenu"); //$NON-NLS-1$
560 menuMgr
.setRemoveAllWhenShown(true);
561 menuMgr
.addMenuListener(new IMenuListener() {
562 public void menuAboutToShow(IMenuManager manager
) {
563 ControlFlowView
.this.fillContextMenu(manager
);
566 Menu menu
= menuMgr
.createContextMenu(tableViewer
.getControl());
567 tableViewer
.getControl().setMenu(menu
);
568 getSite().registerContextMenu(menuMgr
, tableViewer
);
571 private void contributeToActionBars() {
572 IActionBars bars
= getViewSite().getActionBars();
573 fillLocalPullDown(bars
.getMenuManager());
574 fillLocalToolBar(bars
.getToolBarManager());
577 private void fillLocalPullDown(IMenuManager manager
) {
578 manager
.add(new Separator());
579 // manager.add(showLegend);
580 manager
.add(new Separator());
581 manager
.add(resetScale
);
582 manager
.add(nextEvent
);
583 manager
.add(prevEvent
);
584 manager
.add(nextTrace
);
585 manager
.add(prevTrace
);
586 // manager.add(filterTraces);
588 manager
.add(zoomOut
);
589 manager
.add(zoomFilter
);
590 manager
.add(new Separator());
593 private void fillContextMenu(IMenuManager manager
) {
594 // manager.add(showLegend);
595 manager
.add(new Separator());
596 manager
.add(resetScale
);
597 manager
.add(nextEvent
);
598 manager
.add(prevEvent
);
599 manager
.add(nextTrace
);
600 manager
.add(prevTrace
);
601 // manager.add(showLegend);
602 // manager.add(filterTraces);
604 manager
.add(zoomOut
);
605 manager
.add(zoomFilter
);
606 manager
.add(new Separator());
607 manager
.add(new Separator(IWorkbenchActionConstants
.MB_ADDITIONS
));
610 private void fillLocalToolBar(IToolBarManager manager
) {
611 // manager.add(showLegend);
612 manager
.add(new Separator());
613 manager
.add(resetScale
);
614 manager
.add(nextEvent
);
615 manager
.add(prevEvent
);
616 manager
.add(nextTrace
);
617 manager
.add(prevTrace
);
618 // manager.add(filterTraces);
620 manager
.add(zoomOut
);
621 manager
.add(zoomFilter
);
622 manager
.add(new Separator());
625 private void makeActions() {
627 resetScale
= new Action() {
630 if (tsfviewer
!= null) {
631 tsfviewer
.resetStartFinishTime();
636 resetScale
.setText(Messages
.getString("ControlFlowView.Action.Reset")); //$NON-NLS-1$
637 resetScale
.setToolTipText(Messages
638 .getString("ControlFlowView.Action.Reset.ToolTip")); //$NON-NLS-1$
639 resetScale
.setImageDescriptor(AbstractUIPlugin
640 .imageDescriptorFromPlugin(Messages
641 .getString("ControlFlowView.tmf.UI"),
642 "icons/home_nav.gif"));
645 nextEvent
= new Action() {
648 if (tsfviewer
!= null) {
649 tsfviewer
.selectNextEvent();
653 nextEvent
.setText(Messages
654 .getString("ControlFlowView.Action.NextEvent")); //$NON-NLS-1$
655 nextEvent
.setToolTipText(Messages
656 .getString("ControlFlowView.Action.NextEvent.Tooltip")); //$NON-NLS-1$
657 nextEvent
.setImageDescriptor(AbstractUIPlugin
658 .imageDescriptorFromPlugin(Messages
659 .getString("ControlFlowView.tmf.UI"),
660 "icons/next_event.gif"));
663 prevEvent
= new Action() {
666 if (tsfviewer
!= null) {
667 tsfviewer
.selectPrevEvent();
671 prevEvent
.setText(Messages
672 .getString("ControlFlowView.Action.PrevEvent")); //$NON-NLS-1$
673 prevEvent
.setToolTipText(Messages
674 .getString("ControlFlowView.Action.PrevEvent.Tooltip")); //$NON-NLS-1$
675 prevEvent
.setImageDescriptor(AbstractUIPlugin
676 .imageDescriptorFromPlugin(Messages
677 .getString("ControlFlowView.tmf.UI"),
678 "icons/prev_event.gif"));
681 nextTrace
= new Action() {
684 if (tsfviewer
!= null) {
685 tsfviewer
.selectNextTrace();
689 nextTrace
.setText(Messages
690 .getString("ControlFlowView.Action.NextProcess")); //$NON-NLS-1$
691 nextTrace
.setToolTipText(Messages
692 .getString("ControlFlowView.Action.NextProcess.ToolTip")); //$NON-NLS-1$
693 nextTrace
.setImageDescriptor(AbstractUIPlugin
694 .imageDescriptorFromPlugin(Messages
695 .getString("ControlFlowView.tmf.UI"),
696 "icons/next_item.gif"));
699 prevTrace
= new Action() {
702 if (tsfviewer
!= null) {
703 tsfviewer
.selectPrevTrace();
707 prevTrace
.setText(Messages
708 .getString("ControlFlowView.Action.PreviousProcess")); //$NON-NLS-1$
709 prevTrace
.setToolTipText(Messages
710 .getString("ControlFlowView.Action.PreviousProcess.Tooltip")); //$NON-NLS-1$
711 prevTrace
.setImageDescriptor(AbstractUIPlugin
712 .imageDescriptorFromPlugin(Messages
713 .getString("ControlFlowView.tmf.UI"),
714 "icons/prev_item.gif"));
717 showLegend
= new Action() {
720 if (tsfviewer
!= null) {
721 tsfviewer
.showLegend();
725 showLegend
.setText(Messages
.getString("ControlFlowView.Action.Legend")); //$NON-NLS-1$
726 showLegend
.setToolTipText(Messages
727 .getString("ControlFlowView.Action.Legend.ToolTip")); //$NON-NLS-1$
730 filterTraces
= new Action() {
733 if (tsfviewer
!= null) {
734 tsfviewer
.filterTraces();
738 filterTraces
.setText(Messages
739 .getString("ControlFlowView.Action.Filter")); //$NON-NLS-1$
740 filterTraces
.setToolTipText(Messages
741 .getString("ControlFlowView.Action.Filter.ToolTip")); //$NON-NLS-1$
742 filterTraces
.setImageDescriptor(AbstractUIPlugin
743 .imageDescriptorFromPlugin(Messages
744 .getString("ControlFlowView.tmf.UI"),
745 "icons/filter_items.gif"));
748 zoomIn
= new Action() {
751 if (tsfviewer
!= null) {
756 zoomIn
.setText(Messages
.getString("ControlFlowView.Action.ZoomIn")); //$NON-NLS-1$
757 zoomIn
.setToolTipText(Messages
758 .getString("ControlFlowView.Action.ZoomIn.Tooltip")); //$NON-NLS-1$
759 zoomIn
.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(
760 Messages
.getString("ControlFlowView.tmf.UI"),
761 "icons/zoomin_nav.gif"));
764 zoomOut
= new Action() {
767 if (tsfviewer
!= null) {
772 zoomOut
.setText(Messages
.getString("ControlFlowView.Action.ZoomOut")); //$NON-NLS-1$
773 zoomOut
.setToolTipText(Messages
774 .getString("ControlFlowView.Action.ZoomOut.tooltip")); //$NON-NLS-1$
775 zoomOut
.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(
776 Messages
.getString("ControlFlowView.tmf.UI"),
777 "icons/zoomout_nav.gif"));
780 zoomFilter
= new Action() {
783 // Nothing to do, however the selection status is needed by the
787 zoomFilter
.setText(Messages
788 .getString("ControlFlowView.Action.ZoomFilter")); //$NON-NLS-1$
789 zoomFilter
.setToolTipText(Messages
790 .getString("ControlFlowView.Action.ZoomFilter.tooltip")); //$NON-NLS-1$
791 zoomFilter
.setImageDescriptor(AbstractUIPlugin
792 .imageDescriptorFromPlugin(Messages
793 .getString("ControlFlowView.tmf.UI"),
794 "icons/filter_items.gif"));
795 zoomFilter
.setChecked(false);
797 // PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_SYNCED);
799 doubleClickAction
= new Action() {
802 ISelection selection
= tableViewer
.getSelection();
803 Object obj
= ((IStructuredSelection
) selection
)
805 showMessage("Double-click detected on " + obj
.toString()); //$NON-NLS-1$
810 private void hookDoubleClickAction() {
811 tableViewer
.addDoubleClickListener(new IDoubleClickListener() {
812 public void doubleClick(DoubleClickEvent event
) {
813 doubleClickAction
.run();
818 private void showMessage(String message
) {
819 MessageDialog
.openInformation(tableViewer
.getControl().getShell(),
820 Messages
.getString("ControlFlowView.msgSlogan"), message
); //$NON-NLS-1$
824 * Passing the focus request to the viewer's control.
827 public void setFocus() {
828 tableViewer
.getControl().setFocus();
834 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
835 * tsfTmProcessSelEvent
836 * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent
839 public void tsfTmProcessSelEvent(TmfTimeSelectionEvent event
) {
840 // common implementation
841 super.tsfTmProcessSelEvent(event
);
843 // Reselect the table viewer to widget selection
844 ISelection sel
= tsfviewer
.getSelectionTrace();
845 if (sel
!= null && !sel
.isEmpty()) {
846 tableViewer
.setSelection(sel
);
853 * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.
854 * ITmfTimeScaleSelectionListener
855 * #tsfTmProcessTimeScaleEvent(org.eclipse.linuxtools
856 * .tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent)
858 public synchronized void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event
) {
859 super.tsfTmProcessTimeScaleEvent(event
);
862 private void applyTableLayout(Table table
) {
863 for (int i
= 0; i
< columnNames
.length
; i
++) {
864 TableColumn tableColumn
= new TableColumn(table
, SWT
.LEFT
);
865 tableColumn
.setText(columnNames
[i
]);
868 table
.setHeaderVisible(true);
869 table
.setLinesVisible(true);
876 * org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#displayModel
877 * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.
878 * ITmfTimeAnalysisEntry[], long, long, boolean, long, long,
881 public void displayModel(final ITmfTimeAnalysisEntry
[] items
,
882 final long startBoundTime
, final long endBoundTime
,
883 final boolean updateTimeBounds
, final long startVisibleWindow
,
884 final long endVisibleWindow
, final Object source
) {
885 final Table table
= tableViewer
.getTable();
886 Display display
= table
.getDisplay();
888 // Perform the updates on the UI thread)
889 display
.asyncExec(new Runnable() {
892 tableViewer
.setInput(items
); // This shall be the minimal
894 tableFilter
= new ViewProcessFilter(tableViewer
);
895 tableViewer
.setFilters(new ViewerFilter
[] { tableFilter
});
897 resizeTableColumns(table
);
899 tableViewer
.refresh();
901 tsfviewer
.display(items
, startBoundTime
, endBoundTime
,
904 // validate visible boundaries
905 if (startVisibleWindow
> -1 && endVisibleWindow
> -1) {
906 tsfviewer
.setSelectVisTimeWindow(startVisibleWindow
,
907 endVisibleWindow
, source
);
910 tsfviewer
.resizeControls();
912 // Adjust the size of the vertical scroll bar to fit the
914 if (scrollFrame
!= null) {
915 updateScrolls(scrollFrame
);
922 public void dispose() {
923 // dispose parent resources
926 tsfviewer
.removeFilterSelectionListner(this);
927 tsfviewer
.removeWidgetSelectionListner(this);
928 tsfviewer
.removeWidgetTimeScaleSelectionListner(this);
934 * @param tableComposite
937 private synchronized void resizeTableColumns(Table table
) {
939 Composite parent
= table
.getParent();
940 int tableWidthSum
= parent
.getBorderWidth();
942 TableColumn
[] columns
= table
.getColumns();
943 for (TableColumn column
: columns
) {
945 tableWidthSum
+= column
.getWidth();
951 public void tmfTaProcessFilterSelection(TmfTimeFilterSelectionEvent event
) {
952 if (tableFilter
!= null) {
953 Vector
<ITmfTimeAnalysisEntry
> filteredout
= event
.getFilteredOut();
954 if (filteredout
!= null) {
955 tableFilter
.setFilter(filteredout
);
957 tableFilter
.setFilter(new Vector
<ITmfTimeAnalysisEntry
>());
959 tableViewer
.refresh();
967 private void updateScrolls(final ScrolledComposite scrollFrame
) {
968 scrollFrame
.setMinSize(tableViewer
.getTable().computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
));
972 * Registers as listener of time selection from other views
977 public void synchToTime(TmfTimeSynchSignal signal
) {
978 super.synchToTime(signal
);
982 * Annotation Registers as listener of time range selection from other views
983 * The implementation handles the entry of the signal.
988 public void synchToTimeRange(TmfRangeSynchSignal signal
) {
989 if (zoomFilter
!= null) {
990 synchToTimeRange(signal
, zoomFilter
.isChecked());
995 public void modelIncomplete(ILttngSyntEventRequest request
) {
997 // The data will be refreshed on the next request
1003 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1004 * getEventProcessor()
1007 public ITransEventProcessor
getEventProcessor() {
1008 return FlowEventToHandlerFactory
.getInstance();
1015 public void experimentSelected(
1016 TmfExperimentSelectedSignal
<?
extends TmfEvent
> signal
) {
1017 if (signal
!= null) {
1018 TmfTimeRange experimentTRange
= signal
.getExperiment()
1021 // prepare time intervals in widget
1022 ModelUpdateInit(experimentTRange
, experimentTRange
, signal
1025 // request initial data
1026 initialExperimentDataRequest(signal
1027 .getSource(), experimentTRange
);
1033 * @param experimentTRange
1034 * @return Adjusted time window used for the request (smaller window to
1037 private TmfTimeRange
initialExperimentDataRequest(Object source
,
1038 TmfTimeRange experimentTRange
) {
1039 // Adjust the initial time window to a shorter interval to allow
1040 // user to select the interesting area based on the perspective
1041 TmfTimeRange initTimeWindow
= getInitTRange(experimentTRange
);
1043 dataRequest(initTimeWindow
, experimentTRange
, true);
1044 if (TraceDebug
.isDEBUG()) {
1045 TraceDebug
.debug("Initialization request time range is: "
1046 + initTimeWindow
.getStartTime().toString() + "-"
1047 + initTimeWindow
.getEndTime().toString());
1050 return initTimeWindow
;
1057 public int checkForSWTBugItemHeightAdjustement() {
1058 int returnedAjustement
= 0;
1059 String desktopSessionName
= System
.getenv("DESKTOP_SESSION");
1061 // Gnome : most common case, no adjustement
1062 if ( desktopSessionName
.equals("gnome") ) {
1063 returnedAjustement
= 0;
1065 // Kde : ajustement of 2 is needed
1066 else if ( desktopSessionName
.equals("kde") ) {
1067 returnedAjustement
= 2;
1070 return returnedAjustement
;
1076 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1077 * getParamsUpdater()
1080 protected ParamsUpdater
getParamsUpdater() {
1081 return FlowModelFactory
.getParamsUpdater();
1087 * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
1088 * getItemContainer()
1091 protected ItemContainer
<?
> getItemContainer() {
1092 return FlowModelFactory
.getProcContainer();