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