Commit | Line | Data |
---|---|---|
837a2f8c | 1 | /***************************************************************************** |
4c9c0c87 | 2 | * Copyright (c) 2007, 2014 Intel Corporation, Ericsson, others |
837a2f8c PT |
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 | |
bec1f1ac | 14 | * Geneviève Bastien - Add event links between entries |
837a2f8c PT |
15 | *****************************************************************************/ |
16 | ||
17 | package org.eclipse.linuxtools.tmf.ui.widgets.timegraph; | |
18 | ||
19 | import java.util.ArrayList; | |
f1fae91f | 20 | import java.util.List; |
837a2f8c PT |
21 | |
22 | import org.eclipse.jface.action.Action; | |
79ec0b89 PT |
23 | import org.eclipse.jface.action.IAction; |
24 | import org.eclipse.jface.dialogs.IDialogSettings; | |
837a2f8c | 25 | import org.eclipse.jface.viewers.ISelectionProvider; |
6ac5a950 | 26 | import org.eclipse.jface.viewers.ViewerFilter; |
837a2f8c PT |
27 | import org.eclipse.linuxtools.internal.tmf.ui.Activator; |
28 | import org.eclipse.linuxtools.internal.tmf.ui.ITmfImageConstants; | |
29 | import org.eclipse.linuxtools.internal.tmf.ui.Messages; | |
30 | import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.dialogs.TimeGraphLegend; | |
bec1f1ac | 31 | import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ILinkEvent; |
837a2f8c PT |
32 | import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent; |
33 | import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry; | |
baf92cac | 34 | import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.ITimeDataProvider; |
837a2f8c PT |
35 | import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphColorScheme; |
36 | import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl; | |
37 | import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphScale; | |
38 | import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphTooltipHandler; | |
39 | import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils; | |
026664b7 | 40 | import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils.TimeFormat; |
837a2f8c PT |
41 | import org.eclipse.swt.SWT; |
42 | import org.eclipse.swt.events.ControlAdapter; | |
43 | import org.eclipse.swt.events.ControlEvent; | |
44 | import org.eclipse.swt.events.KeyAdapter; | |
45 | import org.eclipse.swt.events.KeyEvent; | |
27df1564 | 46 | import org.eclipse.swt.events.MenuDetectListener; |
837a2f8c PT |
47 | import org.eclipse.swt.events.MouseEvent; |
48 | import org.eclipse.swt.events.MouseWheelListener; | |
49 | import org.eclipse.swt.events.SelectionAdapter; | |
50 | import org.eclipse.swt.events.SelectionEvent; | |
51 | import org.eclipse.swt.events.SelectionListener; | |
52 | import org.eclipse.swt.graphics.Rectangle; | |
53 | import org.eclipse.swt.layout.FillLayout; | |
54 | import org.eclipse.swt.layout.GridData; | |
55 | import org.eclipse.swt.layout.GridLayout; | |
56 | import org.eclipse.swt.widgets.Composite; | |
57 | import org.eclipse.swt.widgets.Control; | |
58 | import org.eclipse.swt.widgets.ScrollBar; | |
59 | import org.eclipse.swt.widgets.Slider; | |
60 | ||
61 | /** | |
62 | * Generic time graph viewer implementation | |
63 | * | |
64 | * @version 1.0 | |
65 | * @author Patrick Tasse, and others | |
66 | */ | |
baf92cac | 67 | public class TimeGraphViewer implements ITimeDataProvider, SelectionListener { |
837a2f8c | 68 | |
f1fae91f PT |
69 | private static final int DEFAULT_NAME_WIDTH = 200; |
70 | private static final int MIN_NAME_WIDTH = 6; | |
71 | private static final int MAX_NAME_WIDTH = 1000; | |
72 | private static final int DEFAULT_HEIGHT = 22; | |
73 | private static final long RECENTERING_MARGIN_FACTOR = 50; | |
79ec0b89 | 74 | private static final String HIDE_ARROWS_KEY = "hide.arrows"; //$NON-NLS-1$ |
f1fae91f PT |
75 | |
76 | private long fMinTimeInterval; | |
f1fae91f PT |
77 | private ITimeGraphEntry fSelectedEntry; |
78 | private long fBeginTime; | |
79 | private long fEndTime; | |
80 | private long fTime0; | |
81 | private long fTime1; | |
0fcf3b09 PT |
82 | private long fSelectionBegin = 0; |
83 | private long fSelectionEnd = 0; | |
f1fae91f PT |
84 | private long fTime0Bound; |
85 | private long fTime1Bound; | |
86 | private long fTime0ExtSynch = 0; | |
87 | private long fTime1ExtSynch = 0; | |
88 | private boolean fTimeRangeFixed; | |
89 | private int fNameWidthPref = DEFAULT_NAME_WIDTH; | |
90 | private int fMinNameWidth = MIN_NAME_WIDTH; | |
91 | private int fNameWidth; | |
92 | private Composite fDataViewer; | |
93 | ||
94 | private TimeGraphControl fTimeGraphCtrl; | |
95 | private TimeGraphScale fTimeScaleCtrl; | |
96 | private Slider fVerticalScrollBar; | |
97 | private TimeGraphColorScheme fColorScheme; | |
4c9c0c87 PT |
98 | private Object fInputElement; |
99 | private ITimeGraphContentProvider fTimeGraphContentProvider; | |
837a2f8c PT |
100 | private ITimeGraphPresentationProvider fTimeGraphProvider; |
101 | ||
507b1336 AM |
102 | private List<ITimeGraphSelectionListener> fSelectionListeners = new ArrayList<>(); |
103 | private List<ITimeGraphTimeListener> fTimeListeners = new ArrayList<>(); | |
104 | private List<ITimeGraphRangeListener> fRangeListeners = new ArrayList<>(); | |
837a2f8c | 105 | |
79ec0b89 PT |
106 | // Time format, using Epoch reference, Relative time format(default) or |
107 | // Number | |
f1fae91f PT |
108 | private TimeFormat fTimeFormat = TimeFormat.RELATIVE; |
109 | private int fBorderWidth = 0; | |
110 | private int fTimeScaleHeight = DEFAULT_HEIGHT; | |
837a2f8c | 111 | |
f1fae91f PT |
112 | private Action fResetScaleAction; |
113 | private Action fShowLegendAction; | |
114 | private Action fNextEventAction; | |
115 | private Action fPrevEventAction; | |
116 | private Action fNextItemAction; | |
117 | private Action fPreviousItemAction; | |
118 | private Action fZoomInAction; | |
119 | private Action fZoomOutAction; | |
79ec0b89 | 120 | private Action fHideArrowsAction; |
086f21ae PT |
121 | private Action fFollowArrowFwdAction; |
122 | private Action fFollowArrowBwdAction; | |
837a2f8c PT |
123 | |
124 | /** | |
4c9c0c87 PT |
125 | * Standard constructor. |
126 | * <p> | |
127 | * The default timegraph content provider accepts an ITimeGraphEntry[] as input element. | |
837a2f8c PT |
128 | * |
129 | * @param parent | |
130 | * The parent UI composite object | |
131 | * @param style | |
132 | * The style to use | |
133 | */ | |
134 | public TimeGraphViewer(Composite parent, int style) { | |
135 | createDataViewer(parent, style); | |
4c9c0c87 PT |
136 | fTimeGraphContentProvider = new ITimeGraphContentProvider() { |
137 | @Override | |
138 | public ITimeGraphEntry[] getElements(Object inputElement) { | |
139 | if (inputElement instanceof ITimeGraphEntry[]) { | |
140 | return (ITimeGraphEntry[]) inputElement; | |
141 | } | |
142 | return new ITimeGraphEntry[0]; | |
143 | } | |
144 | }; | |
837a2f8c PT |
145 | } |
146 | ||
147 | /** | |
4c9c0c87 PT |
148 | * Sets the timegraph content provider used by this timegraph viewer. |
149 | * | |
150 | * @param timeGraphContentProvider | |
151 | * the timegraph content provider | |
152 | * | |
153 | * @since 3.0 | |
154 | */ | |
155 | public void setTimeGraphContentProvider(ITimeGraphContentProvider timeGraphContentProvider) { | |
156 | fTimeGraphContentProvider = timeGraphContentProvider; | |
157 | } | |
158 | ||
159 | /** | |
160 | * Gets the timegraph content provider used by this timegraph viewer. | |
161 | * | |
162 | * @return the timegraph content provider | |
163 | * | |
164 | * @since 3.0 | |
165 | */ | |
166 | public ITimeGraphContentProvider getTimeGraphContentProvider() { | |
167 | return fTimeGraphContentProvider; | |
168 | } | |
169 | ||
170 | /** | |
171 | * Sets the timegraph presentation provider used by this timegraph viewer. | |
837a2f8c | 172 | * |
79ec0b89 PT |
173 | * @param timeGraphProvider |
174 | * the timegraph provider | |
837a2f8c PT |
175 | */ |
176 | public void setTimeGraphProvider(ITimeGraphPresentationProvider timeGraphProvider) { | |
177 | fTimeGraphProvider = timeGraphProvider; | |
f1fae91f PT |
178 | fTimeGraphCtrl.setTimeGraphProvider(timeGraphProvider); |
179 | TimeGraphTooltipHandler toolTipHandler = new TimeGraphTooltipHandler(fTimeGraphProvider, this); | |
180 | toolTipHandler.activateHoverHelp(fTimeGraphCtrl); | |
837a2f8c PT |
181 | } |
182 | ||
183 | /** | |
4c9c0c87 | 184 | * Sets or clears the input for this time graph viewer. |
837a2f8c | 185 | * |
4c9c0c87 | 186 | * @param inputElement |
79ec0b89 PT |
187 | * The input of this time graph viewer, or <code>null</code> if |
188 | * none | |
4c9c0c87 PT |
189 | * |
190 | * @since 3.0 | |
837a2f8c | 191 | */ |
4c9c0c87 PT |
192 | public void setInput(Object inputElement) { |
193 | fInputElement = inputElement; | |
194 | ITimeGraphEntry[] input = fTimeGraphContentProvider.getElements(inputElement); | |
41b5c37f | 195 | |
f1fae91f | 196 | if (fTimeGraphCtrl != null) { |
4c9c0c87 | 197 | setTimeRange(input); |
f1fae91f | 198 | fVerticalScrollBar.setEnabled(true); |
837a2f8c | 199 | setTopIndex(0); |
0fcf3b09 PT |
200 | fSelectionBegin = 0; |
201 | fSelectionEnd = 0; | |
f1fae91f | 202 | fSelectedEntry = null; |
4c9c0c87 | 203 | refreshAllData(input); |
837a2f8c PT |
204 | } |
205 | } | |
206 | ||
4c9c0c87 PT |
207 | /** |
208 | * Gets the input for this time graph viewer. | |
209 | * | |
210 | * @return The input of this time graph viewer, or <code>null</code> if none | |
211 | * | |
212 | * @since 3.0 | |
213 | */ | |
214 | public Object getInput() { | |
215 | return fInputElement; | |
216 | } | |
217 | ||
bec1f1ac GB |
218 | /** |
219 | * Sets (or clears if null) the list of links to display on this combo | |
220 | * | |
221 | * @param links | |
222 | * the links to display in this time graph combo | |
223 | * @since 2.1 | |
224 | */ | |
225 | public void setLinks(List<ILinkEvent> links) { | |
226 | if (fTimeGraphCtrl != null) { | |
227 | fTimeGraphCtrl.refreshArrows(links); | |
228 | } | |
229 | } | |
230 | ||
837a2f8c PT |
231 | /** |
232 | * Refresh the view | |
233 | */ | |
234 | public void refresh() { | |
4c9c0c87 PT |
235 | ITimeGraphEntry[] input = fTimeGraphContentProvider.getElements(fInputElement); |
236 | setTimeRange(input); | |
f1fae91f | 237 | fVerticalScrollBar.setEnabled(true); |
4c9c0c87 | 238 | refreshAllData(input); |
837a2f8c PT |
239 | } |
240 | ||
241 | /** | |
242 | * Callback for when the control is moved | |
243 | * | |
244 | * @param e | |
245 | * The caller event | |
246 | */ | |
247 | public void controlMoved(ControlEvent e) { | |
248 | } | |
249 | ||
250 | /** | |
251 | * Callback for when the control is resized | |
252 | * | |
253 | * @param e | |
254 | * The caller event | |
255 | */ | |
256 | public void controlResized(ControlEvent e) { | |
257 | resizeControls(); | |
258 | } | |
259 | ||
260 | /** | |
261 | * Handler for when the model is updated. Called from the display order in | |
262 | * the API | |
263 | * | |
264 | * @param traces | |
265 | * The traces in the model | |
266 | * @param start | |
267 | * The start time | |
268 | * @param end | |
269 | * The end time | |
270 | * @param updateTimeBounds | |
271 | * Should we updated the time bounds too | |
272 | */ | |
273 | public void modelUpdate(ITimeGraphEntry[] traces, long start, | |
274 | long end, boolean updateTimeBounds) { | |
f1fae91f | 275 | if (null != fTimeGraphCtrl) { |
837a2f8c PT |
276 | updateInternalData(traces, start, end); |
277 | if (updateTimeBounds) { | |
f1fae91f | 278 | fTimeRangeFixed = true; |
837a2f8c | 279 | // set window to match limits |
f1fae91f | 280 | setStartFinishTime(fTime0Bound, fTime1Bound); |
837a2f8c | 281 | } else { |
f1fae91f PT |
282 | fTimeGraphCtrl.redraw(); |
283 | fTimeScaleCtrl.redraw(); | |
837a2f8c PT |
284 | } |
285 | } | |
286 | } | |
287 | ||
a0a88f65 AM |
288 | /** |
289 | * @return The string representing the view type | |
290 | */ | |
837a2f8c PT |
291 | protected String getViewTypeStr() { |
292 | return "viewoption.threads"; //$NON-NLS-1$ | |
293 | } | |
294 | ||
a0a88f65 | 295 | int getMarginWidth() { |
837a2f8c PT |
296 | return 0; |
297 | } | |
298 | ||
a0a88f65 | 299 | int getMarginHeight() { |
837a2f8c PT |
300 | return 0; |
301 | } | |
302 | ||
303 | void loadOptions() { | |
f1fae91f | 304 | fMinTimeInterval = 1; |
0fcf3b09 PT |
305 | fSelectionBegin = -1; |
306 | fSelectionEnd = -1; | |
f1fae91f PT |
307 | fNameWidth = Utils.loadIntOption(getPreferenceString("namewidth"), //$NON-NLS-1$ |
308 | fNameWidthPref, fMinNameWidth, MAX_NAME_WIDTH); | |
837a2f8c PT |
309 | } |
310 | ||
311 | void saveOptions() { | |
f1fae91f | 312 | Utils.saveIntOption(getPreferenceString("namewidth"), fNameWidth); //$NON-NLS-1$ |
837a2f8c PT |
313 | } |
314 | ||
a0a88f65 AM |
315 | /** |
316 | * Create a data viewer. | |
317 | * | |
318 | * @param parent | |
319 | * Parent composite | |
320 | * @param style | |
321 | * Style to use | |
322 | * @return The new data viewer | |
323 | */ | |
837a2f8c PT |
324 | protected Control createDataViewer(Composite parent, int style) { |
325 | loadOptions(); | |
f1fae91f PT |
326 | fColorScheme = new TimeGraphColorScheme(); |
327 | fDataViewer = new Composite(parent, style) { | |
837a2f8c PT |
328 | @Override |
329 | public void redraw() { | |
f1fae91f PT |
330 | fTimeScaleCtrl.redraw(); |
331 | fTimeGraphCtrl.redraw(); | |
837a2f8c PT |
332 | super.redraw(); |
333 | } | |
334 | }; | |
335 | GridLayout gl = new GridLayout(2, false); | |
f1fae91f | 336 | gl.marginHeight = fBorderWidth; |
837a2f8c PT |
337 | gl.marginWidth = 0; |
338 | gl.verticalSpacing = 0; | |
339 | gl.horizontalSpacing = 0; | |
f1fae91f | 340 | fDataViewer.setLayout(gl); |
837a2f8c | 341 | |
f1fae91f PT |
342 | fTimeScaleCtrl = new TimeGraphScale(fDataViewer, fColorScheme); |
343 | fTimeScaleCtrl.setTimeProvider(this); | |
344 | fTimeScaleCtrl.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); | |
345 | fTimeScaleCtrl.setHeight(fTimeScaleHeight); | |
837a2f8c | 346 | |
f1fae91f PT |
347 | fVerticalScrollBar = new Slider(fDataViewer, SWT.VERTICAL | SWT.NO_FOCUS); |
348 | fVerticalScrollBar.setLayoutData(new GridData(SWT.DEFAULT, SWT.FILL, false, true, 1, 2)); | |
349 | fVerticalScrollBar.addSelectionListener(new SelectionAdapter() { | |
837a2f8c PT |
350 | @Override |
351 | public void widgetSelected(SelectionEvent e) { | |
f1fae91f | 352 | setTopIndex(fVerticalScrollBar.getSelection()); |
837a2f8c PT |
353 | } |
354 | }); | |
f1fae91f | 355 | fVerticalScrollBar.setEnabled(false); |
837a2f8c | 356 | |
f1fae91f | 357 | fTimeGraphCtrl = createTimeGraphControl(fDataViewer, fColorScheme); |
837a2f8c | 358 | |
f1fae91f | 359 | fTimeGraphCtrl.setTimeProvider(this); |
0fcf3b09 | 360 | fTimeGraphCtrl.setTimeGraphScale(fTimeScaleCtrl); |
f1fae91f PT |
361 | fTimeGraphCtrl.addSelectionListener(this); |
362 | fTimeGraphCtrl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2)); | |
363 | fTimeGraphCtrl.addMouseWheelListener(new MouseWheelListener() { | |
837a2f8c PT |
364 | @Override |
365 | public void mouseScrolled(MouseEvent e) { | |
366 | adjustVerticalScrollBar(); | |
367 | } | |
368 | }); | |
f1fae91f | 369 | fTimeGraphCtrl.addKeyListener(new KeyAdapter() { |
837a2f8c PT |
370 | @Override |
371 | public void keyPressed(KeyEvent e) { | |
372 | adjustVerticalScrollBar(); | |
373 | } | |
374 | }); | |
375 | ||
f1fae91f | 376 | Composite filler = new Composite(fDataViewer, SWT.NONE); |
837a2f8c | 377 | GridData gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false); |
f1fae91f | 378 | gd.heightHint = fTimeGraphCtrl.getHorizontalBar().getSize().y; |
837a2f8c PT |
379 | filler.setLayoutData(gd); |
380 | filler.setLayout(new FillLayout()); | |
381 | ||
f1fae91f | 382 | fTimeGraphCtrl.addControlListener(new ControlAdapter() { |
837a2f8c PT |
383 | @Override |
384 | public void controlResized(ControlEvent event) { | |
385 | resizeControls(); | |
386 | } | |
387 | }); | |
388 | resizeControls(); | |
f1fae91f | 389 | fDataViewer.update(); |
837a2f8c | 390 | adjustVerticalScrollBar(); |
f1fae91f | 391 | return fDataViewer; |
837a2f8c PT |
392 | } |
393 | ||
394 | /** | |
395 | * Dispose the view. | |
396 | */ | |
397 | public void dispose() { | |
398 | saveOptions(); | |
f1fae91f PT |
399 | fTimeGraphCtrl.dispose(); |
400 | fDataViewer.dispose(); | |
401 | fColorScheme.dispose(); | |
837a2f8c PT |
402 | } |
403 | ||
96d00a83 | 404 | /** |
a0a88f65 AM |
405 | * Create a new time graph control. |
406 | * | |
407 | * @param parent | |
408 | * The parent composite | |
409 | * @param colors | |
410 | * The color scheme | |
411 | * @return The new TimeGraphControl | |
96d00a83 PT |
412 | * @since 2.0 |
413 | */ | |
a0a88f65 AM |
414 | protected TimeGraphControl createTimeGraphControl(Composite parent, |
415 | TimeGraphColorScheme colors) { | |
96d00a83 | 416 | return new TimeGraphControl(parent, colors); |
837a2f8c PT |
417 | } |
418 | ||
419 | /** | |
420 | * Resize the controls | |
421 | */ | |
422 | public void resizeControls() { | |
f1fae91f | 423 | Rectangle r = fDataViewer.getClientArea(); |
837a2f8c PT |
424 | if (r.isEmpty()) { |
425 | return; | |
426 | } | |
427 | ||
428 | int width = r.width; | |
f1fae91f PT |
429 | if (fNameWidth > width - fMinNameWidth) { |
430 | fNameWidth = width - fMinNameWidth; | |
837a2f8c | 431 | } |
f1fae91f PT |
432 | if (fNameWidth < fMinNameWidth) { |
433 | fNameWidth = fMinNameWidth; | |
837a2f8c PT |
434 | } |
435 | adjustVerticalScrollBar(); | |
436 | } | |
437 | ||
438 | /** | |
439 | * Try to set most convenient time range for display. | |
440 | * | |
441 | * @param traces | |
442 | * The traces in the model | |
443 | */ | |
444 | public void setTimeRange(ITimeGraphEntry traces[]) { | |
f1fae91f PT |
445 | fEndTime = 0; |
446 | fBeginTime = -1; | |
837a2f8c PT |
447 | for (int i = 0; i < traces.length; i++) { |
448 | ITimeGraphEntry entry = traces[i]; | |
449 | if (entry.getEndTime() >= entry.getStartTime() && entry.getEndTime() > 0) { | |
f1fae91f PT |
450 | if (fBeginTime < 0 || entry.getStartTime() < fBeginTime) { |
451 | fBeginTime = entry.getStartTime(); | |
837a2f8c | 452 | } |
f1fae91f PT |
453 | if (entry.getEndTime() > fEndTime) { |
454 | fEndTime = entry.getEndTime(); | |
837a2f8c PT |
455 | } |
456 | } | |
457 | } | |
458 | ||
f1fae91f PT |
459 | if (fBeginTime < 0) { |
460 | fBeginTime = 0; | |
837a2f8c PT |
461 | } |
462 | } | |
463 | ||
464 | /** | |
465 | * Recalculate the time bounds | |
466 | */ | |
467 | public void setTimeBounds() { | |
f1fae91f PT |
468 | fTime0Bound = fBeginTime; |
469 | if (fTime0Bound < 0) { | |
470 | fTime0Bound = 0; | |
837a2f8c | 471 | } |
f1fae91f PT |
472 | fTime1Bound = fEndTime; |
473 | if (!fTimeRangeFixed) { | |
474 | fTime0 = fTime0Bound; | |
475 | fTime1 = fTime1Bound; | |
837a2f8c | 476 | } |
407bfdd5 PT |
477 | fTime0 = Math.max(fTime0Bound, Math.min(fTime0, fTime1Bound)); |
478 | fTime1 = Math.max(fTime0Bound, Math.min(fTime1, fTime1Bound)); | |
f1fae91f PT |
479 | if (fTime1 - fTime0 < fMinTimeInterval) { |
480 | fTime1 = Math.min(fTime1Bound, fTime0 + fMinTimeInterval); | |
837a2f8c PT |
481 | } |
482 | } | |
483 | ||
484 | /** | |
485 | * @param traces | |
486 | * @param start | |
487 | * @param end | |
488 | */ | |
489 | void updateInternalData(ITimeGraphEntry[] traces, long start, long end) { | |
41b5c37f AM |
490 | ITimeGraphEntry[] realTraces = traces; |
491 | ||
492 | if (null == realTraces) { | |
493 | realTraces = new ITimeGraphEntry[0]; | |
837a2f8c PT |
494 | } |
495 | if ((start == 0 && end == 0) || start < 0 || end < 0) { | |
496 | // Start and end time are unspecified and need to be determined from | |
497 | // individual processes | |
41b5c37f | 498 | setTimeRange(realTraces); |
837a2f8c | 499 | } else { |
f1fae91f PT |
500 | fBeginTime = start; |
501 | fEndTime = end; | |
837a2f8c PT |
502 | } |
503 | ||
41b5c37f | 504 | refreshAllData(realTraces); |
837a2f8c PT |
505 | } |
506 | ||
507 | /** | |
508 | * @param traces | |
509 | */ | |
510 | private void refreshAllData(ITimeGraphEntry[] traces) { | |
511 | setTimeBounds(); | |
0fcf3b09 PT |
512 | if (fSelectionBegin < fBeginTime) { |
513 | fSelectionBegin = fBeginTime; | |
514 | } else if (fSelectionBegin > fEndTime) { | |
515 | fSelectionBegin = fEndTime; | |
516 | } | |
517 | if (fSelectionEnd < fBeginTime) { | |
518 | fSelectionEnd = fBeginTime; | |
519 | } else if (fSelectionEnd > fEndTime) { | |
520 | fSelectionEnd = fEndTime; | |
837a2f8c | 521 | } |
f1fae91f PT |
522 | fTimeGraphCtrl.refreshData(traces); |
523 | fTimeScaleCtrl.redraw(); | |
837a2f8c PT |
524 | adjustVerticalScrollBar(); |
525 | } | |
526 | ||
527 | /** | |
528 | * Callback for when this view is focused | |
529 | */ | |
530 | public void setFocus() { | |
f1fae91f PT |
531 | if (null != fTimeGraphCtrl) { |
532 | fTimeGraphCtrl.setFocus(); | |
837a2f8c PT |
533 | } |
534 | } | |
535 | ||
536 | /** | |
537 | * Get the current focus status of this view. | |
538 | * | |
539 | * @return If the view is currently focused, or not | |
540 | */ | |
541 | public boolean isInFocus() { | |
f1fae91f | 542 | return fTimeGraphCtrl.isInFocus(); |
837a2f8c PT |
543 | } |
544 | ||
545 | /** | |
546 | * Get the view's current selection | |
547 | * | |
548 | * @return The entry that is selected | |
549 | */ | |
550 | public ITimeGraphEntry getSelection() { | |
f1fae91f | 551 | return fTimeGraphCtrl.getSelectedTrace(); |
837a2f8c PT |
552 | } |
553 | ||
554 | /** | |
555 | * Get the index of the current selection | |
556 | * | |
557 | * @return The index | |
558 | */ | |
559 | public int getSelectionIndex() { | |
f1fae91f | 560 | return fTimeGraphCtrl.getSelectedIndex(); |
837a2f8c PT |
561 | } |
562 | ||
563 | @Override | |
564 | public long getTime0() { | |
f1fae91f | 565 | return fTime0; |
837a2f8c PT |
566 | } |
567 | ||
568 | @Override | |
569 | public long getTime1() { | |
f1fae91f | 570 | return fTime1; |
837a2f8c PT |
571 | } |
572 | ||
573 | @Override | |
574 | public long getMinTimeInterval() { | |
f1fae91f | 575 | return fMinTimeInterval; |
837a2f8c PT |
576 | } |
577 | ||
578 | @Override | |
579 | public int getNameSpace() { | |
f1fae91f | 580 | return fNameWidth; |
837a2f8c PT |
581 | } |
582 | ||
583 | @Override | |
584 | public void setNameSpace(int width) { | |
f1fae91f PT |
585 | fNameWidth = width; |
586 | int w = fTimeGraphCtrl.getClientArea().width; | |
587 | if (fNameWidth > w - MIN_NAME_WIDTH) { | |
588 | fNameWidth = w - MIN_NAME_WIDTH; | |
837a2f8c | 589 | } |
f1fae91f PT |
590 | if (fNameWidth < MIN_NAME_WIDTH) { |
591 | fNameWidth = MIN_NAME_WIDTH; | |
837a2f8c | 592 | } |
f1fae91f PT |
593 | fTimeGraphCtrl.adjustScrolls(); |
594 | fTimeGraphCtrl.redraw(); | |
595 | fTimeScaleCtrl.redraw(); | |
837a2f8c PT |
596 | } |
597 | ||
598 | @Override | |
599 | public int getTimeSpace() { | |
f1fae91f PT |
600 | int w = fTimeGraphCtrl.getClientArea().width; |
601 | return w - fNameWidth; | |
837a2f8c PT |
602 | } |
603 | ||
837a2f8c PT |
604 | @Override |
605 | public long getBeginTime() { | |
f1fae91f | 606 | return fBeginTime; |
837a2f8c PT |
607 | } |
608 | ||
609 | @Override | |
610 | public long getEndTime() { | |
f1fae91f | 611 | return fEndTime; |
837a2f8c PT |
612 | } |
613 | ||
614 | @Override | |
615 | public long getMaxTime() { | |
f1fae91f | 616 | return fTime1Bound; |
837a2f8c PT |
617 | } |
618 | ||
619 | @Override | |
620 | public long getMinTime() { | |
f1fae91f | 621 | return fTime0Bound; |
837a2f8c PT |
622 | } |
623 | ||
0fcf3b09 PT |
624 | /** |
625 | * @since 2.1 | |
626 | */ | |
627 | @Override | |
628 | public long getSelectionBegin() { | |
629 | return fSelectionBegin; | |
630 | } | |
631 | ||
632 | /** | |
633 | * @since 2.1 | |
634 | */ | |
635 | @Override | |
636 | public long getSelectionEnd() { | |
637 | return fSelectionEnd; | |
638 | } | |
639 | ||
837a2f8c PT |
640 | @Override |
641 | public void setStartFinishTimeNotify(long time0, long time1) { | |
642 | setStartFinishTime(time0, time1); | |
643 | notifyRangeListeners(time0, time1); | |
644 | } | |
645 | ||
837a2f8c PT |
646 | @Override |
647 | public void notifyStartFinishTime() { | |
f1fae91f | 648 | notifyRangeListeners(fTime0, fTime1); |
837a2f8c PT |
649 | } |
650 | ||
837a2f8c PT |
651 | @Override |
652 | public void setStartFinishTime(long time0, long time1) { | |
f1fae91f PT |
653 | fTime0 = time0; |
654 | if (fTime0 < fTime0Bound) { | |
655 | fTime0 = fTime0Bound; | |
837a2f8c | 656 | } |
f1fae91f PT |
657 | if (fTime0 > fTime1Bound) { |
658 | fTime0 = fTime1Bound; | |
837a2f8c | 659 | } |
f1fae91f PT |
660 | fTime1 = time1; |
661 | if (fTime1 < fTime0Bound) { | |
662 | fTime1 = fTime0Bound; | |
837a2f8c | 663 | } |
f1fae91f PT |
664 | if (fTime1 > fTime1Bound) { |
665 | fTime1 = fTime1Bound; | |
837a2f8c | 666 | } |
f1fae91f PT |
667 | if (fTime1 - fTime0 < fMinTimeInterval) { |
668 | fTime1 = Math.min(fTime1Bound, fTime0 + fMinTimeInterval); | |
837a2f8c | 669 | } |
f1fae91f PT |
670 | fTimeRangeFixed = true; |
671 | fTimeGraphCtrl.adjustScrolls(); | |
672 | fTimeGraphCtrl.redraw(); | |
673 | fTimeScaleCtrl.redraw(); | |
837a2f8c PT |
674 | } |
675 | ||
676 | /** | |
677 | * Set the time bounds to the provided values | |
678 | * | |
679 | * @param beginTime | |
680 | * The start time of the window | |
681 | * @param endTime | |
682 | * The end time | |
683 | */ | |
684 | public void setTimeBounds(long beginTime, long endTime) { | |
407bfdd5 PT |
685 | if (endTime >= beginTime) { |
686 | fBeginTime = beginTime; | |
687 | fEndTime = endTime; | |
688 | fTime0Bound = beginTime; | |
689 | fTime1Bound = endTime; | |
690 | } else { | |
691 | fBeginTime = 0; | |
692 | fEndTime = 0; | |
693 | fTime0Bound = 0; | |
694 | fTime1Bound = 0; | |
695 | } | |
f1fae91f | 696 | fTimeGraphCtrl.adjustScrolls(); |
837a2f8c PT |
697 | } |
698 | ||
699 | @Override | |
700 | public void resetStartFinishTime() { | |
f1fae91f PT |
701 | setStartFinishTime(fTime0Bound, fTime1Bound); |
702 | fTimeRangeFixed = false; | |
837a2f8c PT |
703 | } |
704 | ||
705 | @Override | |
706 | public void setSelectedTimeNotify(long time, boolean ensureVisible) { | |
707 | setSelectedTimeInt(time, ensureVisible, true); | |
708 | } | |
709 | ||
710 | @Override | |
711 | public void setSelectedTime(long time, boolean ensureVisible) { | |
712 | setSelectedTimeInt(time, ensureVisible, false); | |
713 | } | |
714 | ||
0fcf3b09 PT |
715 | /** |
716 | * @since 2.1 | |
717 | */ | |
718 | @Override | |
719 | public void setSelectionRangeNotify(long beginTime, long endTime) { | |
720 | boolean changed = (beginTime != fSelectionBegin || endTime != fSelectionEnd); | |
721 | fSelectionBegin = Math.max(fTime0Bound, Math.min(fTime1Bound, beginTime)); | |
722 | fSelectionEnd = Math.max(fTime0Bound, Math.min(fTime1Bound, endTime)); | |
723 | fTimeGraphCtrl.redraw(); | |
724 | fTimeScaleCtrl.redraw(); | |
725 | if (changed) { | |
726 | notifyTimeListeners(fSelectionBegin, fSelectionEnd); | |
727 | } | |
728 | } | |
729 | ||
730 | /** | |
731 | * @since 2.1 | |
732 | */ | |
733 | @Override | |
734 | public void setSelectionRange(long beginTime, long endTime) { | |
735 | fSelectionBegin = Math.max(fTime0Bound, Math.min(fTime1Bound, beginTime)); | |
736 | fSelectionEnd = Math.max(fTime0Bound, Math.min(fTime1Bound, endTime)); | |
737 | fTimeGraphCtrl.redraw(); | |
738 | fTimeScaleCtrl.redraw(); | |
739 | } | |
740 | ||
837a2f8c | 741 | private void setSelectedTimeInt(long time, boolean ensureVisible, boolean doNotify) { |
f1fae91f PT |
742 | long time0 = fTime0; |
743 | long time1 = fTime1; | |
837a2f8c | 744 | if (ensureVisible) { |
f1fae91f PT |
745 | long timeSpace = (fTime1 - fTime0) / RECENTERING_MARGIN_FACTOR; |
746 | long timeMid = (fTime1 - fTime0) / 2; | |
747 | if (time < fTime0 + timeSpace) { | |
748 | long dt = fTime0 - time + timeMid; | |
749 | fTime0 -= dt; | |
750 | fTime1 -= dt; | |
751 | } else if (time > fTime1 - timeSpace) { | |
752 | long dt = time - fTime1 + timeMid; | |
753 | fTime0 += dt; | |
754 | fTime1 += dt; | |
837a2f8c | 755 | } |
f1fae91f PT |
756 | if (fTime0 < fTime0Bound) { |
757 | fTime1 = Math.min(fTime1Bound, fTime1 + (fTime0Bound - fTime0)); | |
758 | fTime0 = fTime0Bound; | |
759 | } else if (fTime1 > fTime1Bound) { | |
760 | fTime0 = Math.max(fTime0Bound, fTime0 - (fTime1 - fTime1Bound)); | |
761 | fTime1 = fTime1Bound; | |
837a2f8c PT |
762 | } |
763 | } | |
f1fae91f PT |
764 | if (fTime1 - fTime0 < fMinTimeInterval) { |
765 | fTime1 = Math.min(fTime1Bound, fTime0 + fMinTimeInterval); | |
837a2f8c | 766 | } |
f1fae91f PT |
767 | fTimeGraphCtrl.adjustScrolls(); |
768 | fTimeGraphCtrl.redraw(); | |
769 | fTimeScaleCtrl.redraw(); | |
837a2f8c | 770 | |
0fcf3b09 PT |
771 | boolean notifySelectedTime = (time != fSelectionBegin || time != fSelectionEnd); |
772 | fSelectionBegin = time; | |
773 | fSelectionEnd = time; | |
837a2f8c | 774 | |
f1fae91f PT |
775 | if (doNotify && ((time0 != fTime0) || (time1 != fTime1))) { |
776 | notifyRangeListeners(fTime0, fTime1); | |
837a2f8c PT |
777 | } |
778 | ||
779 | if (doNotify && notifySelectedTime) { | |
0fcf3b09 | 780 | notifyTimeListeners(fSelectionBegin, fSelectionEnd); |
837a2f8c PT |
781 | } |
782 | } | |
783 | ||
784 | @Override | |
785 | public void widgetDefaultSelected(SelectionEvent e) { | |
f1fae91f PT |
786 | if (fSelectedEntry != getSelection()) { |
787 | fSelectedEntry = getSelection(); | |
788 | notifySelectionListeners(fSelectedEntry); | |
837a2f8c PT |
789 | } |
790 | } | |
791 | ||
792 | @Override | |
793 | public void widgetSelected(SelectionEvent e) { | |
f1fae91f PT |
794 | if (fSelectedEntry != getSelection()) { |
795 | fSelectedEntry = getSelection(); | |
796 | notifySelectionListeners(fSelectedEntry); | |
837a2f8c PT |
797 | } |
798 | } | |
799 | ||
800 | /** | |
801 | * Callback for when the next event is selected | |
802 | */ | |
803 | public void selectNextEvent() { | |
f1fae91f | 804 | fTimeGraphCtrl.selectNextEvent(); |
837a2f8c PT |
805 | adjustVerticalScrollBar(); |
806 | } | |
807 | ||
808 | /** | |
809 | * Callback for when the previous event is selected | |
810 | */ | |
811 | public void selectPrevEvent() { | |
f1fae91f | 812 | fTimeGraphCtrl.selectPrevEvent(); |
837a2f8c PT |
813 | adjustVerticalScrollBar(); |
814 | } | |
815 | ||
816 | /** | |
817 | * Callback for when the next item is selected | |
818 | */ | |
819 | public void selectNextItem() { | |
f1fae91f | 820 | fTimeGraphCtrl.selectNextTrace(); |
837a2f8c PT |
821 | adjustVerticalScrollBar(); |
822 | } | |
823 | ||
824 | /** | |
825 | * Callback for when the previous item is selected | |
826 | */ | |
827 | public void selectPrevItem() { | |
f1fae91f | 828 | fTimeGraphCtrl.selectPrevTrace(); |
837a2f8c PT |
829 | adjustVerticalScrollBar(); |
830 | } | |
831 | ||
832 | /** | |
833 | * Callback for the show legend action | |
834 | */ | |
835 | public void showLegend() { | |
f1fae91f | 836 | if (fDataViewer == null || fDataViewer.isDisposed()) { |
837a2f8c PT |
837 | return; |
838 | } | |
839 | ||
f1fae91f | 840 | TimeGraphLegend.open(fDataViewer.getShell(), fTimeGraphProvider); |
837a2f8c PT |
841 | } |
842 | ||
843 | /** | |
844 | * Callback for the Zoom In action | |
845 | */ | |
846 | public void zoomIn() { | |
f1fae91f | 847 | fTimeGraphCtrl.zoomIn(); |
837a2f8c PT |
848 | } |
849 | ||
850 | /** | |
851 | * Callback for the Zoom Out action | |
852 | */ | |
853 | public void zoomOut() { | |
f1fae91f | 854 | fTimeGraphCtrl.zoomOut(); |
837a2f8c PT |
855 | } |
856 | ||
857 | private String getPreferenceString(String string) { | |
858 | return getViewTypeStr() + "." + string; //$NON-NLS-1$ | |
859 | } | |
860 | ||
861 | /** | |
862 | * Add a selection listener | |
863 | * | |
864 | * @param listener | |
865 | * The listener to add | |
866 | */ | |
867 | public void addSelectionListener(ITimeGraphSelectionListener listener) { | |
868 | fSelectionListeners.add(listener); | |
869 | } | |
870 | ||
871 | /** | |
872 | * Remove a selection listener | |
873 | * | |
874 | * @param listener | |
875 | * The listener to remove | |
876 | */ | |
877 | public void removeSelectionListener(ITimeGraphSelectionListener listener) { | |
878 | fSelectionListeners.remove(listener); | |
879 | } | |
880 | ||
881 | private void notifySelectionListeners(ITimeGraphEntry selection) { | |
882 | TimeGraphSelectionEvent event = new TimeGraphSelectionEvent(this, selection); | |
883 | ||
884 | for (ITimeGraphSelectionListener listener : fSelectionListeners) { | |
885 | listener.selectionChanged(event); | |
886 | } | |
887 | } | |
888 | ||
889 | /** | |
890 | * Add a time listener | |
891 | * | |
892 | * @param listener | |
893 | * The listener to add | |
894 | */ | |
895 | public void addTimeListener(ITimeGraphTimeListener listener) { | |
896 | fTimeListeners.add(listener); | |
897 | } | |
898 | ||
899 | /** | |
900 | * Remove a time listener | |
901 | * | |
902 | * @param listener | |
903 | * The listener to remove | |
904 | */ | |
905 | public void removeTimeListener(ITimeGraphTimeListener listener) { | |
906 | fTimeListeners.remove(listener); | |
907 | } | |
908 | ||
0fcf3b09 PT |
909 | private void notifyTimeListeners(long startTime, long endTime) { |
910 | TimeGraphTimeEvent event = new TimeGraphTimeEvent(this, startTime, endTime); | |
837a2f8c PT |
911 | |
912 | for (ITimeGraphTimeListener listener : fTimeListeners) { | |
913 | listener.timeSelected(event); | |
914 | } | |
915 | } | |
916 | ||
917 | /** | |
918 | * Add a range listener | |
919 | * | |
920 | * @param listener | |
921 | * The listener to add | |
922 | */ | |
923 | public void addRangeListener(ITimeGraphRangeListener listener) { | |
924 | fRangeListeners.add(listener); | |
925 | } | |
926 | ||
927 | /** | |
928 | * Remove a range listener | |
929 | * | |
930 | * @param listener | |
931 | * The listener to remove | |
932 | */ | |
933 | public void removeRangeListener(ITimeGraphRangeListener listener) { | |
934 | fRangeListeners.remove(listener); | |
935 | } | |
936 | ||
937 | private void notifyRangeListeners(long startTime, long endTime) { | |
938 | // Check if the time has actually changed from last notification | |
f1fae91f | 939 | if (startTime != fTime0ExtSynch || endTime != fTime1ExtSynch) { |
837a2f8c PT |
940 | // Notify Time Scale Selection Listeners |
941 | TimeGraphRangeUpdateEvent event = new TimeGraphRangeUpdateEvent(this, startTime, endTime); | |
942 | ||
943 | for (ITimeGraphRangeListener listener : fRangeListeners) { | |
944 | listener.timeRangeUpdated(event); | |
945 | } | |
946 | ||
947 | // update external synch timers | |
948 | updateExtSynchTimers(); | |
949 | } | |
950 | } | |
951 | ||
952 | /** | |
953 | * Callback to set a selected event in the view | |
954 | * | |
955 | * @param event | |
956 | * The event that was selected | |
957 | * @param source | |
958 | * The source of this selection event | |
959 | */ | |
960 | public void setSelectedEvent(ITimeEvent event, Object source) { | |
961 | if (event == null || source == this) { | |
962 | return; | |
963 | } | |
f1fae91f PT |
964 | fSelectedEntry = event.getEntry(); |
965 | fTimeGraphCtrl.selectItem(fSelectedEntry, false); | |
837a2f8c PT |
966 | |
967 | setSelectedTimeInt(event.getTime(), true, true); | |
968 | adjustVerticalScrollBar(); | |
969 | } | |
970 | ||
971 | /** | |
972 | * Set the seeked time of a trace | |
973 | * | |
974 | * @param trace | |
975 | * The trace that was seeked | |
976 | * @param time | |
977 | * The target time | |
978 | * @param source | |
979 | * The source of this seek event | |
980 | */ | |
981 | public void setSelectedTraceTime(ITimeGraphEntry trace, long time, Object source) { | |
982 | if (trace == null || source == this) { | |
983 | return; | |
984 | } | |
f1fae91f PT |
985 | fSelectedEntry = trace; |
986 | fTimeGraphCtrl.selectItem(trace, false); | |
837a2f8c PT |
987 | |
988 | setSelectedTimeInt(time, true, true); | |
989 | } | |
990 | ||
991 | /** | |
992 | * Callback for a trace selection | |
993 | * | |
994 | * @param trace | |
995 | * The trace that was selected | |
996 | */ | |
997 | public void setSelection(ITimeGraphEntry trace) { | |
f1fae91f PT |
998 | fSelectedEntry = trace; |
999 | fTimeGraphCtrl.selectItem(trace, false); | |
837a2f8c PT |
1000 | adjustVerticalScrollBar(); |
1001 | } | |
1002 | ||
1003 | /** | |
1004 | * Callback for a time window selection | |
1005 | * | |
1006 | * @param time0 | |
1007 | * Start time of the range | |
1008 | * @param time1 | |
1009 | * End time of the range | |
1010 | * @param source | |
1011 | * Source of the event | |
1012 | */ | |
1013 | public void setSelectVisTimeWindow(long time0, long time1, Object source) { | |
1014 | if (source == this) { | |
1015 | return; | |
1016 | } | |
1017 | ||
1018 | setStartFinishTime(time0, time1); | |
1019 | ||
1020 | // update notification time values since we are now in synch with the | |
1021 | // external application | |
1022 | updateExtSynchTimers(); | |
1023 | } | |
1024 | ||
1025 | /** | |
1026 | * update the cache timers used to identify the need to send a time window | |
1027 | * update to external registered listeners | |
1028 | */ | |
1029 | private void updateExtSynchTimers() { | |
1030 | // last time notification cache | |
f1fae91f PT |
1031 | fTime0ExtSynch = fTime0; |
1032 | fTime1ExtSynch = fTime1; | |
837a2f8c PT |
1033 | } |
1034 | ||
1035 | /** | |
026664b7 | 1036 | * @since 2.0 |
837a2f8c | 1037 | */ |
026664b7 XR |
1038 | @Override |
1039 | public TimeFormat getTimeFormat() { | |
f1fae91f | 1040 | return fTimeFormat; |
837a2f8c PT |
1041 | } |
1042 | ||
026664b7 | 1043 | /** |
79ec0b89 PT |
1044 | * @param tf |
1045 | * the {@link TimeFormat} used to display timestamps | |
026664b7 XR |
1046 | * @since 2.0 |
1047 | */ | |
1048 | public void setTimeFormat(TimeFormat tf) { | |
f1fae91f | 1049 | this.fTimeFormat = tf; |
837a2f8c PT |
1050 | } |
1051 | ||
1052 | /** | |
1053 | * Retrieve the border width | |
1054 | * | |
1055 | * @return The width | |
1056 | */ | |
1057 | public int getBorderWidth() { | |
f1fae91f | 1058 | return fBorderWidth; |
837a2f8c PT |
1059 | } |
1060 | ||
1061 | /** | |
1062 | * Set the border width | |
1063 | * | |
1064 | * @param borderWidth | |
1065 | * The width | |
1066 | */ | |
1067 | public void setBorderWidth(int borderWidth) { | |
1068 | if (borderWidth > -1) { | |
f1fae91f | 1069 | this.fBorderWidth = borderWidth; |
79ec0b89 | 1070 | GridLayout gl = (GridLayout) fDataViewer.getLayout(); |
837a2f8c PT |
1071 | gl.marginHeight = borderWidth; |
1072 | } | |
1073 | } | |
1074 | ||
1075 | /** | |
1076 | * Retrieve the height of the header | |
1077 | * | |
1078 | * @return The height | |
1079 | */ | |
1080 | public int getHeaderHeight() { | |
f1fae91f | 1081 | return fTimeScaleHeight; |
837a2f8c PT |
1082 | } |
1083 | ||
1084 | /** | |
1085 | * Set the height of the header | |
1086 | * | |
1087 | * @param headerHeight | |
1088 | * The height to set | |
1089 | */ | |
1090 | public void setHeaderHeight(int headerHeight) { | |
1091 | if (headerHeight > -1) { | |
f1fae91f PT |
1092 | this.fTimeScaleHeight = headerHeight; |
1093 | fTimeScaleCtrl.setHeight(headerHeight); | |
837a2f8c PT |
1094 | } |
1095 | } | |
1096 | ||
1097 | /** | |
1098 | * Retrieve the height of an item row | |
1099 | * | |
1100 | * @return The height | |
1101 | */ | |
1102 | public int getItemHeight() { | |
f1fae91f PT |
1103 | if (fTimeGraphCtrl != null) { |
1104 | return fTimeGraphCtrl.getItemHeight(); | |
837a2f8c PT |
1105 | } |
1106 | return 0; | |
1107 | } | |
1108 | ||
1109 | /** | |
1110 | * Set the height of an item row | |
1111 | * | |
1112 | * @param rowHeight | |
1113 | * The height to set | |
1114 | */ | |
1115 | public void setItemHeight(int rowHeight) { | |
f1fae91f PT |
1116 | if (fTimeGraphCtrl != null) { |
1117 | fTimeGraphCtrl.setItemHeight(rowHeight); | |
837a2f8c PT |
1118 | } |
1119 | } | |
1120 | ||
1121 | /** | |
1122 | * Set the minimum item width | |
1123 | * | |
1124 | * @param width | |
1125 | * The min width | |
1126 | */ | |
1127 | public void setMinimumItemWidth(int width) { | |
f1fae91f PT |
1128 | if (fTimeGraphCtrl != null) { |
1129 | fTimeGraphCtrl.setMinimumItemWidth(width); | |
837a2f8c PT |
1130 | } |
1131 | } | |
1132 | ||
1133 | /** | |
1134 | * Set the width for the name column | |
1135 | * | |
79ec0b89 PT |
1136 | * @param width |
1137 | * The width | |
837a2f8c PT |
1138 | */ |
1139 | public void setNameWidthPref(int width) { | |
f1fae91f | 1140 | fNameWidthPref = width; |
837a2f8c | 1141 | if (width == 0) { |
f1fae91f PT |
1142 | fMinNameWidth = 0; |
1143 | fNameWidth = 0; | |
837a2f8c PT |
1144 | } |
1145 | } | |
1146 | ||
1147 | /** | |
1148 | * Retrieve the configure width for the name column | |
1149 | * | |
1150 | * @param width | |
1151 | * Unused? | |
1152 | * @return The width | |
1153 | */ | |
1154 | public int getNameWidthPref(int width) { | |
f1fae91f | 1155 | return fNameWidthPref; |
837a2f8c PT |
1156 | } |
1157 | ||
1158 | /** | |
1159 | * Returns the primary control associated with this viewer. | |
1160 | * | |
1161 | * @return the SWT control which displays this viewer's content | |
1162 | */ | |
1163 | public Control getControl() { | |
f1fae91f | 1164 | return fDataViewer; |
837a2f8c PT |
1165 | } |
1166 | ||
1167 | /** | |
1168 | * Returns the time graph control associated with this viewer. | |
1169 | * | |
1170 | * @return the time graph control | |
3e9a3685 | 1171 | * @since 2.0 |
837a2f8c | 1172 | */ |
3e9a3685 | 1173 | public TimeGraphControl getTimeGraphControl() { |
f1fae91f | 1174 | return fTimeGraphCtrl; |
837a2f8c PT |
1175 | } |
1176 | ||
1177 | /** | |
1178 | * Returns the time graph scale associated with this viewer. | |
1179 | * | |
1180 | * @return the time graph scale | |
3e9a3685 | 1181 | * @since 2.0 |
837a2f8c | 1182 | */ |
3e9a3685 | 1183 | public TimeGraphScale getTimeGraphScale() { |
f1fae91f | 1184 | return fTimeScaleCtrl; |
837a2f8c PT |
1185 | } |
1186 | ||
713a70ae PT |
1187 | /** |
1188 | * Return the x coordinate corresponding to a time | |
1189 | * | |
79ec0b89 PT |
1190 | * @param time |
1191 | * the time | |
713a70ae PT |
1192 | * @return the x coordinate corresponding to the time |
1193 | * | |
1194 | * @since 2.0 | |
1195 | */ | |
1196 | public int getXForTime(long time) { | |
f1fae91f | 1197 | return fTimeGraphCtrl.getXForTime(time); |
713a70ae PT |
1198 | } |
1199 | ||
1200 | /** | |
1201 | * Return the time corresponding to an x coordinate | |
1202 | * | |
79ec0b89 PT |
1203 | * @param x |
1204 | * the x coordinate | |
713a70ae PT |
1205 | * @return the time corresponding to the x coordinate |
1206 | * | |
1207 | * @since 2.0 | |
1208 | */ | |
1209 | public long getTimeAtX(int x) { | |
f1fae91f | 1210 | return fTimeGraphCtrl.getTimeAtX(x); |
713a70ae PT |
1211 | } |
1212 | ||
837a2f8c PT |
1213 | /** |
1214 | * Get the selection provider | |
1215 | * | |
1216 | * @return the selection provider | |
1217 | */ | |
1218 | public ISelectionProvider getSelectionProvider() { | |
f1fae91f | 1219 | return fTimeGraphCtrl; |
837a2f8c PT |
1220 | } |
1221 | ||
1222 | /** | |
1223 | * Wait for the cursor | |
1224 | * | |
1225 | * @param waitInd | |
1226 | * Wait indefinitely? | |
1227 | */ | |
1228 | public void waitCursor(boolean waitInd) { | |
f1fae91f | 1229 | fTimeGraphCtrl.waitCursor(waitInd); |
837a2f8c PT |
1230 | } |
1231 | ||
1232 | /** | |
1233 | * Get the horizontal scroll bar object | |
1234 | * | |
1235 | * @return The scroll bar | |
1236 | */ | |
1237 | public ScrollBar getHorizontalBar() { | |
f1fae91f | 1238 | return fTimeGraphCtrl.getHorizontalBar(); |
837a2f8c PT |
1239 | } |
1240 | ||
1241 | /** | |
1242 | * Get the vertical scroll bar object | |
1243 | * | |
1244 | * @return The scroll bar | |
1245 | */ | |
1246 | public Slider getVerticalBar() { | |
f1fae91f | 1247 | return fVerticalScrollBar; |
837a2f8c PT |
1248 | } |
1249 | ||
1250 | /** | |
1251 | * Set the given index as the top one | |
1252 | * | |
1253 | * @param index | |
1254 | * The index that will go to the top | |
1255 | */ | |
1256 | public void setTopIndex(int index) { | |
f1fae91f | 1257 | fTimeGraphCtrl.setTopIndex(index); |
837a2f8c PT |
1258 | adjustVerticalScrollBar(); |
1259 | } | |
1260 | ||
1261 | /** | |
1262 | * Retrieve the current top index | |
1263 | * | |
1264 | * @return The top index | |
1265 | */ | |
1266 | public int getTopIndex() { | |
f1fae91f | 1267 | return fTimeGraphCtrl.getTopIndex(); |
837a2f8c PT |
1268 | } |
1269 | ||
1270 | /** | |
1271 | * Set the expanded state of an entry | |
1272 | * | |
1273 | * @param entry | |
1274 | * The entry to expand/collapse | |
1275 | * @param expanded | |
1276 | * True for expanded, false for collapsed | |
1277 | */ | |
1278 | public void setExpandedState(ITimeGraphEntry entry, boolean expanded) { | |
f1fae91f | 1279 | fTimeGraphCtrl.setExpandedState(entry, expanded); |
837a2f8c PT |
1280 | adjustVerticalScrollBar(); |
1281 | } | |
1282 | ||
1283 | /** | |
1284 | * Collapses all nodes of the viewer's tree, starting with the root. | |
1285 | * | |
1286 | * @since 2.0 | |
1287 | */ | |
1288 | public void collapseAll() { | |
f1fae91f | 1289 | fTimeGraphCtrl.collapseAll(); |
837a2f8c PT |
1290 | adjustVerticalScrollBar(); |
1291 | } | |
1292 | ||
1293 | /** | |
1294 | * Expands all nodes of the viewer's tree, starting with the root. | |
1295 | * | |
1296 | * @since 2.0 | |
1297 | */ | |
1298 | public void expandAll() { | |
f1fae91f | 1299 | fTimeGraphCtrl.expandAll(); |
837a2f8c PT |
1300 | adjustVerticalScrollBar(); |
1301 | } | |
1302 | ||
1303 | /** | |
1304 | * Get the number of sub-elements when expanded | |
1305 | * | |
1306 | * @return The element count | |
1307 | */ | |
1308 | public int getExpandedElementCount() { | |
f1fae91f | 1309 | return fTimeGraphCtrl.getExpandedElementCount(); |
837a2f8c PT |
1310 | } |
1311 | ||
1312 | /** | |
1313 | * Get the sub-elements | |
1314 | * | |
1315 | * @return The array of entries that are below this one | |
1316 | */ | |
1317 | public ITimeGraphEntry[] getExpandedElements() { | |
f1fae91f | 1318 | return fTimeGraphCtrl.getExpandedElements(); |
837a2f8c PT |
1319 | } |
1320 | ||
1321 | /** | |
1322 | * Add a tree listener | |
1323 | * | |
1324 | * @param listener | |
1325 | * The listener to add | |
1326 | */ | |
1327 | public void addTreeListener(ITimeGraphTreeListener listener) { | |
f1fae91f | 1328 | fTimeGraphCtrl.addTreeListener(listener); |
837a2f8c PT |
1329 | } |
1330 | ||
1331 | /** | |
1332 | * Remove a tree listener | |
1333 | * | |
1334 | * @param listener | |
1335 | * The listener to remove | |
1336 | */ | |
1337 | public void removeTreeListener(ITimeGraphTreeListener listener) { | |
f1fae91f | 1338 | fTimeGraphCtrl.removeTreeListener(listener); |
837a2f8c PT |
1339 | } |
1340 | ||
1341 | /** | |
1342 | * Get the reset scale action. | |
1343 | * | |
1344 | * @return The Action object | |
1345 | */ | |
1346 | public Action getResetScaleAction() { | |
f1fae91f | 1347 | if (fResetScaleAction == null) { |
837a2f8c | 1348 | // resetScale |
f1fae91f | 1349 | fResetScaleAction = new Action() { |
837a2f8c PT |
1350 | @Override |
1351 | public void run() { | |
1352 | resetStartFinishTime(); | |
894d6929 | 1353 | notifyStartFinishTime(); |
837a2f8c PT |
1354 | } |
1355 | }; | |
f1fae91f PT |
1356 | fResetScaleAction.setText(Messages.TmfTimeGraphViewer_ResetScaleActionNameText); |
1357 | fResetScaleAction.setToolTipText(Messages.TmfTimeGraphViewer_ResetScaleActionToolTipText); | |
1358 | fResetScaleAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_HOME_MENU)); | |
837a2f8c | 1359 | } |
f1fae91f | 1360 | return fResetScaleAction; |
837a2f8c PT |
1361 | } |
1362 | ||
1363 | /** | |
1364 | * Get the show legend action. | |
1365 | * | |
1366 | * @return The Action object | |
1367 | */ | |
1368 | public Action getShowLegendAction() { | |
f1fae91f | 1369 | if (fShowLegendAction == null) { |
837a2f8c | 1370 | // showLegend |
f1fae91f | 1371 | fShowLegendAction = new Action() { |
837a2f8c PT |
1372 | @Override |
1373 | public void run() { | |
1374 | showLegend(); | |
1375 | } | |
1376 | }; | |
f1fae91f PT |
1377 | fShowLegendAction.setText(Messages.TmfTimeGraphViewer_LegendActionNameText); |
1378 | fShowLegendAction.setToolTipText(Messages.TmfTimeGraphViewer_LegendActionToolTipText); | |
1379 | fShowLegendAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_SHOW_LEGEND)); | |
837a2f8c PT |
1380 | } |
1381 | ||
f1fae91f | 1382 | return fShowLegendAction; |
837a2f8c PT |
1383 | } |
1384 | ||
1385 | /** | |
1386 | * Get the the next event action. | |
1387 | * | |
1388 | * @return The action object | |
1389 | */ | |
1390 | public Action getNextEventAction() { | |
f1fae91f PT |
1391 | if (fNextEventAction == null) { |
1392 | fNextEventAction = new Action() { | |
837a2f8c PT |
1393 | @Override |
1394 | public void run() { | |
1395 | selectNextEvent(); | |
1396 | } | |
1397 | }; | |
1398 | ||
f1fae91f PT |
1399 | fNextEventAction.setText(Messages.TmfTimeGraphViewer_NextEventActionNameText); |
1400 | fNextEventAction.setToolTipText(Messages.TmfTimeGraphViewer_NextEventActionToolTipText); | |
1401 | fNextEventAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_NEXT_EVENT)); | |
837a2f8c PT |
1402 | } |
1403 | ||
f1fae91f | 1404 | return fNextEventAction; |
837a2f8c PT |
1405 | } |
1406 | ||
1407 | /** | |
1408 | * Get the previous event action. | |
1409 | * | |
1410 | * @return The Action object | |
1411 | */ | |
1412 | public Action getPreviousEventAction() { | |
f1fae91f PT |
1413 | if (fPrevEventAction == null) { |
1414 | fPrevEventAction = new Action() { | |
837a2f8c PT |
1415 | @Override |
1416 | public void run() { | |
1417 | selectPrevEvent(); | |
1418 | } | |
1419 | }; | |
1420 | ||
f1fae91f PT |
1421 | fPrevEventAction.setText(Messages.TmfTimeGraphViewer_PreviousEventActionNameText); |
1422 | fPrevEventAction.setToolTipText(Messages.TmfTimeGraphViewer_PreviousEventActionToolTipText); | |
1423 | fPrevEventAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_PREV_EVENT)); | |
837a2f8c PT |
1424 | } |
1425 | ||
f1fae91f | 1426 | return fPrevEventAction; |
837a2f8c PT |
1427 | } |
1428 | ||
1429 | /** | |
1430 | * Get the next item action. | |
1431 | * | |
1432 | * @return The Action object | |
1433 | */ | |
1434 | public Action getNextItemAction() { | |
f1fae91f | 1435 | if (fNextItemAction == null) { |
837a2f8c | 1436 | |
f1fae91f | 1437 | fNextItemAction = new Action() { |
837a2f8c PT |
1438 | @Override |
1439 | public void run() { | |
1440 | selectNextItem(); | |
1441 | } | |
1442 | }; | |
f1fae91f PT |
1443 | fNextItemAction.setText(Messages.TmfTimeGraphViewer_NextItemActionNameText); |
1444 | fNextItemAction.setToolTipText(Messages.TmfTimeGraphViewer_NextItemActionToolTipText); | |
1445 | fNextItemAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_NEXT_ITEM)); | |
837a2f8c | 1446 | } |
f1fae91f | 1447 | return fNextItemAction; |
837a2f8c PT |
1448 | } |
1449 | ||
1450 | /** | |
1451 | * Get the previous item action. | |
1452 | * | |
1453 | * @return The Action object | |
1454 | */ | |
1455 | public Action getPreviousItemAction() { | |
f1fae91f | 1456 | if (fPreviousItemAction == null) { |
837a2f8c | 1457 | |
f1fae91f | 1458 | fPreviousItemAction = new Action() { |
837a2f8c PT |
1459 | @Override |
1460 | public void run() { | |
1461 | selectPrevItem(); | |
1462 | } | |
1463 | }; | |
f1fae91f PT |
1464 | fPreviousItemAction.setText(Messages.TmfTimeGraphViewer_PreviousItemActionNameText); |
1465 | fPreviousItemAction.setToolTipText(Messages.TmfTimeGraphViewer_PreviousItemActionToolTipText); | |
1466 | fPreviousItemAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_PREV_ITEM)); | |
837a2f8c | 1467 | } |
f1fae91f | 1468 | return fPreviousItemAction; |
837a2f8c PT |
1469 | } |
1470 | ||
1471 | /** | |
1472 | * Get the zoom in action | |
1473 | * | |
1474 | * @return The Action object | |
1475 | */ | |
1476 | public Action getZoomInAction() { | |
f1fae91f PT |
1477 | if (fZoomInAction == null) { |
1478 | fZoomInAction = new Action() { | |
837a2f8c PT |
1479 | @Override |
1480 | public void run() { | |
1481 | zoomIn(); | |
1482 | } | |
1483 | }; | |
f1fae91f PT |
1484 | fZoomInAction.setText(Messages.TmfTimeGraphViewer_ZoomInActionNameText); |
1485 | fZoomInAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomInActionToolTipText); | |
1486 | fZoomInAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_IN_MENU)); | |
837a2f8c | 1487 | } |
f1fae91f | 1488 | return fZoomInAction; |
837a2f8c PT |
1489 | } |
1490 | ||
1491 | /** | |
1492 | * Get the zoom out action | |
1493 | * | |
1494 | * @return The Action object | |
1495 | */ | |
1496 | public Action getZoomOutAction() { | |
f1fae91f PT |
1497 | if (fZoomOutAction == null) { |
1498 | fZoomOutAction = new Action() { | |
837a2f8c PT |
1499 | @Override |
1500 | public void run() { | |
1501 | zoomOut(); | |
1502 | } | |
1503 | }; | |
f1fae91f PT |
1504 | fZoomOutAction.setText(Messages.TmfTimeGraphViewer_ZoomOutActionNameText); |
1505 | fZoomOutAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomOutActionToolTipText); | |
1506 | fZoomOutAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_OUT_MENU)); | |
837a2f8c | 1507 | } |
f1fae91f | 1508 | return fZoomOutAction; |
837a2f8c PT |
1509 | } |
1510 | ||
79ec0b89 PT |
1511 | /** |
1512 | * Get the hide arrows action | |
1513 | * | |
1514 | * @param dialogSettings | |
1515 | * The dialog settings section where the state should be stored, | |
1516 | * or null | |
1517 | * | |
1518 | * @return The Action object | |
1519 | * | |
1520 | * @since 2.1 | |
1521 | */ | |
1522 | public Action getHideArrowsAction(final IDialogSettings dialogSettings) { | |
1523 | if (fHideArrowsAction == null) { | |
1524 | fHideArrowsAction = new Action(Messages.TmfTimeGraphViewer_HideArrowsActionNameText, IAction.AS_CHECK_BOX) { | |
1525 | @Override | |
1526 | public void run() { | |
1527 | boolean hideArrows = fHideArrowsAction.isChecked(); | |
1528 | fTimeGraphCtrl.hideArrows(hideArrows); | |
1529 | refresh(); | |
1530 | if (dialogSettings != null) { | |
1531 | dialogSettings.put(HIDE_ARROWS_KEY, hideArrows); | |
1532 | } | |
086f21ae PT |
1533 | if (fFollowArrowFwdAction != null) { |
1534 | fFollowArrowFwdAction.setEnabled(!hideArrows); | |
1535 | } | |
1536 | if (fFollowArrowBwdAction != null) { | |
1537 | fFollowArrowBwdAction.setEnabled(!hideArrows); | |
1538 | } | |
79ec0b89 PT |
1539 | } |
1540 | }; | |
1541 | fHideArrowsAction.setToolTipText(Messages.TmfTimeGraphViewer_HideArrowsActionToolTipText); | |
1542 | fHideArrowsAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_HIDE_ARROWS)); | |
1543 | if (dialogSettings != null) { | |
1544 | boolean hideArrows = dialogSettings.getBoolean(HIDE_ARROWS_KEY); | |
1545 | fTimeGraphCtrl.hideArrows(hideArrows); | |
1546 | fHideArrowsAction.setChecked(hideArrows); | |
086f21ae PT |
1547 | if (fFollowArrowFwdAction != null) { |
1548 | fFollowArrowFwdAction.setEnabled(!hideArrows); | |
1549 | } | |
1550 | if (fFollowArrowBwdAction != null) { | |
1551 | fFollowArrowBwdAction.setEnabled(!hideArrows); | |
1552 | } | |
79ec0b89 PT |
1553 | } |
1554 | } | |
1555 | return fHideArrowsAction; | |
1556 | } | |
837a2f8c | 1557 | |
086f21ae PT |
1558 | /** |
1559 | * Get the follow arrow forward action. | |
1560 | * | |
1561 | * @return The Action object | |
1562 | * | |
1563 | * @since 2.1 | |
1564 | */ | |
1565 | public Action getFollowArrowFwdAction() { | |
1566 | if (fFollowArrowFwdAction == null) { | |
1567 | fFollowArrowFwdAction = new Action() { | |
1568 | @Override | |
1569 | public void run() { | |
1570 | fTimeGraphCtrl.followArrowFwd(); | |
1571 | adjustVerticalScrollBar(); | |
1572 | } | |
1573 | }; | |
1574 | fFollowArrowFwdAction.setText(Messages.TmfTimeGraphViewer_FollowArrowForwardActionNameText); | |
1575 | fFollowArrowFwdAction.setToolTipText(Messages.TmfTimeGraphViewer_FollowArrowForwardActionToolTipText); | |
1576 | fFollowArrowFwdAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_FOLLOW_ARROW_FORWARD)); | |
1577 | if (fHideArrowsAction != null) { | |
1578 | fFollowArrowFwdAction.setEnabled(!fHideArrowsAction.isChecked()); | |
1579 | } | |
1580 | } | |
1581 | return fFollowArrowFwdAction; | |
1582 | } | |
1583 | ||
1584 | /** | |
1585 | * Get the follow arrow backward action. | |
1586 | * | |
1587 | * @return The Action object | |
1588 | * | |
1589 | * @since 2.1 | |
1590 | */ | |
1591 | public Action getFollowArrowBwdAction() { | |
1592 | if (fFollowArrowBwdAction == null) { | |
1593 | fFollowArrowBwdAction = new Action() { | |
1594 | @Override | |
1595 | public void run() { | |
1596 | fTimeGraphCtrl.followArrowBwd(); | |
1597 | adjustVerticalScrollBar(); | |
1598 | } | |
1599 | }; | |
1600 | fFollowArrowBwdAction.setText(Messages.TmfTimeGraphViewer_FollowArrowBackwardActionNameText); | |
1601 | fFollowArrowBwdAction.setToolTipText(Messages.TmfTimeGraphViewer_FollowArrowBackwardActionToolTipText); | |
1602 | fFollowArrowBwdAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_FOLLOW_ARROW_BACKWARD)); | |
1603 | if (fHideArrowsAction != null) { | |
1604 | fFollowArrowBwdAction.setEnabled(!fHideArrowsAction.isChecked()); | |
1605 | } | |
1606 | } | |
1607 | return fFollowArrowBwdAction; | |
1608 | } | |
1609 | ||
837a2f8c | 1610 | private void adjustVerticalScrollBar() { |
f1fae91f PT |
1611 | int topIndex = fTimeGraphCtrl.getTopIndex(); |
1612 | int countPerPage = fTimeGraphCtrl.countPerPage(); | |
1613 | int expandedElementCount = fTimeGraphCtrl.getExpandedElementCount(); | |
837a2f8c | 1614 | if (topIndex + countPerPage > expandedElementCount) { |
f1fae91f | 1615 | fTimeGraphCtrl.setTopIndex(Math.max(0, expandedElementCount - countPerPage)); |
837a2f8c PT |
1616 | } |
1617 | ||
f1fae91f | 1618 | int selection = fTimeGraphCtrl.getTopIndex(); |
837a2f8c PT |
1619 | int min = 0; |
1620 | int max = Math.max(1, expandedElementCount - 1); | |
1621 | int thumb = Math.min(max, Math.max(1, countPerPage - 1)); | |
1622 | int increment = 1; | |
1623 | int pageIncrement = Math.max(1, countPerPage); | |
f1fae91f | 1624 | fVerticalScrollBar.setValues(selection, min, max, thumb, increment, pageIncrement); |
837a2f8c PT |
1625 | } |
1626 | ||
27df1564 | 1627 | /** |
79ec0b89 PT |
1628 | * @param listener |
1629 | * a {@link MenuDetectListener} | |
27df1564 | 1630 | * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#addTimeGraphEntryMenuListener(org.eclipse.swt.events.MenuDetectListener) |
77c4a6df | 1631 | * @since 1.2 |
27df1564 XR |
1632 | */ |
1633 | public void addTimeGraphEntryMenuListener(MenuDetectListener listener) { | |
f1fae91f | 1634 | fTimeGraphCtrl.addTimeGraphEntryMenuListener(listener); |
27df1564 XR |
1635 | } |
1636 | ||
1637 | /** | |
79ec0b89 PT |
1638 | * @param listener |
1639 | * a {@link MenuDetectListener} | |
27df1564 | 1640 | * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#removeTimeGraphEntryMenuListener(org.eclipse.swt.events.MenuDetectListener) |
77c4a6df | 1641 | * @since 1.2 |
27df1564 XR |
1642 | */ |
1643 | public void removeTimeGraphEntryMenuListener(MenuDetectListener listener) { | |
f1fae91f | 1644 | fTimeGraphCtrl.removeTimeGraphEntryMenuListener(listener); |
27df1564 XR |
1645 | } |
1646 | ||
1647 | /** | |
79ec0b89 PT |
1648 | * @param listener |
1649 | * a {@link MenuDetectListener} | |
27df1564 | 1650 | * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#addTimeEventMenuListener(org.eclipse.swt.events.MenuDetectListener) |
77c4a6df | 1651 | * @since 1.2 |
27df1564 XR |
1652 | */ |
1653 | public void addTimeEventMenuListener(MenuDetectListener listener) { | |
f1fae91f | 1654 | fTimeGraphCtrl.addTimeEventMenuListener(listener); |
27df1564 XR |
1655 | } |
1656 | ||
1657 | /** | |
79ec0b89 PT |
1658 | * @param listener |
1659 | * a {@link MenuDetectListener} | |
27df1564 | 1660 | * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#removeTimeEventMenuListener(org.eclipse.swt.events.MenuDetectListener) |
77c4a6df | 1661 | * @since 1.2 |
27df1564 XR |
1662 | */ |
1663 | public void removeTimeEventMenuListener(MenuDetectListener listener) { | |
f1fae91f | 1664 | fTimeGraphCtrl.removeTimeEventMenuListener(listener); |
27df1564 XR |
1665 | } |
1666 | ||
6ac5a950 | 1667 | /** |
79ec0b89 PT |
1668 | * @param filter |
1669 | * The filter object to be attached to the view | |
6ac5a950 AM |
1670 | * @since 2.0 |
1671 | */ | |
1672 | public void addFilter(ViewerFilter filter) { | |
f1fae91f | 1673 | fTimeGraphCtrl.addFilter(filter); |
6ac5a950 AM |
1674 | refresh(); |
1675 | } | |
837a2f8c | 1676 | |
6ac5a950 | 1677 | /** |
79ec0b89 PT |
1678 | * @param filter |
1679 | * The filter object to be attached to the view | |
6ac5a950 AM |
1680 | * @since 2.0 |
1681 | */ | |
1682 | public void removeFilter(ViewerFilter filter) { | |
f1fae91f | 1683 | fTimeGraphCtrl.removeFilter(filter); |
6ac5a950 AM |
1684 | refresh(); |
1685 | } | |
837a2f8c PT |
1686 | |
1687 | } |