1 /*****************************************************************************
2 * Copyright (c) 2007, 2014 Intel Corporation, Ericsson, others
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Intel Corporation - Initial API and implementation
10 * Ruslan A. Scherbakov, Intel - Initial API and implementation
11 * Alexander N. Alexeev, Intel - Add monitors statistics support
12 * Alvaro Sanchez-Leon - Adapted for TMF
13 * Patrick Tasse - Refactoring
14 * Geneviève Bastien - Add event links between entries
15 *****************************************************************************/
17 package org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
;
19 import java
.util
.ArrayList
;
20 import java
.util
.List
;
22 import org
.eclipse
.jface
.action
.Action
;
23 import org
.eclipse
.jface
.action
.IAction
;
24 import org
.eclipse
.jface
.dialogs
.IDialogSettings
;
25 import org
.eclipse
.jface
.viewers
.AbstractTreeViewer
;
26 import org
.eclipse
.jface
.viewers
.ISelectionProvider
;
27 import org
.eclipse
.jface
.viewers
.ViewerFilter
;
28 import org
.eclipse
.swt
.SWT
;
29 import org
.eclipse
.swt
.events
.ControlAdapter
;
30 import org
.eclipse
.swt
.events
.ControlEvent
;
31 import org
.eclipse
.swt
.events
.KeyAdapter
;
32 import org
.eclipse
.swt
.events
.KeyEvent
;
33 import org
.eclipse
.swt
.events
.MenuDetectListener
;
34 import org
.eclipse
.swt
.events
.MouseEvent
;
35 import org
.eclipse
.swt
.events
.MouseWheelListener
;
36 import org
.eclipse
.swt
.events
.SelectionAdapter
;
37 import org
.eclipse
.swt
.events
.SelectionEvent
;
38 import org
.eclipse
.swt
.events
.SelectionListener
;
39 import org
.eclipse
.swt
.graphics
.Rectangle
;
40 import org
.eclipse
.swt
.layout
.FillLayout
;
41 import org
.eclipse
.swt
.layout
.GridData
;
42 import org
.eclipse
.swt
.layout
.GridLayout
;
43 import org
.eclipse
.swt
.widgets
.Composite
;
44 import org
.eclipse
.swt
.widgets
.Control
;
45 import org
.eclipse
.swt
.widgets
.Event
;
46 import org
.eclipse
.swt
.widgets
.Listener
;
47 import org
.eclipse
.swt
.widgets
.Slider
;
48 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.Activator
;
49 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.ITmfImageConstants
;
50 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.Messages
;
51 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.dialogs
.TimeGraphLegend
;
52 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.ILinkEvent
;
53 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.ITimeEvent
;
54 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.ITimeGraphEntry
;
55 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.widgets
.ITimeDataProvider
;
56 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.widgets
.TimeDataProviderCyclesConverter
;
57 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.widgets
.TimeGraphColorScheme
;
58 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.widgets
.TimeGraphControl
;
59 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.widgets
.TimeGraphScale
;
60 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.widgets
.TimeGraphTooltipHandler
;
61 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.widgets
.Utils
;
62 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.widgets
.Utils
.TimeFormat
;
65 * Generic time graph viewer implementation
68 * @author Patrick Tasse, and others
70 public class TimeGraphViewer
implements ITimeDataProvider
, SelectionListener
{
72 /** Constant indicating that all levels of the time graph should be expanded
74 public static final int ALL_LEVELS
= AbstractTreeViewer
.ALL_LEVELS
;
76 private static final int DEFAULT_NAME_WIDTH
= 200;
77 private static final int MIN_NAME_WIDTH
= 6;
78 private static final int MAX_NAME_WIDTH
= 1000;
79 private static final int DEFAULT_HEIGHT
= 22;
80 private static final long RECENTERING_MARGIN_FACTOR
= 50;
81 private static final String HIDE_ARROWS_KEY
= "hide.arrows"; //$NON-NLS-1$
82 private static final long DEFAULT_FREQUENCY
= 1000000000L;
83 private static final int H_SCROLLBAR_MAX
= Integer
.MAX_VALUE
- 1;
85 private long fMinTimeInterval
;
86 private ITimeGraphEntry fSelectedEntry
;
87 private long fBeginTime
;
88 private long fEndTime
;
91 private long fSelectionBegin
= 0;
92 private long fSelectionEnd
= 0;
93 private long fTime0Bound
;
94 private long fTime1Bound
;
95 private long fTime0ExtSynch
= 0;
96 private long fTime1ExtSynch
= 0;
97 private boolean fTimeRangeFixed
;
98 private int fNameWidthPref
= DEFAULT_NAME_WIDTH
;
99 private int fMinNameWidth
= MIN_NAME_WIDTH
;
100 private int fNameWidth
;
101 private Composite fDataViewer
;
103 private TimeGraphControl fTimeGraphCtrl
;
104 private TimeGraphScale fTimeScaleCtrl
;
105 private Slider fHorizontalScrollBar
;
106 private Slider fVerticalScrollBar
;
107 private TimeGraphColorScheme fColorScheme
;
108 private Object fInputElement
;
109 private ITimeGraphContentProvider fTimeGraphContentProvider
;
110 private ITimeGraphPresentationProvider fTimeGraphProvider
;
111 private ITimeDataProvider fTimeDataProvider
= this;
112 private TimeGraphTooltipHandler fToolTipHandler
;
114 private List
<ITimeGraphSelectionListener
> fSelectionListeners
= new ArrayList
<>();
115 private List
<ITimeGraphTimeListener
> fTimeListeners
= new ArrayList
<>();
116 private List
<ITimeGraphRangeListener
> fRangeListeners
= new ArrayList
<>();
118 // Time format, using Epoch reference, Relative time format(default),
120 private TimeFormat fTimeFormat
= TimeFormat
.RELATIVE
;
121 // Clock frequency to use for Cycles time format
122 private long fClockFrequency
= DEFAULT_FREQUENCY
;
123 private int fBorderWidth
= 0;
124 private int fTimeScaleHeight
= DEFAULT_HEIGHT
;
126 private Action fResetScaleAction
;
127 private Action fShowLegendAction
;
128 private Action fNextEventAction
;
129 private Action fPrevEventAction
;
130 private Action fNextItemAction
;
131 private Action fPreviousItemAction
;
132 private Action fZoomInAction
;
133 private Action fZoomOutAction
;
134 private Action fHideArrowsAction
;
135 private Action fFollowArrowFwdAction
;
136 private Action fFollowArrowBwdAction
;
139 * Standard constructor.
141 * The default timegraph content provider accepts an ITimeGraphEntry[] as input element.
144 * The parent UI composite object
148 public TimeGraphViewer(Composite parent
, int style
) {
149 createDataViewer(parent
, style
);
150 fTimeGraphContentProvider
= new ITimeGraphContentProvider() {
152 public ITimeGraphEntry
[] getElements(Object inputElement
) {
153 if (inputElement
instanceof ITimeGraphEntry
[]) {
154 return (ITimeGraphEntry
[]) inputElement
;
156 return new ITimeGraphEntry
[0];
162 * Sets the timegraph content provider used by this timegraph viewer.
164 * @param timeGraphContentProvider
165 * the timegraph content provider
169 public void setTimeGraphContentProvider(ITimeGraphContentProvider timeGraphContentProvider
) {
170 fTimeGraphContentProvider
= timeGraphContentProvider
;
174 * Gets the timegraph content provider used by this timegraph viewer.
176 * @return the timegraph content provider
180 public ITimeGraphContentProvider
getTimeGraphContentProvider() {
181 return fTimeGraphContentProvider
;
185 * Sets the timegraph presentation provider used by this timegraph viewer.
187 * @param timeGraphProvider
188 * the timegraph provider
190 public void setTimeGraphProvider(ITimeGraphPresentationProvider timeGraphProvider
) {
191 fTimeGraphProvider
= timeGraphProvider
;
192 fTimeGraphCtrl
.setTimeGraphProvider(timeGraphProvider
);
193 fToolTipHandler
= new TimeGraphTooltipHandler(fTimeGraphProvider
, fTimeDataProvider
);
194 fToolTipHandler
.activateHoverHelp(fTimeGraphCtrl
);
198 * Sets or clears the input for this time graph viewer.
200 * @param inputElement
201 * The input of this time graph viewer, or <code>null</code> if
206 public void setInput(Object inputElement
) {
207 fInputElement
= inputElement
;
208 ITimeGraphEntry
[] input
= fTimeGraphContentProvider
.getElements(inputElement
);
210 if (fTimeGraphCtrl
!= null) {
215 fSelectedEntry
= null;
216 refreshAllData(input
);
221 * Gets the input for this time graph viewer.
223 * @return The input of this time graph viewer, or <code>null</code> if none
227 public Object
getInput() {
228 return fInputElement
;
232 * Sets (or clears if null) the list of links to display on this combo
235 * the links to display in this time graph combo
238 public void setLinks(List
<ILinkEvent
> links
) {
239 if (fTimeGraphCtrl
!= null) {
240 fTimeGraphCtrl
.refreshArrows(links
);
247 public void refresh() {
248 ITimeGraphEntry
[] input
= fTimeGraphContentProvider
.getElements(fInputElement
);
250 refreshAllData(input
);
254 * Callback for when the control is moved
259 public void controlMoved(ControlEvent e
) {
263 * Callback for when the control is resized
268 public void controlResized(ControlEvent e
) {
273 * Handler for when the model is updated. Called from the display order in
277 * The traces in the model
282 * @param updateTimeBounds
283 * Should we updated the time bounds too
285 public void modelUpdate(ITimeGraphEntry
[] traces
, long start
,
286 long end
, boolean updateTimeBounds
) {
287 if (null != fTimeGraphCtrl
) {
288 updateInternalData(traces
, start
, end
);
289 if (updateTimeBounds
) {
290 fTimeRangeFixed
= true;
291 // set window to match limits
292 setStartFinishTime(fTime0Bound
, fTime1Bound
);
294 fTimeGraphCtrl
.redraw();
295 fTimeScaleCtrl
.redraw();
301 * @return The string representing the view type
303 protected String
getViewTypeStr() {
304 return "viewoption.threads"; //$NON-NLS-1$
307 int getMarginWidth() {
311 int getMarginHeight() {
316 fMinTimeInterval
= 1;
317 fSelectionBegin
= -1;
319 fNameWidth
= Utils
.loadIntOption(getPreferenceString("namewidth"), //$NON-NLS-1$
320 fNameWidthPref
, fMinNameWidth
, MAX_NAME_WIDTH
);
324 Utils
.saveIntOption(getPreferenceString("namewidth"), fNameWidth
); //$NON-NLS-1$
328 * Create a data viewer.
334 * @return The new data viewer
336 protected Control
createDataViewer(Composite parent
, int style
) {
338 fColorScheme
= new TimeGraphColorScheme();
339 fDataViewer
= new Composite(parent
, style
) {
341 public void redraw() {
342 fTimeScaleCtrl
.redraw();
343 fTimeGraphCtrl
.redraw();
347 GridLayout gl
= new GridLayout(2, false);
348 gl
.marginHeight
= fBorderWidth
;
350 gl
.verticalSpacing
= 0;
351 gl
.horizontalSpacing
= 0;
352 fDataViewer
.setLayout(gl
);
354 fTimeScaleCtrl
= new TimeGraphScale(fDataViewer
, fColorScheme
);
355 fTimeScaleCtrl
.setTimeProvider(fTimeDataProvider
);
356 fTimeScaleCtrl
.setLayoutData(new GridData(SWT
.FILL
, SWT
.DEFAULT
, true, false));
357 fTimeScaleCtrl
.setHeight(fTimeScaleHeight
);
358 fTimeScaleCtrl
.addMouseWheelListener(new MouseWheelListener() {
360 public void mouseScrolled(MouseEvent e
) {
361 fTimeGraphCtrl
.zoom(e
.count
> 0);
365 fVerticalScrollBar
= new Slider(fDataViewer
, SWT
.VERTICAL
| SWT
.NO_FOCUS
);
366 fVerticalScrollBar
.setLayoutData(new GridData(SWT
.DEFAULT
, SWT
.FILL
, false, true, 1, 2));
367 fVerticalScrollBar
.addSelectionListener(new SelectionAdapter() {
369 public void widgetSelected(SelectionEvent e
) {
370 setTopIndex(fVerticalScrollBar
.getSelection());
374 fTimeGraphCtrl
= createTimeGraphControl(fDataViewer
, fColorScheme
);
376 fTimeGraphCtrl
.setTimeProvider(this);
377 fTimeGraphCtrl
.setTimeGraphScale(fTimeScaleCtrl
);
378 fTimeGraphCtrl
.addSelectionListener(this);
379 fTimeGraphCtrl
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
380 fTimeGraphCtrl
.addMouseWheelListener(new MouseWheelListener() {
382 public void mouseScrolled(MouseEvent e
) {
383 adjustVerticalScrollBar();
386 fTimeGraphCtrl
.addKeyListener(new KeyAdapter() {
388 public void keyPressed(KeyEvent e
) {
389 if (e
.character
== '+') {
391 } else if (e
.character
== '-') {
394 adjustVerticalScrollBar();
398 fHorizontalScrollBar
= new Slider(fDataViewer
, SWT
.HORIZONTAL
| SWT
.NO_FOCUS
);
399 fHorizontalScrollBar
.setLayoutData(new GridData(SWT
.FILL
, SWT
.DEFAULT
, true, false));
400 fHorizontalScrollBar
.addListener(SWT
.MouseWheel
, new Listener() {
402 public void handleEvent(Event event
) {
403 if ((event
.stateMask
& SWT
.MODIFIER_MASK
) == SWT
.CTRL
) {
404 getTimeGraphControl().zoom(event
.count
> 0);
406 getTimeGraphControl().horizontalScroll(event
.count
> 0);
408 // don't handle the immediately following SWT.Selection event
412 fHorizontalScrollBar
.addListener(SWT
.Selection
, new Listener() {
414 public void handleEvent(Event event
) {
415 int start
= fHorizontalScrollBar
.getSelection();
416 long time0
= getTime0();
417 long time1
= getTime1();
418 long timeMin
= getMinTime();
419 long timeMax
= getMaxTime();
420 long delta
= timeMax
- timeMin
;
422 long range
= time1
- time0
;
423 time0
= timeMin
+ Math
.round(delta
* ((double) start
/ H_SCROLLBAR_MAX
));
424 time1
= time0
+ range
;
426 // TODO: Follow-up with Bug 310310
427 // In Linux SWT.DRAG is the only value received
428 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310310
429 if (event
.detail
== SWT
.DRAG
) {
430 setStartFinishTime(time0
, time1
);
432 setStartFinishTimeNotify(time0
, time1
);
437 Composite filler
= new Composite(fDataViewer
, SWT
.NONE
);
438 GridData gd
= new GridData(SWT
.DEFAULT
, SWT
.DEFAULT
, false, false);
439 gd
.heightHint
= fHorizontalScrollBar
.getSize().y
;
440 filler
.setLayoutData(gd
);
441 filler
.setLayout(new FillLayout());
443 fTimeGraphCtrl
.addControlListener(new ControlAdapter() {
445 public void controlResized(ControlEvent event
) {
450 fDataViewer
.update();
451 adjustHorizontalScrollBar();
452 adjustVerticalScrollBar();
459 public void dispose() {
461 fTimeGraphCtrl
.dispose();
462 fDataViewer
.dispose();
463 fColorScheme
.dispose();
467 * Create a new time graph control.
470 * The parent composite
473 * @return The new TimeGraphControl
476 protected TimeGraphControl
createTimeGraphControl(Composite parent
,
477 TimeGraphColorScheme colors
) {
478 return new TimeGraphControl(parent
, colors
);
482 * Resize the controls
484 public void resizeControls() {
485 Rectangle r
= fDataViewer
.getClientArea();
491 if (fNameWidth
> width
- fMinNameWidth
) {
492 fNameWidth
= width
- fMinNameWidth
;
494 if (fNameWidth
< fMinNameWidth
) {
495 fNameWidth
= fMinNameWidth
;
497 adjustHorizontalScrollBar();
498 adjustVerticalScrollBar();
502 * Try to set most convenient time range for display.
505 * The traces in the model
507 public void setTimeRange(ITimeGraphEntry traces
[]) {
510 for (int i
= 0; i
< traces
.length
; i
++) {
511 ITimeGraphEntry entry
= traces
[i
];
512 if (entry
.getEndTime() >= entry
.getStartTime() && entry
.getEndTime() > 0) {
513 if (fBeginTime
< 0 || entry
.getStartTime() < fBeginTime
) {
514 fBeginTime
= entry
.getStartTime();
516 if (entry
.getEndTime() > fEndTime
) {
517 fEndTime
= entry
.getEndTime();
522 if (fBeginTime
< 0) {
528 * Recalculate the time bounds
530 public void setTimeBounds() {
531 fTime0Bound
= fBeginTime
;
532 if (fTime0Bound
< 0) {
535 fTime1Bound
= fEndTime
;
536 if (!fTimeRangeFixed
) {
537 fTime0
= fTime0Bound
;
538 fTime1
= fTime1Bound
;
540 fTime0
= Math
.max(fTime0Bound
, Math
.min(fTime0
, fTime1Bound
));
541 fTime1
= Math
.max(fTime0Bound
, Math
.min(fTime1
, fTime1Bound
));
542 if (fTime1
- fTime0
< fMinTimeInterval
) {
543 fTime1
= Math
.min(fTime1Bound
, fTime0
+ fMinTimeInterval
);
552 void updateInternalData(ITimeGraphEntry
[] traces
, long start
, long end
) {
553 ITimeGraphEntry
[] realTraces
= traces
;
555 if (null == realTraces
) {
556 realTraces
= new ITimeGraphEntry
[0];
558 if ((start
== 0 && end
== 0) || start
< 0 || end
< 0) {
559 // Start and end time are unspecified and need to be determined from
560 // individual processes
561 setTimeRange(realTraces
);
567 refreshAllData(realTraces
);
573 private void refreshAllData(ITimeGraphEntry
[] traces
) {
575 if (fSelectionBegin
< fBeginTime
) {
576 fSelectionBegin
= fBeginTime
;
577 } else if (fSelectionBegin
> fEndTime
) {
578 fSelectionBegin
= fEndTime
;
580 if (fSelectionEnd
< fBeginTime
) {
581 fSelectionEnd
= fBeginTime
;
582 } else if (fSelectionEnd
> fEndTime
) {
583 fSelectionEnd
= fEndTime
;
585 fTimeGraphCtrl
.refreshData(traces
);
586 fTimeScaleCtrl
.redraw();
587 adjustVerticalScrollBar();
591 * Callback for when this view is focused
593 public void setFocus() {
594 if (null != fTimeGraphCtrl
) {
595 fTimeGraphCtrl
.setFocus();
600 * Get the current focus status of this view.
602 * @return If the view is currently focused, or not
604 public boolean isInFocus() {
605 return fTimeGraphCtrl
.isInFocus();
609 * Get the view's current selection
611 * @return The entry that is selected
613 public ITimeGraphEntry
getSelection() {
614 return fTimeGraphCtrl
.getSelectedTrace();
618 * Get the index of the current selection
622 public int getSelectionIndex() {
623 return fTimeGraphCtrl
.getSelectedIndex();
627 public long getTime0() {
632 public long getTime1() {
637 public long getMinTimeInterval() {
638 return fMinTimeInterval
;
642 public int getNameSpace() {
647 public void setNameSpace(int width
) {
649 int w
= fTimeGraphCtrl
.getClientArea().width
;
650 if (fNameWidth
> w
- MIN_NAME_WIDTH
) {
651 fNameWidth
= w
- MIN_NAME_WIDTH
;
653 if (fNameWidth
< MIN_NAME_WIDTH
) {
654 fNameWidth
= MIN_NAME_WIDTH
;
656 fTimeGraphCtrl
.redraw();
657 fTimeScaleCtrl
.redraw();
661 public int getTimeSpace() {
662 int w
= fTimeGraphCtrl
.getClientArea().width
;
663 return w
- fNameWidth
;
667 public long getBeginTime() {
672 public long getEndTime() {
677 public long getMaxTime() {
682 public long getMinTime() {
690 public long getSelectionBegin() {
691 return fSelectionBegin
;
698 public long getSelectionEnd() {
699 return fSelectionEnd
;
703 public void setStartFinishTimeNotify(long time0
, long time1
) {
704 setStartFinishTime(time0
, time1
);
705 notifyRangeListeners(fTime0
, fTime1
);
709 public void notifyStartFinishTime() {
710 notifyRangeListeners(fTime0
, fTime1
);
714 public void setStartFinishTime(long time0
, long time1
) {
716 if (fTime0
< fTime0Bound
) {
717 fTime0
= fTime0Bound
;
719 if (fTime0
> fTime1Bound
) {
720 fTime0
= fTime1Bound
;
723 if (fTime1
< fTime0Bound
) {
724 fTime1
= fTime0Bound
;
726 if (fTime1
> fTime1Bound
) {
727 fTime1
= fTime1Bound
;
729 if (fTime1
- fTime0
< fMinTimeInterval
) {
730 fTime1
= Math
.min(fTime1Bound
, fTime0
+ fMinTimeInterval
);
732 fTimeRangeFixed
= true;
733 adjustHorizontalScrollBar();
734 fTimeGraphCtrl
.redraw();
735 fTimeScaleCtrl
.redraw();
739 * Set the time bounds to the provided values
742 * The start time of the window
746 public void setTimeBounds(long beginTime
, long endTime
) {
747 if (endTime
>= beginTime
) {
748 fBeginTime
= beginTime
;
750 fTime0Bound
= beginTime
;
751 fTime1Bound
= endTime
;
758 adjustHorizontalScrollBar();
762 public void resetStartFinishTime() {
763 setStartFinishTime(fTime0Bound
, fTime1Bound
);
764 fTimeRangeFixed
= false;
768 public void setSelectedTimeNotify(long time
, boolean ensureVisible
) {
769 setSelectedTimeInt(time
, ensureVisible
, true);
773 public void setSelectedTime(long time
, boolean ensureVisible
) {
774 setSelectedTimeInt(time
, ensureVisible
, false);
781 public void setSelectionRangeNotify(long beginTime
, long endTime
) {
782 boolean changed
= (beginTime
!= fSelectionBegin
|| endTime
!= fSelectionEnd
);
783 fSelectionBegin
= Math
.max(fTime0Bound
, Math
.min(fTime1Bound
, beginTime
));
784 fSelectionEnd
= Math
.max(fTime0Bound
, Math
.min(fTime1Bound
, endTime
));
785 fTimeGraphCtrl
.redraw();
786 fTimeScaleCtrl
.redraw();
788 notifyTimeListeners(fSelectionBegin
, fSelectionEnd
);
796 public void setSelectionRange(long beginTime
, long endTime
) {
797 fSelectionBegin
= Math
.max(fTime0Bound
, Math
.min(fTime1Bound
, beginTime
));
798 fSelectionEnd
= Math
.max(fTime0Bound
, Math
.min(fTime1Bound
, endTime
));
799 fTimeGraphCtrl
.redraw();
800 fTimeScaleCtrl
.redraw();
803 private void setSelectedTimeInt(long time
, boolean ensureVisible
, boolean doNotify
) {
807 long timeSpace
= (fTime1
- fTime0
) / RECENTERING_MARGIN_FACTOR
;
808 long timeMid
= (fTime1
- fTime0
) / 2;
809 if (time
< fTime0
+ timeSpace
) {
810 long dt
= fTime0
- time
+ timeMid
;
813 } else if (time
> fTime1
- timeSpace
) {
814 long dt
= time
- fTime1
+ timeMid
;
818 if (fTime0
< fTime0Bound
) {
819 fTime1
= Math
.min(fTime1Bound
, fTime1
+ (fTime0Bound
- fTime0
));
820 fTime0
= fTime0Bound
;
821 } else if (fTime1
> fTime1Bound
) {
822 fTime0
= Math
.max(fTime0Bound
, fTime0
- (fTime1
- fTime1Bound
));
823 fTime1
= fTime1Bound
;
826 if (fTime1
- fTime0
< fMinTimeInterval
) {
827 fTime1
= Math
.min(fTime1Bound
, fTime0
+ fMinTimeInterval
);
829 adjustHorizontalScrollBar();
830 fTimeGraphCtrl
.redraw();
831 fTimeScaleCtrl
.redraw();
833 boolean notifySelectedTime
= (time
!= fSelectionBegin
|| time
!= fSelectionEnd
);
834 fSelectionBegin
= time
;
835 fSelectionEnd
= time
;
837 if (doNotify
&& ((time0
!= fTime0
) || (time1
!= fTime1
))) {
838 notifyRangeListeners(fTime0
, fTime1
);
841 if (doNotify
&& notifySelectedTime
) {
842 notifyTimeListeners(fSelectionBegin
, fSelectionEnd
);
847 public void widgetDefaultSelected(SelectionEvent e
) {
848 if (fSelectedEntry
!= getSelection()) {
849 fSelectedEntry
= getSelection();
850 notifySelectionListeners(fSelectedEntry
);
855 public void widgetSelected(SelectionEvent e
) {
856 if (fSelectedEntry
!= getSelection()) {
857 fSelectedEntry
= getSelection();
858 notifySelectionListeners(fSelectedEntry
);
863 * Callback for when the next event is selected
865 public void selectNextEvent() {
866 fTimeGraphCtrl
.selectNextEvent();
867 adjustVerticalScrollBar();
871 * Callback for when the previous event is selected
873 public void selectPrevEvent() {
874 fTimeGraphCtrl
.selectPrevEvent();
875 adjustVerticalScrollBar();
879 * Callback for when the next item is selected
881 public void selectNextItem() {
882 fTimeGraphCtrl
.selectNextTrace();
883 adjustVerticalScrollBar();
887 * Callback for when the previous item is selected
889 public void selectPrevItem() {
890 fTimeGraphCtrl
.selectPrevTrace();
891 adjustVerticalScrollBar();
895 * Callback for the show legend action
897 public void showLegend() {
898 if (fDataViewer
== null || fDataViewer
.isDisposed()) {
902 TimeGraphLegend
.open(fDataViewer
.getShell(), fTimeGraphProvider
);
906 * Callback for the Zoom In action
908 public void zoomIn() {
909 fTimeGraphCtrl
.zoomIn();
913 * Callback for the Zoom Out action
915 public void zoomOut() {
916 fTimeGraphCtrl
.zoomOut();
919 private String
getPreferenceString(String string
) {
920 return getViewTypeStr() + "." + string
; //$NON-NLS-1$
924 * Add a selection listener
927 * The listener to add
929 public void addSelectionListener(ITimeGraphSelectionListener listener
) {
930 fSelectionListeners
.add(listener
);
934 * Remove a selection listener
937 * The listener to remove
939 public void removeSelectionListener(ITimeGraphSelectionListener listener
) {
940 fSelectionListeners
.remove(listener
);
943 private void notifySelectionListeners(ITimeGraphEntry selection
) {
944 TimeGraphSelectionEvent event
= new TimeGraphSelectionEvent(this, selection
);
946 for (ITimeGraphSelectionListener listener
: fSelectionListeners
) {
947 listener
.selectionChanged(event
);
952 * Add a time listener
955 * The listener to add
957 public void addTimeListener(ITimeGraphTimeListener listener
) {
958 fTimeListeners
.add(listener
);
962 * Remove a time listener
965 * The listener to remove
967 public void removeTimeListener(ITimeGraphTimeListener listener
) {
968 fTimeListeners
.remove(listener
);
971 private void notifyTimeListeners(long startTime
, long endTime
) {
972 TimeGraphTimeEvent event
= new TimeGraphTimeEvent(this, startTime
, endTime
);
974 for (ITimeGraphTimeListener listener
: fTimeListeners
) {
975 listener
.timeSelected(event
);
980 * Add a range listener
983 * The listener to add
985 public void addRangeListener(ITimeGraphRangeListener listener
) {
986 fRangeListeners
.add(listener
);
990 * Remove a range listener
993 * The listener to remove
995 public void removeRangeListener(ITimeGraphRangeListener listener
) {
996 fRangeListeners
.remove(listener
);
999 private void notifyRangeListeners(long startTime
, long endTime
) {
1000 // Check if the time has actually changed from last notification
1001 if (startTime
!= fTime0ExtSynch
|| endTime
!= fTime1ExtSynch
) {
1002 // Notify Time Scale Selection Listeners
1003 TimeGraphRangeUpdateEvent event
= new TimeGraphRangeUpdateEvent(this, startTime
, endTime
);
1005 for (ITimeGraphRangeListener listener
: fRangeListeners
) {
1006 listener
.timeRangeUpdated(event
);
1009 // update external synch timers
1010 updateExtSynchTimers();
1015 * Callback to set a selected event in the view
1018 * The event that was selected
1020 * The source of this selection event
1022 public void setSelectedEvent(ITimeEvent event
, Object source
) {
1023 if (event
== null || source
== this) {
1026 fSelectedEntry
= event
.getEntry();
1027 fTimeGraphCtrl
.selectItem(fSelectedEntry
, false);
1029 setSelectedTimeInt(event
.getTime(), true, true);
1030 adjustVerticalScrollBar();
1034 * Set the seeked time of a trace
1037 * The trace that was seeked
1041 * The source of this seek event
1043 public void setSelectedTraceTime(ITimeGraphEntry trace
, long time
, Object source
) {
1044 if (trace
== null || source
== this) {
1047 fSelectedEntry
= trace
;
1048 fTimeGraphCtrl
.selectItem(trace
, false);
1050 setSelectedTimeInt(time
, true, true);
1054 * Callback for a trace selection
1057 * The trace that was selected
1059 public void setSelection(ITimeGraphEntry trace
) {
1060 fSelectedEntry
= trace
;
1061 fTimeGraphCtrl
.selectItem(trace
, false);
1062 adjustVerticalScrollBar();
1066 * Callback for a time window selection
1069 * Start time of the range
1071 * End time of the range
1073 * Source of the event
1075 public void setSelectVisTimeWindow(long time0
, long time1
, Object source
) {
1076 if (source
== this) {
1080 setStartFinishTime(time0
, time1
);
1082 // update notification time values since we are now in synch with the
1083 // external application
1084 updateExtSynchTimers();
1088 * update the cache timers used to identify the need to send a time window
1089 * update to external registered listeners
1091 private void updateExtSynchTimers() {
1092 // last time notification cache
1093 fTime0ExtSynch
= fTime0
;
1094 fTime1ExtSynch
= fTime1
;
1101 public TimeFormat
getTimeFormat() {
1107 * the {@link TimeFormat} used to display timestamps
1110 public void setTimeFormat(TimeFormat tf
) {
1111 this.fTimeFormat
= tf
;
1112 if (tf
== TimeFormat
.CYCLES
) {
1113 fTimeDataProvider
= new TimeDataProviderCyclesConverter(this, fClockFrequency
);
1115 fTimeDataProvider
= this;
1117 fTimeScaleCtrl
.setTimeProvider(fTimeDataProvider
);
1118 if (fToolTipHandler
!= null) {
1119 fToolTipHandler
.setTimeProvider(fTimeDataProvider
);
1124 * Sets the clock frequency. Used when the time format is set to CYCLES.
1126 * @param clockFrequency
1127 * the clock frequency in Hz
1130 public void setClockFrequency(long clockFrequency
) {
1131 fClockFrequency
= clockFrequency
;
1132 if (fTimeFormat
== TimeFormat
.CYCLES
) {
1133 fTimeDataProvider
= new TimeDataProviderCyclesConverter(this, fClockFrequency
);
1134 fTimeScaleCtrl
.setTimeProvider(fTimeDataProvider
);
1135 if (fToolTipHandler
!= null) {
1136 fToolTipHandler
.setTimeProvider(fTimeDataProvider
);
1142 * Retrieve the border width
1146 public int getBorderWidth() {
1147 return fBorderWidth
;
1151 * Set the border width
1153 * @param borderWidth
1156 public void setBorderWidth(int borderWidth
) {
1157 if (borderWidth
> -1) {
1158 this.fBorderWidth
= borderWidth
;
1159 GridLayout gl
= (GridLayout
) fDataViewer
.getLayout();
1160 gl
.marginHeight
= borderWidth
;
1165 * Retrieve the height of the header
1167 * @return The height
1169 public int getHeaderHeight() {
1170 return fTimeScaleHeight
;
1174 * Set the height of the header
1176 * @param headerHeight
1179 public void setHeaderHeight(int headerHeight
) {
1180 if (headerHeight
> -1) {
1181 this.fTimeScaleHeight
= headerHeight
;
1182 fTimeScaleCtrl
.setHeight(headerHeight
);
1187 * Retrieve the height of an item row
1189 * @return The height
1191 public int getItemHeight() {
1192 if (fTimeGraphCtrl
!= null) {
1193 return fTimeGraphCtrl
.getItemHeight();
1199 * Set the height of an item row
1204 public void setItemHeight(int rowHeight
) {
1205 if (fTimeGraphCtrl
!= null) {
1206 fTimeGraphCtrl
.setItemHeight(rowHeight
);
1211 * Set the minimum item width
1216 public void setMinimumItemWidth(int width
) {
1217 if (fTimeGraphCtrl
!= null) {
1218 fTimeGraphCtrl
.setMinimumItemWidth(width
);
1223 * Set the width for the name column
1228 public void setNameWidthPref(int width
) {
1229 fNameWidthPref
= width
;
1237 * Retrieve the configure width for the name column
1243 public int getNameWidthPref(int width
) {
1244 return fNameWidthPref
;
1248 * Returns the primary control associated with this viewer.
1250 * @return the SWT control which displays this viewer's content
1252 public Control
getControl() {
1257 * Returns the time graph control associated with this viewer.
1259 * @return the time graph control
1262 public TimeGraphControl
getTimeGraphControl() {
1263 return fTimeGraphCtrl
;
1267 * Returns the time graph scale associated with this viewer.
1269 * @return the time graph scale
1272 public TimeGraphScale
getTimeGraphScale() {
1273 return fTimeScaleCtrl
;
1277 * Return the x coordinate corresponding to a time
1281 * @return the x coordinate corresponding to the time
1285 public int getXForTime(long time
) {
1286 return fTimeGraphCtrl
.getXForTime(time
);
1290 * Return the time corresponding to an x coordinate
1294 * @return the time corresponding to the x coordinate
1298 public long getTimeAtX(int x
) {
1299 return fTimeGraphCtrl
.getTimeAtX(x
);
1303 * Get the selection provider
1305 * @return the selection provider
1307 public ISelectionProvider
getSelectionProvider() {
1308 return fTimeGraphCtrl
;
1312 * Wait for the cursor
1315 * Wait indefinitely?
1317 public void waitCursor(boolean waitInd
) {
1318 fTimeGraphCtrl
.waitCursor(waitInd
);
1322 * Get the horizontal scroll bar object
1324 * @return The scroll bar
1326 public Slider
getHorizontalBar() {
1327 return fHorizontalScrollBar
;
1331 * Get the vertical scroll bar object
1333 * @return The scroll bar
1335 public Slider
getVerticalBar() {
1336 return fVerticalScrollBar
;
1340 * Set the given index as the top one
1343 * The index that will go to the top
1345 public void setTopIndex(int index
) {
1346 fTimeGraphCtrl
.setTopIndex(index
);
1347 adjustVerticalScrollBar();
1351 * Retrieve the current top index
1353 * @return The top index
1355 public int getTopIndex() {
1356 return fTimeGraphCtrl
.getTopIndex();
1360 * Sets the auto-expand level to be used when the input of the viewer is set
1361 * using {@link #setInput(Object)}. The value 0 means that there is no
1362 * auto-expand; 1 means that top-level elements are expanded, but not their
1363 * children; 2 means that top-level elements are expanded, and their
1364 * children, but not grand-children; and so on.
1366 * The value {@link #ALL_LEVELS} means that all subtrees should be expanded.
1369 * non-negative level, or <code>ALL_LEVELS</code> to expand all
1370 * levels of the tree
1373 public void setAutoExpandLevel(int level
) {
1374 fTimeGraphCtrl
.setAutoExpandLevel(level
);
1378 * Returns the auto-expand level.
1380 * @return non-negative level, or <code>ALL_LEVELS</code> if all levels of
1381 * the tree are expanded automatically
1382 * @see #setAutoExpandLevel
1385 public int getAutoExpandLevel() {
1386 return fTimeGraphCtrl
.getAutoExpandLevel();
1390 * Set the expanded state of an entry
1393 * The entry to expand/collapse
1395 * True for expanded, false for collapsed
1397 public void setExpandedState(ITimeGraphEntry entry
, boolean expanded
) {
1398 fTimeGraphCtrl
.setExpandedState(entry
, expanded
);
1399 adjustVerticalScrollBar();
1403 * Collapses all nodes of the viewer's tree, starting with the root.
1407 public void collapseAll() {
1408 fTimeGraphCtrl
.collapseAll();
1409 adjustVerticalScrollBar();
1413 * Expands all nodes of the viewer's tree, starting with the root.
1417 public void expandAll() {
1418 fTimeGraphCtrl
.expandAll();
1419 adjustVerticalScrollBar();
1423 * Get the number of sub-elements when expanded
1425 * @return The element count
1427 public int getExpandedElementCount() {
1428 return fTimeGraphCtrl
.getExpandedElementCount();
1432 * Get the sub-elements
1434 * @return The array of entries that are below this one
1436 public ITimeGraphEntry
[] getExpandedElements() {
1437 return fTimeGraphCtrl
.getExpandedElements();
1441 * Add a tree listener
1444 * The listener to add
1446 public void addTreeListener(ITimeGraphTreeListener listener
) {
1447 fTimeGraphCtrl
.addTreeListener(listener
);
1451 * Remove a tree listener
1454 * The listener to remove
1456 public void removeTreeListener(ITimeGraphTreeListener listener
) {
1457 fTimeGraphCtrl
.removeTreeListener(listener
);
1461 * Get the reset scale action.
1463 * @return The Action object
1465 public Action
getResetScaleAction() {
1466 if (fResetScaleAction
== null) {
1468 fResetScaleAction
= new Action() {
1471 resetStartFinishTime();
1472 notifyStartFinishTime();
1475 fResetScaleAction
.setText(Messages
.TmfTimeGraphViewer_ResetScaleActionNameText
);
1476 fResetScaleAction
.setToolTipText(Messages
.TmfTimeGraphViewer_ResetScaleActionToolTipText
);
1477 fResetScaleAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_HOME_MENU
));
1479 return fResetScaleAction
;
1483 * Get the show legend action.
1485 * @return The Action object
1487 public Action
getShowLegendAction() {
1488 if (fShowLegendAction
== null) {
1490 fShowLegendAction
= new Action() {
1496 fShowLegendAction
.setText(Messages
.TmfTimeGraphViewer_LegendActionNameText
);
1497 fShowLegendAction
.setToolTipText(Messages
.TmfTimeGraphViewer_LegendActionToolTipText
);
1498 fShowLegendAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_SHOW_LEGEND
));
1501 return fShowLegendAction
;
1505 * Get the the next event action.
1507 * @return The action object
1509 public Action
getNextEventAction() {
1510 if (fNextEventAction
== null) {
1511 fNextEventAction
= new Action() {
1518 fNextEventAction
.setText(Messages
.TmfTimeGraphViewer_NextEventActionNameText
);
1519 fNextEventAction
.setToolTipText(Messages
.TmfTimeGraphViewer_NextEventActionToolTipText
);
1520 fNextEventAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_NEXT_EVENT
));
1523 return fNextEventAction
;
1527 * Get the previous event action.
1529 * @return The Action object
1531 public Action
getPreviousEventAction() {
1532 if (fPrevEventAction
== null) {
1533 fPrevEventAction
= new Action() {
1540 fPrevEventAction
.setText(Messages
.TmfTimeGraphViewer_PreviousEventActionNameText
);
1541 fPrevEventAction
.setToolTipText(Messages
.TmfTimeGraphViewer_PreviousEventActionToolTipText
);
1542 fPrevEventAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_PREV_EVENT
));
1545 return fPrevEventAction
;
1549 * Get the next item action.
1551 * @return The Action object
1553 public Action
getNextItemAction() {
1554 if (fNextItemAction
== null) {
1556 fNextItemAction
= new Action() {
1562 fNextItemAction
.setText(Messages
.TmfTimeGraphViewer_NextItemActionNameText
);
1563 fNextItemAction
.setToolTipText(Messages
.TmfTimeGraphViewer_NextItemActionToolTipText
);
1564 fNextItemAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_NEXT_ITEM
));
1566 return fNextItemAction
;
1570 * Get the previous item action.
1572 * @return The Action object
1574 public Action
getPreviousItemAction() {
1575 if (fPreviousItemAction
== null) {
1577 fPreviousItemAction
= new Action() {
1583 fPreviousItemAction
.setText(Messages
.TmfTimeGraphViewer_PreviousItemActionNameText
);
1584 fPreviousItemAction
.setToolTipText(Messages
.TmfTimeGraphViewer_PreviousItemActionToolTipText
);
1585 fPreviousItemAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_PREV_ITEM
));
1587 return fPreviousItemAction
;
1591 * Get the zoom in action
1593 * @return The Action object
1595 public Action
getZoomInAction() {
1596 if (fZoomInAction
== null) {
1597 fZoomInAction
= new Action() {
1603 fZoomInAction
.setText(Messages
.TmfTimeGraphViewer_ZoomInActionNameText
);
1604 fZoomInAction
.setToolTipText(Messages
.TmfTimeGraphViewer_ZoomInActionToolTipText
);
1605 fZoomInAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_ZOOM_IN_MENU
));
1607 return fZoomInAction
;
1611 * Get the zoom out action
1613 * @return The Action object
1615 public Action
getZoomOutAction() {
1616 if (fZoomOutAction
== null) {
1617 fZoomOutAction
= new Action() {
1623 fZoomOutAction
.setText(Messages
.TmfTimeGraphViewer_ZoomOutActionNameText
);
1624 fZoomOutAction
.setToolTipText(Messages
.TmfTimeGraphViewer_ZoomOutActionToolTipText
);
1625 fZoomOutAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_ZOOM_OUT_MENU
));
1627 return fZoomOutAction
;
1631 * Get the hide arrows action
1633 * @param dialogSettings
1634 * The dialog settings section where the state should be stored,
1637 * @return The Action object
1641 public Action
getHideArrowsAction(final IDialogSettings dialogSettings
) {
1642 if (fHideArrowsAction
== null) {
1643 fHideArrowsAction
= new Action(Messages
.TmfTimeGraphViewer_HideArrowsActionNameText
, IAction
.AS_CHECK_BOX
) {
1646 boolean hideArrows
= fHideArrowsAction
.isChecked();
1647 fTimeGraphCtrl
.hideArrows(hideArrows
);
1649 if (dialogSettings
!= null) {
1650 dialogSettings
.put(HIDE_ARROWS_KEY
, hideArrows
);
1652 if (fFollowArrowFwdAction
!= null) {
1653 fFollowArrowFwdAction
.setEnabled(!hideArrows
);
1655 if (fFollowArrowBwdAction
!= null) {
1656 fFollowArrowBwdAction
.setEnabled(!hideArrows
);
1660 fHideArrowsAction
.setToolTipText(Messages
.TmfTimeGraphViewer_HideArrowsActionToolTipText
);
1661 fHideArrowsAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_HIDE_ARROWS
));
1662 if (dialogSettings
!= null) {
1663 boolean hideArrows
= dialogSettings
.getBoolean(HIDE_ARROWS_KEY
);
1664 fTimeGraphCtrl
.hideArrows(hideArrows
);
1665 fHideArrowsAction
.setChecked(hideArrows
);
1666 if (fFollowArrowFwdAction
!= null) {
1667 fFollowArrowFwdAction
.setEnabled(!hideArrows
);
1669 if (fFollowArrowBwdAction
!= null) {
1670 fFollowArrowBwdAction
.setEnabled(!hideArrows
);
1674 return fHideArrowsAction
;
1678 * Get the follow arrow forward action.
1680 * @return The Action object
1684 public Action
getFollowArrowFwdAction() {
1685 if (fFollowArrowFwdAction
== null) {
1686 fFollowArrowFwdAction
= new Action() {
1689 fTimeGraphCtrl
.followArrowFwd();
1690 adjustVerticalScrollBar();
1693 fFollowArrowFwdAction
.setText(Messages
.TmfTimeGraphViewer_FollowArrowForwardActionNameText
);
1694 fFollowArrowFwdAction
.setToolTipText(Messages
.TmfTimeGraphViewer_FollowArrowForwardActionToolTipText
);
1695 fFollowArrowFwdAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_FOLLOW_ARROW_FORWARD
));
1696 if (fHideArrowsAction
!= null) {
1697 fFollowArrowFwdAction
.setEnabled(!fHideArrowsAction
.isChecked());
1700 return fFollowArrowFwdAction
;
1704 * Get the follow arrow backward action.
1706 * @return The Action object
1710 public Action
getFollowArrowBwdAction() {
1711 if (fFollowArrowBwdAction
== null) {
1712 fFollowArrowBwdAction
= new Action() {
1715 fTimeGraphCtrl
.followArrowBwd();
1716 adjustVerticalScrollBar();
1719 fFollowArrowBwdAction
.setText(Messages
.TmfTimeGraphViewer_FollowArrowBackwardActionNameText
);
1720 fFollowArrowBwdAction
.setToolTipText(Messages
.TmfTimeGraphViewer_FollowArrowBackwardActionToolTipText
);
1721 fFollowArrowBwdAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_FOLLOW_ARROW_BACKWARD
));
1722 if (fHideArrowsAction
!= null) {
1723 fFollowArrowBwdAction
.setEnabled(!fHideArrowsAction
.isChecked());
1726 return fFollowArrowBwdAction
;
1729 private void adjustHorizontalScrollBar() {
1730 long time0
= getTime0();
1731 long time1
= getTime1();
1732 long timeMin
= getMinTime();
1733 long timeMax
= getMaxTime();
1734 long delta
= timeMax
- timeMin
;
1736 int thumb
= H_SCROLLBAR_MAX
;
1738 // Thumb size (page size)
1739 thumb
= Math
.max(1, (int) (H_SCROLLBAR_MAX
* ((double) (time1
- time0
) / delta
)));
1740 // At the beginning of visible window
1741 timePos
= (int) (H_SCROLLBAR_MAX
* ((double) (time0
- timeMin
) / delta
));
1743 fHorizontalScrollBar
.setValues(timePos
, 0, H_SCROLLBAR_MAX
, thumb
, Math
.max(1, thumb
/ 2), Math
.max(2, thumb
));
1746 private void adjustVerticalScrollBar() {
1747 int topIndex
= fTimeGraphCtrl
.getTopIndex();
1748 int countPerPage
= fTimeGraphCtrl
.countPerPage();
1749 int expandedElementCount
= fTimeGraphCtrl
.getExpandedElementCount();
1750 if (topIndex
+ countPerPage
> expandedElementCount
) {
1751 fTimeGraphCtrl
.setTopIndex(Math
.max(0, expandedElementCount
- countPerPage
));
1754 int selection
= fTimeGraphCtrl
.getTopIndex();
1756 int max
= Math
.max(1, expandedElementCount
- 1);
1757 int thumb
= Math
.min(max
, Math
.max(1, countPerPage
- 1));
1759 int pageIncrement
= Math
.max(1, countPerPage
);
1760 fVerticalScrollBar
.setValues(selection
, min
, max
, thumb
, increment
, pageIncrement
);
1765 * a {@link MenuDetectListener}
1766 * @see org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#addTimeGraphEntryMenuListener(org.eclipse.swt.events.MenuDetectListener)
1769 public void addTimeGraphEntryMenuListener(MenuDetectListener listener
) {
1770 fTimeGraphCtrl
.addTimeGraphEntryMenuListener(listener
);
1775 * a {@link MenuDetectListener}
1776 * @see org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#removeTimeGraphEntryMenuListener(org.eclipse.swt.events.MenuDetectListener)
1779 public void removeTimeGraphEntryMenuListener(MenuDetectListener listener
) {
1780 fTimeGraphCtrl
.removeTimeGraphEntryMenuListener(listener
);
1785 * a {@link MenuDetectListener}
1786 * @see org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#addTimeEventMenuListener(org.eclipse.swt.events.MenuDetectListener)
1789 public void addTimeEventMenuListener(MenuDetectListener listener
) {
1790 fTimeGraphCtrl
.addTimeEventMenuListener(listener
);
1795 * a {@link MenuDetectListener}
1796 * @see org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#removeTimeEventMenuListener(org.eclipse.swt.events.MenuDetectListener)
1799 public void removeTimeEventMenuListener(MenuDetectListener listener
) {
1800 fTimeGraphCtrl
.removeTimeEventMenuListener(listener
);
1805 * The filter object to be attached to the view
1808 public void addFilter(ViewerFilter filter
) {
1809 fTimeGraphCtrl
.addFilter(filter
);
1815 * The filter object to be attached to the view
1818 public void removeFilter(ViewerFilter filter
) {
1819 fTimeGraphCtrl
.removeFilter(filter
);