tmf: Support user bookmarks in time graph
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / views / timegraph / AbstractTimeGraphView.java
... / ...
CommitLineData
1/*******************************************************************************
2 * Copyright (c) 2012, 2015 Ericsson, École Polytechnique de Montréal
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Patrick Tasse - Initial API and implementation
11 * Bernd Hufmann - Updated signal handling
12 * Geneviève Bastien - Move code to provide base classes for time graph view
13 * Marc-Andre Laperle - Add time zone preference
14 * Geneviève Bastien - Add event links between entries
15 *******************************************************************************/
16
17package org.eclipse.tracecompass.tmf.ui.views.timegraph;
18
19import java.util.ArrayList;
20import java.util.Collections;
21import java.util.Comparator;
22import java.util.HashMap;
23import java.util.List;
24import java.util.Map;
25import java.util.concurrent.CopyOnWriteArrayList;
26
27import org.eclipse.core.runtime.IProgressMonitor;
28import org.eclipse.core.runtime.NullProgressMonitor;
29import org.eclipse.jdt.annotation.NonNull;
30import org.eclipse.jdt.annotation.Nullable;
31import org.eclipse.jface.action.Action;
32import org.eclipse.jface.action.IAction;
33import org.eclipse.jface.action.IStatusLineManager;
34import org.eclipse.jface.action.IToolBarManager;
35import org.eclipse.jface.action.Separator;
36import org.eclipse.jface.viewers.AbstractTreeViewer;
37import org.eclipse.jface.viewers.ILabelProvider;
38import org.eclipse.jface.viewers.ILabelProviderListener;
39import org.eclipse.jface.viewers.ISelectionProvider;
40import org.eclipse.jface.viewers.ITableLabelProvider;
41import org.eclipse.jface.viewers.ITreeContentProvider;
42import org.eclipse.jface.viewers.TreeViewer;
43import org.eclipse.jface.viewers.ViewerFilter;
44import org.eclipse.swt.SWT;
45import org.eclipse.swt.graphics.Image;
46import org.eclipse.swt.widgets.Composite;
47import org.eclipse.swt.widgets.Display;
48import org.eclipse.swt.widgets.TreeColumn;
49import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
50import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
51import org.eclipse.tracecompass.tmf.core.signal.TmfTimestampFormatUpdateSignal;
52import org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal;
53import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
54import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal;
55import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
56import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
57import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
58import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
59import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
60import org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext;
61import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
62import org.eclipse.tracecompass.tmf.ui.TmfUiRefreshHandler;
63import org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentInfo;
64import org.eclipse.tracecompass.tmf.ui.views.ITmfTimeAligned;
65import org.eclipse.tracecompass.tmf.ui.views.TmfView;
66import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphContentProvider;
67import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider2;
68import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphRangeListener;
69import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphSelectionListener;
70import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphTimeListener;
71import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphCombo;
72import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphContentProvider;
73import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphPresentationProvider;
74import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphRangeUpdateEvent;
75import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphTimeEvent;
76import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphViewer;
77import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ILinkEvent;
78import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent;
79import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent;
80import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
81import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry;
82import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils.TimeFormat;
83import org.eclipse.ui.IActionBars;
84
85/**
86 * An abstract view all time graph views can inherit
87 *
88 * This view contains either a time graph viewer, or a time graph combo which is
89 * divided between a tree viewer on the left and a time graph viewer on the right.
90 */
91public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeAligned {
92
93 /** Constant indicating that all levels of the time graph should be expanded */
94 protected static final int ALL_LEVELS = AbstractTreeViewer.ALL_LEVELS;
95
96 /**
97 * Redraw state enum
98 */
99 private enum State {
100 IDLE, BUSY, PENDING
101 }
102
103 // ------------------------------------------------------------------------
104 // Fields
105 // ------------------------------------------------------------------------
106
107 /** The timegraph wrapper */
108 private ITimeGraphWrapper fTimeGraphWrapper;
109
110 /** The selected trace */
111 private ITmfTrace fTrace;
112
113 /** The timegraph entry list */
114 private List<TimeGraphEntry> fEntryList;
115
116 /** The trace to entry list hash map */
117 private final Map<ITmfTrace, List<TimeGraphEntry>> fEntryListMap = new HashMap<>();
118
119 /** The trace to filters hash map */
120 private final Map<ITmfTrace, ViewerFilter[]> fFiltersMap = new HashMap<>();
121
122 /** The trace to build thread hash map */
123 private final Map<ITmfTrace, BuildThread> fBuildThreadMap = new HashMap<>();
124
125 /** The start time */
126 private long fStartTime = SWT.DEFAULT;
127
128 /** The end time */
129 private long fEndTime = SWT.DEFAULT;
130
131 /** The display width */
132 private final int fDisplayWidth;
133
134 /** The zoom thread */
135 private ZoomThread fZoomThread;
136
137 /** The next resource action */
138 private Action fNextResourceAction;
139
140 /** The previous resource action */
141 private Action fPreviousResourceAction;
142
143 /** A comparator class */
144 private Comparator<ITimeGraphEntry> fEntryComparator = null;
145
146 /** The redraw state used to prevent unnecessary queuing of display runnables */
147 private State fRedrawState = State.IDLE;
148
149 /** The redraw synchronization object */
150 private final Object fSyncObj = new Object();
151
152 /** The presentation provider for this view */
153 private final TimeGraphPresentationProvider fPresentation;
154
155 /** The tree column label array, or null if combo is not used */
156 private String[] fColumns;
157
158 /** The tree label provider, or null if combo is not used */
159 private TreeLabelProvider fLabelProvider = null;
160
161 /** The time graph content provider */
162 private @NonNull ITimeGraphContentProvider fTimeGraphContentProvider = new TimeGraphContentProvider();
163
164 /** The relative weight of the sash, ignored if combo is not used */
165 private int[] fWeight = { 1, 3 };
166
167 /** The filter column label array, or null if filter is not used */
168 private String[] fFilterColumns;
169
170 /** The pack done flag */
171 private boolean fPackDone = false;
172
173 /** The filter label provider, or null if filter is not used */
174 private TreeLabelProvider fFilterLabelProvider;
175
176 private int fAutoExpandLevel = ALL_LEVELS;
177
178 // ------------------------------------------------------------------------
179 // Classes
180 // ------------------------------------------------------------------------
181
182 private interface ITimeGraphWrapper {
183
184 void setTimeGraphContentProvider(ITimeGraphContentProvider timeGraphContentProvider);
185
186 void setTimeGraphPresentationProvider(TimeGraphPresentationProvider timeGraphPresentationProvider);
187
188 TimeGraphViewer getTimeGraphViewer();
189
190 void addSelectionListener(ITimeGraphSelectionListener listener);
191
192 ISelectionProvider getSelectionProvider();
193
194 void setFocus();
195
196 boolean isDisposed();
197
198 void refresh();
199
200 void setInput(Object input);
201
202 Object getInput();
203
204 void setFilters(ViewerFilter[] filters);
205
206 ViewerFilter[] getFilters();
207
208 void redraw();
209
210 void update();
211
212 void setAutoExpandLevel(int level);
213
214 void setFilterColumns(String[] columnNames);
215
216 void setFilterContentProvider(ITreeContentProvider contentProvider);
217
218 void setFilterLabelProvider(ITableLabelProvider labelProvider);
219
220 IAction getShowFilterDialogAction();
221
222 void performAlign(int offset, int width);
223
224 TmfTimeViewAlignmentInfo getTimeViewAlignmentInfo();
225
226 int getAvailableWidth(int requestedOffset);
227 }
228
229 private class TimeGraphViewerWrapper implements ITimeGraphWrapper {
230 private TimeGraphViewer viewer;
231
232 private TimeGraphViewerWrapper(Composite parent, int style) {
233 viewer = new TimeGraphViewer(parent, style);
234 }
235
236 @Override
237 public void setTimeGraphContentProvider(ITimeGraphContentProvider timeGraphContentProvider) {
238 viewer.setTimeGraphContentProvider(timeGraphContentProvider);
239 }
240
241 @Override
242 public void setTimeGraphPresentationProvider(TimeGraphPresentationProvider timeGraphPresentationProvider) {
243 viewer.setTimeGraphProvider(timeGraphPresentationProvider);
244 }
245
246 @Override
247 public TimeGraphViewer getTimeGraphViewer() {
248 return viewer;
249 }
250
251 @Override
252 public void addSelectionListener(ITimeGraphSelectionListener listener) {
253 viewer.addSelectionListener(listener);
254 }
255
256 @Override
257 public ISelectionProvider getSelectionProvider() {
258 return viewer.getSelectionProvider();
259 }
260
261 @Override
262 public void setFocus() {
263 viewer.setFocus();
264 }
265
266 @Override
267 public boolean isDisposed() {
268 return viewer.getControl().isDisposed();
269 }
270
271 @Override
272 public void setInput(Object input) {
273 viewer.setInput(input);
274 }
275
276 @Override
277 public Object getInput() {
278 return viewer.getInput();
279 }
280
281 @Override
282 public void setFilterColumns(String[] columnNames) {
283 viewer.setFilterColumns(columnNames);
284 }
285
286 @Override
287 public void setFilterContentProvider(ITreeContentProvider contentProvider) {
288 viewer.setFilterContentProvider(contentProvider);
289 }
290
291 @Override
292 public void setFilterLabelProvider(ITableLabelProvider labelProvider) {
293 viewer.setFilterLabelProvider(labelProvider);
294 }
295
296 @Override
297 public void setFilters(ViewerFilter[] filters) {
298 viewer.setFilters(filters);
299 }
300
301 @Override
302 public ViewerFilter[] getFilters() {
303 return viewer.getFilters();
304 }
305
306 @Override
307 public IAction getShowFilterDialogAction() {
308 return viewer.getShowFilterDialogAction();
309 }
310
311 @Override
312 public void refresh() {
313 viewer.refresh();
314 }
315
316 @Override
317 public void redraw() {
318 viewer.getControl().redraw();
319 }
320
321 @Override
322 public void update() {
323 viewer.getControl().update();
324 }
325
326 @Override
327 public void setAutoExpandLevel(int level) {
328 viewer.setAutoExpandLevel(level);
329 }
330
331 @Override
332 public void performAlign(int offset, int width) {
333 viewer.performAlign(offset, width);
334 }
335
336 @Override
337 public TmfTimeViewAlignmentInfo getTimeViewAlignmentInfo() {
338 return viewer.getTimeViewAlignmentInfo();
339 }
340
341 @Override
342 public int getAvailableWidth(int requestedOffset) {
343 return viewer.getAvailableWidth(requestedOffset);
344 }
345 }
346
347 private class TimeGraphComboWrapper implements ITimeGraphWrapper {
348 private TimeGraphCombo combo;
349
350 private TimeGraphComboWrapper(Composite parent, int style) {
351 combo = new TimeGraphCombo(parent, style, fWeight);
352 }
353
354 @Override
355 public void setTimeGraphContentProvider(ITimeGraphContentProvider timeGraphContentProvider) {
356 combo.setTimeGraphContentProvider(timeGraphContentProvider);
357 }
358
359 @Override
360 public void setTimeGraphPresentationProvider(TimeGraphPresentationProvider timeGraphPresentationProvider) {
361 combo.setTimeGraphProvider(timeGraphPresentationProvider);
362 }
363
364 @Override
365 public TimeGraphViewer getTimeGraphViewer() {
366 return combo.getTimeGraphViewer();
367 }
368
369 @Override
370 public void addSelectionListener(ITimeGraphSelectionListener listener) {
371 combo.addSelectionListener(listener);
372 }
373
374 @Override
375 public ISelectionProvider getSelectionProvider() {
376 return combo.getTreeViewer();
377 }
378
379 @Override
380 public void setFocus() {
381 combo.setFocus();
382 }
383
384 @Override
385 public boolean isDisposed() {
386 return combo.isDisposed();
387 }
388
389 @Override
390 public void setInput(Object input) {
391 combo.setInput(input);
392 }
393
394 @Override
395 public Object getInput() {
396 return combo.getInput();
397 }
398
399 @Override
400 public void setFilterColumns(String[] columnNames) {
401 combo.setFilterColumns(columnNames);
402 }
403
404 @Override
405 public void setFilterContentProvider(ITreeContentProvider contentProvider) {
406 combo.setFilterContentProvider(contentProvider);
407 }
408
409 @Override
410 public void setFilterLabelProvider(ITableLabelProvider labelProvider) {
411 combo.setFilterLabelProvider(labelProvider);
412 }
413
414 @Override
415 public void setFilters(ViewerFilter[] filters) {
416 combo.setFilters(filters);
417 }
418
419 @Override
420 public ViewerFilter[] getFilters() {
421 return combo.getFilters();
422 }
423
424 @Override
425 public IAction getShowFilterDialogAction() {
426 return combo.getShowFilterDialogAction();
427 }
428
429 @Override
430 public void refresh() {
431 combo.refresh();
432 }
433
434 @Override
435 public void redraw() {
436 combo.redraw();
437 }
438
439 @Override
440 public void update() {
441 combo.update();
442 }
443
444 @Override
445 public void setAutoExpandLevel(int level) {
446 combo.setAutoExpandLevel(level);
447 }
448
449 TimeGraphCombo getTimeGraphCombo() {
450 return combo;
451 }
452
453 TreeViewer getTreeViewer() {
454 return combo.getTreeViewer();
455 }
456
457 @Override
458 public void performAlign(int offset, int width) {
459 combo.performAlign(offset, width);
460 }
461
462 @Override
463 public TmfTimeViewAlignmentInfo getTimeViewAlignmentInfo() {
464 return combo.getTimeViewAlignmentInfo();
465 }
466
467 @Override
468 public int getAvailableWidth(int requestedOffset) {
469 return combo.getAvailableWidth(requestedOffset);
470 }
471 }
472
473 /**
474 * Base class to provide the labels for the tree viewer. Views extending
475 * this class typically need to override the getColumnText method if they
476 * have more than one column to display
477 */
478 protected static class TreeLabelProvider implements ITableLabelProvider, ILabelProvider {
479
480 @Override
481 public void addListener(ILabelProviderListener listener) {
482 }
483
484 @Override
485 public void dispose() {
486 }
487
488 @Override
489 public boolean isLabelProperty(Object element, String property) {
490 return false;
491 }
492
493 @Override
494 public void removeListener(ILabelProviderListener listener) {
495 }
496
497 @Override
498 public Image getColumnImage(Object element, int columnIndex) {
499 return null;
500 }
501
502 @Override
503 public String getColumnText(Object element, int columnIndex) {
504 TimeGraphEntry entry = (TimeGraphEntry) element;
505 if (columnIndex == 0) {
506 return entry.getName();
507 }
508 return new String();
509 }
510
511 @Override
512 public Image getImage(Object element) {
513 return null;
514 }
515
516 @Override
517 public String getText(Object element) {
518 TimeGraphEntry entry = (TimeGraphEntry) element;
519 return entry.getName();
520 }
521
522 }
523
524 private class BuildThread extends Thread {
525 private final @NonNull ITmfTrace fBuildTrace;
526 private final @NonNull ITmfTrace fParentTrace;
527 private final @NonNull IProgressMonitor fMonitor;
528
529 public BuildThread(final @NonNull ITmfTrace trace, final @NonNull ITmfTrace parentTrace, final String name) {
530 super(name + " build"); //$NON-NLS-1$
531 fBuildTrace = trace;
532 fParentTrace = parentTrace;
533 fMonitor = new NullProgressMonitor();
534 }
535
536 @Override
537 public void run() {
538 buildEventList(fBuildTrace, fParentTrace, fMonitor);
539 synchronized (fBuildThreadMap) {
540 fBuildThreadMap.remove(fBuildTrace);
541 }
542 }
543
544 public void cancel() {
545 fMonitor.setCanceled(true);
546 }
547 }
548
549 /**
550 * Zoom thread
551 * @since 2.0
552 */
553 protected abstract class ZoomThread extends Thread {
554 private final long fZoomStartTime;
555 private final long fZoomEndTime;
556 private final long fResolution;
557 private final @NonNull IProgressMonitor fMonitor;
558
559 /**
560 * Constructor
561 *
562 * @param startTime
563 * the start time
564 * @param endTime
565 * the end time
566 * @param resolution
567 * the resolution
568 */
569 public ZoomThread(long startTime, long endTime, long resolution) {
570 super(AbstractTimeGraphView.this.getName() + " zoom"); //$NON-NLS-1$
571 fZoomStartTime = startTime;
572 fZoomEndTime = endTime;
573 fResolution = resolution;
574 fMonitor = new NullProgressMonitor();
575 }
576
577 /**
578 * @return the zoom start time
579 */
580 public long getZoomStartTime() {
581 return fZoomStartTime;
582 }
583
584 /**
585 * @return the zoom end time
586 */
587 public long getZoomEndTime() {
588 return fZoomEndTime;
589 }
590
591 /**
592 * @return the resolution
593 */
594 public long getResolution() {
595 return fResolution;
596 }
597
598 /**
599 * @return the monitor
600 */
601 public @NonNull IProgressMonitor getMonitor() {
602 return fMonitor;
603 }
604
605 /**
606 * Cancel the zoom thread
607 */
608 public void cancel() {
609 fMonitor.setCanceled(true);
610 }
611 }
612
613 private class ZoomThreadByEntry extends ZoomThread {
614 private final @NonNull List<TimeGraphEntry> fZoomEntryList;
615
616 public ZoomThreadByEntry(@NonNull List<TimeGraphEntry> entryList, long startTime, long endTime, long resolution) {
617 super(startTime, endTime, resolution);
618 fZoomEntryList = entryList;
619 }
620
621 @Override
622 public void run() {
623 for (TimeGraphEntry entry : fZoomEntryList) {
624 if (getMonitor().isCanceled()) {
625 return;
626 }
627 if (entry == null) {
628 break;
629 }
630 zoom(entry, getMonitor());
631 }
632 /* Refresh the arrows when zooming */
633 List<ILinkEvent> events = getLinkList(getZoomStartTime(), getZoomEndTime(), getResolution(), getMonitor());
634 if (events != null) {
635 fTimeGraphWrapper.getTimeGraphViewer().setLinks(events);
636 redraw();
637 }
638 /* Refresh the markers when zooming */
639 List<IMarkerEvent> markers = getMarkerList(getZoomStartTime(), getZoomEndTime(), getResolution(), getMonitor());
640 if (markers != null) {
641 fTimeGraphWrapper.getTimeGraphViewer().getTimeGraphControl().setMarkers(markers);
642 redraw();
643 }
644 }
645
646 private void zoom(@NonNull TimeGraphEntry entry, @NonNull IProgressMonitor monitor) {
647 if (getZoomStartTime() <= fStartTime && getZoomEndTime() >= fEndTime) {
648 entry.setZoomedEventList(null);
649 } else {
650 List<ITimeEvent> zoomedEventList = getEventList(entry, getZoomStartTime(), getZoomEndTime(), getResolution(), monitor);
651 if (zoomedEventList != null) {
652 entry.setZoomedEventList(zoomedEventList);
653 }
654 }
655 redraw();
656 for (ITimeGraphEntry child : entry.getChildren()) {
657 if (monitor.isCanceled()) {
658 return;
659 }
660 if (child instanceof TimeGraphEntry) {
661 zoom((TimeGraphEntry) child, monitor);
662 }
663 }
664 }
665
666 }
667
668 // ------------------------------------------------------------------------
669 // Constructors
670 // ------------------------------------------------------------------------
671
672 /**
673 * Constructs a time graph view that contains either a time graph viewer or
674 * a time graph combo.
675 *
676 * By default, the view uses a time graph viewer. To use a time graph combo,
677 * the subclass constructor must call {@link #setTreeColumns(String[])} and
678 * {@link #setTreeLabelProvider(TreeLabelProvider)}.
679 *
680 * @param id
681 * The id of the view
682 * @param pres
683 * The presentation provider
684 */
685 public AbstractTimeGraphView(String id, TimeGraphPresentationProvider pres) {
686 super(id);
687 fPresentation = pres;
688 fDisplayWidth = Display.getDefault().getBounds().width;
689 }
690
691 // ------------------------------------------------------------------------
692 // Getters and setters
693 // ------------------------------------------------------------------------
694
695 /**
696 * Getter for the time graph combo
697 *
698 * @return The time graph combo, or null if combo is not used
699 */
700 protected TimeGraphCombo getTimeGraphCombo() {
701 if (fTimeGraphWrapper instanceof TimeGraphComboWrapper) {
702 return ((TimeGraphComboWrapper) fTimeGraphWrapper).getTimeGraphCombo();
703 }
704 return null;
705 }
706
707 /**
708 * Getter for the time graph viewer
709 *
710 * @return The time graph viewer
711 */
712 protected TimeGraphViewer getTimeGraphViewer() {
713 return fTimeGraphWrapper.getTimeGraphViewer();
714 }
715
716 /**
717 * Getter for the presentation provider
718 *
719 * @return The time graph presentation provider
720 */
721 protected ITimeGraphPresentationProvider2 getPresentationProvider() {
722 return fPresentation;
723 }
724
725 /**
726 * Sets the tree column labels.
727 * This should be called from the constructor.
728 *
729 * @param columns
730 * The array of tree column labels
731 */
732 protected void setTreeColumns(final String[] columns) {
733 fColumns = columns;
734 }
735
736 /**
737 * Sets the tree label provider.
738 * This should be called from the constructor.
739 *
740 * @param tlp
741 * The tree label provider
742 */
743 protected void setTreeLabelProvider(final TreeLabelProvider tlp) {
744 fLabelProvider = tlp;
745 }
746
747 /**
748 * Sets the time graph content provider. This should be called from the
749 * constructor.
750 *
751 * @param tgcp
752 * The time graph content provider
753 * @since 1.0
754 */
755 protected void setTimeGraphContentProvider(final @NonNull ITimeGraphContentProvider tgcp) {
756 fTimeGraphContentProvider = tgcp;
757 }
758
759 /**
760 * Sets the relative weight of each part of the time graph combo.
761 * This should be called from the constructor.
762 *
763 * @param weights
764 * The array (length 2) of relative weights of each part of the combo
765 */
766 protected void setWeight(final int[] weights) {
767 fWeight = weights;
768 }
769
770 /**
771 * Sets the filter column labels.
772 * This should be called from the constructor.
773 *
774 * @param filterColumns
775 * The array of filter column labels
776 */
777 protected void setFilterColumns(final String[] filterColumns) {
778 fFilterColumns = filterColumns;
779 }
780
781 /**
782 * Sets the filter label provider.
783 * This should be called from the constructor.
784 *
785 * @param labelProvider
786 * The filter label provider
787 */
788 protected void setFilterLabelProvider(final TreeLabelProvider labelProvider) {
789 fFilterLabelProvider = labelProvider;
790 }
791
792 /**
793 * Gets the display width
794 *
795 * @return the display width
796 */
797 protected int getDisplayWidth() {
798 return fDisplayWidth;
799 }
800
801 /**
802 * Gets the comparator for the entries
803 *
804 * @return The entry comparator
805 */
806 protected Comparator<ITimeGraphEntry> getEntryComparator() {
807 return fEntryComparator;
808 }
809
810 /**
811 * Sets the comparator class for the entries
812 *
813 * @param comparator
814 * A comparator object
815 */
816 protected void setEntryComparator(final Comparator<ITimeGraphEntry> comparator) {
817 fEntryComparator = comparator;
818 }
819
820 /**
821 * Gets the trace displayed in the view
822 *
823 * @return The trace
824 */
825 protected ITmfTrace getTrace() {
826 return fTrace;
827 }
828
829 /**
830 * Gets the start time
831 *
832 * @return The start time
833 */
834 protected long getStartTime() {
835 return fStartTime;
836 }
837
838 /**
839 * Sets the start time
840 *
841 * @param time
842 * The start time
843 */
844 protected void setStartTime(long time) {
845 fStartTime = time;
846 }
847
848 /**
849 * Gets the end time
850 *
851 * @return The end time
852 */
853 protected long getEndTime() {
854 return fEndTime;
855 }
856
857 /**
858 * Sets the end time
859 *
860 * @param time
861 * The end time
862 */
863 protected void setEndTime(long time) {
864 fEndTime = time;
865 }
866
867 /**
868 * Sets the auto-expand level to be used for the input of the view. The
869 * value 0 means that there is no auto-expand; 1 means that top-level
870 * elements are expanded, but not their children; 2 means that top-level
871 * elements are expanded, and their children, but not grand-children; and so
872 * on.
873 * <p>
874 * The value {@link #ALL_LEVELS} means that all subtrees should be expanded.
875 * </p>
876 *
877 * @param level
878 * non-negative level, or <code>ALL_LEVELS</code> to expand all
879 * levels of the tree
880 */
881 protected void setAutoExpandLevel(int level) {
882 fAutoExpandLevel = level;
883 ITimeGraphWrapper tgWrapper = fTimeGraphWrapper;
884 if (tgWrapper != null) {
885 tgWrapper.setAutoExpandLevel(level);
886 }
887 }
888
889 /**
890 * Gets the entry list for a trace
891 *
892 * @param trace
893 * the trace
894 *
895 * @return the entry list map
896 */
897 protected List<TimeGraphEntry> getEntryList(ITmfTrace trace) {
898 synchronized (fEntryListMap) {
899 return fEntryListMap.get(trace);
900 }
901 }
902
903 /**
904 * Adds a trace entry list to the entry list map
905 *
906 * @param trace
907 * the trace to add
908 * @param list
909 * the list of time graph entries
910 */
911 protected void putEntryList(ITmfTrace trace, List<TimeGraphEntry> list) {
912 synchronized (fEntryListMap) {
913 fEntryListMap.put(trace, new CopyOnWriteArrayList<>(list));
914 }
915 }
916
917 /**
918 * Adds a list of entries to a trace's entry list
919 *
920 * @param trace
921 * the trace
922 * @param list
923 * the list of time graph entries to add
924 */
925 protected void addToEntryList(ITmfTrace trace, List<TimeGraphEntry> list) {
926 synchronized (fEntryListMap) {
927 List<TimeGraphEntry> entryList = fEntryListMap.get(trace);
928 if (entryList == null) {
929 fEntryListMap.put(trace, new CopyOnWriteArrayList<>(list));
930 } else {
931 entryList.addAll(list);
932 }
933 }
934 }
935
936 /**
937 * Removes a list of entries from a trace's entry list
938 *
939 * @param trace
940 * the trace
941 * @param list
942 * the list of time graph entries to remove
943 */
944 protected void removeFromEntryList(ITmfTrace trace, List<TimeGraphEntry> list) {
945 synchronized (fEntryListMap) {
946 List<TimeGraphEntry> entryList = fEntryListMap.get(trace);
947 if (entryList != null) {
948 entryList.removeAll(list);
949 }
950 }
951 }
952
953 /**
954 * Text for the "next" button
955 *
956 * @return The "next" button text
957 */
958 protected String getNextText() {
959 return Messages.AbstractTimeGraphtView_NextText;
960 }
961
962 /**
963 * Tooltip for the "next" button
964 *
965 * @return Tooltip for the "next" button
966 */
967 protected String getNextTooltip() {
968 return Messages.AbstractTimeGraphView_NextTooltip;
969 }
970
971 /**
972 * Text for the "Previous" button
973 *
974 * @return The "Previous" button text
975 */
976 protected String getPrevText() {
977 return Messages.AbstractTimeGraphView_PreviousText;
978 }
979
980 /**
981 * Tooltip for the "previous" button
982 *
983 * @return Tooltip for the "previous" button
984 */
985 protected String getPrevTooltip() {
986 return Messages.AbstractTimeGraphView_PreviousTooltip;
987 }
988
989 // ------------------------------------------------------------------------
990 // ViewPart
991 // ------------------------------------------------------------------------
992
993 @Override
994 public void createPartControl(Composite parent) {
995 super.createPartControl(parent);
996 if (fColumns == null || fLabelProvider == null) {
997 fTimeGraphWrapper = new TimeGraphViewerWrapper(parent, SWT.NONE);
998 } else {
999 TimeGraphComboWrapper wrapper = new TimeGraphComboWrapper(parent, SWT.NONE);
1000 fTimeGraphWrapper = wrapper;
1001 TimeGraphCombo combo = wrapper.getTimeGraphCombo();
1002 combo.setTreeContentProvider(fTimeGraphContentProvider);
1003 combo.setTreeLabelProvider(fLabelProvider);
1004 combo.setTreeColumns(fColumns);
1005 }
1006 fTimeGraphWrapper.setTimeGraphContentProvider(fTimeGraphContentProvider);
1007 fTimeGraphWrapper.setFilterContentProvider(fTimeGraphContentProvider);
1008 fTimeGraphWrapper.setFilterLabelProvider(fFilterLabelProvider);
1009 fTimeGraphWrapper.setFilterColumns(fFilterColumns);
1010
1011 fTimeGraphWrapper.setTimeGraphPresentationProvider(fPresentation);
1012 fTimeGraphWrapper.setAutoExpandLevel(fAutoExpandLevel);
1013
1014 fTimeGraphWrapper.getTimeGraphViewer().addRangeListener(new ITimeGraphRangeListener() {
1015 @Override
1016 public void timeRangeUpdated(TimeGraphRangeUpdateEvent event) {
1017 final long startTime = event.getStartTime();
1018 final long endTime = event.getEndTime();
1019 TmfTimeRange range = new TmfTimeRange(new TmfNanoTimestamp(startTime), new TmfNanoTimestamp(endTime));
1020 broadcast(new TmfWindowRangeUpdatedSignal(AbstractTimeGraphView.this, range));
1021 startZoomThread(startTime, endTime);
1022 }
1023 });
1024
1025 fTimeGraphWrapper.getTimeGraphViewer().addTimeListener(new ITimeGraphTimeListener() {
1026 @Override
1027 public void timeSelected(TimeGraphTimeEvent event) {
1028 TmfNanoTimestamp startTime = new TmfNanoTimestamp(event.getBeginTime());
1029 TmfNanoTimestamp endTime = new TmfNanoTimestamp(event.getEndTime());
1030 broadcast(new TmfSelectionRangeUpdatedSignal(AbstractTimeGraphView.this, startTime, endTime));
1031 }
1032 });
1033
1034 fTimeGraphWrapper.getTimeGraphViewer().setTimeFormat(TimeFormat.CALENDAR);
1035
1036 IStatusLineManager statusLineManager = getViewSite().getActionBars().getStatusLineManager();
1037 fTimeGraphWrapper.getTimeGraphViewer().getTimeGraphControl().setStatusLineManager(statusLineManager);
1038
1039 // View Action Handling
1040 makeActions();
1041 contributeToActionBars();
1042
1043 ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace();
1044 if (trace != null) {
1045 traceSelected(new TmfTraceSelectedSignal(this, trace));
1046 }
1047
1048 // make selection available to other views
1049 getSite().setSelectionProvider(fTimeGraphWrapper.getSelectionProvider());
1050 }
1051
1052 @Override
1053 public void setFocus() {
1054 fTimeGraphWrapper.setFocus();
1055 }
1056
1057 // ------------------------------------------------------------------------
1058 // Signal handlers
1059 // ------------------------------------------------------------------------
1060
1061 /**
1062 * Handler for the trace opened signal.
1063 *
1064 * @param signal
1065 * The incoming signal
1066 */
1067 @TmfSignalHandler
1068 public void traceOpened(TmfTraceOpenedSignal signal) {
1069 loadTrace(signal.getTrace());
1070 }
1071
1072 /**
1073 * Handler for the trace selected signal
1074 *
1075 * @param signal
1076 * The incoming signal
1077 */
1078 @TmfSignalHandler
1079 public void traceSelected(final TmfTraceSelectedSignal signal) {
1080 if (signal.getTrace() == fTrace) {
1081 return;
1082 }
1083 loadTrace(signal.getTrace());
1084 }
1085
1086 /**
1087 * Trace is closed: clear the data structures and the view
1088 *
1089 * @param signal
1090 * the signal received
1091 */
1092 @TmfSignalHandler
1093 public void traceClosed(final TmfTraceClosedSignal signal) {
1094 synchronized (fBuildThreadMap) {
1095 for (ITmfTrace trace : getTracesToBuild(signal.getTrace())) {
1096 BuildThread buildThread = fBuildThreadMap.remove(trace);
1097 if (buildThread != null) {
1098 buildThread.cancel();
1099 }
1100 }
1101 }
1102 synchronized (fEntryListMap) {
1103 fEntryListMap.remove(signal.getTrace());
1104 }
1105 fFiltersMap.remove(signal.getTrace());
1106 if (signal.getTrace() == fTrace) {
1107 fTrace = null;
1108 fStartTime = SWT.DEFAULT;
1109 fEndTime = SWT.DEFAULT;
1110 if (fZoomThread != null) {
1111 fZoomThread.cancel();
1112 fZoomThread = null;
1113 }
1114 refresh();
1115 }
1116 }
1117
1118 /**
1119 * Handler for the selection range signal.
1120 *
1121 * @param signal
1122 * The signal that's received
1123 * @since 1.0
1124 */
1125 @TmfSignalHandler
1126 public void selectionRangeUpdated(final TmfSelectionRangeUpdatedSignal signal) {
1127 if (signal.getSource() == this || fTrace == null) {
1128 return;
1129 }
1130 final long beginTime = signal.getBeginTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
1131 final long endTime = signal.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
1132
1133 Display.getDefault().asyncExec(new Runnable() {
1134 @Override
1135 public void run() {
1136 if (fTimeGraphWrapper.isDisposed()) {
1137 return;
1138 }
1139 if (beginTime == endTime) {
1140 fTimeGraphWrapper.getTimeGraphViewer().setSelectedTime(beginTime, true);
1141 } else {
1142 fTimeGraphWrapper.getTimeGraphViewer().setSelectionRange(beginTime, endTime);
1143 }
1144 synchingToTime(fTimeGraphWrapper.getTimeGraphViewer().getTime0());
1145 }
1146 });
1147 }
1148
1149 /**
1150 * Handler for the window range signal.
1151 *
1152 * @param signal
1153 * The signal that's received
1154 * @since 1.0
1155 */
1156 @TmfSignalHandler
1157 public void windowRangeUpdated(final TmfWindowRangeUpdatedSignal signal) {
1158 if (signal.getSource() == this || fTrace == null) {
1159 return;
1160 }
1161 if (signal.getCurrentRange().getIntersection(fTrace.getTimeRange()) == null) {
1162 return;
1163 }
1164 final long startTime = signal.getCurrentRange().getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
1165 final long endTime = signal.getCurrentRange().getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
1166 Display.getDefault().asyncExec(new Runnable() {
1167 @Override
1168 public void run() {
1169 if (fTimeGraphWrapper.isDisposed()) {
1170 return;
1171 }
1172 fTimeGraphWrapper.getTimeGraphViewer().setStartFinishTime(startTime, endTime);
1173 startZoomThread(startTime, endTime);
1174 }
1175 });
1176 }
1177
1178 /**
1179 * @param signal the format of the timestamps was updated.
1180 */
1181 @TmfSignalHandler
1182 public void updateTimeFormat( final TmfTimestampFormatUpdateSignal signal){
1183 fTimeGraphWrapper.refresh();
1184 }
1185
1186 // ------------------------------------------------------------------------
1187 // Internal
1188 // ------------------------------------------------------------------------
1189
1190 private void loadTrace(final ITmfTrace trace) {
1191 if (fZoomThread != null) {
1192 fZoomThread.cancel();
1193 fZoomThread = null;
1194 }
1195 if (fTrace != null) {
1196 /* save the filters of the previous trace */
1197 fFiltersMap.put(fTrace, fTimeGraphWrapper.getFilters());
1198 }
1199 fTrace = trace;
1200 synchronized (fEntryListMap) {
1201 fEntryList = fEntryListMap.get(fTrace);
1202 if (fEntryList == null) {
1203 rebuild();
1204 } else {
1205 fStartTime = fTrace.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
1206 fEndTime = fTrace.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
1207 refresh();
1208 }
1209 }
1210 }
1211
1212 /**
1213 * Forces a rebuild of the entries list, even if entries already exist for this trace
1214 */
1215 protected void rebuild() {
1216 setStartTime(Long.MAX_VALUE);
1217 setEndTime(Long.MIN_VALUE);
1218 refresh();
1219 ITmfTrace viewTrace = fTrace;
1220 if (viewTrace == null) {
1221 return;
1222 }
1223 synchronized (fBuildThreadMap) {
1224 for (ITmfTrace trace : getTracesToBuild(viewTrace)) {
1225 if (trace == null) {
1226 break;
1227 }
1228 BuildThread buildThread = new BuildThread(trace, viewTrace, getName());
1229 fBuildThreadMap.put(trace, buildThread);
1230 buildThread.start();
1231 }
1232 }
1233 }
1234
1235 /**
1236 * Method called when synching to a given timestamp. Inheriting classes can
1237 * perform actions here to update the view at the given timestamp.
1238 *
1239 * @param time
1240 * The currently selected time
1241 */
1242 protected void synchingToTime(long time) {
1243
1244 }
1245
1246 /**
1247 * Return the list of traces whose data or analysis results will be used to
1248 * populate the view. By default, if the trace is an experiment, the traces
1249 * under it will be returned, otherwise, the trace itself is returned.
1250 *
1251 * A build thread will be started for each trace returned by this method,
1252 * some of which may receive events in live streaming mode.
1253 *
1254 * @param trace
1255 * The trace associated with this view
1256 * @return List of traces with data to display
1257 */
1258 protected @NonNull Iterable<ITmfTrace> getTracesToBuild(@NonNull ITmfTrace trace) {
1259 return TmfTraceManager.getTraceSet(trace);
1260 }
1261
1262 /**
1263 * Build the entries list to show in this time graph
1264 *
1265 * Called from the BuildThread
1266 *
1267 * @param trace
1268 * The trace being built
1269 * @param parentTrace
1270 * The parent of the trace set, or the trace itself
1271 * @param monitor
1272 * The progress monitor object
1273 */
1274 protected abstract void buildEventList(@NonNull ITmfTrace trace, @NonNull ITmfTrace parentTrace, @NonNull IProgressMonitor monitor);
1275
1276 /**
1277 * Gets the list of event for an entry in a given timerange
1278 *
1279 * @param entry
1280 * The entry to get events for
1281 * @param startTime
1282 * Start of the time range
1283 * @param endTime
1284 * End of the time range
1285 * @param resolution
1286 * The resolution
1287 * @param monitor
1288 * The progress monitor object
1289 * @return The list of events for the entry
1290 */
1291 protected abstract @Nullable List<ITimeEvent> getEventList(@NonNull TimeGraphEntry entry,
1292 long startTime, long endTime, long resolution,
1293 @NonNull IProgressMonitor monitor);
1294
1295 /**
1296 * Gets the list of links (displayed as arrows) for a trace in a given
1297 * timerange. Default implementation returns an empty list.
1298 *
1299 * @param startTime
1300 * Start of the time range
1301 * @param endTime
1302 * End of the time range
1303 * @param resolution
1304 * The resolution
1305 * @param monitor
1306 * The progress monitor object
1307 * @return The list of link events
1308 */
1309 protected @Nullable List<ILinkEvent> getLinkList(long startTime, long endTime,
1310 long resolution, @NonNull IProgressMonitor monitor) {
1311 return new ArrayList<>();
1312 }
1313
1314 /**
1315 * Gets the list of markers for a trace in a given time range. Default
1316 * implementation returns an empty list.
1317 *
1318 * @param startTime
1319 * Start of the time range
1320 * @param endTime
1321 * End of the time range
1322 * @param resolution
1323 * The resolution
1324 * @param monitor
1325 * The progress monitor object
1326 * @return The list of marker events
1327 * @since 2.0
1328 */
1329 protected @Nullable List<IMarkerEvent> getMarkerList(long startTime, long endTime,
1330 long resolution, @NonNull IProgressMonitor monitor) {
1331 return new ArrayList<>();
1332 }
1333
1334 /**
1335 * Refresh the display
1336 */
1337 protected void refresh() {
1338 final boolean zoomThread = Thread.currentThread() instanceof ZoomThread;
1339 TmfUiRefreshHandler.getInstance().queueUpdate(this, new Runnable() {
1340 @Override
1341 public void run() {
1342 if (fTimeGraphWrapper.isDisposed()) {
1343 return;
1344 }
1345 boolean hasEntries = false;
1346 synchronized (fEntryListMap) {
1347 fEntryList = fEntryListMap.get(fTrace);
1348 if (fEntryList == null) {
1349 fEntryList = new CopyOnWriteArrayList<>();
1350 } else if (fEntryComparator != null) {
1351 List<TimeGraphEntry> list = new ArrayList<>(fEntryList);
1352 Collections.sort(list, fEntryComparator);
1353 fEntryList.clear();
1354 fEntryList.addAll(list);
1355 }
1356 hasEntries = fEntryList.size() != 0;
1357 }
1358 if (fEntryList != fTimeGraphWrapper.getInput()) {
1359 fTimeGraphWrapper.setInput(fEntryList);
1360 /* restore the previously saved filters, if any */
1361 fTimeGraphWrapper.setFilters(fFiltersMap.get(fTrace));
1362 fTimeGraphWrapper.getTimeGraphViewer().setLinks(null);
1363 } else {
1364 fTimeGraphWrapper.refresh();
1365 }
1366 long startBound = (fStartTime == Long.MAX_VALUE ? SWT.DEFAULT : fStartTime);
1367 long endBound = (fEndTime == Long.MIN_VALUE ? SWT.DEFAULT : fEndTime);
1368 fTimeGraphWrapper.getTimeGraphViewer().setTimeBounds(startBound, endBound);
1369
1370 TmfTraceContext ctx = TmfTraceManager.getInstance().getCurrentTraceContext();
1371 long selectionBeginTime = fTrace == null ? SWT.DEFAULT : ctx.getSelectionRange().getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
1372 long selectionEndTime = fTrace == null ? SWT.DEFAULT : ctx.getSelectionRange().getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
1373 long startTime = fTrace == null ? SWT.DEFAULT : ctx.getWindowRange().getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
1374 long endTime = fTrace == null ? SWT.DEFAULT : ctx.getWindowRange().getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
1375 startTime = (fStartTime == Long.MAX_VALUE ? SWT.DEFAULT : Math.max(startTime, fStartTime));
1376 endTime = (fEndTime == Long.MIN_VALUE ? SWT.DEFAULT : Math.min(endTime, fEndTime));
1377 fTimeGraphWrapper.getTimeGraphViewer().setSelectionRange(selectionBeginTime, selectionEndTime);
1378 fTimeGraphWrapper.getTimeGraphViewer().setStartFinishTime(startTime, endTime);
1379
1380 if (fTimeGraphWrapper instanceof TimeGraphComboWrapper && !fPackDone) {
1381 for (TreeColumn column : ((TimeGraphComboWrapper) fTimeGraphWrapper).getTreeViewer().getTree().getColumns()) {
1382 column.pack();
1383 }
1384 if (hasEntries) {
1385 fPackDone = true;
1386 }
1387 }
1388
1389 if (!zoomThread) {
1390 startZoomThread(startTime, endTime);
1391 }
1392 }
1393 });
1394 }
1395
1396 /**
1397 * Redraw the canvas
1398 */
1399 protected void redraw() {
1400 synchronized (fSyncObj) {
1401 if (fRedrawState == State.IDLE) {
1402 fRedrawState = State.BUSY;
1403 } else {
1404 fRedrawState = State.PENDING;
1405 return;
1406 }
1407 }
1408 Display.getDefault().asyncExec(new Runnable() {
1409 @Override
1410 public void run() {
1411 if (fTimeGraphWrapper.isDisposed()) {
1412 return;
1413 }
1414 fTimeGraphWrapper.redraw();
1415 fTimeGraphWrapper.update();
1416 synchronized (fSyncObj) {
1417 if (fRedrawState == State.PENDING) {
1418 fRedrawState = State.IDLE;
1419 redraw();
1420 } else {
1421 fRedrawState = State.IDLE;
1422 }
1423 }
1424 }
1425 });
1426 }
1427
1428 private void startZoomThread(long startTime, long endTime) {
1429 boolean restart = false;
1430 if (fZoomThread != null) {
1431 fZoomThread.cancel();
1432 if (fZoomThread.fZoomStartTime == startTime && fZoomThread.fZoomEndTime == endTime) {
1433 restart = true;
1434 }
1435 }
1436 long resolution = Math.max(1, (endTime - startTime) / fDisplayWidth);
1437 fZoomThread = createZoomThread(startTime, endTime, resolution, restart);
1438 if (fZoomThread != null) {
1439 fZoomThread.start();
1440 }
1441 }
1442
1443 /**
1444 * Create a zoom thread.
1445 *
1446 * @param startTime
1447 * the zoom start time
1448 * @param endTime
1449 * the zoom end time
1450 * @param resolution
1451 * the resolution
1452 * @param restart
1453 * true if restarting zoom for the same time range
1454 * @return a zoom thread
1455 * @since 2.0
1456 */
1457 protected @Nullable ZoomThread createZoomThread(long startTime, long endTime, long resolution, boolean restart) {
1458 final List<TimeGraphEntry> entryList = fEntryList;
1459 if (entryList == null) {
1460 return null;
1461 }
1462 return new ZoomThreadByEntry(entryList, startTime, endTime, resolution);
1463 }
1464
1465 private void makeActions() {
1466 fPreviousResourceAction = fTimeGraphWrapper.getTimeGraphViewer().getPreviousItemAction();
1467 fPreviousResourceAction.setText(getPrevText());
1468 fPreviousResourceAction.setToolTipText(getPrevTooltip());
1469 fNextResourceAction = fTimeGraphWrapper.getTimeGraphViewer().getNextItemAction();
1470 fNextResourceAction.setText(getNextText());
1471 fNextResourceAction.setToolTipText(getNextTooltip());
1472 }
1473
1474 private void contributeToActionBars() {
1475 IActionBars bars = getViewSite().getActionBars();
1476 fillLocalToolBar(bars.getToolBarManager());
1477 }
1478
1479 /**
1480 * Add actions to local tool bar manager
1481 *
1482 * @param manager the tool bar manager
1483 */
1484 protected void fillLocalToolBar(IToolBarManager manager) {
1485 if (fFilterColumns != null && fFilterLabelProvider != null && fFilterColumns.length > 0) {
1486 manager.add(fTimeGraphWrapper.getShowFilterDialogAction());
1487 }
1488 manager.add(fTimeGraphWrapper.getTimeGraphViewer().getShowLegendAction());
1489 manager.add(new Separator());
1490 manager.add(fTimeGraphWrapper.getTimeGraphViewer().getResetScaleAction());
1491 manager.add(fTimeGraphWrapper.getTimeGraphViewer().getPreviousEventAction());
1492 manager.add(fTimeGraphWrapper.getTimeGraphViewer().getNextEventAction());
1493 manager.add(fTimeGraphWrapper.getTimeGraphViewer().getToggleBookmarkAction());
1494 manager.add(fTimeGraphWrapper.getTimeGraphViewer().getPreviousBookmarkAction());
1495 manager.add(fTimeGraphWrapper.getTimeGraphViewer().getNextBookmarkAction());
1496 manager.add(fPreviousResourceAction);
1497 manager.add(fNextResourceAction);
1498 manager.add(fTimeGraphWrapper.getTimeGraphViewer().getZoomInAction());
1499 manager.add(fTimeGraphWrapper.getTimeGraphViewer().getZoomOutAction());
1500 manager.add(new Separator());
1501 }
1502
1503 /**
1504 * @since 1.0
1505 */
1506 @Override
1507 public TmfTimeViewAlignmentInfo getTimeViewAlignmentInfo() {
1508 if (fTimeGraphWrapper == null) {
1509 return null;
1510 }
1511 return fTimeGraphWrapper.getTimeViewAlignmentInfo();
1512 }
1513
1514 /**
1515 * @since 1.0
1516 */
1517 @Override
1518 public int getAvailableWidth(int requestedOffset) {
1519 if (fTimeGraphWrapper == null) {
1520 return 0;
1521 }
1522 return fTimeGraphWrapper.getAvailableWidth(requestedOffset);
1523 }
1524
1525 /**
1526 * @since 1.0
1527 */
1528 @Override
1529 public void performAlign(int offset, int width) {
1530 if (fTimeGraphWrapper != null) {
1531 fTimeGraphWrapper.performAlign(offset, width);
1532 }
1533 }
1534}
This page took 0.028116 seconds and 5 git commands to generate.