1 /*****************************************************************************
2 * Copyright (c) 2007, 2008 Intel Corporation, 2009, 2010, 2011, 2012 Ericsson.
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
15 *****************************************************************************/
17 package org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
;
19 import java
.util
.ArrayList
;
21 import org
.eclipse
.jface
.action
.Action
;
22 import org
.eclipse
.jface
.viewers
.ISelectionProvider
;
23 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Activator
;
24 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.ITmfImageConstants
;
25 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Messages
;
26 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.dialogs
.TimeGraphLegend
;
27 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.model
.ITimeEvent
;
28 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.model
.ITimeGraphEntry
;
29 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
.ITimeDataProvider
;
30 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
.TimeGraphColorScheme
;
31 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
.TimeGraphControl
;
32 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
.TimeGraphScale
;
33 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
.TimeGraphTooltipHandler
;
34 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
.Utils
;
35 import org
.eclipse
.swt
.SWT
;
36 import org
.eclipse
.swt
.events
.ControlAdapter
;
37 import org
.eclipse
.swt
.events
.ControlEvent
;
38 import org
.eclipse
.swt
.events
.KeyAdapter
;
39 import org
.eclipse
.swt
.events
.KeyEvent
;
40 import org
.eclipse
.swt
.events
.MouseEvent
;
41 import org
.eclipse
.swt
.events
.MouseWheelListener
;
42 import org
.eclipse
.swt
.events
.SelectionAdapter
;
43 import org
.eclipse
.swt
.events
.SelectionEvent
;
44 import org
.eclipse
.swt
.events
.SelectionListener
;
45 import org
.eclipse
.swt
.graphics
.Rectangle
;
46 import org
.eclipse
.swt
.layout
.FillLayout
;
47 import org
.eclipse
.swt
.layout
.GridData
;
48 import org
.eclipse
.swt
.layout
.GridLayout
;
49 import org
.eclipse
.swt
.widgets
.Composite
;
50 import org
.eclipse
.swt
.widgets
.Control
;
51 import org
.eclipse
.swt
.widgets
.ScrollBar
;
52 import org
.eclipse
.swt
.widgets
.Slider
;
54 public class TimeGraphViewer
implements ITimeDataProvider
, SelectionListener
{
57 private long _minTimeInterval
;
58 private long _selectedTime
;
59 private ITimeGraphEntry _selectedEntry
;
60 private long _beginTime
;
61 private long _endTime
;
66 private long _time0_extSynch
= 0;
67 private long _time1_extSynch
= 0;
68 private boolean _timeRangeFixed
;
69 private int _nameWidthPref
= 200;
70 private int _minNameWidth
= 6;
71 private int _nameWidth
;
72 private Composite _dataViewer
;
74 private TimeGraphControl _stateCtrl
;
75 private TimeGraphScale _timeScaleCtrl
;
76 private Slider _verticalScrollBar
;
77 private TimeGraphTooltipHandler _threadTip
;
78 private TimeGraphColorScheme _colors
;
79 private ITimeGraphPresentationProvider fTimeGraphProvider
;
81 ArrayList
<ITimeGraphSelectionListener
> fSelectionListeners
= new ArrayList
<ITimeGraphSelectionListener
>();
82 ArrayList
<ITimeGraphTimeListener
> fTimeListeners
= new ArrayList
<ITimeGraphTimeListener
>();
83 ArrayList
<ITimeGraphRangeListener
> fRangeListeners
= new ArrayList
<ITimeGraphRangeListener
>();
85 // Calender Time format, using Epoch reference or Relative time
87 private boolean calendarTimeFormat
= false;
88 private int borderWidth
= 0;
89 private int timeScaleHeight
= 22;
91 private Action resetScale
;
92 private Action showLegendAction
;
93 private Action nextEventAction
;
94 private Action prevEventAction
;
95 private Action nextItemAction
;
96 private Action previousItemAction
;
97 private Action zoomInAction
;
98 private Action zoomOutAction
;
101 public TimeGraphViewer(Composite parent
, int style
) {
102 createDataViewer(parent
, style
);
106 * Sets the timegraph provider used by this timegraph viewer.
108 * @param timeGraphProvider the timegraph provider
110 public void setTimeGraphProvider(ITimeGraphPresentationProvider timeGraphProvider
) {
111 fTimeGraphProvider
= timeGraphProvider
;
112 _stateCtrl
.setTimeGraphProvider(timeGraphProvider
);
113 _threadTip
= new TimeGraphTooltipHandler(_dataViewer
.getShell(), fTimeGraphProvider
, this);
114 _threadTip
.activateHoverHelp(_stateCtrl
);
118 * Sets or clears the input for this time graph viewer.
119 * The input array should only contain top-level elements.
121 * @param input the input of this time graph viewer, or <code>null</code> if none
123 public void setInput(ITimeGraphEntry
[] input
) {
124 if (null != _stateCtrl
) {
126 input
= new ITimeGraphEntry
[0];
129 _verticalScrollBar
.setEnabled(true);
132 refreshAllData(input
);
136 public void refresh() {
137 setInput(_stateCtrl
.getTraces());
140 public void controlMoved(ControlEvent e
) {
143 public void controlResized(ControlEvent e
) {
147 // called from the display order in the API
148 public void modelUpdate(ITimeGraphEntry
[] traces
, long start
,
149 long end
, boolean updateTimeBounds
) {
150 if (null != _stateCtrl
) {
152 updateInternalData(traces
, start
, end
);
153 if (updateTimeBounds
) {
154 _timeRangeFixed
= true;
155 // set window to match limits
156 setStartFinishTime(_time0_
, _time1_
);
159 _timeScaleCtrl
.redraw();
164 protected String
getViewTypeStr() {
165 return "viewoption.threads"; //$NON-NLS-1$
168 int getMarginWidth(int idx
) {
172 int getMarginHeight(int idx
) {
177 _minTimeInterval
= 1;
179 _nameWidth
= Utils
.loadIntOption(getPreferenceString("namewidth"), //$NON-NLS-1$
180 _nameWidthPref
, _minNameWidth
, 1000);
184 Utils
.saveIntOption(getPreferenceString("namewidth"), _nameWidth
); //$NON-NLS-1$
187 protected Control
createDataViewer(Composite parent
, int style
) {
189 _colors
= new TimeGraphColorScheme();
190 _dataViewer
= new Composite(parent
, style
) {
192 public void redraw() {
193 _timeScaleCtrl
.redraw();
198 GridLayout gl
= new GridLayout(2, false);
199 gl
.marginHeight
= borderWidth
;
201 gl
.verticalSpacing
= 0;
202 gl
.horizontalSpacing
= 0;
203 _dataViewer
.setLayout(gl
);
205 _timeScaleCtrl
= new TimeGraphScale(_dataViewer
, _colors
);
206 _timeScaleCtrl
.setTimeProvider(this);
207 _timeScaleCtrl
.setLayoutData(new GridData(SWT
.FILL
, SWT
.DEFAULT
, true, false));
208 _timeScaleCtrl
.setHeight(timeScaleHeight
);
210 _verticalScrollBar
= new Slider(_dataViewer
, SWT
.VERTICAL
| SWT
.NO_FOCUS
);
211 _verticalScrollBar
.setLayoutData(new GridData(SWT
.DEFAULT
, SWT
.FILL
, false, true, 1, 2));
212 _verticalScrollBar
.addSelectionListener(new SelectionAdapter() {
214 public void widgetSelected(SelectionEvent e
) {
215 setTopIndex(_verticalScrollBar
.getSelection());
218 _verticalScrollBar
.setEnabled(false);
220 _stateCtrl
= createTimeGraphControl();
222 _stateCtrl
.setTimeProvider(this);
223 _stateCtrl
.addSelectionListener(this);
224 _stateCtrl
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true, 1, 2));
225 _stateCtrl
.addMouseWheelListener(new MouseWheelListener() {
227 public void mouseScrolled(MouseEvent e
) {
228 adjustVerticalScrollBar();
231 _stateCtrl
.addKeyListener(new KeyAdapter() {
233 public void keyPressed(KeyEvent e
) {
234 adjustVerticalScrollBar();
238 Composite filler
= new Composite(_dataViewer
, SWT
.NONE
);
239 GridData gd
= new GridData(SWT
.DEFAULT
, SWT
.DEFAULT
, false, false);
240 gd
.heightHint
= _stateCtrl
.getHorizontalBar().getSize().y
;
241 filler
.setLayoutData(gd
);
242 filler
.setLayout(new FillLayout());
244 _stateCtrl
.addControlListener(new ControlAdapter() {
246 public void controlResized(ControlEvent event
) {
251 _dataViewer
.update();
252 adjustVerticalScrollBar();
256 public void dispose() {
258 _stateCtrl
.dispose();
259 _dataViewer
.dispose();
263 protected TimeGraphControl
createTimeGraphControl() {
264 return new TimeGraphControl(_dataViewer
, _colors
);
267 public void resizeControls() {
268 Rectangle r
= _dataViewer
.getClientArea();
273 if (_nameWidth
> width
- _minNameWidth
)
274 _nameWidth
= width
- _minNameWidth
;
275 if (_nameWidth
< _minNameWidth
)
276 _nameWidth
= _minNameWidth
;
277 adjustVerticalScrollBar();
280 /** Tries to set most convenient time range for display. */
281 public void setTimeRange(ITimeGraphEntry traces
[]) {
284 for (int i
= 0; i
< traces
.length
; i
++) {
285 ITimeGraphEntry entry
= traces
[i
];
286 if (entry
.getEndTime() >= entry
.getStartTime() && entry
.getEndTime() > 0) {
287 if (_beginTime
< 0 || entry
.getStartTime() < _beginTime
) {
288 _beginTime
= entry
.getStartTime();
290 if (entry
.getEndTime() > _endTime
) {
291 _endTime
= entry
.getEndTime();
296 if (_beginTime
< 0) {
301 public void setTimeBounds() {
302 //_time0_ = _beginTime - (long) ((_endTime - _beginTime) * 0.02);
303 _time0_
= _beginTime
;
306 // _time1_ = _time0_ + (_endTime - _time0_) * 1.05;
308 // _time0_ = Math.floor(_time0_);
309 // _time1_ = Math.ceil(_time1_);
310 if (!_timeRangeFixed
) {
314 if (_time1
- _time0
< _minTimeInterval
) {
315 _time1
= _time0
+ _minTimeInterval
;
324 void updateInternalData(ITimeGraphEntry
[] traces
, long start
, long end
) {
326 traces
= new ITimeGraphEntry
[0];
327 if ((start
== 0 && end
== 0) || start
< 0 || end
< 0) {
328 // Start and end time are unspecified and need to be determined from
329 // individual processes
330 setTimeRange(traces
);
336 refreshAllData(traces
);
342 private void refreshAllData(ITimeGraphEntry
[] traces
) {
344 if (_selectedTime
< _beginTime
) {
345 _selectedTime
= _beginTime
;
346 } else if (_selectedTime
> _endTime
) {
347 _selectedTime
= _endTime
;
349 _stateCtrl
.refreshData(traces
);
350 _timeScaleCtrl
.redraw();
351 adjustVerticalScrollBar();
354 public void setFocus() {
355 if (null != _stateCtrl
)
356 _stateCtrl
.setFocus();
359 public boolean isInFocus() {
360 return _stateCtrl
.isInFocus();
363 public ITimeGraphEntry
getSelection() {
364 return _stateCtrl
.getSelectedTrace();
367 public int getSelectionIndex() {
368 return _stateCtrl
.getSelectedIndex();
372 public long getTime0() {
377 public long getTime1() {
382 public long getMinTimeInterval() {
383 return _minTimeInterval
;
387 public int getNameSpace() {
392 public void setNameSpace(int width
) {
394 width
= _stateCtrl
.getClientArea().width
;
395 if (_nameWidth
> width
- 6)
396 _nameWidth
= width
- 6;
399 _stateCtrl
.adjustScrolls();
401 _timeScaleCtrl
.redraw();
405 public int getTimeSpace() {
406 int w
= _stateCtrl
.getClientArea().width
;
407 return w
- _nameWidth
;
411 public long getSelectedTime() {
412 return _selectedTime
;
416 public long getBeginTime() {
421 public long getEndTime() {
426 public long getMaxTime() {
431 public long getMinTime() {
439 * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider
440 * #setStartFinishTimeNotify(long, long)
443 public void setStartFinishTimeNotify(long time0
, long time1
) {
444 setStartFinishTime(time0
, time1
);
445 notifyRangeListeners(time0
, time1
);
450 * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider#notifyStartFinishTime()
453 public void notifyStartFinishTime() {
454 notifyRangeListeners(_time0
, _time1
);
461 * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider
462 * #setStartFinishTime(long, long)
465 public void setStartFinishTime(long time0
, long time1
) {
467 if (_time0
< _time0_
)
469 if (_time0
> _time1_
)
472 if (_time1
< _time0_
)
474 if (_time1
> _time1_
)
476 if (_time1
- _time0
< _minTimeInterval
)
477 _time1
= Math
.min(_time1_
, _time0
+ _minTimeInterval
);
478 _timeRangeFixed
= true;
479 _stateCtrl
.adjustScrolls();
481 _timeScaleCtrl
.redraw();
484 public void setTimeBounds(long beginTime
, long endTime
) {
485 _beginTime
= beginTime
;
489 _stateCtrl
.adjustScrolls();
493 public void resetStartFinishTime() {
494 setStartFinishTimeNotify(_time0_
, _time1_
);
495 _timeRangeFixed
= false;
499 public void setSelectedTimeNotify(long time
, boolean ensureVisible
) {
500 setSelectedTimeInt(time
, ensureVisible
, true);
504 public void setSelectedTime(long time
, boolean ensureVisible
) {
505 setSelectedTimeInt(time
, ensureVisible
, false);
508 private void setSelectedTimeInt(long time
, boolean ensureVisible
, boolean doNotify
) {
512 long timeSpace
= (long) ((_time1
- _time0
) * .02);
513 long timeMid
= (long) ((_time1
- _time0
) * .5);
514 if (time
< _time0
+ timeSpace
) {
515 long dt
= _time0
- time
+ timeMid
;
518 } else if (time
> _time1
- timeSpace
) {
519 long dt
= time
- _time1
+ timeMid
;
523 if (_time0
< _time0_
) {
524 _time1
= Math
.min(_time1_
, _time1
+ (_time0_
- _time0
));
526 } else if (_time1
> _time1_
) {
527 _time0
= Math
.max(_time0_
, _time0
- (_time1
- _time1_
));
531 if (_time1
- _time0
< _minTimeInterval
) {
532 _time1
= _time0
+ _minTimeInterval
;
534 _stateCtrl
.adjustScrolls();
536 _timeScaleCtrl
.redraw();
539 boolean notifySelectedTime
= (time
!= _selectedTime
);
540 _selectedTime
= time
;
542 if (doNotify
&& ((time0
!= _time0
) || (time1
!= _time1
))) {
543 notifyRangeListeners(_time0
, _time1
);
546 if (doNotify
&& notifySelectedTime
) {
547 notifyTimeListeners(_selectedTime
);
552 public void widgetDefaultSelected(SelectionEvent e
) {
553 if (_selectedEntry
!= getSelection()) {
554 _selectedEntry
= getSelection();
555 notifySelectionListeners(_selectedEntry
);
560 public void widgetSelected(SelectionEvent e
) {
561 if (_selectedEntry
!= getSelection()) {
562 _selectedEntry
= getSelection();
563 notifySelectionListeners(_selectedEntry
);
567 public void selectNextEvent() {
568 _stateCtrl
.selectNextEvent();
569 adjustVerticalScrollBar();
572 public void selectPrevEvent() {
573 _stateCtrl
.selectPrevEvent();
574 adjustVerticalScrollBar();
577 public void selectNextItem() {
578 _stateCtrl
.selectNextTrace();
579 adjustVerticalScrollBar();
582 public void selectPrevItem() {
583 _stateCtrl
.selectPrevTrace();
584 adjustVerticalScrollBar();
587 public void showLegend() {
588 if (_dataViewer
== null || _dataViewer
.isDisposed())
591 TimeGraphLegend
.open(_dataViewer
.getShell(), fTimeGraphProvider
);
594 public void zoomIn() {
598 public void zoomOut() {
599 _stateCtrl
.zoomOut();
602 private String
getPreferenceString(String string
) {
603 return getViewTypeStr() + "." + string
; //$NON-NLS-1$
606 public void addSelectionListener(ITimeGraphSelectionListener listener
) {
607 fSelectionListeners
.add(listener
);
610 public void removeSelectionListener(ITimeGraphSelectionListener listener
) {
611 fSelectionListeners
.remove(listener
);
614 private void notifySelectionListeners(ITimeGraphEntry selection
) {
615 TimeGraphSelectionEvent event
= new TimeGraphSelectionEvent(this, selection
);
617 for (ITimeGraphSelectionListener listener
: fSelectionListeners
) {
618 listener
.selectionChanged(event
);
622 public void addTimeListener(ITimeGraphTimeListener listener
) {
623 fTimeListeners
.add(listener
);
626 public void removeTimeListener(ITimeGraphTimeListener listener
) {
627 fTimeListeners
.remove(listener
);
630 private void notifyTimeListeners(long time
) {
631 TimeGraphTimeEvent event
= new TimeGraphTimeEvent(this, time
);
633 for (ITimeGraphTimeListener listener
: fTimeListeners
) {
634 listener
.timeSelected(event
);
638 public void addRangeListener(ITimeGraphRangeListener listener
) {
639 fRangeListeners
.add(listener
);
642 public void removeRangeListener(ITimeGraphRangeListener listener
) {
643 fRangeListeners
.remove(listener
);
646 private void notifyRangeListeners(long startTime
, long endTime
) {
647 // Check if the time has actually changed from last notification
648 if (startTime
!= _time0_extSynch
|| endTime
!= _time1_extSynch
) {
649 // Notify Time Scale Selection Listeners
650 TimeGraphRangeUpdateEvent event
= new TimeGraphRangeUpdateEvent(this, startTime
, endTime
);
652 for (ITimeGraphRangeListener listener
: fRangeListeners
) {
653 listener
.timeRangeUpdated(event
);
656 // update external synch timers
657 updateExtSynchTimers();
661 public void setSelectedEvent(ITimeEvent event
, Object source
) {
662 if (event
== null || source
== this) {
665 _selectedEntry
= event
.getEntry();
666 _stateCtrl
.selectItem(_selectedEntry
, false);
668 setSelectedTimeInt(event
.getTime(), true, true);
669 adjustVerticalScrollBar();
672 public void setSelectedTraceTime(ITimeGraphEntry trace
, long time
, Object source
) {
673 if (trace
== null || source
== this) {
676 _selectedEntry
= trace
;
677 _stateCtrl
.selectItem(trace
, false);
679 setSelectedTimeInt(time
, true, true);
682 public void setSelection(ITimeGraphEntry trace
) {
683 _selectedEntry
= trace
;
684 _stateCtrl
.selectItem(trace
, false);
685 adjustVerticalScrollBar();
688 public void setSelectVisTimeWindow(long time0
, long time1
, Object source
) {
689 if (source
== this) {
693 setStartFinishTime(time0
, time1
);
695 // update notification time values since we are now in synch with the
696 // external application
697 updateExtSynchTimers();
701 * update the cache timers used to identify the need to send a time window
702 * update to external registered listeners
704 private void updateExtSynchTimers() {
705 // last time notification cache
706 _time0_extSynch
= _time0
;
707 _time1_extSynch
= _time1
;
710 public void setTimeCalendarFormat(boolean toAbsoluteCaltime
) {
711 calendarTimeFormat
= toAbsoluteCaltime
;
715 public boolean isCalendarFormat() {
716 return calendarTimeFormat
;
719 public int getBorderWidth() {
723 public void setBorderWidth(int borderWidth
) {
724 if (borderWidth
> -1) {
725 this.borderWidth
= borderWidth
;
726 GridLayout gl
= (GridLayout
)_dataViewer
.getLayout();
727 gl
.marginHeight
= borderWidth
;
731 public int getHeaderHeight() {
732 return timeScaleHeight
;
735 public void setHeaderHeight(int headerHeight
) {
736 if (headerHeight
> -1) {
737 this.timeScaleHeight
= headerHeight
;
738 _timeScaleCtrl
.setHeight(headerHeight
);
742 public int getItemHeight() {
743 if (_stateCtrl
!= null) {
744 return _stateCtrl
.getItemHeight();
749 public void setItemHeight(int rowHeight
) {
750 if (_stateCtrl
!= null) {
751 _stateCtrl
.setItemHeight(rowHeight
);
755 public void setMinimumItemWidth(int width
) {
756 if (_stateCtrl
!= null) {
757 _stateCtrl
.setMinimumItemWidth(width
);
761 public void setNameWidthPref(int width
) {
762 _nameWidthPref
= width
;
769 public int getNameWidthPref(int width
) {
770 return _nameWidthPref
;
774 * Returns the primary control associated with this viewer.
776 * @return the SWT control which displays this viewer's content
778 public Control
getControl() {
783 * Returns the time graph control associated with this viewer.
785 * @return the time graph control
787 TimeGraphControl
getTimeGraphControl() {
792 * Returns the time graph scale associated with this viewer.
794 * @return the time graph scale
796 TimeGraphScale
getTimeGraphScale() {
797 return _timeScaleCtrl
;
801 * Get the selection provider
803 * @return the selection provider
805 public ISelectionProvider
getSelectionProvider() {
813 * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer
814 * #waitCursor(boolean)
816 public void waitCursor(boolean waitInd
) {
817 _stateCtrl
.waitCursor(waitInd
);
820 public ScrollBar
getHorizontalBar() {
821 return _stateCtrl
.getHorizontalBar();
824 public Slider
getVerticalBar() {
825 return _verticalScrollBar
;
828 public void setTopIndex(int index
) {
829 _stateCtrl
.setTopIndex(index
);
830 adjustVerticalScrollBar();
833 public int getTopIndex() {
834 return _stateCtrl
.getTopIndex();
837 public void setExpandedState(ITimeGraphEntry entry
, boolean expanded
) {
838 _stateCtrl
.setExpandedState(entry
, expanded
);
839 adjustVerticalScrollBar();
842 public int getExpandedElementCount() {
843 return _stateCtrl
.getExpandedElementCount();
846 public ITimeGraphEntry
[] getExpandedElements() {
847 return _stateCtrl
.getExpandedElements();
850 public void addTreeListener(ITimeGraphTreeListener listener
) {
851 _stateCtrl
.addTreeListener(listener
);
854 public void removeTreeListener(ITimeGraphTreeListener listener
) {
855 _stateCtrl
.removeTreeListener(listener
);
858 public Action
getResetScaleAction() {
859 if (resetScale
== null) {
861 resetScale
= new Action() {
864 resetStartFinishTime();
867 resetScale
.setText(Messages
.TmfTimeGraphViewer_ResetScaleActionNameText
);
868 resetScale
.setToolTipText(Messages
.TmfTimeGraphViewer_ResetScaleActionToolTipText
);
869 resetScale
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_HOME_MENU
));
874 public Action
getShowLegendAction() {
875 if (showLegendAction
== null) {
877 showLegendAction
= new Action() {
883 showLegendAction
.setText(Messages
.TmfTimeGraphViewer_LegendActionNameText
);
884 showLegendAction
.setToolTipText(Messages
.TmfTimeGraphViewer_LegendActionToolTipText
);
885 showLegendAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_SHOW_LEGEND
));
888 return showLegendAction
;
891 public Action
getNextEventAction() {
892 if (nextEventAction
== null) {
893 nextEventAction
= new Action() {
900 nextEventAction
.setText(Messages
.TmfTimeGraphViewer_NextEventActionNameText
);
901 nextEventAction
.setToolTipText(Messages
.TmfTimeGraphViewer_NextEventActionToolTipText
);
902 nextEventAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_NEXT_EVENT
));
905 return nextEventAction
;
908 public Action
getPreviousEventAction() {
909 if (prevEventAction
== null) {
910 prevEventAction
= new Action() {
917 prevEventAction
.setText(Messages
.TmfTimeGraphViewer_PreviousEventActionNameText
);
918 prevEventAction
.setToolTipText(Messages
.TmfTimeGraphViewer_PreviousEventActionToolTipText
);
919 prevEventAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_PREV_EVENT
));
922 return prevEventAction
;
925 public Action
getNextItemAction() {
926 if (nextItemAction
== null) {
928 nextItemAction
= new Action() {
934 nextItemAction
.setText(Messages
.TmfTimeGraphViewer_NextItemActionNameText
);
935 nextItemAction
.setToolTipText(Messages
.TmfTimeGraphViewer_NextItemActionToolTipText
);
936 nextItemAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_NEXT_ITEM
));
938 return nextItemAction
;
941 public Action
getPreviousItemAction() {
942 if (previousItemAction
== null) {
944 previousItemAction
= new Action() {
950 previousItemAction
.setText(Messages
.TmfTimeGraphViewer_PreviousItemActionNameText
);
951 previousItemAction
.setToolTipText(Messages
.TmfTimeGraphViewer_PreviousItemActionToolTipText
);
952 previousItemAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_PREV_ITEM
));
954 return previousItemAction
;
957 public Action
getZoomInAction() {
958 if (zoomInAction
== null) {
959 zoomInAction
= new Action() {
965 zoomInAction
.setText(Messages
.TmfTimeGraphViewer_ZoomInActionNameText
);
966 zoomInAction
.setToolTipText(Messages
.TmfTimeGraphViewer_ZoomInActionToolTipText
);
967 zoomInAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_ZOOM_IN_MENU
));
972 public Action
getZoomOutAction() {
973 if (zoomOutAction
== null) {
974 zoomOutAction
= new Action() {
980 zoomOutAction
.setText(Messages
.TmfTimeGraphViewer_ZoomOutActionNameText
);
981 zoomOutAction
.setToolTipText(Messages
.TmfTimeGraphViewer_ZoomOutActionToolTipText
);
982 zoomOutAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_ZOOM_OUT_MENU
));
984 return zoomOutAction
;
988 private void adjustVerticalScrollBar() {
989 int topIndex
= _stateCtrl
.getTopIndex();
990 int countPerPage
= _stateCtrl
.countPerPage();
991 int expandedElementCount
= _stateCtrl
.getExpandedElementCount();
992 if (topIndex
+ countPerPage
> expandedElementCount
) {
993 _stateCtrl
.setTopIndex(Math
.max(0, expandedElementCount
- countPerPage
));
996 int selection
= _stateCtrl
.getTopIndex();
998 int max
= Math
.max(1, expandedElementCount
- 1);
999 int thumb
= Math
.min(max
, Math
.max(1, countPerPage
- 1));
1001 int pageIncrement
= Math
.max(1, countPerPage
);
1002 _verticalScrollBar
.setValues(selection
, min
, max
, thumb
, increment
, pageIncrement
);