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 | ||
f1fae91f PT |
100 | private List<ITimeGraphSelectionListener> fSelectionListeners = new ArrayList<ITimeGraphSelectionListener>(); |
101 | private List<ITimeGraphTimeListener> fTimeListeners = new ArrayList<ITimeGraphTimeListener>(); | |
102 | private List<ITimeGraphRangeListener> fRangeListeners = new ArrayList<ITimeGraphRangeListener>(); | |
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 | } |
f1fae91f PT |
430 | if (fTime1 - fTime0 < fMinTimeInterval) { |
431 | fTime1 = Math.min(fTime1Bound, fTime0 + fMinTimeInterval); | |
837a2f8c PT |
432 | } |
433 | } | |
434 | ||
435 | /** | |
436 | * @param traces | |
437 | * @param start | |
438 | * @param end | |
439 | */ | |
440 | void updateInternalData(ITimeGraphEntry[] traces, long start, long end) { | |
41b5c37f AM |
441 | ITimeGraphEntry[] realTraces = traces; |
442 | ||
443 | if (null == realTraces) { | |
444 | realTraces = new ITimeGraphEntry[0]; | |
837a2f8c PT |
445 | } |
446 | if ((start == 0 && end == 0) || start < 0 || end < 0) { | |
447 | // Start and end time are unspecified and need to be determined from | |
448 | // individual processes | |
41b5c37f | 449 | setTimeRange(realTraces); |
837a2f8c | 450 | } else { |
f1fae91f PT |
451 | fBeginTime = start; |
452 | fEndTime = end; | |
837a2f8c PT |
453 | } |
454 | ||
41b5c37f | 455 | refreshAllData(realTraces); |
837a2f8c PT |
456 | } |
457 | ||
458 | /** | |
459 | * @param traces | |
460 | */ | |
461 | private void refreshAllData(ITimeGraphEntry[] traces) { | |
462 | setTimeBounds(); | |
0fcf3b09 PT |
463 | if (fSelectionBegin < fBeginTime) { |
464 | fSelectionBegin = fBeginTime; | |
465 | } else if (fSelectionBegin > fEndTime) { | |
466 | fSelectionBegin = fEndTime; | |
467 | } | |
468 | if (fSelectionEnd < fBeginTime) { | |
469 | fSelectionEnd = fBeginTime; | |
470 | } else if (fSelectionEnd > fEndTime) { | |
471 | fSelectionEnd = fEndTime; | |
837a2f8c | 472 | } |
f1fae91f PT |
473 | fTimeGraphCtrl.refreshData(traces); |
474 | fTimeScaleCtrl.redraw(); | |
837a2f8c PT |
475 | adjustVerticalScrollBar(); |
476 | } | |
477 | ||
478 | /** | |
479 | * Callback for when this view is focused | |
480 | */ | |
481 | public void setFocus() { | |
f1fae91f PT |
482 | if (null != fTimeGraphCtrl) { |
483 | fTimeGraphCtrl.setFocus(); | |
837a2f8c PT |
484 | } |
485 | } | |
486 | ||
487 | /** | |
488 | * Get the current focus status of this view. | |
489 | * | |
490 | * @return If the view is currently focused, or not | |
491 | */ | |
492 | public boolean isInFocus() { | |
f1fae91f | 493 | return fTimeGraphCtrl.isInFocus(); |
837a2f8c PT |
494 | } |
495 | ||
496 | /** | |
497 | * Get the view's current selection | |
498 | * | |
499 | * @return The entry that is selected | |
500 | */ | |
501 | public ITimeGraphEntry getSelection() { | |
f1fae91f | 502 | return fTimeGraphCtrl.getSelectedTrace(); |
837a2f8c PT |
503 | } |
504 | ||
505 | /** | |
506 | * Get the index of the current selection | |
507 | * | |
508 | * @return The index | |
509 | */ | |
510 | public int getSelectionIndex() { | |
f1fae91f | 511 | return fTimeGraphCtrl.getSelectedIndex(); |
837a2f8c PT |
512 | } |
513 | ||
514 | @Override | |
515 | public long getTime0() { | |
f1fae91f | 516 | return fTime0; |
837a2f8c PT |
517 | } |
518 | ||
519 | @Override | |
520 | public long getTime1() { | |
f1fae91f | 521 | return fTime1; |
837a2f8c PT |
522 | } |
523 | ||
524 | @Override | |
525 | public long getMinTimeInterval() { | |
f1fae91f | 526 | return fMinTimeInterval; |
837a2f8c PT |
527 | } |
528 | ||
529 | @Override | |
530 | public int getNameSpace() { | |
f1fae91f | 531 | return fNameWidth; |
837a2f8c PT |
532 | } |
533 | ||
534 | @Override | |
535 | public void setNameSpace(int width) { | |
f1fae91f PT |
536 | fNameWidth = width; |
537 | int w = fTimeGraphCtrl.getClientArea().width; | |
538 | if (fNameWidth > w - MIN_NAME_WIDTH) { | |
539 | fNameWidth = w - MIN_NAME_WIDTH; | |
837a2f8c | 540 | } |
f1fae91f PT |
541 | if (fNameWidth < MIN_NAME_WIDTH) { |
542 | fNameWidth = MIN_NAME_WIDTH; | |
837a2f8c | 543 | } |
f1fae91f PT |
544 | fTimeGraphCtrl.adjustScrolls(); |
545 | fTimeGraphCtrl.redraw(); | |
546 | fTimeScaleCtrl.redraw(); | |
837a2f8c PT |
547 | } |
548 | ||
549 | @Override | |
550 | public int getTimeSpace() { | |
f1fae91f PT |
551 | int w = fTimeGraphCtrl.getClientArea().width; |
552 | return w - fNameWidth; | |
837a2f8c PT |
553 | } |
554 | ||
0fcf3b09 PT |
555 | @SuppressWarnings("deprecation") |
556 | @Deprecated | |
837a2f8c PT |
557 | @Override |
558 | public long getSelectedTime() { | |
0fcf3b09 | 559 | return fSelectionBegin; |
837a2f8c PT |
560 | } |
561 | ||
562 | @Override | |
563 | public long getBeginTime() { | |
f1fae91f | 564 | return fBeginTime; |
837a2f8c PT |
565 | } |
566 | ||
567 | @Override | |
568 | public long getEndTime() { | |
f1fae91f | 569 | return fEndTime; |
837a2f8c PT |
570 | } |
571 | ||
572 | @Override | |
573 | public long getMaxTime() { | |
f1fae91f | 574 | return fTime1Bound; |
837a2f8c PT |
575 | } |
576 | ||
577 | @Override | |
578 | public long getMinTime() { | |
f1fae91f | 579 | return fTime0Bound; |
837a2f8c PT |
580 | } |
581 | ||
0fcf3b09 PT |
582 | /** |
583 | * @since 2.1 | |
584 | */ | |
585 | @Override | |
586 | public long getSelectionBegin() { | |
587 | return fSelectionBegin; | |
588 | } | |
589 | ||
590 | /** | |
591 | * @since 2.1 | |
592 | */ | |
593 | @Override | |
594 | public long getSelectionEnd() { | |
595 | return fSelectionEnd; | |
596 | } | |
597 | ||
837a2f8c PT |
598 | @Override |
599 | public void setStartFinishTimeNotify(long time0, long time1) { | |
600 | setStartFinishTime(time0, time1); | |
601 | notifyRangeListeners(time0, time1); | |
602 | } | |
603 | ||
837a2f8c PT |
604 | @Override |
605 | public void notifyStartFinishTime() { | |
f1fae91f | 606 | notifyRangeListeners(fTime0, fTime1); |
837a2f8c PT |
607 | } |
608 | ||
837a2f8c PT |
609 | @Override |
610 | public void setStartFinishTime(long time0, long time1) { | |
f1fae91f PT |
611 | fTime0 = time0; |
612 | if (fTime0 < fTime0Bound) { | |
613 | fTime0 = fTime0Bound; | |
837a2f8c | 614 | } |
f1fae91f PT |
615 | if (fTime0 > fTime1Bound) { |
616 | fTime0 = fTime1Bound; | |
837a2f8c | 617 | } |
f1fae91f PT |
618 | fTime1 = time1; |
619 | if (fTime1 < fTime0Bound) { | |
620 | fTime1 = fTime0Bound; | |
837a2f8c | 621 | } |
f1fae91f PT |
622 | if (fTime1 > fTime1Bound) { |
623 | fTime1 = fTime1Bound; | |
837a2f8c | 624 | } |
f1fae91f PT |
625 | if (fTime1 - fTime0 < fMinTimeInterval) { |
626 | fTime1 = Math.min(fTime1Bound, fTime0 + fMinTimeInterval); | |
837a2f8c | 627 | } |
f1fae91f PT |
628 | fTimeRangeFixed = true; |
629 | fTimeGraphCtrl.adjustScrolls(); | |
630 | fTimeGraphCtrl.redraw(); | |
631 | fTimeScaleCtrl.redraw(); | |
837a2f8c PT |
632 | } |
633 | ||
634 | /** | |
635 | * Set the time bounds to the provided values | |
636 | * | |
637 | * @param beginTime | |
638 | * The start time of the window | |
639 | * @param endTime | |
640 | * The end time | |
641 | */ | |
642 | public void setTimeBounds(long beginTime, long endTime) { | |
f1fae91f PT |
643 | fBeginTime = beginTime; |
644 | fEndTime = endTime; | |
645 | fTime0Bound = beginTime; | |
646 | fTime1Bound = endTime; | |
647 | fTimeGraphCtrl.adjustScrolls(); | |
837a2f8c PT |
648 | } |
649 | ||
650 | @Override | |
651 | public void resetStartFinishTime() { | |
f1fae91f PT |
652 | setStartFinishTime(fTime0Bound, fTime1Bound); |
653 | fTimeRangeFixed = false; | |
837a2f8c PT |
654 | } |
655 | ||
656 | @Override | |
657 | public void setSelectedTimeNotify(long time, boolean ensureVisible) { | |
658 | setSelectedTimeInt(time, ensureVisible, true); | |
659 | } | |
660 | ||
661 | @Override | |
662 | public void setSelectedTime(long time, boolean ensureVisible) { | |
663 | setSelectedTimeInt(time, ensureVisible, false); | |
664 | } | |
665 | ||
0fcf3b09 PT |
666 | /** |
667 | * @since 2.1 | |
668 | */ | |
669 | @Override | |
670 | public void setSelectionRangeNotify(long beginTime, long endTime) { | |
671 | boolean changed = (beginTime != fSelectionBegin || endTime != fSelectionEnd); | |
672 | fSelectionBegin = Math.max(fTime0Bound, Math.min(fTime1Bound, beginTime)); | |
673 | fSelectionEnd = Math.max(fTime0Bound, Math.min(fTime1Bound, endTime)); | |
674 | fTimeGraphCtrl.redraw(); | |
675 | fTimeScaleCtrl.redraw(); | |
676 | if (changed) { | |
677 | notifyTimeListeners(fSelectionBegin, fSelectionEnd); | |
678 | } | |
679 | } | |
680 | ||
681 | /** | |
682 | * @since 2.1 | |
683 | */ | |
684 | @Override | |
685 | public void setSelectionRange(long beginTime, long endTime) { | |
686 | fSelectionBegin = Math.max(fTime0Bound, Math.min(fTime1Bound, beginTime)); | |
687 | fSelectionEnd = Math.max(fTime0Bound, Math.min(fTime1Bound, endTime)); | |
688 | fTimeGraphCtrl.redraw(); | |
689 | fTimeScaleCtrl.redraw(); | |
690 | } | |
691 | ||
837a2f8c | 692 | private void setSelectedTimeInt(long time, boolean ensureVisible, boolean doNotify) { |
f1fae91f PT |
693 | long time0 = fTime0; |
694 | long time1 = fTime1; | |
837a2f8c | 695 | if (ensureVisible) { |
f1fae91f PT |
696 | long timeSpace = (fTime1 - fTime0) / RECENTERING_MARGIN_FACTOR; |
697 | long timeMid = (fTime1 - fTime0) / 2; | |
698 | if (time < fTime0 + timeSpace) { | |
699 | long dt = fTime0 - time + timeMid; | |
700 | fTime0 -= dt; | |
701 | fTime1 -= dt; | |
702 | } else if (time > fTime1 - timeSpace) { | |
703 | long dt = time - fTime1 + timeMid; | |
704 | fTime0 += dt; | |
705 | fTime1 += dt; | |
837a2f8c | 706 | } |
f1fae91f PT |
707 | if (fTime0 < fTime0Bound) { |
708 | fTime1 = Math.min(fTime1Bound, fTime1 + (fTime0Bound - fTime0)); | |
709 | fTime0 = fTime0Bound; | |
710 | } else if (fTime1 > fTime1Bound) { | |
711 | fTime0 = Math.max(fTime0Bound, fTime0 - (fTime1 - fTime1Bound)); | |
712 | fTime1 = fTime1Bound; | |
837a2f8c PT |
713 | } |
714 | } | |
f1fae91f PT |
715 | if (fTime1 - fTime0 < fMinTimeInterval) { |
716 | fTime1 = Math.min(fTime1Bound, fTime0 + fMinTimeInterval); | |
837a2f8c | 717 | } |
f1fae91f PT |
718 | fTimeGraphCtrl.adjustScrolls(); |
719 | fTimeGraphCtrl.redraw(); | |
720 | fTimeScaleCtrl.redraw(); | |
837a2f8c | 721 | |
0fcf3b09 PT |
722 | boolean notifySelectedTime = (time != fSelectionBegin || time != fSelectionEnd); |
723 | fSelectionBegin = time; | |
724 | fSelectionEnd = time; | |
837a2f8c | 725 | |
f1fae91f PT |
726 | if (doNotify && ((time0 != fTime0) || (time1 != fTime1))) { |
727 | notifyRangeListeners(fTime0, fTime1); | |
837a2f8c PT |
728 | } |
729 | ||
730 | if (doNotify && notifySelectedTime) { | |
0fcf3b09 | 731 | notifyTimeListeners(fSelectionBegin, fSelectionEnd); |
837a2f8c PT |
732 | } |
733 | } | |
734 | ||
735 | @Override | |
736 | public void widgetDefaultSelected(SelectionEvent e) { | |
f1fae91f PT |
737 | if (fSelectedEntry != getSelection()) { |
738 | fSelectedEntry = getSelection(); | |
739 | notifySelectionListeners(fSelectedEntry); | |
837a2f8c PT |
740 | } |
741 | } | |
742 | ||
743 | @Override | |
744 | public void widgetSelected(SelectionEvent e) { | |
f1fae91f PT |
745 | if (fSelectedEntry != getSelection()) { |
746 | fSelectedEntry = getSelection(); | |
747 | notifySelectionListeners(fSelectedEntry); | |
837a2f8c PT |
748 | } |
749 | } | |
750 | ||
751 | /** | |
752 | * Callback for when the next event is selected | |
753 | */ | |
754 | public void selectNextEvent() { | |
f1fae91f | 755 | fTimeGraphCtrl.selectNextEvent(); |
837a2f8c PT |
756 | adjustVerticalScrollBar(); |
757 | } | |
758 | ||
759 | /** | |
760 | * Callback for when the previous event is selected | |
761 | */ | |
762 | public void selectPrevEvent() { | |
f1fae91f | 763 | fTimeGraphCtrl.selectPrevEvent(); |
837a2f8c PT |
764 | adjustVerticalScrollBar(); |
765 | } | |
766 | ||
767 | /** | |
768 | * Callback for when the next item is selected | |
769 | */ | |
770 | public void selectNextItem() { | |
f1fae91f | 771 | fTimeGraphCtrl.selectNextTrace(); |
837a2f8c PT |
772 | adjustVerticalScrollBar(); |
773 | } | |
774 | ||
775 | /** | |
776 | * Callback for when the previous item is selected | |
777 | */ | |
778 | public void selectPrevItem() { | |
f1fae91f | 779 | fTimeGraphCtrl.selectPrevTrace(); |
837a2f8c PT |
780 | adjustVerticalScrollBar(); |
781 | } | |
782 | ||
783 | /** | |
784 | * Callback for the show legend action | |
785 | */ | |
786 | public void showLegend() { | |
f1fae91f | 787 | if (fDataViewer == null || fDataViewer.isDisposed()) { |
837a2f8c PT |
788 | return; |
789 | } | |
790 | ||
f1fae91f | 791 | TimeGraphLegend.open(fDataViewer.getShell(), fTimeGraphProvider); |
837a2f8c PT |
792 | } |
793 | ||
794 | /** | |
795 | * Callback for the Zoom In action | |
796 | */ | |
797 | public void zoomIn() { | |
f1fae91f | 798 | fTimeGraphCtrl.zoomIn(); |
837a2f8c PT |
799 | } |
800 | ||
801 | /** | |
802 | * Callback for the Zoom Out action | |
803 | */ | |
804 | public void zoomOut() { | |
f1fae91f | 805 | fTimeGraphCtrl.zoomOut(); |
837a2f8c PT |
806 | } |
807 | ||
808 | private String getPreferenceString(String string) { | |
809 | return getViewTypeStr() + "." + string; //$NON-NLS-1$ | |
810 | } | |
811 | ||
812 | /** | |
813 | * Add a selection listener | |
814 | * | |
815 | * @param listener | |
816 | * The listener to add | |
817 | */ | |
818 | public void addSelectionListener(ITimeGraphSelectionListener listener) { | |
819 | fSelectionListeners.add(listener); | |
820 | } | |
821 | ||
822 | /** | |
823 | * Remove a selection listener | |
824 | * | |
825 | * @param listener | |
826 | * The listener to remove | |
827 | */ | |
828 | public void removeSelectionListener(ITimeGraphSelectionListener listener) { | |
829 | fSelectionListeners.remove(listener); | |
830 | } | |
831 | ||
832 | private void notifySelectionListeners(ITimeGraphEntry selection) { | |
833 | TimeGraphSelectionEvent event = new TimeGraphSelectionEvent(this, selection); | |
834 | ||
835 | for (ITimeGraphSelectionListener listener : fSelectionListeners) { | |
836 | listener.selectionChanged(event); | |
837 | } | |
838 | } | |
839 | ||
840 | /** | |
841 | * Add a time listener | |
842 | * | |
843 | * @param listener | |
844 | * The listener to add | |
845 | */ | |
846 | public void addTimeListener(ITimeGraphTimeListener listener) { | |
847 | fTimeListeners.add(listener); | |
848 | } | |
849 | ||
850 | /** | |
851 | * Remove a time listener | |
852 | * | |
853 | * @param listener | |
854 | * The listener to remove | |
855 | */ | |
856 | public void removeTimeListener(ITimeGraphTimeListener listener) { | |
857 | fTimeListeners.remove(listener); | |
858 | } | |
859 | ||
0fcf3b09 PT |
860 | private void notifyTimeListeners(long startTime, long endTime) { |
861 | TimeGraphTimeEvent event = new TimeGraphTimeEvent(this, startTime, endTime); | |
837a2f8c PT |
862 | |
863 | for (ITimeGraphTimeListener listener : fTimeListeners) { | |
864 | listener.timeSelected(event); | |
865 | } | |
866 | } | |
867 | ||
868 | /** | |
869 | * Add a range listener | |
870 | * | |
871 | * @param listener | |
872 | * The listener to add | |
873 | */ | |
874 | public void addRangeListener(ITimeGraphRangeListener listener) { | |
875 | fRangeListeners.add(listener); | |
876 | } | |
877 | ||
878 | /** | |
879 | * Remove a range listener | |
880 | * | |
881 | * @param listener | |
882 | * The listener to remove | |
883 | */ | |
884 | public void removeRangeListener(ITimeGraphRangeListener listener) { | |
885 | fRangeListeners.remove(listener); | |
886 | } | |
887 | ||
888 | private void notifyRangeListeners(long startTime, long endTime) { | |
889 | // Check if the time has actually changed from last notification | |
f1fae91f | 890 | if (startTime != fTime0ExtSynch || endTime != fTime1ExtSynch) { |
837a2f8c PT |
891 | // Notify Time Scale Selection Listeners |
892 | TimeGraphRangeUpdateEvent event = new TimeGraphRangeUpdateEvent(this, startTime, endTime); | |
893 | ||
894 | for (ITimeGraphRangeListener listener : fRangeListeners) { | |
895 | listener.timeRangeUpdated(event); | |
896 | } | |
897 | ||
898 | // update external synch timers | |
899 | updateExtSynchTimers(); | |
900 | } | |
901 | } | |
902 | ||
903 | /** | |
904 | * Callback to set a selected event in the view | |
905 | * | |
906 | * @param event | |
907 | * The event that was selected | |
908 | * @param source | |
909 | * The source of this selection event | |
910 | */ | |
911 | public void setSelectedEvent(ITimeEvent event, Object source) { | |
912 | if (event == null || source == this) { | |
913 | return; | |
914 | } | |
f1fae91f PT |
915 | fSelectedEntry = event.getEntry(); |
916 | fTimeGraphCtrl.selectItem(fSelectedEntry, false); | |
837a2f8c PT |
917 | |
918 | setSelectedTimeInt(event.getTime(), true, true); | |
919 | adjustVerticalScrollBar(); | |
920 | } | |
921 | ||
922 | /** | |
923 | * Set the seeked time of a trace | |
924 | * | |
925 | * @param trace | |
926 | * The trace that was seeked | |
927 | * @param time | |
928 | * The target time | |
929 | * @param source | |
930 | * The source of this seek event | |
931 | */ | |
932 | public void setSelectedTraceTime(ITimeGraphEntry trace, long time, Object source) { | |
933 | if (trace == null || source == this) { | |
934 | return; | |
935 | } | |
f1fae91f PT |
936 | fSelectedEntry = trace; |
937 | fTimeGraphCtrl.selectItem(trace, false); | |
837a2f8c PT |
938 | |
939 | setSelectedTimeInt(time, true, true); | |
940 | } | |
941 | ||
942 | /** | |
943 | * Callback for a trace selection | |
944 | * | |
945 | * @param trace | |
946 | * The trace that was selected | |
947 | */ | |
948 | public void setSelection(ITimeGraphEntry trace) { | |
f1fae91f PT |
949 | fSelectedEntry = trace; |
950 | fTimeGraphCtrl.selectItem(trace, false); | |
837a2f8c PT |
951 | adjustVerticalScrollBar(); |
952 | } | |
953 | ||
954 | /** | |
955 | * Callback for a time window selection | |
956 | * | |
957 | * @param time0 | |
958 | * Start time of the range | |
959 | * @param time1 | |
960 | * End time of the range | |
961 | * @param source | |
962 | * Source of the event | |
963 | */ | |
964 | public void setSelectVisTimeWindow(long time0, long time1, Object source) { | |
965 | if (source == this) { | |
966 | return; | |
967 | } | |
968 | ||
969 | setStartFinishTime(time0, time1); | |
970 | ||
971 | // update notification time values since we are now in synch with the | |
972 | // external application | |
973 | updateExtSynchTimers(); | |
974 | } | |
975 | ||
976 | /** | |
977 | * update the cache timers used to identify the need to send a time window | |
978 | * update to external registered listeners | |
979 | */ | |
980 | private void updateExtSynchTimers() { | |
981 | // last time notification cache | |
f1fae91f PT |
982 | fTime0ExtSynch = fTime0; |
983 | fTime1ExtSynch = fTime1; | |
837a2f8c PT |
984 | } |
985 | ||
986 | /** | |
026664b7 | 987 | * @since 2.0 |
837a2f8c | 988 | */ |
026664b7 XR |
989 | @Override |
990 | public TimeFormat getTimeFormat() { | |
f1fae91f | 991 | return fTimeFormat; |
837a2f8c PT |
992 | } |
993 | ||
026664b7 | 994 | /** |
79ec0b89 PT |
995 | * @param tf |
996 | * the {@link TimeFormat} used to display timestamps | |
026664b7 XR |
997 | * @since 2.0 |
998 | */ | |
999 | public void setTimeFormat(TimeFormat tf) { | |
f1fae91f | 1000 | this.fTimeFormat = tf; |
837a2f8c PT |
1001 | } |
1002 | ||
1003 | /** | |
1004 | * Retrieve the border width | |
1005 | * | |
1006 | * @return The width | |
1007 | */ | |
1008 | public int getBorderWidth() { | |
f1fae91f | 1009 | return fBorderWidth; |
837a2f8c PT |
1010 | } |
1011 | ||
1012 | /** | |
1013 | * Set the border width | |
1014 | * | |
1015 | * @param borderWidth | |
1016 | * The width | |
1017 | */ | |
1018 | public void setBorderWidth(int borderWidth) { | |
1019 | if (borderWidth > -1) { | |
f1fae91f | 1020 | this.fBorderWidth = borderWidth; |
79ec0b89 | 1021 | GridLayout gl = (GridLayout) fDataViewer.getLayout(); |
837a2f8c PT |
1022 | gl.marginHeight = borderWidth; |
1023 | } | |
1024 | } | |
1025 | ||
1026 | /** | |
1027 | * Retrieve the height of the header | |
1028 | * | |
1029 | * @return The height | |
1030 | */ | |
1031 | public int getHeaderHeight() { | |
f1fae91f | 1032 | return fTimeScaleHeight; |
837a2f8c PT |
1033 | } |
1034 | ||
1035 | /** | |
1036 | * Set the height of the header | |
1037 | * | |
1038 | * @param headerHeight | |
1039 | * The height to set | |
1040 | */ | |
1041 | public void setHeaderHeight(int headerHeight) { | |
1042 | if (headerHeight > -1) { | |
f1fae91f PT |
1043 | this.fTimeScaleHeight = headerHeight; |
1044 | fTimeScaleCtrl.setHeight(headerHeight); | |
837a2f8c PT |
1045 | } |
1046 | } | |
1047 | ||
1048 | /** | |
1049 | * Retrieve the height of an item row | |
1050 | * | |
1051 | * @return The height | |
1052 | */ | |
1053 | public int getItemHeight() { | |
f1fae91f PT |
1054 | if (fTimeGraphCtrl != null) { |
1055 | return fTimeGraphCtrl.getItemHeight(); | |
837a2f8c PT |
1056 | } |
1057 | return 0; | |
1058 | } | |
1059 | ||
1060 | /** | |
1061 | * Set the height of an item row | |
1062 | * | |
1063 | * @param rowHeight | |
1064 | * The height to set | |
1065 | */ | |
1066 | public void setItemHeight(int rowHeight) { | |
f1fae91f PT |
1067 | if (fTimeGraphCtrl != null) { |
1068 | fTimeGraphCtrl.setItemHeight(rowHeight); | |
837a2f8c PT |
1069 | } |
1070 | } | |
1071 | ||
1072 | /** | |
1073 | * Set the minimum item width | |
1074 | * | |
1075 | * @param width | |
1076 | * The min width | |
1077 | */ | |
1078 | public void setMinimumItemWidth(int width) { | |
f1fae91f PT |
1079 | if (fTimeGraphCtrl != null) { |
1080 | fTimeGraphCtrl.setMinimumItemWidth(width); | |
837a2f8c PT |
1081 | } |
1082 | } | |
1083 | ||
1084 | /** | |
1085 | * Set the width for the name column | |
1086 | * | |
79ec0b89 PT |
1087 | * @param width |
1088 | * The width | |
837a2f8c PT |
1089 | */ |
1090 | public void setNameWidthPref(int width) { | |
f1fae91f | 1091 | fNameWidthPref = width; |
837a2f8c | 1092 | if (width == 0) { |
f1fae91f PT |
1093 | fMinNameWidth = 0; |
1094 | fNameWidth = 0; | |
837a2f8c PT |
1095 | } |
1096 | } | |
1097 | ||
1098 | /** | |
1099 | * Retrieve the configure width for the name column | |
1100 | * | |
1101 | * @param width | |
1102 | * Unused? | |
1103 | * @return The width | |
1104 | */ | |
1105 | public int getNameWidthPref(int width) { | |
f1fae91f | 1106 | return fNameWidthPref; |
837a2f8c PT |
1107 | } |
1108 | ||
1109 | /** | |
1110 | * Returns the primary control associated with this viewer. | |
1111 | * | |
1112 | * @return the SWT control which displays this viewer's content | |
1113 | */ | |
1114 | public Control getControl() { | |
f1fae91f | 1115 | return fDataViewer; |
837a2f8c PT |
1116 | } |
1117 | ||
1118 | /** | |
1119 | * Returns the time graph control associated with this viewer. | |
1120 | * | |
1121 | * @return the time graph control | |
3e9a3685 | 1122 | * @since 2.0 |
837a2f8c | 1123 | */ |
3e9a3685 | 1124 | public TimeGraphControl getTimeGraphControl() { |
f1fae91f | 1125 | return fTimeGraphCtrl; |
837a2f8c PT |
1126 | } |
1127 | ||
1128 | /** | |
1129 | * Returns the time graph scale associated with this viewer. | |
1130 | * | |
1131 | * @return the time graph scale | |
3e9a3685 | 1132 | * @since 2.0 |
837a2f8c | 1133 | */ |
3e9a3685 | 1134 | public TimeGraphScale getTimeGraphScale() { |
f1fae91f | 1135 | return fTimeScaleCtrl; |
837a2f8c PT |
1136 | } |
1137 | ||
713a70ae PT |
1138 | /** |
1139 | * Return the x coordinate corresponding to a time | |
1140 | * | |
79ec0b89 PT |
1141 | * @param time |
1142 | * the time | |
713a70ae PT |
1143 | * @return the x coordinate corresponding to the time |
1144 | * | |
1145 | * @since 2.0 | |
1146 | */ | |
1147 | public int getXForTime(long time) { | |
f1fae91f | 1148 | return fTimeGraphCtrl.getXForTime(time); |
713a70ae PT |
1149 | } |
1150 | ||
1151 | /** | |
1152 | * Return the time corresponding to an x coordinate | |
1153 | * | |
79ec0b89 PT |
1154 | * @param x |
1155 | * the x coordinate | |
713a70ae PT |
1156 | * @return the time corresponding to the x coordinate |
1157 | * | |
1158 | * @since 2.0 | |
1159 | */ | |
1160 | public long getTimeAtX(int x) { | |
f1fae91f | 1161 | return fTimeGraphCtrl.getTimeAtX(x); |
713a70ae PT |
1162 | } |
1163 | ||
837a2f8c PT |
1164 | /** |
1165 | * Get the selection provider | |
1166 | * | |
1167 | * @return the selection provider | |
1168 | */ | |
1169 | public ISelectionProvider getSelectionProvider() { | |
f1fae91f | 1170 | return fTimeGraphCtrl; |
837a2f8c PT |
1171 | } |
1172 | ||
1173 | /** | |
1174 | * Wait for the cursor | |
1175 | * | |
1176 | * @param waitInd | |
1177 | * Wait indefinitely? | |
1178 | */ | |
1179 | public void waitCursor(boolean waitInd) { | |
f1fae91f | 1180 | fTimeGraphCtrl.waitCursor(waitInd); |
837a2f8c PT |
1181 | } |
1182 | ||
1183 | /** | |
1184 | * Get the horizontal scroll bar object | |
1185 | * | |
1186 | * @return The scroll bar | |
1187 | */ | |
1188 | public ScrollBar getHorizontalBar() { | |
f1fae91f | 1189 | return fTimeGraphCtrl.getHorizontalBar(); |
837a2f8c PT |
1190 | } |
1191 | ||
1192 | /** | |
1193 | * Get the vertical scroll bar object | |
1194 | * | |
1195 | * @return The scroll bar | |
1196 | */ | |
1197 | public Slider getVerticalBar() { | |
f1fae91f | 1198 | return fVerticalScrollBar; |
837a2f8c PT |
1199 | } |
1200 | ||
1201 | /** | |
1202 | * Set the given index as the top one | |
1203 | * | |
1204 | * @param index | |
1205 | * The index that will go to the top | |
1206 | */ | |
1207 | public void setTopIndex(int index) { | |
f1fae91f | 1208 | fTimeGraphCtrl.setTopIndex(index); |
837a2f8c PT |
1209 | adjustVerticalScrollBar(); |
1210 | } | |
1211 | ||
1212 | /** | |
1213 | * Retrieve the current top index | |
1214 | * | |
1215 | * @return The top index | |
1216 | */ | |
1217 | public int getTopIndex() { | |
f1fae91f | 1218 | return fTimeGraphCtrl.getTopIndex(); |
837a2f8c PT |
1219 | } |
1220 | ||
1221 | /** | |
1222 | * Set the expanded state of an entry | |
1223 | * | |
1224 | * @param entry | |
1225 | * The entry to expand/collapse | |
1226 | * @param expanded | |
1227 | * True for expanded, false for collapsed | |
1228 | */ | |
1229 | public void setExpandedState(ITimeGraphEntry entry, boolean expanded) { | |
f1fae91f | 1230 | fTimeGraphCtrl.setExpandedState(entry, expanded); |
837a2f8c PT |
1231 | adjustVerticalScrollBar(); |
1232 | } | |
1233 | ||
1234 | /** | |
1235 | * Collapses all nodes of the viewer's tree, starting with the root. | |
1236 | * | |
1237 | * @since 2.0 | |
1238 | */ | |
1239 | public void collapseAll() { | |
f1fae91f | 1240 | fTimeGraphCtrl.collapseAll(); |
837a2f8c PT |
1241 | adjustVerticalScrollBar(); |
1242 | } | |
1243 | ||
1244 | /** | |
1245 | * Expands all nodes of the viewer's tree, starting with the root. | |
1246 | * | |
1247 | * @since 2.0 | |
1248 | */ | |
1249 | public void expandAll() { | |
f1fae91f | 1250 | fTimeGraphCtrl.expandAll(); |
837a2f8c PT |
1251 | adjustVerticalScrollBar(); |
1252 | } | |
1253 | ||
1254 | /** | |
1255 | * Get the number of sub-elements when expanded | |
1256 | * | |
1257 | * @return The element count | |
1258 | */ | |
1259 | public int getExpandedElementCount() { | |
f1fae91f | 1260 | return fTimeGraphCtrl.getExpandedElementCount(); |
837a2f8c PT |
1261 | } |
1262 | ||
1263 | /** | |
1264 | * Get the sub-elements | |
1265 | * | |
1266 | * @return The array of entries that are below this one | |
1267 | */ | |
1268 | public ITimeGraphEntry[] getExpandedElements() { | |
f1fae91f | 1269 | return fTimeGraphCtrl.getExpandedElements(); |
837a2f8c PT |
1270 | } |
1271 | ||
1272 | /** | |
1273 | * Add a tree listener | |
1274 | * | |
1275 | * @param listener | |
1276 | * The listener to add | |
1277 | */ | |
1278 | public void addTreeListener(ITimeGraphTreeListener listener) { | |
f1fae91f | 1279 | fTimeGraphCtrl.addTreeListener(listener); |
837a2f8c PT |
1280 | } |
1281 | ||
1282 | /** | |
1283 | * Remove a tree listener | |
1284 | * | |
1285 | * @param listener | |
1286 | * The listener to remove | |
1287 | */ | |
1288 | public void removeTreeListener(ITimeGraphTreeListener listener) { | |
f1fae91f | 1289 | fTimeGraphCtrl.removeTreeListener(listener); |
837a2f8c PT |
1290 | } |
1291 | ||
1292 | /** | |
1293 | * Get the reset scale action. | |
1294 | * | |
1295 | * @return The Action object | |
1296 | */ | |
1297 | public Action getResetScaleAction() { | |
f1fae91f | 1298 | if (fResetScaleAction == null) { |
837a2f8c | 1299 | // resetScale |
f1fae91f | 1300 | fResetScaleAction = new Action() { |
837a2f8c PT |
1301 | @Override |
1302 | public void run() { | |
1303 | resetStartFinishTime(); | |
894d6929 | 1304 | notifyStartFinishTime(); |
837a2f8c PT |
1305 | } |
1306 | }; | |
f1fae91f PT |
1307 | fResetScaleAction.setText(Messages.TmfTimeGraphViewer_ResetScaleActionNameText); |
1308 | fResetScaleAction.setToolTipText(Messages.TmfTimeGraphViewer_ResetScaleActionToolTipText); | |
1309 | fResetScaleAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_HOME_MENU)); | |
837a2f8c | 1310 | } |
f1fae91f | 1311 | return fResetScaleAction; |
837a2f8c PT |
1312 | } |
1313 | ||
1314 | /** | |
1315 | * Get the show legend action. | |
1316 | * | |
1317 | * @return The Action object | |
1318 | */ | |
1319 | public Action getShowLegendAction() { | |
f1fae91f | 1320 | if (fShowLegendAction == null) { |
837a2f8c | 1321 | // showLegend |
f1fae91f | 1322 | fShowLegendAction = new Action() { |
837a2f8c PT |
1323 | @Override |
1324 | public void run() { | |
1325 | showLegend(); | |
1326 | } | |
1327 | }; | |
f1fae91f PT |
1328 | fShowLegendAction.setText(Messages.TmfTimeGraphViewer_LegendActionNameText); |
1329 | fShowLegendAction.setToolTipText(Messages.TmfTimeGraphViewer_LegendActionToolTipText); | |
1330 | fShowLegendAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_SHOW_LEGEND)); | |
837a2f8c PT |
1331 | } |
1332 | ||
f1fae91f | 1333 | return fShowLegendAction; |
837a2f8c PT |
1334 | } |
1335 | ||
1336 | /** | |
1337 | * Get the the next event action. | |
1338 | * | |
1339 | * @return The action object | |
1340 | */ | |
1341 | public Action getNextEventAction() { | |
f1fae91f PT |
1342 | if (fNextEventAction == null) { |
1343 | fNextEventAction = new Action() { | |
837a2f8c PT |
1344 | @Override |
1345 | public void run() { | |
1346 | selectNextEvent(); | |
1347 | } | |
1348 | }; | |
1349 | ||
f1fae91f PT |
1350 | fNextEventAction.setText(Messages.TmfTimeGraphViewer_NextEventActionNameText); |
1351 | fNextEventAction.setToolTipText(Messages.TmfTimeGraphViewer_NextEventActionToolTipText); | |
1352 | fNextEventAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_NEXT_EVENT)); | |
837a2f8c PT |
1353 | } |
1354 | ||
f1fae91f | 1355 | return fNextEventAction; |
837a2f8c PT |
1356 | } |
1357 | ||
1358 | /** | |
1359 | * Get the previous event action. | |
1360 | * | |
1361 | * @return The Action object | |
1362 | */ | |
1363 | public Action getPreviousEventAction() { | |
f1fae91f PT |
1364 | if (fPrevEventAction == null) { |
1365 | fPrevEventAction = new Action() { | |
837a2f8c PT |
1366 | @Override |
1367 | public void run() { | |
1368 | selectPrevEvent(); | |
1369 | } | |
1370 | }; | |
1371 | ||
f1fae91f PT |
1372 | fPrevEventAction.setText(Messages.TmfTimeGraphViewer_PreviousEventActionNameText); |
1373 | fPrevEventAction.setToolTipText(Messages.TmfTimeGraphViewer_PreviousEventActionToolTipText); | |
1374 | fPrevEventAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_PREV_EVENT)); | |
837a2f8c PT |
1375 | } |
1376 | ||
f1fae91f | 1377 | return fPrevEventAction; |
837a2f8c PT |
1378 | } |
1379 | ||
1380 | /** | |
1381 | * Get the next item action. | |
1382 | * | |
1383 | * @return The Action object | |
1384 | */ | |
1385 | public Action getNextItemAction() { | |
f1fae91f | 1386 | if (fNextItemAction == null) { |
837a2f8c | 1387 | |
f1fae91f | 1388 | fNextItemAction = new Action() { |
837a2f8c PT |
1389 | @Override |
1390 | public void run() { | |
1391 | selectNextItem(); | |
1392 | } | |
1393 | }; | |
f1fae91f PT |
1394 | fNextItemAction.setText(Messages.TmfTimeGraphViewer_NextItemActionNameText); |
1395 | fNextItemAction.setToolTipText(Messages.TmfTimeGraphViewer_NextItemActionToolTipText); | |
1396 | fNextItemAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_NEXT_ITEM)); | |
837a2f8c | 1397 | } |
f1fae91f | 1398 | return fNextItemAction; |
837a2f8c PT |
1399 | } |
1400 | ||
1401 | /** | |
1402 | * Get the previous item action. | |
1403 | * | |
1404 | * @return The Action object | |
1405 | */ | |
1406 | public Action getPreviousItemAction() { | |
f1fae91f | 1407 | if (fPreviousItemAction == null) { |
837a2f8c | 1408 | |
f1fae91f | 1409 | fPreviousItemAction = new Action() { |
837a2f8c PT |
1410 | @Override |
1411 | public void run() { | |
1412 | selectPrevItem(); | |
1413 | } | |
1414 | }; | |
f1fae91f PT |
1415 | fPreviousItemAction.setText(Messages.TmfTimeGraphViewer_PreviousItemActionNameText); |
1416 | fPreviousItemAction.setToolTipText(Messages.TmfTimeGraphViewer_PreviousItemActionToolTipText); | |
1417 | fPreviousItemAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_PREV_ITEM)); | |
837a2f8c | 1418 | } |
f1fae91f | 1419 | return fPreviousItemAction; |
837a2f8c PT |
1420 | } |
1421 | ||
1422 | /** | |
1423 | * Get the zoom in action | |
1424 | * | |
1425 | * @return The Action object | |
1426 | */ | |
1427 | public Action getZoomInAction() { | |
f1fae91f PT |
1428 | if (fZoomInAction == null) { |
1429 | fZoomInAction = new Action() { | |
837a2f8c PT |
1430 | @Override |
1431 | public void run() { | |
1432 | zoomIn(); | |
1433 | } | |
1434 | }; | |
f1fae91f PT |
1435 | fZoomInAction.setText(Messages.TmfTimeGraphViewer_ZoomInActionNameText); |
1436 | fZoomInAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomInActionToolTipText); | |
1437 | fZoomInAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_IN_MENU)); | |
837a2f8c | 1438 | } |
f1fae91f | 1439 | return fZoomInAction; |
837a2f8c PT |
1440 | } |
1441 | ||
1442 | /** | |
1443 | * Get the zoom out action | |
1444 | * | |
1445 | * @return The Action object | |
1446 | */ | |
1447 | public Action getZoomOutAction() { | |
f1fae91f PT |
1448 | if (fZoomOutAction == null) { |
1449 | fZoomOutAction = new Action() { | |
837a2f8c PT |
1450 | @Override |
1451 | public void run() { | |
1452 | zoomOut(); | |
1453 | } | |
1454 | }; | |
f1fae91f PT |
1455 | fZoomOutAction.setText(Messages.TmfTimeGraphViewer_ZoomOutActionNameText); |
1456 | fZoomOutAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomOutActionToolTipText); | |
1457 | fZoomOutAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_OUT_MENU)); | |
837a2f8c | 1458 | } |
f1fae91f | 1459 | return fZoomOutAction; |
837a2f8c PT |
1460 | } |
1461 | ||
79ec0b89 PT |
1462 | /** |
1463 | * Get the hide arrows action | |
1464 | * | |
1465 | * @param dialogSettings | |
1466 | * The dialog settings section where the state should be stored, | |
1467 | * or null | |
1468 | * | |
1469 | * @return The Action object | |
1470 | * | |
1471 | * @since 2.1 | |
1472 | */ | |
1473 | public Action getHideArrowsAction(final IDialogSettings dialogSettings) { | |
1474 | if (fHideArrowsAction == null) { | |
1475 | fHideArrowsAction = new Action(Messages.TmfTimeGraphViewer_HideArrowsActionNameText, IAction.AS_CHECK_BOX) { | |
1476 | @Override | |
1477 | public void run() { | |
1478 | boolean hideArrows = fHideArrowsAction.isChecked(); | |
1479 | fTimeGraphCtrl.hideArrows(hideArrows); | |
1480 | refresh(); | |
1481 | if (dialogSettings != null) { | |
1482 | dialogSettings.put(HIDE_ARROWS_KEY, hideArrows); | |
1483 | } | |
086f21ae PT |
1484 | if (fFollowArrowFwdAction != null) { |
1485 | fFollowArrowFwdAction.setEnabled(!hideArrows); | |
1486 | } | |
1487 | if (fFollowArrowBwdAction != null) { | |
1488 | fFollowArrowBwdAction.setEnabled(!hideArrows); | |
1489 | } | |
79ec0b89 PT |
1490 | } |
1491 | }; | |
1492 | fHideArrowsAction.setToolTipText(Messages.TmfTimeGraphViewer_HideArrowsActionToolTipText); | |
1493 | fHideArrowsAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_HIDE_ARROWS)); | |
1494 | if (dialogSettings != null) { | |
1495 | boolean hideArrows = dialogSettings.getBoolean(HIDE_ARROWS_KEY); | |
1496 | fTimeGraphCtrl.hideArrows(hideArrows); | |
1497 | fHideArrowsAction.setChecked(hideArrows); | |
086f21ae PT |
1498 | if (fFollowArrowFwdAction != null) { |
1499 | fFollowArrowFwdAction.setEnabled(!hideArrows); | |
1500 | } | |
1501 | if (fFollowArrowBwdAction != null) { | |
1502 | fFollowArrowBwdAction.setEnabled(!hideArrows); | |
1503 | } | |
79ec0b89 PT |
1504 | } |
1505 | } | |
1506 | return fHideArrowsAction; | |
1507 | } | |
837a2f8c | 1508 | |
086f21ae PT |
1509 | /** |
1510 | * Get the follow arrow forward action. | |
1511 | * | |
1512 | * @return The Action object | |
1513 | * | |
1514 | * @since 2.1 | |
1515 | */ | |
1516 | public Action getFollowArrowFwdAction() { | |
1517 | if (fFollowArrowFwdAction == null) { | |
1518 | fFollowArrowFwdAction = new Action() { | |
1519 | @Override | |
1520 | public void run() { | |
1521 | fTimeGraphCtrl.followArrowFwd(); | |
1522 | adjustVerticalScrollBar(); | |
1523 | } | |
1524 | }; | |
1525 | fFollowArrowFwdAction.setText(Messages.TmfTimeGraphViewer_FollowArrowForwardActionNameText); | |
1526 | fFollowArrowFwdAction.setToolTipText(Messages.TmfTimeGraphViewer_FollowArrowForwardActionToolTipText); | |
1527 | fFollowArrowFwdAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_FOLLOW_ARROW_FORWARD)); | |
1528 | if (fHideArrowsAction != null) { | |
1529 | fFollowArrowFwdAction.setEnabled(!fHideArrowsAction.isChecked()); | |
1530 | } | |
1531 | } | |
1532 | return fFollowArrowFwdAction; | |
1533 | } | |
1534 | ||
1535 | /** | |
1536 | * Get the follow arrow backward action. | |
1537 | * | |
1538 | * @return The Action object | |
1539 | * | |
1540 | * @since 2.1 | |
1541 | */ | |
1542 | public Action getFollowArrowBwdAction() { | |
1543 | if (fFollowArrowBwdAction == null) { | |
1544 | fFollowArrowBwdAction = new Action() { | |
1545 | @Override | |
1546 | public void run() { | |
1547 | fTimeGraphCtrl.followArrowBwd(); | |
1548 | adjustVerticalScrollBar(); | |
1549 | } | |
1550 | }; | |
1551 | fFollowArrowBwdAction.setText(Messages.TmfTimeGraphViewer_FollowArrowBackwardActionNameText); | |
1552 | fFollowArrowBwdAction.setToolTipText(Messages.TmfTimeGraphViewer_FollowArrowBackwardActionToolTipText); | |
1553 | fFollowArrowBwdAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_FOLLOW_ARROW_BACKWARD)); | |
1554 | if (fHideArrowsAction != null) { | |
1555 | fFollowArrowBwdAction.setEnabled(!fHideArrowsAction.isChecked()); | |
1556 | } | |
1557 | } | |
1558 | return fFollowArrowBwdAction; | |
1559 | } | |
1560 | ||
837a2f8c | 1561 | private void adjustVerticalScrollBar() { |
f1fae91f PT |
1562 | int topIndex = fTimeGraphCtrl.getTopIndex(); |
1563 | int countPerPage = fTimeGraphCtrl.countPerPage(); | |
1564 | int expandedElementCount = fTimeGraphCtrl.getExpandedElementCount(); | |
837a2f8c | 1565 | if (topIndex + countPerPage > expandedElementCount) { |
f1fae91f | 1566 | fTimeGraphCtrl.setTopIndex(Math.max(0, expandedElementCount - countPerPage)); |
837a2f8c PT |
1567 | } |
1568 | ||
f1fae91f | 1569 | int selection = fTimeGraphCtrl.getTopIndex(); |
837a2f8c PT |
1570 | int min = 0; |
1571 | int max = Math.max(1, expandedElementCount - 1); | |
1572 | int thumb = Math.min(max, Math.max(1, countPerPage - 1)); | |
1573 | int increment = 1; | |
1574 | int pageIncrement = Math.max(1, countPerPage); | |
f1fae91f | 1575 | fVerticalScrollBar.setValues(selection, min, max, thumb, increment, pageIncrement); |
837a2f8c PT |
1576 | } |
1577 | ||
27df1564 | 1578 | /** |
79ec0b89 PT |
1579 | * @param listener |
1580 | * a {@link MenuDetectListener} | |
27df1564 | 1581 | * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#addTimeGraphEntryMenuListener(org.eclipse.swt.events.MenuDetectListener) |
77c4a6df | 1582 | * @since 1.2 |
27df1564 XR |
1583 | */ |
1584 | public void addTimeGraphEntryMenuListener(MenuDetectListener listener) { | |
f1fae91f | 1585 | fTimeGraphCtrl.addTimeGraphEntryMenuListener(listener); |
27df1564 XR |
1586 | } |
1587 | ||
1588 | /** | |
79ec0b89 PT |
1589 | * @param listener |
1590 | * a {@link MenuDetectListener} | |
27df1564 | 1591 | * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#removeTimeGraphEntryMenuListener(org.eclipse.swt.events.MenuDetectListener) |
77c4a6df | 1592 | * @since 1.2 |
27df1564 XR |
1593 | */ |
1594 | public void removeTimeGraphEntryMenuListener(MenuDetectListener listener) { | |
f1fae91f | 1595 | fTimeGraphCtrl.removeTimeGraphEntryMenuListener(listener); |
27df1564 XR |
1596 | } |
1597 | ||
1598 | /** | |
79ec0b89 PT |
1599 | * @param listener |
1600 | * a {@link MenuDetectListener} | |
27df1564 | 1601 | * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#addTimeEventMenuListener(org.eclipse.swt.events.MenuDetectListener) |
77c4a6df | 1602 | * @since 1.2 |
27df1564 XR |
1603 | */ |
1604 | public void addTimeEventMenuListener(MenuDetectListener listener) { | |
f1fae91f | 1605 | fTimeGraphCtrl.addTimeEventMenuListener(listener); |
27df1564 XR |
1606 | } |
1607 | ||
1608 | /** | |
79ec0b89 PT |
1609 | * @param listener |
1610 | * a {@link MenuDetectListener} | |
27df1564 | 1611 | * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#removeTimeEventMenuListener(org.eclipse.swt.events.MenuDetectListener) |
77c4a6df | 1612 | * @since 1.2 |
27df1564 XR |
1613 | */ |
1614 | public void removeTimeEventMenuListener(MenuDetectListener listener) { | |
f1fae91f | 1615 | fTimeGraphCtrl.removeTimeEventMenuListener(listener); |
27df1564 XR |
1616 | } |
1617 | ||
6ac5a950 | 1618 | /** |
79ec0b89 PT |
1619 | * @param filter |
1620 | * The filter object to be attached to the view | |
6ac5a950 AM |
1621 | * @since 2.0 |
1622 | */ | |
1623 | public void addFilter(ViewerFilter filter) { | |
f1fae91f | 1624 | fTimeGraphCtrl.addFilter(filter); |
6ac5a950 AM |
1625 | refresh(); |
1626 | } | |
837a2f8c | 1627 | |
6ac5a950 | 1628 | /** |
79ec0b89 PT |
1629 | * @param filter |
1630 | * The filter object to be attached to the view | |
6ac5a950 AM |
1631 | * @since 2.0 |
1632 | */ | |
1633 | public void removeFilter(ViewerFilter filter) { | |
f1fae91f | 1634 | fTimeGraphCtrl.removeFilter(filter); |
6ac5a950 AM |
1635 | refresh(); |
1636 | } | |
837a2f8c PT |
1637 | |
1638 | } |