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