Commit | Line | Data |
---|---|---|
be222f56 PT |
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 | |
7 | * | |
8 | * Contributors: | |
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 | * | |
15 | *****************************************************************************/ | |
16 | ||
17 | package org.eclipse.linuxtools.tmf.ui.widgets.timegraph; | |
18 | ||
19 | import java.util.ArrayList; | |
20 | ||
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; | |
53 | ||
54 | /** | |
55 | * Generic time graph viewer implementation | |
56 | * | |
57 | * @version 1.0 | |
58 | * @author Patrick Tasse, and others | |
59 | */ | |
60 | public class TimeGraphViewer implements ITimeDataProvider, SelectionListener { | |
61 | ||
62 | /** vars */ | |
63 | private long _minTimeInterval; | |
64 | private long _selectedTime; | |
65 | private ITimeGraphEntry _selectedEntry; | |
66 | private long _beginTime; | |
67 | private long _endTime; | |
68 | private long _time0; | |
69 | private long _time1; | |
70 | private long _time0_; | |
71 | private long _time1_; | |
72 | private long _time0_extSynch = 0; | |
73 | private long _time1_extSynch = 0; | |
74 | private boolean _timeRangeFixed; | |
75 | private int _nameWidthPref = 200; | |
76 | private int _minNameWidth = 6; | |
77 | private int _nameWidth; | |
78 | private Composite _dataViewer; | |
79 | ||
80 | private TimeGraphControl _stateCtrl; | |
81 | private TimeGraphScale _timeScaleCtrl; | |
82 | private Slider _verticalScrollBar; | |
83 | private TimeGraphTooltipHandler _threadTip; | |
84 | private TimeGraphColorScheme _colors; | |
85 | private ITimeGraphPresentationProvider fTimeGraphProvider; | |
86 | ||
87 | ArrayList<ITimeGraphSelectionListener> fSelectionListeners = new ArrayList<ITimeGraphSelectionListener>(); | |
88 | ArrayList<ITimeGraphTimeListener> fTimeListeners = new ArrayList<ITimeGraphTimeListener>(); | |
89 | ArrayList<ITimeGraphRangeListener> fRangeListeners = new ArrayList<ITimeGraphRangeListener>(); | |
90 | ||
91 | // Calender Time format, using Epoch reference or Relative time | |
92 | // format(default | |
93 | private boolean calendarTimeFormat = false; | |
94 | private int borderWidth = 0; | |
95 | private int timeScaleHeight = 22; | |
96 | ||
97 | private Action resetScale; | |
98 | private Action showLegendAction; | |
99 | private Action nextEventAction; | |
100 | private Action prevEventAction; | |
101 | private Action nextItemAction; | |
102 | private Action previousItemAction; | |
103 | private Action zoomInAction; | |
104 | private Action zoomOutAction; | |
105 | ||
106 | /** | |
107 | * Standard constructor | |
108 | * | |
109 | * @param parent | |
110 | * The parent UI composite object | |
111 | * @param style | |
112 | * The style to use | |
113 | */ | |
114 | public TimeGraphViewer(Composite parent, int style) { | |
115 | createDataViewer(parent, style); | |
116 | } | |
117 | ||
118 | /** | |
119 | * Sets the timegraph provider used by this timegraph viewer. | |
120 | * | |
121 | * @param timeGraphProvider the timegraph provider | |
122 | */ | |
123 | public void setTimeGraphProvider(ITimeGraphPresentationProvider timeGraphProvider) { | |
124 | fTimeGraphProvider = timeGraphProvider; | |
125 | _stateCtrl.setTimeGraphProvider(timeGraphProvider); | |
126 | _threadTip = new TimeGraphTooltipHandler(_dataViewer.getShell(), fTimeGraphProvider, this); | |
127 | _threadTip.activateHoverHelp(_stateCtrl); | |
128 | } | |
129 | ||
130 | /** | |
131 | * Sets or clears the input for this time graph viewer. | |
132 | * The input array should only contain top-level elements. | |
133 | * | |
134 | * @param input the input of this time graph viewer, or <code>null</code> if none | |
135 | */ | |
136 | public void setInput(ITimeGraphEntry[] input) { | |
137 | if (null != _stateCtrl) { | |
138 | if (null == input) { | |
139 | input = new ITimeGraphEntry[0]; | |
140 | } | |
141 | setTimeRange(input); | |
142 | _verticalScrollBar.setEnabled(true); | |
143 | setTopIndex(0); | |
144 | _selectedTime = 0; | |
145 | _selectedEntry = null; | |
146 | refreshAllData(input); | |
147 | } | |
148 | } | |
149 | ||
150 | /** | |
151 | * Refresh the view | |
152 | */ | |
153 | public void refresh() { | |
154 | setInput(_stateCtrl.getTraces()); | |
155 | } | |
156 | ||
157 | /** | |
158 | * Callback for when the control is moved | |
159 | * | |
160 | * @param e | |
161 | * The caller event | |
162 | */ | |
163 | public void controlMoved(ControlEvent e) { | |
164 | } | |
165 | ||
166 | /** | |
167 | * Callback for when the control is resized | |
168 | * | |
169 | * @param e | |
170 | * The caller event | |
171 | */ | |
172 | public void controlResized(ControlEvent e) { | |
173 | resizeControls(); | |
174 | } | |
175 | ||
176 | /** | |
177 | * Handler for when the model is updated. Called from the display order in | |
178 | * the API | |
179 | * | |
180 | * @param traces | |
181 | * The traces in the model | |
182 | * @param start | |
183 | * The start time | |
184 | * @param end | |
185 | * The end time | |
186 | * @param updateTimeBounds | |
187 | * Should we updated the time bounds too | |
188 | */ | |
189 | public void modelUpdate(ITimeGraphEntry[] traces, long start, | |
190 | long end, boolean updateTimeBounds) { | |
191 | if (null != _stateCtrl) { | |
192 | //loadOptions(); | |
193 | updateInternalData(traces, start, end); | |
194 | if (updateTimeBounds) { | |
195 | _timeRangeFixed = true; | |
196 | // set window to match limits | |
197 | setStartFinishTime(_time0_, _time1_); | |
198 | } else { | |
199 | _stateCtrl.redraw(); | |
200 | _timeScaleCtrl.redraw(); | |
201 | } | |
202 | } | |
203 | } | |
204 | ||
205 | protected String getViewTypeStr() { | |
206 | return "viewoption.threads"; //$NON-NLS-1$ | |
207 | } | |
208 | ||
209 | int getMarginWidth(int idx) { | |
210 | return 0; | |
211 | } | |
212 | ||
213 | int getMarginHeight(int idx) { | |
214 | return 0; | |
215 | } | |
216 | ||
217 | void loadOptions() { | |
218 | _minTimeInterval = 1; | |
219 | _selectedTime = -1; | |
220 | _nameWidth = Utils.loadIntOption(getPreferenceString("namewidth"), //$NON-NLS-1$ | |
221 | _nameWidthPref, _minNameWidth, 1000); | |
222 | } | |
223 | ||
224 | void saveOptions() { | |
225 | Utils.saveIntOption(getPreferenceString("namewidth"), _nameWidth); //$NON-NLS-1$ | |
226 | } | |
227 | ||
228 | protected Control createDataViewer(Composite parent, int style) { | |
229 | loadOptions(); | |
230 | _colors = new TimeGraphColorScheme(); | |
231 | _dataViewer = new Composite(parent, style) { | |
232 | @Override | |
233 | public void redraw() { | |
234 | _timeScaleCtrl.redraw(); | |
235 | _stateCtrl.redraw(); | |
236 | super.redraw(); | |
237 | } | |
238 | }; | |
239 | GridLayout gl = new GridLayout(2, false); | |
240 | gl.marginHeight = borderWidth; | |
241 | gl.marginWidth = 0; | |
242 | gl.verticalSpacing = 0; | |
243 | gl.horizontalSpacing = 0; | |
244 | _dataViewer.setLayout(gl); | |
245 | ||
246 | _timeScaleCtrl = new TimeGraphScale(_dataViewer, _colors); | |
247 | _timeScaleCtrl.setTimeProvider(this); | |
248 | _timeScaleCtrl.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); | |
249 | _timeScaleCtrl.setHeight(timeScaleHeight); | |
250 | ||
251 | _verticalScrollBar = new Slider(_dataViewer, SWT.VERTICAL | SWT.NO_FOCUS); | |
252 | _verticalScrollBar.setLayoutData(new GridData(SWT.DEFAULT, SWT.FILL, false, true, 1, 2)); | |
253 | _verticalScrollBar.addSelectionListener(new SelectionAdapter() { | |
254 | @Override | |
255 | public void widgetSelected(SelectionEvent e) { | |
256 | setTopIndex(_verticalScrollBar.getSelection()); | |
257 | } | |
258 | }); | |
259 | _verticalScrollBar.setEnabled(false); | |
260 | ||
261 | _stateCtrl = createTimeGraphControl(); | |
262 | ||
263 | _stateCtrl.setTimeProvider(this); | |
264 | _stateCtrl.addSelectionListener(this); | |
265 | _stateCtrl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2)); | |
266 | _stateCtrl.addMouseWheelListener(new MouseWheelListener() { | |
267 | @Override | |
268 | public void mouseScrolled(MouseEvent e) { | |
269 | adjustVerticalScrollBar(); | |
270 | } | |
271 | }); | |
272 | _stateCtrl.addKeyListener(new KeyAdapter() { | |
273 | @Override | |
274 | public void keyPressed(KeyEvent e) { | |
275 | adjustVerticalScrollBar(); | |
276 | } | |
277 | }); | |
278 | ||
279 | Composite filler = new Composite(_dataViewer, SWT.NONE); | |
280 | GridData gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false); | |
281 | gd.heightHint = _stateCtrl.getHorizontalBar().getSize().y; | |
282 | filler.setLayoutData(gd); | |
283 | filler.setLayout(new FillLayout()); | |
284 | ||
285 | _stateCtrl.addControlListener(new ControlAdapter() { | |
286 | @Override | |
287 | public void controlResized(ControlEvent event) { | |
288 | resizeControls(); | |
289 | } | |
290 | }); | |
291 | resizeControls(); | |
292 | _dataViewer.update(); | |
293 | adjustVerticalScrollBar(); | |
294 | return _dataViewer; | |
295 | } | |
296 | ||
297 | /** | |
298 | * Dispose the view. | |
299 | */ | |
300 | public void dispose() { | |
301 | saveOptions(); | |
302 | _stateCtrl.dispose(); | |
303 | _dataViewer.dispose(); | |
304 | _colors.dispose(); | |
305 | } | |
306 | ||
307 | protected TimeGraphControl createTimeGraphControl() { | |
308 | return new TimeGraphControl(_dataViewer, _colors); | |
309 | } | |
310 | ||
311 | /** | |
312 | * Resize the controls | |
313 | */ | |
314 | public void resizeControls() { | |
315 | Rectangle r = _dataViewer.getClientArea(); | |
316 | if (r.isEmpty()) { | |
317 | return; | |
318 | } | |
319 | ||
320 | int width = r.width; | |
321 | if (_nameWidth > width - _minNameWidth) { | |
322 | _nameWidth = width - _minNameWidth; | |
323 | } | |
324 | if (_nameWidth < _minNameWidth) { | |
325 | _nameWidth = _minNameWidth; | |
326 | } | |
327 | adjustVerticalScrollBar(); | |
328 | } | |
329 | ||
330 | /** | |
331 | * Try to set most convenient time range for display. | |
332 | * | |
333 | * @param traces | |
334 | * The traces in the model | |
335 | */ | |
336 | public void setTimeRange(ITimeGraphEntry traces[]) { | |
337 | _endTime = 0; | |
338 | _beginTime = -1; | |
339 | for (int i = 0; i < traces.length; i++) { | |
340 | ITimeGraphEntry entry = traces[i]; | |
341 | if (entry.getEndTime() >= entry.getStartTime() && entry.getEndTime() > 0) { | |
342 | if (_beginTime < 0 || entry.getStartTime() < _beginTime) { | |
343 | _beginTime = entry.getStartTime(); | |
344 | } | |
345 | if (entry.getEndTime() > _endTime) { | |
346 | _endTime = entry.getEndTime(); | |
347 | } | |
348 | } | |
349 | } | |
350 | ||
351 | if (_beginTime < 0) { | |
352 | _beginTime = 0; | |
353 | } | |
354 | } | |
355 | ||
356 | /** | |
357 | * Recalculate the time bounds | |
358 | */ | |
359 | public void setTimeBounds() { | |
360 | //_time0_ = _beginTime - (long) ((_endTime - _beginTime) * 0.02); | |
361 | _time0_ = _beginTime; | |
362 | if (_time0_ < 0) { | |
363 | _time0_ = 0; | |
364 | } | |
365 | // _time1_ = _time0_ + (_endTime - _time0_) * 1.05; | |
366 | _time1_ = _endTime; | |
367 | // _time0_ = Math.floor(_time0_); | |
368 | // _time1_ = Math.ceil(_time1_); | |
369 | if (!_timeRangeFixed) { | |
370 | _time0 = _time0_; | |
371 | _time1 = _time1_; | |
372 | } | |
373 | if (_time1 - _time0 < _minTimeInterval) { | |
374 | _time1 = Math.min(_time1_, _time0 + _minTimeInterval); | |
375 | } | |
376 | } | |
377 | ||
378 | /** | |
379 | * @param traces | |
380 | * @param start | |
381 | * @param end | |
382 | */ | |
383 | void updateInternalData(ITimeGraphEntry[] traces, long start, long end) { | |
384 | if (null == traces) { | |
385 | traces = new ITimeGraphEntry[0]; | |
386 | } | |
387 | if ((start == 0 && end == 0) || start < 0 || end < 0) { | |
388 | // Start and end time are unspecified and need to be determined from | |
389 | // individual processes | |
390 | setTimeRange(traces); | |
391 | } else { | |
392 | _beginTime = start; | |
393 | _endTime = end; | |
394 | } | |
395 | ||
396 | refreshAllData(traces); | |
397 | } | |
398 | ||
399 | /** | |
400 | * @param traces | |
401 | */ | |
402 | private void refreshAllData(ITimeGraphEntry[] traces) { | |
403 | setTimeBounds(); | |
404 | if (_selectedTime < _beginTime) { | |
405 | _selectedTime = _beginTime; | |
406 | } else if (_selectedTime > _endTime) { | |
407 | _selectedTime = _endTime; | |
408 | } | |
409 | _stateCtrl.refreshData(traces); | |
410 | _timeScaleCtrl.redraw(); | |
411 | adjustVerticalScrollBar(); | |
412 | } | |
413 | ||
414 | /** | |
415 | * Callback for when this view is focused | |
416 | */ | |
417 | public void setFocus() { | |
418 | if (null != _stateCtrl) { | |
419 | _stateCtrl.setFocus(); | |
420 | } | |
421 | } | |
422 | ||
423 | /** | |
424 | * Get the current focus status of this view. | |
425 | * | |
426 | * @return If the view is currently focused, or not | |
427 | */ | |
428 | public boolean isInFocus() { | |
429 | return _stateCtrl.isInFocus(); | |
430 | } | |
431 | ||
432 | /** | |
433 | * Get the view's current selection | |
434 | * | |
435 | * @return The entry that is selected | |
436 | */ | |
437 | public ITimeGraphEntry getSelection() { | |
438 | return _stateCtrl.getSelectedTrace(); | |
439 | } | |
440 | ||
441 | /** | |
442 | * Get the index of the current selection | |
443 | * | |
444 | * @return The index | |
445 | */ | |
446 | public int getSelectionIndex() { | |
447 | return _stateCtrl.getSelectedIndex(); | |
448 | } | |
449 | ||
450 | @Override | |
451 | public long getTime0() { | |
452 | return _time0; | |
453 | } | |
454 | ||
455 | @Override | |
456 | public long getTime1() { | |
457 | return _time1; | |
458 | } | |
459 | ||
460 | @Override | |
461 | public long getMinTimeInterval() { | |
462 | return _minTimeInterval; | |
463 | } | |
464 | ||
465 | @Override | |
466 | public int getNameSpace() { | |
467 | return _nameWidth; | |
468 | } | |
469 | ||
470 | @Override | |
471 | public void setNameSpace(int width) { | |
472 | _nameWidth = width; | |
473 | width = _stateCtrl.getClientArea().width; | |
474 | if (_nameWidth > width - 6) { | |
475 | _nameWidth = width - 6; | |
476 | } | |
477 | if (_nameWidth < 6) { | |
478 | _nameWidth = 6; | |
479 | } | |
480 | _stateCtrl.adjustScrolls(); | |
481 | _stateCtrl.redraw(); | |
482 | _timeScaleCtrl.redraw(); | |
483 | } | |
484 | ||
485 | @Override | |
486 | public int getTimeSpace() { | |
487 | int w = _stateCtrl.getClientArea().width; | |
488 | return w - _nameWidth; | |
489 | } | |
490 | ||
491 | @Override | |
492 | public long getSelectedTime() { | |
493 | return _selectedTime; | |
494 | } | |
495 | ||
496 | @Override | |
497 | public long getBeginTime() { | |
498 | return _beginTime; | |
499 | } | |
500 | ||
501 | @Override | |
502 | public long getEndTime() { | |
503 | return _endTime; | |
504 | } | |
505 | ||
506 | @Override | |
507 | public long getMaxTime() { | |
508 | return _time1_; | |
509 | } | |
510 | ||
511 | @Override | |
512 | public long getMinTime() { | |
513 | return _time0_; | |
514 | } | |
515 | ||
516 | /* | |
517 | * (non-Javadoc) | |
518 | * | |
519 | * @see | |
520 | * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider | |
521 | * #setStartFinishTimeNotify(long, long) | |
522 | */ | |
523 | @Override | |
524 | public void setStartFinishTimeNotify(long time0, long time1) { | |
525 | setStartFinishTime(time0, time1); | |
526 | notifyRangeListeners(time0, time1); | |
527 | } | |
528 | ||
529 | ||
530 | /* (non-Javadoc) | |
531 | * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider#notifyStartFinishTime() | |
532 | */ | |
533 | @Override | |
534 | public void notifyStartFinishTime() { | |
535 | notifyRangeListeners(_time0, _time1); | |
536 | } | |
537 | ||
538 | /* | |
539 | * (non-Javadoc) | |
540 | * | |
541 | * @see | |
542 | * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider | |
543 | * #setStartFinishTime(long, long) | |
544 | */ | |
545 | @Override | |
546 | public void setStartFinishTime(long time0, long time1) { | |
547 | _time0 = time0; | |
548 | if (_time0 < _time0_) { | |
549 | _time0 = _time0_; | |
550 | } | |
551 | if (_time0 > _time1_) { | |
552 | _time0 = _time1_; | |
553 | } | |
554 | _time1 = time1; | |
555 | if (_time1 < _time0_) { | |
556 | _time1 = _time0_; | |
557 | } | |
558 | if (_time1 > _time1_) { | |
559 | _time1 = _time1_; | |
560 | } | |
561 | if (_time1 - _time0 < _minTimeInterval) { | |
562 | _time1 = Math.min(_time1_, _time0 + _minTimeInterval); | |
563 | } | |
564 | _timeRangeFixed = true; | |
565 | _stateCtrl.adjustScrolls(); | |
566 | _stateCtrl.redraw(); | |
567 | _timeScaleCtrl.redraw(); | |
568 | } | |
569 | ||
570 | /** | |
571 | * Set the time bounds to the provided values | |
572 | * | |
573 | * @param beginTime | |
574 | * The start time of the window | |
575 | * @param endTime | |
576 | * The end time | |
577 | */ | |
578 | public void setTimeBounds(long beginTime, long endTime) { | |
579 | _beginTime = beginTime; | |
580 | _endTime = endTime; | |
581 | _time0_ = beginTime; | |
582 | _time1_ = endTime; | |
583 | _stateCtrl.adjustScrolls(); | |
584 | } | |
585 | ||
586 | @Override | |
587 | public void resetStartFinishTime() { | |
588 | setStartFinishTimeNotify(_time0_, _time1_); | |
589 | _timeRangeFixed = false; | |
590 | } | |
591 | ||
592 | @Override | |
593 | public void setSelectedTimeNotify(long time, boolean ensureVisible) { | |
594 | setSelectedTimeInt(time, ensureVisible, true); | |
595 | } | |
596 | ||
597 | @Override | |
598 | public void setSelectedTime(long time, boolean ensureVisible) { | |
599 | setSelectedTimeInt(time, ensureVisible, false); | |
600 | } | |
601 | ||
602 | private void setSelectedTimeInt(long time, boolean ensureVisible, boolean doNotify) { | |
603 | long time0 = _time0; | |
604 | long time1 = _time1; | |
605 | if (ensureVisible) { | |
606 | long timeSpace = (long) ((_time1 - _time0) * .02); | |
607 | long timeMid = (long) ((_time1 - _time0) * .5); | |
608 | if (time < _time0 + timeSpace) { | |
609 | long dt = _time0 - time + timeMid; | |
610 | _time0 -= dt; | |
611 | _time1 -= dt; | |
612 | } else if (time > _time1 - timeSpace) { | |
613 | long dt = time - _time1 + timeMid; | |
614 | _time0 += dt; | |
615 | _time1 += dt; | |
616 | } | |
617 | if (_time0 < _time0_) { | |
618 | _time1 = Math.min(_time1_, _time1 + (_time0_ - _time0)); | |
619 | _time0 = _time0_; | |
620 | } else if (_time1 > _time1_) { | |
621 | _time0 = Math.max(_time0_, _time0 - (_time1 - _time1_)); | |
622 | _time1 = _time1_; | |
623 | } | |
624 | } | |
625 | if (_time1 - _time0 < _minTimeInterval) { | |
626 | _time1 = Math.min(_time1_, _time0 + _minTimeInterval); | |
627 | } | |
628 | _stateCtrl.adjustScrolls(); | |
629 | _stateCtrl.redraw(); | |
630 | _timeScaleCtrl.redraw(); | |
631 | ||
632 | ||
633 | boolean notifySelectedTime = (time != _selectedTime); | |
634 | _selectedTime = time; | |
635 | ||
636 | if (doNotify && ((time0 != _time0) || (time1 != _time1))) { | |
637 | notifyRangeListeners(_time0, _time1); | |
638 | } | |
639 | ||
640 | if (doNotify && notifySelectedTime) { | |
641 | notifyTimeListeners(_selectedTime); | |
642 | } | |
643 | } | |
644 | ||
645 | @Override | |
646 | public void widgetDefaultSelected(SelectionEvent e) { | |
647 | if (_selectedEntry != getSelection()) { | |
648 | _selectedEntry = getSelection(); | |
649 | notifySelectionListeners(_selectedEntry); | |
650 | } | |
651 | } | |
652 | ||
653 | @Override | |
654 | public void widgetSelected(SelectionEvent e) { | |
655 | if (_selectedEntry != getSelection()) { | |
656 | _selectedEntry = getSelection(); | |
657 | notifySelectionListeners(_selectedEntry); | |
658 | } | |
659 | } | |
660 | ||
661 | /** | |
662 | * Callback for when the next event is selected | |
663 | */ | |
664 | public void selectNextEvent() { | |
665 | _stateCtrl.selectNextEvent(); | |
666 | adjustVerticalScrollBar(); | |
667 | } | |
668 | ||
669 | /** | |
670 | * Callback for when the previous event is selected | |
671 | */ | |
672 | public void selectPrevEvent() { | |
673 | _stateCtrl.selectPrevEvent(); | |
674 | adjustVerticalScrollBar(); | |
675 | } | |
676 | ||
677 | /** | |
678 | * Callback for when the next item is selected | |
679 | */ | |
680 | public void selectNextItem() { | |
681 | _stateCtrl.selectNextTrace(); | |
682 | adjustVerticalScrollBar(); | |
683 | } | |
684 | ||
685 | /** | |
686 | * Callback for when the previous item is selected | |
687 | */ | |
688 | public void selectPrevItem() { | |
689 | _stateCtrl.selectPrevTrace(); | |
690 | adjustVerticalScrollBar(); | |
691 | } | |
692 | ||
693 | /** | |
694 | * Callback for the show legend action | |
695 | */ | |
696 | public void showLegend() { | |
697 | if (_dataViewer == null || _dataViewer.isDisposed()) { | |
698 | return; | |
699 | } | |
700 | ||
701 | TimeGraphLegend.open(_dataViewer.getShell(), fTimeGraphProvider); | |
702 | } | |
703 | ||
704 | /** | |
705 | * Callback for the Zoom In action | |
706 | */ | |
707 | public void zoomIn() { | |
708 | _stateCtrl.zoomIn(); | |
709 | } | |
710 | ||
711 | /** | |
712 | * Callback for the Zoom Out action | |
713 | */ | |
714 | public void zoomOut() { | |
715 | _stateCtrl.zoomOut(); | |
716 | } | |
717 | ||
718 | private String getPreferenceString(String string) { | |
719 | return getViewTypeStr() + "." + string; //$NON-NLS-1$ | |
720 | } | |
721 | ||
722 | /** | |
723 | * Add a selection listener | |
724 | * | |
725 | * @param listener | |
726 | * The listener to add | |
727 | */ | |
728 | public void addSelectionListener(ITimeGraphSelectionListener listener) { | |
729 | fSelectionListeners.add(listener); | |
730 | } | |
731 | ||
732 | /** | |
733 | * Remove a selection listener | |
734 | * | |
735 | * @param listener | |
736 | * The listener to remove | |
737 | */ | |
738 | public void removeSelectionListener(ITimeGraphSelectionListener listener) { | |
739 | fSelectionListeners.remove(listener); | |
740 | } | |
741 | ||
742 | private void notifySelectionListeners(ITimeGraphEntry selection) { | |
743 | TimeGraphSelectionEvent event = new TimeGraphSelectionEvent(this, selection); | |
744 | ||
745 | for (ITimeGraphSelectionListener listener : fSelectionListeners) { | |
746 | listener.selectionChanged(event); | |
747 | } | |
748 | } | |
749 | ||
750 | /** | |
751 | * Add a time listener | |
752 | * | |
753 | * @param listener | |
754 | * The listener to add | |
755 | */ | |
756 | public void addTimeListener(ITimeGraphTimeListener listener) { | |
757 | fTimeListeners.add(listener); | |
758 | } | |
759 | ||
760 | /** | |
761 | * Remove a time listener | |
762 | * | |
763 | * @param listener | |
764 | * The listener to remove | |
765 | */ | |
766 | public void removeTimeListener(ITimeGraphTimeListener listener) { | |
767 | fTimeListeners.remove(listener); | |
768 | } | |
769 | ||
770 | private void notifyTimeListeners(long time) { | |
771 | TimeGraphTimeEvent event = new TimeGraphTimeEvent(this, time); | |
772 | ||
773 | for (ITimeGraphTimeListener listener : fTimeListeners) { | |
774 | listener.timeSelected(event); | |
775 | } | |
776 | } | |
777 | ||
778 | /** | |
779 | * Add a range listener | |
780 | * | |
781 | * @param listener | |
782 | * The listener to add | |
783 | */ | |
784 | public void addRangeListener(ITimeGraphRangeListener listener) { | |
785 | fRangeListeners.add(listener); | |
786 | } | |
787 | ||
788 | /** | |
789 | * Remove a range listener | |
790 | * | |
791 | * @param listener | |
792 | * The listener to remove | |
793 | */ | |
794 | public void removeRangeListener(ITimeGraphRangeListener listener) { | |
795 | fRangeListeners.remove(listener); | |
796 | } | |
797 | ||
798 | private void notifyRangeListeners(long startTime, long endTime) { | |
799 | // Check if the time has actually changed from last notification | |
800 | if (startTime != _time0_extSynch || endTime != _time1_extSynch) { | |
801 | // Notify Time Scale Selection Listeners | |
802 | TimeGraphRangeUpdateEvent event = new TimeGraphRangeUpdateEvent(this, startTime, endTime); | |
803 | ||
804 | for (ITimeGraphRangeListener listener : fRangeListeners) { | |
805 | listener.timeRangeUpdated(event); | |
806 | } | |
807 | ||
808 | // update external synch timers | |
809 | updateExtSynchTimers(); | |
810 | } | |
811 | } | |
812 | ||
813 | /** | |
814 | * Callback to set a selected event in the view | |
815 | * | |
816 | * @param event | |
817 | * The event that was selected | |
818 | * @param source | |
819 | * The source of this selection event | |
820 | */ | |
821 | public void setSelectedEvent(ITimeEvent event, Object source) { | |
822 | if (event == null || source == this) { | |
823 | return; | |
824 | } | |
825 | _selectedEntry = event.getEntry(); | |
826 | _stateCtrl.selectItem(_selectedEntry, false); | |
827 | ||
828 | setSelectedTimeInt(event.getTime(), true, true); | |
829 | adjustVerticalScrollBar(); | |
830 | } | |
831 | ||
832 | /** | |
833 | * Set the seeked time of a trace | |
834 | * | |
835 | * @param trace | |
836 | * The trace that was seeked | |
837 | * @param time | |
838 | * The target time | |
839 | * @param source | |
840 | * The source of this seek event | |
841 | */ | |
842 | public void setSelectedTraceTime(ITimeGraphEntry trace, long time, Object source) { | |
843 | if (trace == null || source == this) { | |
844 | return; | |
845 | } | |
846 | _selectedEntry = trace; | |
847 | _stateCtrl.selectItem(trace, false); | |
848 | ||
849 | setSelectedTimeInt(time, true, true); | |
850 | } | |
851 | ||
852 | /** | |
853 | * Callback for a trace selection | |
854 | * | |
855 | * @param trace | |
856 | * The trace that was selected | |
857 | */ | |
858 | public void setSelection(ITimeGraphEntry trace) { | |
859 | _selectedEntry = trace; | |
860 | _stateCtrl.selectItem(trace, false); | |
861 | adjustVerticalScrollBar(); | |
862 | } | |
863 | ||
864 | /** | |
865 | * Callback for a time window selection | |
866 | * | |
867 | * @param time0 | |
868 | * Start time of the range | |
869 | * @param time1 | |
870 | * End time of the range | |
871 | * @param source | |
872 | * Source of the event | |
873 | */ | |
874 | public void setSelectVisTimeWindow(long time0, long time1, Object source) { | |
875 | if (source == this) { | |
876 | return; | |
877 | } | |
878 | ||
879 | setStartFinishTime(time0, time1); | |
880 | ||
881 | // update notification time values since we are now in synch with the | |
882 | // external application | |
883 | updateExtSynchTimers(); | |
884 | } | |
885 | ||
886 | /** | |
887 | * update the cache timers used to identify the need to send a time window | |
888 | * update to external registered listeners | |
889 | */ | |
890 | private void updateExtSynchTimers() { | |
891 | // last time notification cache | |
892 | _time0_extSynch = _time0; | |
893 | _time1_extSynch = _time1; | |
894 | } | |
895 | ||
896 | /** | |
897 | * Set the calendar format | |
898 | * | |
899 | * @param toAbsoluteCaltime | |
900 | * True for absolute time, false for relative | |
901 | */ | |
902 | public void setTimeCalendarFormat(boolean toAbsoluteCaltime) { | |
903 | calendarTimeFormat = toAbsoluteCaltime; | |
904 | } | |
905 | ||
906 | @Override | |
907 | public boolean isCalendarFormat() { | |
908 | return calendarTimeFormat; | |
909 | } | |
910 | ||
911 | /** | |
912 | * Retrieve the border width | |
913 | * | |
914 | * @return The width | |
915 | */ | |
916 | public int getBorderWidth() { | |
917 | return borderWidth; | |
918 | } | |
919 | ||
920 | /** | |
921 | * Set the border width | |
922 | * | |
923 | * @param borderWidth | |
924 | * The width | |
925 | */ | |
926 | public void setBorderWidth(int borderWidth) { | |
927 | if (borderWidth > -1) { | |
928 | this.borderWidth = borderWidth; | |
929 | GridLayout gl = (GridLayout)_dataViewer.getLayout(); | |
930 | gl.marginHeight = borderWidth; | |
931 | } | |
932 | } | |
933 | ||
934 | /** | |
935 | * Retrieve the height of the header | |
936 | * | |
937 | * @return The height | |
938 | */ | |
939 | public int getHeaderHeight() { | |
940 | return timeScaleHeight; | |
941 | } | |
942 | ||
943 | /** | |
944 | * Set the height of the header | |
945 | * | |
946 | * @param headerHeight | |
947 | * The height to set | |
948 | */ | |
949 | public void setHeaderHeight(int headerHeight) { | |
950 | if (headerHeight > -1) { | |
951 | this.timeScaleHeight = headerHeight; | |
952 | _timeScaleCtrl.setHeight(headerHeight); | |
953 | } | |
954 | } | |
955 | ||
956 | /** | |
957 | * Retrieve the height of an item row | |
958 | * | |
959 | * @return The height | |
960 | */ | |
961 | public int getItemHeight() { | |
962 | if (_stateCtrl != null) { | |
963 | return _stateCtrl.getItemHeight(); | |
964 | } | |
965 | return 0; | |
966 | } | |
967 | ||
968 | /** | |
969 | * Set the height of an item row | |
970 | * | |
971 | * @param rowHeight | |
972 | * The height to set | |
973 | */ | |
974 | public void setItemHeight(int rowHeight) { | |
975 | if (_stateCtrl != null) { | |
976 | _stateCtrl.setItemHeight(rowHeight); | |
977 | } | |
978 | } | |
979 | ||
980 | /** | |
981 | * Set the minimum item width | |
982 | * | |
983 | * @param width | |
984 | * The min width | |
985 | */ | |
986 | public void setMinimumItemWidth(int width) { | |
987 | if (_stateCtrl != null) { | |
988 | _stateCtrl.setMinimumItemWidth(width); | |
989 | } | |
990 | } | |
991 | ||
992 | /** | |
993 | * Set the width for the name column | |
994 | * | |
995 | * @param width The width | |
996 | */ | |
997 | public void setNameWidthPref(int width) { | |
998 | _nameWidthPref = width; | |
999 | if (width == 0) { | |
1000 | _minNameWidth = 0; | |
1001 | _nameWidth = 0; | |
1002 | } | |
1003 | } | |
1004 | ||
1005 | /** | |
1006 | * Retrieve the configure width for the name column | |
1007 | * | |
1008 | * @param width | |
1009 | * Unused? | |
1010 | * @return The width | |
1011 | */ | |
1012 | public int getNameWidthPref(int width) { | |
1013 | return _nameWidthPref; | |
1014 | } | |
1015 | ||
1016 | /** | |
1017 | * Returns the primary control associated with this viewer. | |
1018 | * | |
1019 | * @return the SWT control which displays this viewer's content | |
1020 | */ | |
1021 | public Control getControl() { | |
1022 | return _dataViewer; | |
1023 | } | |
1024 | ||
1025 | /** | |
1026 | * Returns the time graph control associated with this viewer. | |
1027 | * | |
1028 | * @return the time graph control | |
1029 | */ | |
1030 | TimeGraphControl getTimeGraphControl() { | |
1031 | return _stateCtrl; | |
1032 | } | |
1033 | ||
1034 | /** | |
1035 | * Returns the time graph scale associated with this viewer. | |
1036 | * | |
1037 | * @return the time graph scale | |
1038 | */ | |
1039 | TimeGraphScale getTimeGraphScale() { | |
1040 | return _timeScaleCtrl; | |
1041 | } | |
1042 | ||
1043 | /** | |
1044 | * Get the selection provider | |
1045 | * | |
1046 | * @return the selection provider | |
1047 | */ | |
1048 | public ISelectionProvider getSelectionProvider() { | |
1049 | return _stateCtrl; | |
1050 | } | |
1051 | ||
1052 | /** | |
1053 | * Wait for the cursor | |
1054 | * | |
1055 | * @param waitInd | |
1056 | * Wait indefinitely? | |
1057 | */ | |
1058 | public void waitCursor(boolean waitInd) { | |
1059 | _stateCtrl.waitCursor(waitInd); | |
1060 | } | |
1061 | ||
1062 | /** | |
1063 | * Get the horizontal scroll bar object | |
1064 | * | |
1065 | * @return The scroll bar | |
1066 | */ | |
1067 | public ScrollBar getHorizontalBar() { | |
1068 | return _stateCtrl.getHorizontalBar(); | |
1069 | } | |
1070 | ||
1071 | /** | |
1072 | * Get the vertical scroll bar object | |
1073 | * | |
1074 | * @return The scroll bar | |
1075 | */ | |
1076 | public Slider getVerticalBar() { | |
1077 | return _verticalScrollBar; | |
1078 | } | |
1079 | ||
1080 | /** | |
1081 | * Set the given index as the top one | |
1082 | * | |
1083 | * @param index | |
1084 | * The index that will go to the top | |
1085 | */ | |
1086 | public void setTopIndex(int index) { | |
1087 | _stateCtrl.setTopIndex(index); | |
1088 | adjustVerticalScrollBar(); | |
1089 | } | |
1090 | ||
1091 | /** | |
1092 | * Retrieve the current top index | |
1093 | * | |
1094 | * @return The top index | |
1095 | */ | |
1096 | public int getTopIndex() { | |
1097 | return _stateCtrl.getTopIndex(); | |
1098 | } | |
1099 | ||
1100 | /** | |
1101 | * Set the expanded state of an entry | |
1102 | * | |
1103 | * @param entry | |
1104 | * The entry to expand/collapse | |
1105 | * @param expanded | |
1106 | * True for expanded, false for collapsed | |
1107 | */ | |
1108 | public void setExpandedState(ITimeGraphEntry entry, boolean expanded) { | |
1109 | _stateCtrl.setExpandedState(entry, expanded); | |
1110 | adjustVerticalScrollBar(); | |
1111 | } | |
1112 | ||
1113 | /** | |
1114 | * Get the number of sub-elements when expanded | |
1115 | * | |
1116 | * @return The element count | |
1117 | */ | |
1118 | public int getExpandedElementCount() { | |
1119 | return _stateCtrl.getExpandedElementCount(); | |
1120 | } | |
1121 | ||
1122 | /** | |
1123 | * Get the sub-elements | |
1124 | * | |
1125 | * @return The array of entries that are below this one | |
1126 | */ | |
1127 | public ITimeGraphEntry[] getExpandedElements() { | |
1128 | return _stateCtrl.getExpandedElements(); | |
1129 | } | |
1130 | ||
1131 | /** | |
1132 | * Add a tree listener | |
1133 | * | |
1134 | * @param listener | |
1135 | * The listener to add | |
1136 | */ | |
1137 | public void addTreeListener(ITimeGraphTreeListener listener) { | |
1138 | _stateCtrl.addTreeListener(listener); | |
1139 | } | |
1140 | ||
1141 | /** | |
1142 | * Remove a tree listener | |
1143 | * | |
1144 | * @param listener | |
1145 | * The listener to remove | |
1146 | */ | |
1147 | public void removeTreeListener(ITimeGraphTreeListener listener) { | |
1148 | _stateCtrl.removeTreeListener(listener); | |
1149 | } | |
1150 | ||
1151 | /** | |
1152 | * Get the reset scale action. | |
1153 | * | |
1154 | * @return The Action object | |
1155 | */ | |
1156 | public Action getResetScaleAction() { | |
1157 | if (resetScale == null) { | |
1158 | // resetScale | |
1159 | resetScale = new Action() { | |
1160 | @Override | |
1161 | public void run() { | |
1162 | resetStartFinishTime(); | |
1163 | } | |
1164 | }; | |
1165 | resetScale.setText(Messages.TmfTimeGraphViewer_ResetScaleActionNameText); | |
1166 | resetScale.setToolTipText(Messages.TmfTimeGraphViewer_ResetScaleActionToolTipText); | |
1167 | resetScale.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_HOME_MENU)); | |
1168 | } | |
1169 | return resetScale; | |
1170 | } | |
1171 | ||
1172 | /** | |
1173 | * Get the show legend action. | |
1174 | * | |
1175 | * @return The Action object | |
1176 | */ | |
1177 | public Action getShowLegendAction() { | |
1178 | if (showLegendAction == null) { | |
1179 | // showLegend | |
1180 | showLegendAction = new Action() { | |
1181 | @Override | |
1182 | public void run() { | |
1183 | showLegend(); | |
1184 | } | |
1185 | }; | |
1186 | showLegendAction.setText(Messages.TmfTimeGraphViewer_LegendActionNameText); | |
1187 | showLegendAction.setToolTipText(Messages.TmfTimeGraphViewer_LegendActionToolTipText); | |
1188 | showLegendAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_SHOW_LEGEND)); | |
1189 | } | |
1190 | ||
1191 | return showLegendAction; | |
1192 | } | |
1193 | ||
1194 | /** | |
1195 | * Get the the next event action. | |
1196 | * | |
1197 | * @return The action object | |
1198 | */ | |
1199 | public Action getNextEventAction() { | |
1200 | if (nextEventAction == null) { | |
1201 | nextEventAction = new Action() { | |
1202 | @Override | |
1203 | public void run() { | |
1204 | selectNextEvent(); | |
1205 | } | |
1206 | }; | |
1207 | ||
1208 | nextEventAction.setText(Messages.TmfTimeGraphViewer_NextEventActionNameText); | |
1209 | nextEventAction.setToolTipText(Messages.TmfTimeGraphViewer_NextEventActionToolTipText); | |
1210 | nextEventAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_NEXT_EVENT)); | |
1211 | } | |
1212 | ||
1213 | return nextEventAction; | |
1214 | } | |
1215 | ||
1216 | /** | |
1217 | * Get the previous event action. | |
1218 | * | |
1219 | * @return The Action object | |
1220 | */ | |
1221 | public Action getPreviousEventAction() { | |
1222 | if (prevEventAction == null) { | |
1223 | prevEventAction = new Action() { | |
1224 | @Override | |
1225 | public void run() { | |
1226 | selectPrevEvent(); | |
1227 | } | |
1228 | }; | |
1229 | ||
1230 | prevEventAction.setText(Messages.TmfTimeGraphViewer_PreviousEventActionNameText); | |
1231 | prevEventAction.setToolTipText(Messages.TmfTimeGraphViewer_PreviousEventActionToolTipText); | |
1232 | prevEventAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_PREV_EVENT)); | |
1233 | } | |
1234 | ||
1235 | return prevEventAction; | |
1236 | } | |
1237 | ||
1238 | /** | |
1239 | * Get the next item action. | |
1240 | * | |
1241 | * @return The Action object | |
1242 | */ | |
1243 | public Action getNextItemAction() { | |
1244 | if (nextItemAction == null) { | |
1245 | ||
1246 | nextItemAction = new Action() { | |
1247 | @Override | |
1248 | public void run() { | |
1249 | selectNextItem(); | |
1250 | } | |
1251 | }; | |
1252 | nextItemAction.setText(Messages.TmfTimeGraphViewer_NextItemActionNameText); | |
1253 | nextItemAction.setToolTipText(Messages.TmfTimeGraphViewer_NextItemActionToolTipText); | |
1254 | nextItemAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_NEXT_ITEM)); | |
1255 | } | |
1256 | return nextItemAction; | |
1257 | } | |
1258 | ||
1259 | /** | |
1260 | * Get the previous item action. | |
1261 | * | |
1262 | * @return The Action object | |
1263 | */ | |
1264 | public Action getPreviousItemAction() { | |
1265 | if (previousItemAction == null) { | |
1266 | ||
1267 | previousItemAction = new Action() { | |
1268 | @Override | |
1269 | public void run() { | |
1270 | selectPrevItem(); | |
1271 | } | |
1272 | }; | |
1273 | previousItemAction.setText(Messages.TmfTimeGraphViewer_PreviousItemActionNameText); | |
1274 | previousItemAction.setToolTipText(Messages.TmfTimeGraphViewer_PreviousItemActionToolTipText); | |
1275 | previousItemAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_PREV_ITEM)); | |
1276 | } | |
1277 | return previousItemAction; | |
1278 | } | |
1279 | ||
1280 | /** | |
1281 | * Get the zoom in action | |
1282 | * | |
1283 | * @return The Action object | |
1284 | */ | |
1285 | public Action getZoomInAction() { | |
1286 | if (zoomInAction == null) { | |
1287 | zoomInAction = new Action() { | |
1288 | @Override | |
1289 | public void run() { | |
1290 | zoomIn(); | |
1291 | } | |
1292 | }; | |
1293 | zoomInAction.setText(Messages.TmfTimeGraphViewer_ZoomInActionNameText); | |
1294 | zoomInAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomInActionToolTipText); | |
1295 | zoomInAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_IN_MENU)); | |
1296 | } | |
1297 | return zoomInAction; | |
1298 | } | |
1299 | ||
1300 | /** | |
1301 | * Get the zoom out action | |
1302 | * | |
1303 | * @return The Action object | |
1304 | */ | |
1305 | public Action getZoomOutAction() { | |
1306 | if (zoomOutAction == null) { | |
1307 | zoomOutAction = new Action() { | |
1308 | @Override | |
1309 | public void run() { | |
1310 | zoomOut(); | |
1311 | } | |
1312 | }; | |
1313 | zoomOutAction.setText(Messages.TmfTimeGraphViewer_ZoomOutActionNameText); | |
1314 | zoomOutAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomOutActionToolTipText); | |
1315 | zoomOutAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_OUT_MENU)); | |
1316 | } | |
1317 | return zoomOutAction; | |
1318 | } | |
1319 | ||
1320 | ||
1321 | private void adjustVerticalScrollBar() { | |
1322 | int topIndex = _stateCtrl.getTopIndex(); | |
1323 | int countPerPage = _stateCtrl.countPerPage(); | |
1324 | int expandedElementCount = _stateCtrl.getExpandedElementCount(); | |
1325 | if (topIndex + countPerPage > expandedElementCount) { | |
1326 | _stateCtrl.setTopIndex(Math.max(0, expandedElementCount - countPerPage)); | |
1327 | } | |
1328 | ||
1329 | int selection = _stateCtrl.getTopIndex(); | |
1330 | int min = 0; | |
1331 | int max = Math.max(1, expandedElementCount - 1); | |
1332 | int thumb = Math.min(max, Math.max(1, countPerPage - 1)); | |
1333 | int increment = 1; | |
1334 | int pageIncrement = Math.max(1, countPerPage); | |
1335 | _verticalScrollBar.setValues(selection, min, max, thumb, increment, pageIncrement); | |
1336 | } | |
1337 | ||
1338 | ||
1339 | ||
1340 | } |