1 /*******************************************************************************
2 * Copyright (c) 2012, 2015 Ericsson, École Polytechnique de Montréal
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
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 *******************************************************************************/
17 package org
.eclipse
.tracecompass
.tmf
.ui
.views
.timegraph
;
19 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
21 import java
.util
.ArrayList
;
22 import java
.util
.Collections
;
23 import java
.util
.Comparator
;
24 import java
.util
.HashMap
;
25 import java
.util
.List
;
27 import java
.util
.concurrent
.CopyOnWriteArrayList
;
28 import java
.util
.regex
.Matcher
;
29 import java
.util
.regex
.Pattern
;
31 import org
.eclipse
.core
.resources
.IFile
;
32 import org
.eclipse
.core
.resources
.IMarker
;
33 import org
.eclipse
.core
.resources
.IMarkerDelta
;
34 import org
.eclipse
.core
.resources
.IResource
;
35 import org
.eclipse
.core
.resources
.IResourceChangeEvent
;
36 import org
.eclipse
.core
.resources
.IResourceChangeListener
;
37 import org
.eclipse
.core
.resources
.IWorkspaceRunnable
;
38 import org
.eclipse
.core
.resources
.ResourcesPlugin
;
39 import org
.eclipse
.core
.runtime
.CoreException
;
40 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
41 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
42 import org
.eclipse
.jdt
.annotation
.NonNull
;
43 import org
.eclipse
.jdt
.annotation
.Nullable
;
44 import org
.eclipse
.jface
.action
.Action
;
45 import org
.eclipse
.jface
.action
.IAction
;
46 import org
.eclipse
.jface
.action
.IStatusLineManager
;
47 import org
.eclipse
.jface
.action
.IToolBarManager
;
48 import org
.eclipse
.jface
.action
.Separator
;
49 import org
.eclipse
.jface
.viewers
.AbstractTreeViewer
;
50 import org
.eclipse
.jface
.viewers
.ILabelProvider
;
51 import org
.eclipse
.jface
.viewers
.ILabelProviderListener
;
52 import org
.eclipse
.jface
.viewers
.ISelectionProvider
;
53 import org
.eclipse
.jface
.viewers
.ITableLabelProvider
;
54 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
55 import org
.eclipse
.jface
.viewers
.TreeViewer
;
56 import org
.eclipse
.jface
.viewers
.ViewerFilter
;
57 import org
.eclipse
.osgi
.util
.NLS
;
58 import org
.eclipse
.swt
.SWT
;
59 import org
.eclipse
.swt
.graphics
.Color
;
60 import org
.eclipse
.swt
.graphics
.Image
;
61 import org
.eclipse
.swt
.widgets
.Composite
;
62 import org
.eclipse
.swt
.widgets
.Display
;
63 import org
.eclipse
.swt
.widgets
.TreeColumn
;
64 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.Activator
;
65 import org
.eclipse
.tracecompass
.tmf
.core
.resources
.ITmfMarker
;
66 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfSelectionRangeUpdatedSignal
;
67 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfSignalHandler
;
68 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTimestampFormatUpdateSignal
;
69 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTraceClosedSignal
;
70 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTraceOpenedSignal
;
71 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTraceSelectedSignal
;
72 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfWindowRangeUpdatedSignal
;
73 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.ITmfTimestamp
;
74 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfNanoTimestamp
;
75 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimeRange
;
76 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
77 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceAdapterManager
;
78 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceContext
;
79 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceManager
;
80 import org
.eclipse
.tracecompass
.tmf
.ui
.TmfUiRefreshHandler
;
81 import org
.eclipse
.tracecompass
.tmf
.ui
.signal
.TmfTimeViewAlignmentInfo
;
82 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.ITmfTimeAligned
;
83 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.TmfView
;
84 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.ITimeGraphBookmarkListener
;
85 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.ITimeGraphContentProvider
;
86 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.ITimeGraphPresentationProvider2
;
87 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.ITimeGraphRangeListener
;
88 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.ITimeGraphSelectionListener
;
89 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.ITimeGraphTimeListener
;
90 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.TimeGraphBookmarkEvent
;
91 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.TimeGraphCombo
;
92 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.TimeGraphContentProvider
;
93 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.TimeGraphPresentationProvider
;
94 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.TimeGraphRangeUpdateEvent
;
95 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.TimeGraphTimeEvent
;
96 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.TimeGraphViewer
;
97 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.ILinkEvent
;
98 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.IMarkerEvent
;
99 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.IMarkerEventSource
;
100 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.ITimeEvent
;
101 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.ITimeGraphEntry
;
102 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.MarkerEvent
;
103 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.TimeGraphEntry
;
104 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.widgets
.Utils
.TimeFormat
;
105 import org
.eclipse
.ui
.IActionBars
;
108 * An abstract view all time graph views can inherit
110 * This view contains either a time graph viewer, or a time graph combo which is
111 * divided between a tree viewer on the left and a time graph viewer on the right.
113 public abstract class AbstractTimeGraphView
extends TmfView
implements ITmfTimeAligned
, IResourceChangeListener
{
115 /** Constant indicating that all levels of the time graph should be expanded */
116 protected static final int ALL_LEVELS
= AbstractTreeViewer
.ALL_LEVELS
;
118 private static final Pattern RGBA_PATTERN
= Pattern
.compile("RGBA \\{(\\d+), (\\d+), (\\d+), (\\d+)\\}"); //$NON-NLS-1$
127 // ------------------------------------------------------------------------
129 // ------------------------------------------------------------------------
131 /** The timegraph wrapper */
132 private ITimeGraphWrapper fTimeGraphWrapper
;
134 /** The selected trace */
135 private ITmfTrace fTrace
;
137 /** The selected trace editor file*/
138 private IFile fEditorFile
;
140 /** The timegraph entry list */
141 private List
<TimeGraphEntry
> fEntryList
;
143 /** The trace to entry list hash map */
144 private final Map
<ITmfTrace
, List
<TimeGraphEntry
>> fEntryListMap
= new HashMap
<>();
146 /** The trace to filters hash map */
147 private final Map
<ITmfTrace
, ViewerFilter
[]> fFiltersMap
= new HashMap
<>();
149 /** The trace to marker event sources hash map */
150 private final Map
<ITmfTrace
, List
<IMarkerEventSource
>> fMarkerEventSourcesMap
= new HashMap
<>();
152 /** The trace to build thread hash map */
153 private final Map
<ITmfTrace
, BuildThread
> fBuildThreadMap
= new HashMap
<>();
155 /** The start time */
156 private long fStartTime
= SWT
.DEFAULT
;
159 private long fEndTime
= SWT
.DEFAULT
;
161 /** The display width */
162 private final int fDisplayWidth
;
164 /** The zoom thread */
165 private ZoomThread fZoomThread
;
167 /** The next resource action */
168 private Action fNextResourceAction
;
170 /** The previous resource action */
171 private Action fPreviousResourceAction
;
173 /** A comparator class */
174 private Comparator
<ITimeGraphEntry
> fEntryComparator
= null;
176 /** The redraw state used to prevent unnecessary queuing of display runnables */
177 private State fRedrawState
= State
.IDLE
;
179 /** The redraw synchronization object */
180 private final Object fSyncObj
= new Object();
182 /** The presentation provider for this view */
183 private final TimeGraphPresentationProvider fPresentation
;
185 /** The tree column label array, or null if combo is not used */
186 private String
[] fColumns
;
188 /** The tree label provider, or null if combo is not used */
189 private TreeLabelProvider fLabelProvider
= null;
191 /** The time graph content provider */
192 private @NonNull ITimeGraphContentProvider fTimeGraphContentProvider
= new TimeGraphContentProvider();
194 /** The relative weight of the sash, ignored if combo is not used */
195 private int[] fWeight
= { 1, 3 };
197 /** The filter column label array, or null if filter is not used */
198 private String
[] fFilterColumns
;
200 /** The pack done flag */
201 private boolean fPackDone
= false;
203 /** The filter label provider, or null if filter is not used */
204 private TreeLabelProvider fFilterLabelProvider
;
206 private int fAutoExpandLevel
= ALL_LEVELS
;
208 /** The list of color resources created by this view */
209 private final List
<Color
> fColors
= new ArrayList
<>();
211 // ------------------------------------------------------------------------
213 // ------------------------------------------------------------------------
215 private interface ITimeGraphWrapper
{
217 void setTimeGraphContentProvider(ITimeGraphContentProvider timeGraphContentProvider
);
219 void setTimeGraphPresentationProvider(TimeGraphPresentationProvider timeGraphPresentationProvider
);
221 TimeGraphViewer
getTimeGraphViewer();
223 void addSelectionListener(ITimeGraphSelectionListener listener
);
225 ISelectionProvider
getSelectionProvider();
229 boolean isDisposed();
233 void setInput(Object input
);
237 void setFilters(ViewerFilter
[] filters
);
239 ViewerFilter
[] getFilters();
245 void setAutoExpandLevel(int level
);
247 void setFilterColumns(String
[] columnNames
);
249 void setFilterContentProvider(ITreeContentProvider contentProvider
);
251 void setFilterLabelProvider(ITableLabelProvider labelProvider
);
253 IAction
getShowFilterDialogAction();
255 void performAlign(int offset
, int width
);
257 TmfTimeViewAlignmentInfo
getTimeViewAlignmentInfo();
259 int getAvailableWidth(int requestedOffset
);
262 private class TimeGraphViewerWrapper
implements ITimeGraphWrapper
{
263 private TimeGraphViewer viewer
;
265 private TimeGraphViewerWrapper(Composite parent
, int style
) {
266 viewer
= new TimeGraphViewer(parent
, style
);
270 public void setTimeGraphContentProvider(ITimeGraphContentProvider timeGraphContentProvider
) {
271 viewer
.setTimeGraphContentProvider(timeGraphContentProvider
);
275 public void setTimeGraphPresentationProvider(TimeGraphPresentationProvider timeGraphPresentationProvider
) {
276 viewer
.setTimeGraphProvider(timeGraphPresentationProvider
);
280 public TimeGraphViewer
getTimeGraphViewer() {
285 public void addSelectionListener(ITimeGraphSelectionListener listener
) {
286 viewer
.addSelectionListener(listener
);
290 public ISelectionProvider
getSelectionProvider() {
291 return viewer
.getSelectionProvider();
295 public void setFocus() {
300 public boolean isDisposed() {
301 return viewer
.getControl().isDisposed();
305 public void setInput(Object input
) {
306 viewer
.setInput(input
);
310 public Object
getInput() {
311 return viewer
.getInput();
315 public void setFilterColumns(String
[] columnNames
) {
316 viewer
.setFilterColumns(columnNames
);
320 public void setFilterContentProvider(ITreeContentProvider contentProvider
) {
321 viewer
.setFilterContentProvider(contentProvider
);
325 public void setFilterLabelProvider(ITableLabelProvider labelProvider
) {
326 viewer
.setFilterLabelProvider(labelProvider
);
330 public void setFilters(ViewerFilter
[] filters
) {
331 viewer
.setFilters(filters
);
335 public ViewerFilter
[] getFilters() {
336 return viewer
.getFilters();
340 public IAction
getShowFilterDialogAction() {
341 return viewer
.getShowFilterDialogAction();
345 public void refresh() {
350 public void redraw() {
351 viewer
.getControl().redraw();
355 public void update() {
356 viewer
.getControl().update();
360 public void setAutoExpandLevel(int level
) {
361 viewer
.setAutoExpandLevel(level
);
365 public void performAlign(int offset
, int width
) {
366 viewer
.performAlign(offset
, width
);
370 public TmfTimeViewAlignmentInfo
getTimeViewAlignmentInfo() {
371 return viewer
.getTimeViewAlignmentInfo();
375 public int getAvailableWidth(int requestedOffset
) {
376 return viewer
.getAvailableWidth(requestedOffset
);
380 private class TimeGraphComboWrapper
implements ITimeGraphWrapper
{
381 private TimeGraphCombo combo
;
383 private TimeGraphComboWrapper(Composite parent
, int style
) {
384 combo
= new TimeGraphCombo(parent
, style
, fWeight
);
388 public void setTimeGraphContentProvider(ITimeGraphContentProvider timeGraphContentProvider
) {
389 combo
.setTimeGraphContentProvider(timeGraphContentProvider
);
393 public void setTimeGraphPresentationProvider(TimeGraphPresentationProvider timeGraphPresentationProvider
) {
394 combo
.setTimeGraphProvider(timeGraphPresentationProvider
);
398 public TimeGraphViewer
getTimeGraphViewer() {
399 return combo
.getTimeGraphViewer();
403 public void addSelectionListener(ITimeGraphSelectionListener listener
) {
404 combo
.addSelectionListener(listener
);
408 public ISelectionProvider
getSelectionProvider() {
409 return combo
.getTreeViewer();
413 public void setFocus() {
418 public boolean isDisposed() {
419 return combo
.isDisposed();
423 public void setInput(Object input
) {
424 combo
.setInput(input
);
428 public Object
getInput() {
429 return combo
.getInput();
433 public void setFilterColumns(String
[] columnNames
) {
434 combo
.setFilterColumns(columnNames
);
438 public void setFilterContentProvider(ITreeContentProvider contentProvider
) {
439 combo
.setFilterContentProvider(contentProvider
);
443 public void setFilterLabelProvider(ITableLabelProvider labelProvider
) {
444 combo
.setFilterLabelProvider(labelProvider
);
448 public void setFilters(ViewerFilter
[] filters
) {
449 combo
.setFilters(filters
);
453 public ViewerFilter
[] getFilters() {
454 return combo
.getFilters();
458 public IAction
getShowFilterDialogAction() {
459 return combo
.getShowFilterDialogAction();
463 public void refresh() {
468 public void redraw() {
473 public void update() {
478 public void setAutoExpandLevel(int level
) {
479 combo
.setAutoExpandLevel(level
);
482 TimeGraphCombo
getTimeGraphCombo() {
486 TreeViewer
getTreeViewer() {
487 return combo
.getTreeViewer();
491 public void performAlign(int offset
, int width
) {
492 combo
.performAlign(offset
, width
);
496 public TmfTimeViewAlignmentInfo
getTimeViewAlignmentInfo() {
497 return combo
.getTimeViewAlignmentInfo();
501 public int getAvailableWidth(int requestedOffset
) {
502 return combo
.getAvailableWidth(requestedOffset
);
507 * Base class to provide the labels for the tree viewer. Views extending
508 * this class typically need to override the getColumnText method if they
509 * have more than one column to display
511 protected static class TreeLabelProvider
implements ITableLabelProvider
, ILabelProvider
{
514 public void addListener(ILabelProviderListener listener
) {
518 public void dispose() {
522 public boolean isLabelProperty(Object element
, String property
) {
527 public void removeListener(ILabelProviderListener listener
) {
531 public Image
getColumnImage(Object element
, int columnIndex
) {
536 public String
getColumnText(Object element
, int columnIndex
) {
537 TimeGraphEntry entry
= (TimeGraphEntry
) element
;
538 if (columnIndex
== 0) {
539 return entry
.getName();
545 public Image
getImage(Object element
) {
550 public String
getText(Object element
) {
551 TimeGraphEntry entry
= (TimeGraphEntry
) element
;
552 return entry
.getName();
557 private class BuildThread
extends Thread
{
558 private final @NonNull ITmfTrace fBuildTrace
;
559 private final @NonNull ITmfTrace fParentTrace
;
560 private final @NonNull IProgressMonitor fMonitor
;
562 public BuildThread(final @NonNull ITmfTrace trace
, final @NonNull ITmfTrace parentTrace
, final String name
) {
563 super(name
+ " build"); //$NON-NLS-1$
565 fParentTrace
= parentTrace
;
566 fMonitor
= new NullProgressMonitor();
571 buildEventList(fBuildTrace
, fParentTrace
, fMonitor
);
572 synchronized (fBuildThreadMap
) {
573 fBuildThreadMap
.remove(fBuildTrace
);
577 public void cancel() {
578 fMonitor
.setCanceled(true);
586 protected abstract class ZoomThread
extends Thread
{
587 private final long fZoomStartTime
;
588 private final long fZoomEndTime
;
589 private final long fResolution
;
590 private final @NonNull IProgressMonitor fMonitor
;
602 public ZoomThread(long startTime
, long endTime
, long resolution
) {
603 super(AbstractTimeGraphView
.this.getName() + " zoom"); //$NON-NLS-1$
604 fZoomStartTime
= startTime
;
605 fZoomEndTime
= endTime
;
606 fResolution
= resolution
;
607 fMonitor
= new NullProgressMonitor();
611 * @return the zoom start time
613 public long getZoomStartTime() {
614 return fZoomStartTime
;
618 * @return the zoom end time
620 public long getZoomEndTime() {
625 * @return the resolution
627 public long getResolution() {
632 * @return the monitor
634 public @NonNull IProgressMonitor
getMonitor() {
639 * Cancel the zoom thread
641 public void cancel() {
642 fMonitor
.setCanceled(true);
646 private class ZoomThreadByEntry
extends ZoomThread
{
647 private final @NonNull List
<TimeGraphEntry
> fZoomEntryList
;
649 public ZoomThreadByEntry(@NonNull List
<TimeGraphEntry
> entryList
, long startTime
, long endTime
, long resolution
) {
650 super(startTime
, endTime
, resolution
);
651 fZoomEntryList
= entryList
;
656 for (TimeGraphEntry entry
: fZoomEntryList
) {
657 if (getMonitor().isCanceled()) {
663 zoom(entry
, getMonitor());
665 /* Refresh the arrows when zooming */
666 List
<ILinkEvent
> events
= getLinkList(getZoomStartTime(), getZoomEndTime(), getResolution(), getMonitor());
667 if (events
!= null) {
668 fTimeGraphWrapper
.getTimeGraphViewer().setLinks(events
);
671 /* Refresh the view-specific markers when zooming */
672 List
<IMarkerEvent
> markers
= new ArrayList
<>(getViewMarkerList(getZoomStartTime(), getZoomEndTime(), getResolution(), getMonitor()));
673 /* Refresh the trace-specific markers when zooming */
674 markers
.addAll(getTraceMarkerList(getZoomStartTime(), getZoomEndTime(), getResolution(), getMonitor()));
675 fTimeGraphWrapper
.getTimeGraphViewer().getTimeGraphControl().setMarkers(markers
);
679 private void zoom(@NonNull TimeGraphEntry entry
, @NonNull IProgressMonitor monitor
) {
680 if (getZoomStartTime() <= fStartTime
&& getZoomEndTime() >= fEndTime
) {
681 entry
.setZoomedEventList(null);
683 List
<ITimeEvent
> zoomedEventList
= getEventList(entry
, getZoomStartTime(), getZoomEndTime(), getResolution(), monitor
);
684 if (zoomedEventList
!= null) {
685 entry
.setZoomedEventList(zoomedEventList
);
689 for (ITimeGraphEntry child
: entry
.getChildren()) {
690 if (monitor
.isCanceled()) {
693 if (child
instanceof TimeGraphEntry
) {
694 zoom((TimeGraphEntry
) child
, monitor
);
701 // ------------------------------------------------------------------------
703 // ------------------------------------------------------------------------
706 * Constructs a time graph view that contains either a time graph viewer or
707 * a time graph combo.
709 * By default, the view uses a time graph viewer. To use a time graph combo,
710 * the subclass constructor must call {@link #setTreeColumns(String[])} and
711 * {@link #setTreeLabelProvider(TreeLabelProvider)}.
716 * The presentation provider
718 public AbstractTimeGraphView(String id
, TimeGraphPresentationProvider pres
) {
720 fPresentation
= pres
;
721 fDisplayWidth
= Display
.getDefault().getBounds().width
;
724 // ------------------------------------------------------------------------
725 // Getters and setters
726 // ------------------------------------------------------------------------
729 * Getter for the time graph combo
731 * @return The time graph combo, or null if combo is not used
733 protected TimeGraphCombo
getTimeGraphCombo() {
734 if (fTimeGraphWrapper
instanceof TimeGraphComboWrapper
) {
735 return ((TimeGraphComboWrapper
) fTimeGraphWrapper
).getTimeGraphCombo();
741 * Getter for the time graph viewer
743 * @return The time graph viewer
745 protected TimeGraphViewer
getTimeGraphViewer() {
746 return fTimeGraphWrapper
.getTimeGraphViewer();
750 * Getter for the presentation provider
752 * @return The time graph presentation provider
754 protected ITimeGraphPresentationProvider2
getPresentationProvider() {
755 return fPresentation
;
759 * Sets the tree column labels.
760 * This should be called from the constructor.
763 * The array of tree column labels
765 protected void setTreeColumns(final String
[] columns
) {
770 * Sets the tree label provider.
771 * This should be called from the constructor.
774 * The tree label provider
776 protected void setTreeLabelProvider(final TreeLabelProvider tlp
) {
777 fLabelProvider
= tlp
;
781 * Sets the time graph content provider. This should be called from the
785 * The time graph content provider
788 protected void setTimeGraphContentProvider(final @NonNull ITimeGraphContentProvider tgcp
) {
789 fTimeGraphContentProvider
= tgcp
;
793 * Sets the relative weight of each part of the time graph combo.
794 * This should be called from the constructor.
797 * The array (length 2) of relative weights of each part of the combo
799 protected void setWeight(final int[] weights
) {
804 * Sets the filter column labels.
805 * This should be called from the constructor.
807 * @param filterColumns
808 * The array of filter column labels
810 protected void setFilterColumns(final String
[] filterColumns
) {
811 fFilterColumns
= filterColumns
;
815 * Sets the filter label provider.
816 * This should be called from the constructor.
818 * @param labelProvider
819 * The filter label provider
821 protected void setFilterLabelProvider(final TreeLabelProvider labelProvider
) {
822 fFilterLabelProvider
= labelProvider
;
826 * Gets the display width
828 * @return the display width
830 protected int getDisplayWidth() {
831 return fDisplayWidth
;
835 * Gets the comparator for the entries
837 * @return The entry comparator
839 protected Comparator
<ITimeGraphEntry
> getEntryComparator() {
840 return fEntryComparator
;
844 * Sets the comparator class for the entries
847 * A comparator object
849 protected void setEntryComparator(final Comparator
<ITimeGraphEntry
> comparator
) {
850 fEntryComparator
= comparator
;
854 * Gets the trace displayed in the view
858 protected ITmfTrace
getTrace() {
863 * Gets the start time
865 * @return The start time
867 protected long getStartTime() {
872 * Sets the start time
877 protected void setStartTime(long time
) {
884 * @return The end time
886 protected long getEndTime() {
896 protected void setEndTime(long time
) {
901 * Sets the auto-expand level to be used for the input of the view. The
902 * value 0 means that there is no auto-expand; 1 means that top-level
903 * elements are expanded, but not their children; 2 means that top-level
904 * elements are expanded, and their children, but not grand-children; and so
907 * The value {@link #ALL_LEVELS} means that all subtrees should be expanded.
911 * non-negative level, or <code>ALL_LEVELS</code> to expand all
914 protected void setAutoExpandLevel(int level
) {
915 fAutoExpandLevel
= level
;
916 ITimeGraphWrapper tgWrapper
= fTimeGraphWrapper
;
917 if (tgWrapper
!= null) {
918 tgWrapper
.setAutoExpandLevel(level
);
923 * Gets the entry list for a trace
928 * @return the entry list map
930 protected List
<TimeGraphEntry
> getEntryList(ITmfTrace trace
) {
931 synchronized (fEntryListMap
) {
932 return fEntryListMap
.get(trace
);
937 * Adds a trace entry list to the entry list map
942 * the list of time graph entries
944 protected void putEntryList(ITmfTrace trace
, List
<TimeGraphEntry
> list
) {
945 synchronized (fEntryListMap
) {
946 fEntryListMap
.put(trace
, new CopyOnWriteArrayList
<>(list
));
951 * Adds a list of entries to a trace's entry list
956 * the list of time graph entries to add
958 protected void addToEntryList(ITmfTrace trace
, List
<TimeGraphEntry
> list
) {
959 synchronized (fEntryListMap
) {
960 List
<TimeGraphEntry
> entryList
= fEntryListMap
.get(trace
);
961 if (entryList
== null) {
962 fEntryListMap
.put(trace
, new CopyOnWriteArrayList
<>(list
));
964 entryList
.addAll(list
);
970 * Removes a list of entries from a trace's entry list
975 * the list of time graph entries to remove
977 protected void removeFromEntryList(ITmfTrace trace
, List
<TimeGraphEntry
> list
) {
978 synchronized (fEntryListMap
) {
979 List
<TimeGraphEntry
> entryList
= fEntryListMap
.get(trace
);
980 if (entryList
!= null) {
981 entryList
.removeAll(list
);
987 * Text for the "next" button
989 * @return The "next" button text
991 protected String
getNextText() {
992 return Messages
.AbstractTimeGraphtView_NextText
;
996 * Tooltip for the "next" button
998 * @return Tooltip for the "next" button
1000 protected String
getNextTooltip() {
1001 return Messages
.AbstractTimeGraphView_NextTooltip
;
1005 * Text for the "Previous" button
1007 * @return The "Previous" button text
1009 protected String
getPrevText() {
1010 return Messages
.AbstractTimeGraphView_PreviousText
;
1014 * Tooltip for the "previous" button
1016 * @return Tooltip for the "previous" button
1018 protected String
getPrevTooltip() {
1019 return Messages
.AbstractTimeGraphView_PreviousTooltip
;
1022 // ------------------------------------------------------------------------
1024 // ------------------------------------------------------------------------
1027 public void createPartControl(Composite parent
) {
1028 super.createPartControl(parent
);
1029 if (fColumns
== null || fLabelProvider
== null) {
1030 fTimeGraphWrapper
= new TimeGraphViewerWrapper(parent
, SWT
.NONE
);
1032 TimeGraphComboWrapper wrapper
= new TimeGraphComboWrapper(parent
, SWT
.NONE
);
1033 fTimeGraphWrapper
= wrapper
;
1034 TimeGraphCombo combo
= wrapper
.getTimeGraphCombo();
1035 combo
.setTreeContentProvider(fTimeGraphContentProvider
);
1036 combo
.setTreeLabelProvider(fLabelProvider
);
1037 combo
.setTreeColumns(fColumns
);
1039 fTimeGraphWrapper
.setTimeGraphContentProvider(fTimeGraphContentProvider
);
1040 fTimeGraphWrapper
.setFilterContentProvider(fTimeGraphContentProvider
);
1041 fTimeGraphWrapper
.setFilterLabelProvider(fFilterLabelProvider
);
1042 fTimeGraphWrapper
.setFilterColumns(fFilterColumns
);
1044 fTimeGraphWrapper
.setTimeGraphPresentationProvider(fPresentation
);
1045 fTimeGraphWrapper
.setAutoExpandLevel(fAutoExpandLevel
);
1047 fTimeGraphWrapper
.getTimeGraphViewer().addRangeListener(new ITimeGraphRangeListener() {
1049 public void timeRangeUpdated(TimeGraphRangeUpdateEvent event
) {
1050 final long startTime
= event
.getStartTime();
1051 final long endTime
= event
.getEndTime();
1052 TmfTimeRange range
= new TmfTimeRange(new TmfNanoTimestamp(startTime
), new TmfNanoTimestamp(endTime
));
1053 broadcast(new TmfWindowRangeUpdatedSignal(AbstractTimeGraphView
.this, range
));
1054 startZoomThread(startTime
, endTime
);
1058 fTimeGraphWrapper
.getTimeGraphViewer().addTimeListener(new ITimeGraphTimeListener() {
1060 public void timeSelected(TimeGraphTimeEvent event
) {
1061 TmfNanoTimestamp startTime
= new TmfNanoTimestamp(event
.getBeginTime());
1062 TmfNanoTimestamp endTime
= new TmfNanoTimestamp(event
.getEndTime());
1063 broadcast(new TmfSelectionRangeUpdatedSignal(AbstractTimeGraphView
.this, startTime
, endTime
));
1067 fTimeGraphWrapper
.getTimeGraphViewer().addBookmarkListener(new ITimeGraphBookmarkListener() {
1069 public void bookmarkAdded(final TimeGraphBookmarkEvent event
) {
1071 ResourcesPlugin
.getWorkspace().run(new IWorkspaceRunnable() {
1073 public void run(IProgressMonitor monitor
) throws CoreException
{
1074 IMarkerEvent bookmark
= event
.getBookmark();
1075 IMarker marker
= fEditorFile
.createMarker(IMarker
.BOOKMARK
);
1076 marker
.setAttribute(IMarker
.MESSAGE
, bookmark
.getLabel());
1077 marker
.setAttribute(ITmfMarker
.MARKER_TIME
, Long
.toString(bookmark
.getTime()));
1078 if (bookmark
.getDuration() > 0) {
1079 marker
.setAttribute(ITmfMarker
.MARKER_DURATION
, Long
.toString(bookmark
.getDuration()));
1080 marker
.setAttribute(IMarker
.LOCATION
,
1081 NLS
.bind(org
.eclipse
.tracecompass
.internal
.tmf
.ui
.Messages
.TmfMarker_LocationTimeRange
,
1082 new TmfNanoTimestamp(bookmark
.getTime()),
1083 new TmfNanoTimestamp(bookmark
.getTime() + bookmark
.getDuration())));
1085 marker
.setAttribute(IMarker
.LOCATION
,
1086 NLS
.bind(org
.eclipse
.tracecompass
.internal
.tmf
.ui
.Messages
.TmfMarker_LocationTime
,
1087 new TmfNanoTimestamp(bookmark
.getTime())));
1089 marker
.setAttribute(ITmfMarker
.MARKER_COLOR
, bookmark
.getColor().getRGBA().toString());
1092 } catch (CoreException e
) {
1093 Activator
.getDefault().logError(e
.getMessage());
1098 public void bookmarkRemoved(TimeGraphBookmarkEvent event
) {
1100 IMarkerEvent bookmark
= event
.getBookmark();
1101 IMarker
[] markers
= fEditorFile
.findMarkers(IMarker
.BOOKMARK
, false, IResource
.DEPTH_ZERO
);
1102 for (IMarker marker
: markers
) {
1103 if (bookmark
.getLabel().equals(marker
.getAttribute(IMarker
.MESSAGE
)) &&
1104 Long
.toString(bookmark
.getTime()).equals(marker
.getAttribute(ITmfMarker
.MARKER_TIME
, (String
) null)) &&
1105 Long
.toString(bookmark
.getDuration()).equals(marker
.getAttribute(ITmfMarker
.MARKER_DURATION
, Long
.toString(0))) &&
1106 bookmark
.getColor().getRGBA().toString().equals(marker
.getAttribute(ITmfMarker
.MARKER_COLOR
))) {
1111 } catch (CoreException e
) {
1112 Activator
.getDefault().logError(e
.getMessage());
1117 fTimeGraphWrapper
.getTimeGraphViewer().setTimeFormat(TimeFormat
.CALENDAR
);
1119 IStatusLineManager statusLineManager
= getViewSite().getActionBars().getStatusLineManager();
1120 fTimeGraphWrapper
.getTimeGraphViewer().getTimeGraphControl().setStatusLineManager(statusLineManager
);
1122 // View Action Handling
1124 contributeToActionBars();
1126 ITmfTrace trace
= TmfTraceManager
.getInstance().getActiveTrace();
1127 if (trace
!= null) {
1128 traceSelected(new TmfTraceSelectedSignal(this, trace
));
1131 // make selection available to other views
1132 getSite().setSelectionProvider(fTimeGraphWrapper
.getSelectionProvider());
1134 ResourcesPlugin
.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent
.POST_CHANGE
);
1138 public void setFocus() {
1139 fTimeGraphWrapper
.setFocus();
1143 public void dispose() {
1145 ResourcesPlugin
.getWorkspace().removeResourceChangeListener(this);
1152 public void resourceChanged(final IResourceChangeEvent event
) {
1153 for (final IMarkerDelta delta
: event
.findMarkerDeltas(IMarker
.BOOKMARK
, false)) {
1154 if (delta
.getResource().equals(fEditorFile
)) {
1155 fTimeGraphWrapper
.getTimeGraphViewer().setBookmarks(refreshBookmarks(fEditorFile
));
1162 private List
<IMarkerEvent
> refreshBookmarks(final IFile editorFile
) {
1163 List
<IMarkerEvent
> bookmarks
= new ArrayList
<>();
1164 for (Color color
: fColors
) {
1168 if (editorFile
== null || !editorFile
.exists()) {
1172 IMarker
[] markers
= editorFile
.findMarkers(IMarker
.BOOKMARK
, false, IResource
.DEPTH_ZERO
);
1173 for (IMarker marker
: markers
) {
1174 String label
= marker
.getAttribute(IMarker
.MESSAGE
, (String
) null);
1175 String time
= marker
.getAttribute(ITmfMarker
.MARKER_TIME
, (String
) null);
1176 String duration
= marker
.getAttribute(ITmfMarker
.MARKER_DURATION
, Long
.toString(0));
1177 String rgba
= marker
.getAttribute(ITmfMarker
.MARKER_COLOR
, (String
) null);
1178 if (label
!= null && time
!= null && rgba
!= null) {
1179 Matcher matcher
= RGBA_PATTERN
.matcher(rgba
);
1180 if (matcher
.matches()) {
1182 int red
= Integer
.valueOf(matcher
.group(1));
1183 int green
= Integer
.valueOf(matcher
.group(2));
1184 int blue
= Integer
.valueOf(matcher
.group(3));
1185 int alpha
= Integer
.valueOf(matcher
.group(4));
1186 Color color
= new Color(Display
.getDefault(), red
, green
, blue
, alpha
);
1188 bookmarks
.add(new MarkerEvent(null, Long
.valueOf(time
), Long
.valueOf(duration
), color
, label
, true));
1189 } catch (NumberFormatException e
) {
1190 Activator
.getDefault().logError(e
.getMessage());
1195 } catch (CoreException e
) {
1196 Activator
.getDefault().logError(e
.getMessage());
1201 // ------------------------------------------------------------------------
1203 // ------------------------------------------------------------------------
1206 * Handler for the trace opened signal.
1209 * The incoming signal
1212 public void traceOpened(TmfTraceOpenedSignal signal
) {
1213 loadTrace(signal
.getTrace());
1217 * Handler for the trace selected signal
1220 * The incoming signal
1223 public void traceSelected(final TmfTraceSelectedSignal signal
) {
1224 if (signal
.getTrace() == fTrace
) {
1227 loadTrace(signal
.getTrace());
1231 * Trace is closed: clear the data structures and the view
1234 * the signal received
1237 public void traceClosed(final TmfTraceClosedSignal signal
) {
1238 synchronized (fBuildThreadMap
) {
1239 for (ITmfTrace trace
: getTracesToBuild(signal
.getTrace())) {
1240 BuildThread buildThread
= fBuildThreadMap
.remove(trace
);
1241 if (buildThread
!= null) {
1242 buildThread
.cancel();
1244 fMarkerEventSourcesMap
.remove(trace
);
1247 synchronized (fEntryListMap
) {
1248 fEntryListMap
.remove(signal
.getTrace());
1250 fFiltersMap
.remove(signal
.getTrace());
1251 if (signal
.getTrace() == fTrace
) {
1254 fStartTime
= SWT
.DEFAULT
;
1255 fEndTime
= SWT
.DEFAULT
;
1256 if (fZoomThread
!= null) {
1257 fZoomThread
.cancel();
1265 * Handler for the selection range signal.
1268 * The signal that's received
1272 public void selectionRangeUpdated(final TmfSelectionRangeUpdatedSignal signal
) {
1273 if (signal
.getSource() == this || fTrace
== null) {
1276 final long beginTime
= signal
.getBeginTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
1277 final long endTime
= signal
.getEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
1279 Display
.getDefault().asyncExec(new Runnable() {
1282 if (fTimeGraphWrapper
.isDisposed()) {
1285 if (beginTime
== endTime
) {
1286 fTimeGraphWrapper
.getTimeGraphViewer().setSelectedTime(beginTime
, true);
1288 fTimeGraphWrapper
.getTimeGraphViewer().setSelectionRange(beginTime
, endTime
);
1290 synchingToTime(fTimeGraphWrapper
.getTimeGraphViewer().getTime0());
1296 * Handler for the window range signal.
1299 * The signal that's received
1303 public void windowRangeUpdated(final TmfWindowRangeUpdatedSignal signal
) {
1304 if (signal
.getSource() == this || fTrace
== null) {
1307 if (signal
.getCurrentRange().getIntersection(fTrace
.getTimeRange()) == null) {
1310 final long startTime
= signal
.getCurrentRange().getStartTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
1311 final long endTime
= signal
.getCurrentRange().getEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
1312 Display
.getDefault().asyncExec(new Runnable() {
1315 if (fTimeGraphWrapper
.isDisposed()) {
1318 fTimeGraphWrapper
.getTimeGraphViewer().setStartFinishTime(startTime
, endTime
);
1319 startZoomThread(startTime
, endTime
);
1325 * @param signal the format of the timestamps was updated.
1328 public void updateTimeFormat( final TmfTimestampFormatUpdateSignal signal
){
1329 fTimeGraphWrapper
.refresh();
1332 // ------------------------------------------------------------------------
1334 // ------------------------------------------------------------------------
1336 private void loadTrace(final ITmfTrace trace
) {
1337 if (fZoomThread
!= null) {
1338 fZoomThread
.cancel();
1341 if (fTrace
!= null) {
1342 /* save the filters of the previous trace */
1343 fFiltersMap
.put(fTrace
, fTimeGraphWrapper
.getFilters());
1346 fEditorFile
= TmfTraceManager
.getInstance().getTraceEditorFile(trace
);
1347 synchronized (fEntryListMap
) {
1348 fEntryList
= fEntryListMap
.get(fTrace
);
1349 if (fEntryList
== null) {
1352 fStartTime
= fTrace
.getStartTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
1353 fEndTime
= fTrace
.getEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
1360 * Forces a rebuild of the entries list, even if entries already exist for this trace
1362 protected void rebuild() {
1363 setStartTime(Long
.MAX_VALUE
);
1364 setEndTime(Long
.MIN_VALUE
);
1366 ITmfTrace viewTrace
= fTrace
;
1367 if (viewTrace
== null) {
1370 synchronized (fBuildThreadMap
) {
1371 for (ITmfTrace trace
: getTracesToBuild(viewTrace
)) {
1372 if (trace
== null) {
1375 fMarkerEventSourcesMap
.put(trace
, TmfTraceAdapterManager
.getAdapters(trace
, IMarkerEventSource
.class));
1376 BuildThread buildThread
= new BuildThread(trace
, viewTrace
, getName());
1377 fBuildThreadMap
.put(trace
, buildThread
);
1378 buildThread
.start();
1384 * Method called when synching to a given timestamp. Inheriting classes can
1385 * perform actions here to update the view at the given timestamp.
1388 * The currently selected time
1390 protected void synchingToTime(long time
) {
1395 * Return the list of traces whose data or analysis results will be used to
1396 * populate the view. By default, if the trace is an experiment, the traces
1397 * under it will be returned, otherwise, the trace itself is returned.
1399 * A build thread will be started for each trace returned by this method,
1400 * some of which may receive events in live streaming mode.
1403 * The trace associated with this view
1404 * @return List of traces with data to display
1406 protected @NonNull Iterable
<ITmfTrace
> getTracesToBuild(@NonNull ITmfTrace trace
) {
1407 return TmfTraceManager
.getTraceSet(trace
);
1411 * Build the entries list to show in this time graph
1413 * Called from the BuildThread
1416 * The trace being built
1417 * @param parentTrace
1418 * The parent of the trace set, or the trace itself
1420 * The progress monitor object
1422 protected abstract void buildEventList(@NonNull ITmfTrace trace
, @NonNull ITmfTrace parentTrace
, @NonNull IProgressMonitor monitor
);
1425 * Gets the list of event for an entry in a given timerange
1428 * The entry to get events for
1430 * Start of the time range
1432 * End of the time range
1436 * The progress monitor object
1437 * @return The list of events for the entry
1439 protected abstract @Nullable List
<ITimeEvent
> getEventList(@NonNull TimeGraphEntry entry
,
1440 long startTime
, long endTime
, long resolution
,
1441 @NonNull IProgressMonitor monitor
);
1444 * Gets the list of links (displayed as arrows) for a trace in a given
1445 * timerange. Default implementation returns an empty list.
1448 * Start of the time range
1450 * End of the time range
1454 * The progress monitor object
1455 * @return The list of link events
1457 protected @Nullable List
<ILinkEvent
> getLinkList(long startTime
, long endTime
,
1458 long resolution
, @NonNull IProgressMonitor monitor
) {
1459 return new ArrayList
<>();
1463 * Gets the list of view-specific markers for a trace in a given time range.
1464 * Default implementation returns an empty list.
1467 * Start of the time range
1469 * End of the time range
1473 * The progress monitor object
1474 * @return The list of marker events
1477 protected @NonNull List
<IMarkerEvent
> getViewMarkerList(long startTime
, long endTime
,
1478 long resolution
, @NonNull IProgressMonitor monitor
) {
1479 return new ArrayList
<>();
1483 * Gets the list of trace-specific markers for a trace in a given time range.
1486 * Start of the time range
1488 * End of the time range
1492 * The progress monitor object
1493 * @return The list of marker events
1496 protected @NonNull List
<IMarkerEvent
> getTraceMarkerList(long startTime
, long endTime
,
1497 long resolution
, @NonNull IProgressMonitor monitor
) {
1498 List
<IMarkerEvent
> markers
= new ArrayList
<>();
1499 for (IMarkerEventSource markerEventSource
: getMarkerEventSources(getTrace())) {
1500 if (monitor
.isCanceled()) {
1503 markers
.addAll(markerEventSource
.getMarkerList(startTime
, endTime
, resolution
, monitor
));
1509 * Gets the list of marker event sources for a given trace.
1513 * @return The list of marker event sources
1516 protected @NonNull List
<IMarkerEventSource
> getMarkerEventSources(ITmfTrace trace
) {
1517 List
<IMarkerEventSource
> markerEventSources
= fMarkerEventSourcesMap
.get(trace
);
1518 if (markerEventSources
== null) {
1519 markerEventSources
= checkNotNull(Collections
.<IMarkerEventSource
>emptyList());
1521 return markerEventSources
;
1525 * Refresh the display
1527 protected void refresh() {
1528 final boolean zoomThread
= Thread
.currentThread() instanceof ZoomThread
;
1529 TmfUiRefreshHandler
.getInstance().queueUpdate(this, new Runnable() {
1532 if (fTimeGraphWrapper
.isDisposed()) {
1535 boolean hasEntries
= false;
1536 synchronized (fEntryListMap
) {
1537 fEntryList
= fEntryListMap
.get(fTrace
);
1538 if (fEntryList
== null) {
1539 fEntryList
= new CopyOnWriteArrayList
<>();
1540 } else if (fEntryComparator
!= null) {
1541 List
<TimeGraphEntry
> list
= new ArrayList
<>(fEntryList
);
1542 Collections
.sort(list
, fEntryComparator
);
1544 fEntryList
.addAll(list
);
1546 hasEntries
= fEntryList
.size() != 0;
1548 if (fEntryList
!= fTimeGraphWrapper
.getInput()) {
1549 fTimeGraphWrapper
.setInput(fEntryList
);
1550 /* restore the previously saved filters, if any */
1551 fTimeGraphWrapper
.setFilters(fFiltersMap
.get(fTrace
));
1552 fTimeGraphWrapper
.getTimeGraphViewer().setLinks(null);
1553 fTimeGraphWrapper
.getTimeGraphViewer().setBookmarks(refreshBookmarks(fEditorFile
));
1555 fTimeGraphWrapper
.refresh();
1557 long startBound
= (fStartTime
== Long
.MAX_VALUE ? SWT
.DEFAULT
: fStartTime
);
1558 long endBound
= (fEndTime
== Long
.MIN_VALUE ? SWT
.DEFAULT
: fEndTime
);
1559 fTimeGraphWrapper
.getTimeGraphViewer().setTimeBounds(startBound
, endBound
);
1561 TmfTraceContext ctx
= TmfTraceManager
.getInstance().getCurrentTraceContext();
1562 long selectionBeginTime
= fTrace
== null ? SWT
.DEFAULT
: ctx
.getSelectionRange().getStartTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
1563 long selectionEndTime
= fTrace
== null ? SWT
.DEFAULT
: ctx
.getSelectionRange().getEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
1564 long startTime
= fTrace
== null ? SWT
.DEFAULT
: ctx
.getWindowRange().getStartTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
1565 long endTime
= fTrace
== null ? SWT
.DEFAULT
: ctx
.getWindowRange().getEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
1566 startTime
= (fStartTime
== Long
.MAX_VALUE ? SWT
.DEFAULT
: Math
.max(startTime
, fStartTime
));
1567 endTime
= (fEndTime
== Long
.MIN_VALUE ? SWT
.DEFAULT
: Math
.min(endTime
, fEndTime
));
1568 fTimeGraphWrapper
.getTimeGraphViewer().setSelectionRange(selectionBeginTime
, selectionEndTime
);
1569 fTimeGraphWrapper
.getTimeGraphViewer().setStartFinishTime(startTime
, endTime
);
1571 if (fTimeGraphWrapper
instanceof TimeGraphComboWrapper
&& !fPackDone
) {
1572 for (TreeColumn column
: ((TimeGraphComboWrapper
) fTimeGraphWrapper
).getTreeViewer().getTree().getColumns()) {
1581 startZoomThread(startTime
, endTime
);
1590 protected void redraw() {
1591 synchronized (fSyncObj
) {
1592 if (fRedrawState
== State
.IDLE
) {
1593 fRedrawState
= State
.BUSY
;
1595 fRedrawState
= State
.PENDING
;
1599 Display
.getDefault().asyncExec(new Runnable() {
1602 if (fTimeGraphWrapper
.isDisposed()) {
1605 fTimeGraphWrapper
.redraw();
1606 fTimeGraphWrapper
.update();
1607 synchronized (fSyncObj
) {
1608 if (fRedrawState
== State
.PENDING
) {
1609 fRedrawState
= State
.IDLE
;
1612 fRedrawState
= State
.IDLE
;
1619 private void startZoomThread(long startTime
, long endTime
) {
1620 boolean restart
= false;
1621 if (fZoomThread
!= null) {
1622 fZoomThread
.cancel();
1623 if (fZoomThread
.fZoomStartTime
== startTime
&& fZoomThread
.fZoomEndTime
== endTime
) {
1627 long resolution
= Math
.max(1, (endTime
- startTime
) / fDisplayWidth
);
1628 fZoomThread
= createZoomThread(startTime
, endTime
, resolution
, restart
);
1629 if (fZoomThread
!= null) {
1630 fZoomThread
.start();
1635 * Create a zoom thread.
1638 * the zoom start time
1644 * true if restarting zoom for the same time range
1645 * @return a zoom thread
1648 protected @Nullable ZoomThread
createZoomThread(long startTime
, long endTime
, long resolution
, boolean restart
) {
1649 final List
<TimeGraphEntry
> entryList
= fEntryList
;
1650 if (entryList
== null) {
1653 return new ZoomThreadByEntry(entryList
, startTime
, endTime
, resolution
);
1656 private void makeActions() {
1657 fPreviousResourceAction
= fTimeGraphWrapper
.getTimeGraphViewer().getPreviousItemAction();
1658 fPreviousResourceAction
.setText(getPrevText());
1659 fPreviousResourceAction
.setToolTipText(getPrevTooltip());
1660 fNextResourceAction
= fTimeGraphWrapper
.getTimeGraphViewer().getNextItemAction();
1661 fNextResourceAction
.setText(getNextText());
1662 fNextResourceAction
.setToolTipText(getNextTooltip());
1665 private void contributeToActionBars() {
1666 IActionBars bars
= getViewSite().getActionBars();
1667 fillLocalToolBar(bars
.getToolBarManager());
1671 * Add actions to local tool bar manager
1673 * @param manager the tool bar manager
1675 protected void fillLocalToolBar(IToolBarManager manager
) {
1676 if (fFilterColumns
!= null && fFilterLabelProvider
!= null && fFilterColumns
.length
> 0) {
1677 manager
.add(fTimeGraphWrapper
.getShowFilterDialogAction());
1679 manager
.add(fTimeGraphWrapper
.getTimeGraphViewer().getShowLegendAction());
1680 manager
.add(new Separator());
1681 manager
.add(fTimeGraphWrapper
.getTimeGraphViewer().getResetScaleAction());
1682 manager
.add(fTimeGraphWrapper
.getTimeGraphViewer().getPreviousEventAction());
1683 manager
.add(fTimeGraphWrapper
.getTimeGraphViewer().getNextEventAction());
1684 manager
.add(fTimeGraphWrapper
.getTimeGraphViewer().getToggleBookmarkAction());
1685 manager
.add(fTimeGraphWrapper
.getTimeGraphViewer().getPreviousBookmarkAction());
1686 manager
.add(fTimeGraphWrapper
.getTimeGraphViewer().getNextBookmarkAction());
1687 manager
.add(fPreviousResourceAction
);
1688 manager
.add(fNextResourceAction
);
1689 manager
.add(fTimeGraphWrapper
.getTimeGraphViewer().getZoomInAction());
1690 manager
.add(fTimeGraphWrapper
.getTimeGraphViewer().getZoomOutAction());
1691 manager
.add(new Separator());
1698 public TmfTimeViewAlignmentInfo
getTimeViewAlignmentInfo() {
1699 if (fTimeGraphWrapper
== null) {
1702 return fTimeGraphWrapper
.getTimeViewAlignmentInfo();
1709 public int getAvailableWidth(int requestedOffset
) {
1710 if (fTimeGraphWrapper
== null) {
1713 return fTimeGraphWrapper
.getAvailableWidth(requestedOffset
);
1720 public void performAlign(int offset
, int width
) {
1721 if (fTimeGraphWrapper
!= null) {
1722 fTimeGraphWrapper
.performAlign(offset
, width
);