1 /*******************************************************************************
2 * Copyright (c) 2012, 2016 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
.LinkedHashSet
;
26 import java
.util
.List
;
29 import java
.util
.concurrent
.CopyOnWriteArrayList
;
30 import java
.util
.concurrent
.atomic
.AtomicInteger
;
31 import java
.util
.regex
.Matcher
;
32 import java
.util
.regex
.Pattern
;
34 import org
.eclipse
.core
.resources
.IFile
;
35 import org
.eclipse
.core
.resources
.IMarker
;
36 import org
.eclipse
.core
.resources
.IMarkerDelta
;
37 import org
.eclipse
.core
.resources
.IResource
;
38 import org
.eclipse
.core
.resources
.IResourceChangeEvent
;
39 import org
.eclipse
.core
.resources
.IResourceChangeListener
;
40 import org
.eclipse
.core
.resources
.IWorkspaceRunnable
;
41 import org
.eclipse
.core
.resources
.ResourcesPlugin
;
42 import org
.eclipse
.core
.runtime
.CoreException
;
43 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
44 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
45 import org
.eclipse
.jdt
.annotation
.NonNull
;
46 import org
.eclipse
.jdt
.annotation
.Nullable
;
47 import org
.eclipse
.jface
.action
.Action
;
48 import org
.eclipse
.jface
.action
.GroupMarker
;
49 import org
.eclipse
.jface
.action
.IAction
;
50 import org
.eclipse
.jface
.action
.IMenuListener
;
51 import org
.eclipse
.jface
.action
.IMenuManager
;
52 import org
.eclipse
.jface
.action
.IStatusLineManager
;
53 import org
.eclipse
.jface
.action
.IToolBarManager
;
54 import org
.eclipse
.jface
.action
.MenuManager
;
55 import org
.eclipse
.jface
.action
.Separator
;
56 import org
.eclipse
.jface
.commands
.ActionHandler
;
57 import org
.eclipse
.jface
.viewers
.AbstractTreeViewer
;
58 import org
.eclipse
.jface
.viewers
.ILabelProvider
;
59 import org
.eclipse
.jface
.viewers
.ILabelProviderListener
;
60 import org
.eclipse
.jface
.viewers
.ISelectionProvider
;
61 import org
.eclipse
.jface
.viewers
.ITableLabelProvider
;
62 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
63 import org
.eclipse
.jface
.viewers
.TreeSelection
;
64 import org
.eclipse
.jface
.viewers
.TreeViewer
;
65 import org
.eclipse
.jface
.viewers
.ViewerFilter
;
66 import org
.eclipse
.osgi
.util
.NLS
;
67 import org
.eclipse
.swt
.SWT
;
68 import org
.eclipse
.swt
.events
.MenuDetectEvent
;
69 import org
.eclipse
.swt
.events
.MenuDetectListener
;
70 import org
.eclipse
.swt
.events
.SelectionAdapter
;
71 import org
.eclipse
.swt
.events
.SelectionEvent
;
72 import org
.eclipse
.swt
.graphics
.Image
;
73 import org
.eclipse
.swt
.graphics
.Point
;
74 import org
.eclipse
.swt
.graphics
.RGBA
;
75 import org
.eclipse
.swt
.widgets
.Composite
;
76 import org
.eclipse
.swt
.widgets
.Display
;
77 import org
.eclipse
.swt
.widgets
.Menu
;
78 import org
.eclipse
.swt
.widgets
.Shell
;
79 import org
.eclipse
.swt
.widgets
.Tree
;
80 import org
.eclipse
.swt
.widgets
.TreeColumn
;
81 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.Activator
;
82 import org
.eclipse
.tracecompass
.tmf
.core
.resources
.ITmfMarker
;
83 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfSelectionRangeUpdatedSignal
;
84 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfSignalHandler
;
85 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTimestampFormatUpdateSignal
;
86 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTraceClosedSignal
;
87 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTraceOpenedSignal
;
88 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTraceSelectedSignal
;
89 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfWindowRangeUpdatedSignal
;
90 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfNanoTimestamp
;
91 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimeRange
;
92 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
93 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceAdapterManager
;
94 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceContext
;
95 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceManager
;
96 import org
.eclipse
.tracecompass
.tmf
.ui
.TmfUiRefreshHandler
;
97 import org
.eclipse
.tracecompass
.tmf
.ui
.signal
.TmfTimeViewAlignmentInfo
;
98 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.ITmfTimeAligned
;
99 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.TmfView
;
100 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.ITimeGraphBookmarkListener
;
101 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.ITimeGraphContentProvider
;
102 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.ITimeGraphPresentationProvider2
;
103 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.ITimeGraphRangeListener
;
104 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.ITimeGraphSelectionListener
;
105 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.ITimeGraphTimeListener
;
106 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.TimeGraphBookmarkEvent
;
107 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.TimeGraphCombo
;
108 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.TimeGraphContentProvider
;
109 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.TimeGraphPresentationProvider
;
110 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.TimeGraphRangeUpdateEvent
;
111 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.TimeGraphTimeEvent
;
112 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.TimeGraphViewer
;
113 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.ILinkEvent
;
114 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.IMarkerEvent
;
115 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.IMarkerEventSource
;
116 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.ITimeEvent
;
117 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.ITimeGraphEntry
;
118 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.MarkerEvent
;
119 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.TimeGraphEntry
;
120 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.widgets
.TimeGraphControl
;
121 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.widgets
.Utils
.TimeFormat
;
122 import org
.eclipse
.ui
.IActionBars
;
123 import org
.eclipse
.ui
.IPartListener
;
124 import org
.eclipse
.ui
.IWorkbenchActionConstants
;
125 import org
.eclipse
.ui
.IWorkbenchPart
;
126 import org
.eclipse
.ui
.PlatformUI
;
127 import org
.eclipse
.ui
.actions
.ActionFactory
;
128 import org
.eclipse
.ui
.handlers
.IHandlerActivation
;
129 import org
.eclipse
.ui
.handlers
.IHandlerService
;
132 * An abstract view all time graph views can inherit
134 * This view contains either a time graph viewer, or a time graph combo which is
135 * divided between a tree viewer on the left and a time graph viewer on the right.
137 public abstract class AbstractTimeGraphView
extends TmfView
implements ITmfTimeAligned
, IResourceChangeListener
{
139 /** Constant indicating that all levels of the time graph should be expanded */
140 protected static final int ALL_LEVELS
= AbstractTreeViewer
.ALL_LEVELS
;
142 private static final Pattern RGBA_PATTERN
= Pattern
.compile("RGBA \\{(\\d+), (\\d+), (\\d+), (\\d+)\\}"); //$NON-NLS-1$
151 // ------------------------------------------------------------------------
153 // ------------------------------------------------------------------------
155 /** The timegraph wrapper */
156 private ITimeGraphWrapper fTimeGraphWrapper
;
158 private AtomicInteger fDirty
= new AtomicInteger();
160 private final Object fZoomThreadResultLock
= new Object();
162 /** The selected trace */
163 private ITmfTrace fTrace
;
165 /** The selected trace editor file*/
166 private IFile fEditorFile
;
168 /** The timegraph entry list */
169 private List
<TimeGraphEntry
> fEntryList
;
171 /** The trace to entry list hash map */
172 private final Map
<ITmfTrace
, List
<TimeGraphEntry
>> fEntryListMap
= new HashMap
<>();
174 /** The trace to filters hash map */
175 private final Map
<ITmfTrace
, @NonNull ViewerFilter
[]> fFiltersMap
= new HashMap
<>();
177 /** The trace to view context hash map */
178 private final Map
<ITmfTrace
, ViewContext
> fViewContext
= new HashMap
<>();
180 /** The trace to marker event sources hash map */
181 private final Map
<ITmfTrace
, List
<IMarkerEventSource
>> fMarkerEventSourcesMap
= new HashMap
<>();
183 /** The trace to build thread hash map */
184 private final Map
<ITmfTrace
, BuildThread
> fBuildThreadMap
= new HashMap
<>();
186 /** The start time */
187 private long fStartTime
= SWT
.DEFAULT
;
190 private long fEndTime
= SWT
.DEFAULT
;
192 /** The display width */
193 private final int fDisplayWidth
;
195 /** The zoom thread */
196 private ZoomThread fZoomThread
;
198 /** The next resource action */
199 private Action fNextResourceAction
;
201 /** The previous resource action */
202 private Action fPreviousResourceAction
;
204 /** A comparator class */
205 private Comparator
<ITimeGraphEntry
> fEntryComparator
= null;
207 /** The redraw state used to prevent unnecessary queuing of display runnables */
208 private State fRedrawState
= State
.IDLE
;
210 /** The redraw synchronization object */
211 private final Object fSyncObj
= new Object();
213 /** The presentation provider for this view */
214 private final TimeGraphPresentationProvider fPresentation
;
216 /** The tree column label array, or null if combo is not used */
217 private String
[] fColumns
;
219 private Comparator
<ITimeGraphEntry
>[] fColumnComparators
;
221 /** The tree label provider, or null if combo is not used */
222 private TreeLabelProvider fLabelProvider
= null;
224 /** The time graph content provider */
225 private @NonNull ITimeGraphContentProvider fTimeGraphContentProvider
= new TimeGraphContentProvider();
227 /** The relative weight of the sash, ignored if combo is not used */
228 private int[] fWeight
= { 1, 3 };
230 /** The filter column label array, or null if filter is not used */
231 private String
[] fFilterColumns
;
233 /** The pack done flag */
234 private boolean fPackDone
= false;
236 /** The filter content provider, or null if filter is not used */
237 private ITreeContentProvider fFilterContentProvider
;
239 /** The filter label provider, or null if filter is not used */
240 private TreeLabelProvider fFilterLabelProvider
;
242 private int fAutoExpandLevel
= ALL_LEVELS
;
244 /** The default column index for sorting */
245 private int fInitialSortColumn
= 0;
247 /** The default column index for sorting */
248 private int fCurrentSortColumn
= 0;
250 /** The current sort direction */
251 private int fSortDirection
= SWT
.DOWN
;
253 /** Flag to indicate to reveal selection */
254 private volatile boolean fIsRevealSelection
= false;
257 * Menu Manager for context-sensitive menu for time graph entries.
258 * This will be used on the tree viewer in case of the time graph combo
259 * or the on the namespace in case of a single time graph viewer.
261 private final @NonNull MenuManager fEntryMenuManager
= new MenuManager();
263 /** Time Graph View part listener */
264 private TimeGraphPartListener fPartListener
;
266 /** Action for the find command. There is only one for all Time Graph views */
267 private static final ShowFindDialogAction FIND_ACTION
= new ShowFindDialogAction();
269 /** The find action handler */
270 private static ActionHandler fFindActionHandler
;
272 /** The find handler activation */
273 private static IHandlerActivation fFindHandlerActivation
;
275 /** The find target to use */
276 private final FindTarget fFindTarget
;
278 // ------------------------------------------------------------------------
280 // ------------------------------------------------------------------------
282 private interface ITimeGraphWrapper
{
284 void setTimeGraphContentProvider(ITimeGraphContentProvider timeGraphContentProvider
);
286 void setTimeGraphPresentationProvider(TimeGraphPresentationProvider timeGraphPresentationProvider
);
288 TimeGraphViewer
getTimeGraphViewer();
290 void addSelectionListener(ITimeGraphSelectionListener listener
);
292 ISelectionProvider
getSelectionProvider();
296 boolean isDisposed();
300 void setInput(Object input
);
304 void setFilters(@NonNull ViewerFilter
[] filters
);
306 @NonNull ViewerFilter
[] getFilters();
312 void setAutoExpandLevel(int level
);
314 boolean getExpandedState(ITimeGraphEntry entry
);
316 void setExpandedState(ITimeGraphEntry entry
, boolean expanded
);
318 void setFilterColumns(String
[] columnNames
);
320 void setFilterContentProvider(ITreeContentProvider contentProvider
);
322 void setFilterLabelProvider(ITableLabelProvider labelProvider
);
324 IAction
getShowFilterDialogAction();
326 void performAlign(int offset
, int width
);
328 TmfTimeViewAlignmentInfo
getTimeViewAlignmentInfo();
330 int getAvailableWidth(int requestedOffset
);
332 ITimeGraphEntry
getSelection();
334 void setSelection(ITimeGraphEntry selection
);
336 void selectAndReveal(@NonNull ITimeGraphEntry selection
);
340 private class TimeGraphViewerWrapper
implements ITimeGraphWrapper
{
341 private TimeGraphViewer viewer
;
343 private TimeGraphViewerWrapper(Composite parent
, int style
) {
344 viewer
= new TimeGraphViewer(parent
, style
);
348 public void setTimeGraphContentProvider(ITimeGraphContentProvider timeGraphContentProvider
) {
349 viewer
.setTimeGraphContentProvider(timeGraphContentProvider
);
353 public void setTimeGraphPresentationProvider(TimeGraphPresentationProvider timeGraphPresentationProvider
) {
354 viewer
.setTimeGraphProvider(timeGraphPresentationProvider
);
358 public TimeGraphViewer
getTimeGraphViewer() {
363 public void addSelectionListener(ITimeGraphSelectionListener listener
) {
364 viewer
.addSelectionListener(listener
);
368 public ISelectionProvider
getSelectionProvider() {
369 return viewer
.getSelectionProvider();
373 public void setFocus() {
378 public boolean isDisposed() {
379 return viewer
.getControl().isDisposed();
383 public void setInput(Object input
) {
384 viewer
.setInput(input
);
388 public Object
getInput() {
389 return viewer
.getInput();
393 public void setFilterColumns(String
[] columnNames
) {
394 viewer
.setFilterColumns(columnNames
);
398 public void setFilterContentProvider(ITreeContentProvider contentProvider
) {
399 viewer
.setFilterContentProvider(contentProvider
);
403 public void setFilterLabelProvider(ITableLabelProvider labelProvider
) {
404 viewer
.setFilterLabelProvider(labelProvider
);
408 public void setFilters(@NonNull ViewerFilter
[] filters
) {
409 viewer
.setFilters(filters
);
413 public @NonNull ViewerFilter
[] getFilters() {
414 return viewer
.getFilters();
418 public IAction
getShowFilterDialogAction() {
419 return viewer
.getShowFilterDialogAction();
423 public void refresh() {
428 public void redraw() {
429 viewer
.getControl().redraw();
433 public void update() {
434 viewer
.getControl().update();
438 public void setAutoExpandLevel(int level
) {
439 viewer
.setAutoExpandLevel(level
);
443 public boolean getExpandedState(ITimeGraphEntry entry
) {
444 return viewer
.getExpandedState(entry
);
448 public void setExpandedState(ITimeGraphEntry entry
, boolean expanded
) {
449 viewer
.setExpandedState(entry
, expanded
);
453 public void performAlign(int offset
, int width
) {
454 viewer
.performAlign(offset
, width
);
458 public TmfTimeViewAlignmentInfo
getTimeViewAlignmentInfo() {
459 return viewer
.getTimeViewAlignmentInfo();
463 public int getAvailableWidth(int requestedOffset
) {
464 return viewer
.getAvailableWidth(requestedOffset
);
468 public ITimeGraphEntry
getSelection() {
469 return viewer
.getSelection();
473 public void setSelection(ITimeGraphEntry selection
) {
474 viewer
.setSelection(selection
);
478 public void selectAndReveal(@NonNull ITimeGraphEntry selection
) {
479 viewer
.selectAndReveal(selection
);
483 private class TimeGraphComboWrapper
implements ITimeGraphWrapper
{
484 private TimeGraphCombo combo
;
486 private TimeGraphComboWrapper(Composite parent
, int style
) {
487 combo
= new TimeGraphCombo(parent
, style
, fWeight
);
491 public void setTimeGraphContentProvider(ITimeGraphContentProvider timeGraphContentProvider
) {
492 combo
.setTimeGraphContentProvider(timeGraphContentProvider
);
496 public void setTimeGraphPresentationProvider(TimeGraphPresentationProvider timeGraphPresentationProvider
) {
497 combo
.setTimeGraphProvider(timeGraphPresentationProvider
);
501 public TimeGraphViewer
getTimeGraphViewer() {
502 return combo
.getTimeGraphViewer();
506 public void addSelectionListener(ITimeGraphSelectionListener listener
) {
507 combo
.addSelectionListener(listener
);
511 public ISelectionProvider
getSelectionProvider() {
512 return combo
.getTreeViewer();
516 public void setFocus() {
521 public boolean isDisposed() {
522 return combo
.isDisposed();
526 public void setInput(Object input
) {
527 combo
.setInput(input
);
531 public Object
getInput() {
532 return combo
.getInput();
536 public void setFilterColumns(String
[] columnNames
) {
537 combo
.setFilterColumns(columnNames
);
541 public void setFilterContentProvider(ITreeContentProvider contentProvider
) {
542 combo
.setFilterContentProvider(contentProvider
);
546 public void setFilterLabelProvider(ITableLabelProvider labelProvider
) {
547 combo
.setFilterLabelProvider(labelProvider
);
551 public void setFilters(@NonNull ViewerFilter
[] filters
) {
552 combo
.setFilters(filters
);
556 public @NonNull ViewerFilter
[] getFilters() {
557 return combo
.getFilters();
561 public IAction
getShowFilterDialogAction() {
562 return combo
.getShowFilterDialogAction();
566 public void refresh() {
571 public void redraw() {
576 public void update() {
581 public void setAutoExpandLevel(int level
) {
582 combo
.setAutoExpandLevel(level
);
586 public boolean getExpandedState(ITimeGraphEntry entry
) {
587 return combo
.getExpandedState(entry
);
591 public void setExpandedState(ITimeGraphEntry entry
, boolean expanded
) {
592 combo
.setExpandedState(entry
, expanded
);
595 TimeGraphCombo
getTimeGraphCombo() {
599 TreeViewer
getTreeViewer() {
600 return combo
.getTreeViewer();
604 public void performAlign(int offset
, int width
) {
605 combo
.performAlign(offset
, width
);
609 public TmfTimeViewAlignmentInfo
getTimeViewAlignmentInfo() {
610 return combo
.getTimeViewAlignmentInfo();
614 public int getAvailableWidth(int requestedOffset
) {
615 return combo
.getAvailableWidth(requestedOffset
);
619 public ITimeGraphEntry
getSelection() {
620 return combo
.getTimeGraphViewer().getSelection();
624 public void setSelection(ITimeGraphEntry selection
) {
625 combo
.setSelection(selection
);
629 public void selectAndReveal(@NonNull ITimeGraphEntry selection
) {
630 combo
.selectAndReveal(selection
);
635 * Base class to provide the labels for the tree viewer. Views extending
636 * this class typically need to override the getColumnText method if they
637 * have more than one column to display
639 protected static class TreeLabelProvider
implements ITableLabelProvider
, ILabelProvider
{
642 public void addListener(ILabelProviderListener listener
) {
646 public void dispose() {
650 public boolean isLabelProperty(Object element
, String property
) {
655 public void removeListener(ILabelProviderListener listener
) {
659 public Image
getColumnImage(Object element
, int columnIndex
) {
664 public String
getColumnText(Object element
, int columnIndex
) {
665 TimeGraphEntry entry
= (TimeGraphEntry
) element
;
666 if (columnIndex
== 0) {
667 return entry
.getName();
673 public Image
getImage(Object element
) {
678 public String
getText(Object element
) {
679 TimeGraphEntry entry
= (TimeGraphEntry
) element
;
680 return entry
.getName();
685 private class BuildThread
extends Thread
{
686 private final @NonNull ITmfTrace fBuildTrace
;
687 private final @NonNull ITmfTrace fParentTrace
;
688 private final @NonNull IProgressMonitor fMonitor
;
690 public BuildThread(final @NonNull ITmfTrace trace
, final @NonNull ITmfTrace parentTrace
, final String name
) {
691 super(name
+ " build"); //$NON-NLS-1$
693 fParentTrace
= parentTrace
;
694 fMonitor
= new NullProgressMonitor();
699 buildEntryList(fBuildTrace
, fParentTrace
, fMonitor
);
700 synchronized (fBuildThreadMap
) {
701 fBuildThreadMap
.remove(fBuildTrace
);
705 public void cancel() {
706 fMonitor
.setCanceled(true);
714 protected abstract class ZoomThread
extends Thread
{
715 private final long fZoomStartTime
;
716 private final long fZoomEndTime
;
717 private final long fResolution
;
718 private final @NonNull IProgressMonitor fMonitor
;
730 public ZoomThread(long startTime
, long endTime
, long resolution
) {
731 super(AbstractTimeGraphView
.this.getName() + " zoom"); //$NON-NLS-1$
732 fZoomStartTime
= startTime
;
733 fZoomEndTime
= endTime
;
734 fResolution
= resolution
;
735 fMonitor
= new NullProgressMonitor();
739 * @return the zoom start time
741 public long getZoomStartTime() {
742 return fZoomStartTime
;
746 * @return the zoom end time
748 public long getZoomEndTime() {
753 * @return the resolution
755 public long getResolution() {
760 * @return the monitor
762 public @NonNull IProgressMonitor
getMonitor() {
767 * Cancel the zoom thread
769 public void cancel() {
770 fMonitor
.setCanceled(true);
774 public final void run() {
776 fDirty
.decrementAndGet();
780 * Applies the results of the ZoomThread calculations.
782 * Note: This method makes sure that only the results of the last
783 * created ZoomThread are applied.
786 * the code to run in order to apply the results
789 protected void applyResults(Runnable runnable
) {
790 synchronized (fZoomThreadResultLock
) {
791 if (this == fZoomThread
) {
798 * Run the zoom operation.
801 public abstract void doRun();
804 private class ZoomThreadByEntry
extends ZoomThread
{
805 private final @NonNull List
<TimeGraphEntry
> fZoomEntryList
;
807 public ZoomThreadByEntry(@NonNull List
<TimeGraphEntry
> entryList
, long startTime
, long endTime
, long resolution
) {
808 super(startTime
, endTime
, resolution
);
809 fZoomEntryList
= entryList
;
813 public void doRun() {
814 for (TimeGraphEntry entry
: fZoomEntryList
) {
815 if (getMonitor().isCanceled()) {
821 zoom(entry
, getMonitor());
823 /* Refresh the arrows when zooming */
824 List
<ILinkEvent
> events
= getLinkList(getZoomStartTime(), getZoomEndTime(), getResolution(), getMonitor());
825 /* Refresh the view-specific markers when zooming */
826 List
<IMarkerEvent
> markers
= new ArrayList
<>(getViewMarkerList(getZoomStartTime(), getZoomEndTime(), getResolution(), getMonitor()));
827 /* Refresh the trace-specific markers when zooming */
828 markers
.addAll(getTraceMarkerList(getZoomStartTime(), getZoomEndTime(), getResolution(), getMonitor()));
830 if (events
!= null) {
831 fTimeGraphWrapper
.getTimeGraphViewer().setLinks(events
);
833 fTimeGraphWrapper
.getTimeGraphViewer().setMarkers(markers
);
838 private void zoom(@NonNull TimeGraphEntry entry
, @NonNull IProgressMonitor monitor
) {
839 if (getZoomStartTime() <= fStartTime
&& getZoomEndTime() >= fEndTime
) {
841 entry
.setZoomedEventList(null);
844 List
<ITimeEvent
> zoomedEventList
= getEventList(entry
, getZoomStartTime(), getZoomEndTime(), getResolution(), monitor
);
845 if (zoomedEventList
!= null) {
847 entry
.setZoomedEventList(zoomedEventList
);
852 for (TimeGraphEntry child
: entry
.getChildren()) {
853 if (monitor
.isCanceled()) {
856 zoom(child
, monitor
);
862 // ------------------------------------------------------------------------
864 // ------------------------------------------------------------------------
867 * Constructs a time graph view that contains either a time graph viewer or
868 * a time graph combo.
870 * By default, the view uses a time graph viewer. To use a time graph combo,
871 * the subclass constructor must call {@link #setTreeColumns(String[])} and
872 * {@link #setTreeLabelProvider(TreeLabelProvider)}.
877 * The presentation provider
879 public AbstractTimeGraphView(String id
, TimeGraphPresentationProvider pres
) {
881 fPresentation
= pres
;
882 fDisplayWidth
= Display
.getDefault().getBounds().width
;
883 fFindTarget
= new FindTarget();
886 // ------------------------------------------------------------------------
887 // Getters and setters
888 // ------------------------------------------------------------------------
891 * Getter for the time graph combo
893 * @return The time graph combo, or null if combo is not used
895 protected TimeGraphCombo
getTimeGraphCombo() {
896 if (fTimeGraphWrapper
instanceof TimeGraphComboWrapper
) {
897 return ((TimeGraphComboWrapper
) fTimeGraphWrapper
).getTimeGraphCombo();
903 * Getter for the time graph viewer
905 * @return The time graph viewer
907 protected TimeGraphViewer
getTimeGraphViewer() {
908 return fTimeGraphWrapper
.getTimeGraphViewer();
912 * Getter for the presentation provider
914 * @return The time graph presentation provider
916 protected ITimeGraphPresentationProvider2
getPresentationProvider() {
917 return fPresentation
;
921 * Sets the tree column labels.
923 * This should be called from the constructor.
926 * The array of tree column labels
928 protected void setTreeColumns(final String
[] columns
) {
929 setTreeColumns(columns
, null, 0);
933 * Sets the tree column labels.
935 * This should be called from the constructor.
938 * The array of tree column labels
940 * An array of column comparators for sorting of columns when
941 * clicking on column header
942 * @param initialSortColumn
943 * Index of column to sort initially
946 protected void setTreeColumns(final String
[] columns
, final Comparator
<ITimeGraphEntry
>[] comparators
, int initialSortColumn
) {
947 checkPartNotCreated();
949 fColumnComparators
= comparators
;
950 fInitialSortColumn
= initialSortColumn
;
954 * Sets the tree label provider.
956 * This should be called from the constructor.
959 * The tree label provider
961 protected void setTreeLabelProvider(final TreeLabelProvider tlp
) {
962 checkPartNotCreated();
963 fLabelProvider
= tlp
;
967 * Sets the time graph content provider.
969 * This should be called from the constructor.
972 * The time graph content provider
975 protected void setTimeGraphContentProvider(final @NonNull ITimeGraphContentProvider tgcp
) {
976 checkPartNotCreated();
977 fTimeGraphContentProvider
= tgcp
;
981 * Sets the relative weight of each part of the time graph combo.
983 * This should be called from the constructor.
986 * The array (length 2) of relative weights of each part of the combo
988 protected void setWeight(final int[] weights
) {
989 checkPartNotCreated();
994 * Sets the filter column labels.
996 * This should be called from the constructor.
998 * @param filterColumns
999 * The array of filter column labels
1001 protected void setFilterColumns(final String
[] filterColumns
) {
1002 checkPartNotCreated();
1003 fFilterColumns
= filterColumns
;
1007 * Sets the filter content provider.
1009 * This should be called from the constructor.
1011 * @param contentProvider
1012 * The filter content provider
1015 protected void setFilterContentProvider(final ITreeContentProvider contentProvider
) {
1016 checkPartNotCreated();
1017 fFilterContentProvider
= contentProvider
;
1021 * Sets the filter label provider.
1023 * This should be called from the constructor.
1025 * @param labelProvider
1026 * The filter label provider
1028 protected void setFilterLabelProvider(final TreeLabelProvider labelProvider
) {
1029 checkPartNotCreated();
1030 fFilterLabelProvider
= labelProvider
;
1033 private void checkPartNotCreated() {
1034 if (getParentComposite() != null) {
1035 throw new IllegalStateException("This method must be called before createPartControl."); //$NON-NLS-1$
1040 * Gets the display width
1042 * @return the display width
1044 protected int getDisplayWidth() {
1045 return fDisplayWidth
;
1049 * Gets the comparator for the entries
1051 * @return The entry comparator
1053 protected Comparator
<ITimeGraphEntry
> getEntryComparator() {
1054 return fEntryComparator
;
1058 * Sets the comparator class for the entries.
1060 * This comparator will apply recursively to entries that implement
1061 * {@link TimeGraphEntry#sortChildren(Comparator)}.
1064 * A comparator object
1066 protected void setEntryComparator(final Comparator
<ITimeGraphEntry
> comparator
) {
1067 fEntryComparator
= comparator
;
1071 * Gets the trace displayed in the view
1075 protected ITmfTrace
getTrace() {
1080 * Gets the start time
1082 * @return The start time
1084 protected long getStartTime() {
1089 * Sets the start time
1094 protected void setStartTime(long time
) {
1101 * @return The end time
1103 protected long getEndTime() {
1113 protected void setEndTime(long time
) {
1118 * Sets the auto-expand level to be used for the input of the view. The
1119 * value 0 means that there is no auto-expand; 1 means that top-level
1120 * elements are expanded, but not their children; 2 means that top-level
1121 * elements are expanded, and their children, but not grand-children; and so
1124 * The value {@link #ALL_LEVELS} means that all subtrees should be expanded.
1128 * non-negative level, or <code>ALL_LEVELS</code> to expand all
1129 * levels of the tree
1131 protected void setAutoExpandLevel(int level
) {
1132 fAutoExpandLevel
= level
;
1133 ITimeGraphWrapper tgWrapper
= fTimeGraphWrapper
;
1134 if (tgWrapper
!= null) {
1135 tgWrapper
.setAutoExpandLevel(level
);
1140 * Gets the entry list for a trace
1145 * @return the entry list map
1147 protected List
<TimeGraphEntry
> getEntryList(ITmfTrace trace
) {
1148 synchronized (fEntryListMap
) {
1149 return fEntryListMap
.get(trace
);
1154 * Adds a trace entry list to the entry list map
1159 * the list of time graph entries
1161 protected void putEntryList(ITmfTrace trace
, List
<TimeGraphEntry
> list
) {
1162 synchronized (fEntryListMap
) {
1163 fEntryListMap
.put(trace
, new CopyOnWriteArrayList
<>(list
));
1168 * Adds a list of entries to a trace's entry list
1173 * the list of time graph entries to add
1175 protected void addToEntryList(ITmfTrace trace
, List
<TimeGraphEntry
> list
) {
1176 synchronized (fEntryListMap
) {
1177 List
<TimeGraphEntry
> entryList
= fEntryListMap
.get(trace
);
1178 if (entryList
== null) {
1179 fEntryListMap
.put(trace
, new CopyOnWriteArrayList
<>(list
));
1181 entryList
.addAll(list
);
1187 * Removes a list of entries from a trace's entry list
1192 * the list of time graph entries to remove
1194 protected void removeFromEntryList(ITmfTrace trace
, List
<TimeGraphEntry
> list
) {
1195 synchronized (fEntryListMap
) {
1196 List
<TimeGraphEntry
> entryList
= fEntryListMap
.get(trace
);
1197 if (entryList
!= null) {
1198 entryList
.removeAll(list
);
1204 * Text for the "next" button
1206 * @return The "next" button text
1208 protected String
getNextText() {
1209 return Messages
.AbstractTimeGraphtView_NextText
;
1213 * Tooltip for the "next" button
1215 * @return Tooltip for the "next" button
1217 protected String
getNextTooltip() {
1218 return Messages
.AbstractTimeGraphView_NextTooltip
;
1222 * Text for the "Previous" button
1224 * @return The "Previous" button text
1226 protected String
getPrevText() {
1227 return Messages
.AbstractTimeGraphView_PreviousText
;
1231 * Tooltip for the "previous" button
1233 * @return Tooltip for the "previous" button
1235 protected String
getPrevTooltip() {
1236 return Messages
.AbstractTimeGraphView_PreviousTooltip
;
1240 FindTarget
getFindTarget() {
1244 // ------------------------------------------------------------------------
1246 // ------------------------------------------------------------------------
1249 public void createPartControl(Composite parent
) {
1250 super.createPartControl(parent
);
1251 if (fColumns
== null || fLabelProvider
== null) {
1252 fTimeGraphWrapper
= new TimeGraphViewerWrapper(parent
, SWT
.NONE
);
1254 TimeGraphComboWrapper wrapper
= new TimeGraphComboWrapper(parent
, SWT
.NONE
);
1255 fTimeGraphWrapper
= wrapper
;
1256 TimeGraphCombo combo
= wrapper
.getTimeGraphCombo();
1257 combo
.setTreeContentProvider(fTimeGraphContentProvider
);
1258 combo
.setTreeLabelProvider(fLabelProvider
);
1259 combo
.setTreeColumns(fColumns
);
1260 if (fColumnComparators
!= null) {
1261 createColumnSelectionListener(combo
.getTreeViewer());
1263 // Add double click listener to tree viewer
1264 createDoubleClickListener(combo
.getTreeViewer());
1266 fTimeGraphWrapper
.setTimeGraphContentProvider(fTimeGraphContentProvider
);
1267 fTimeGraphWrapper
.setFilterContentProvider(fFilterContentProvider
!= null ? fFilterContentProvider
: fTimeGraphContentProvider
);
1268 fTimeGraphWrapper
.setFilterLabelProvider(fFilterLabelProvider
);
1269 fTimeGraphWrapper
.setFilterColumns(fFilterColumns
);
1271 fTimeGraphWrapper
.setTimeGraphPresentationProvider(fPresentation
);
1272 fTimeGraphWrapper
.setAutoExpandLevel(fAutoExpandLevel
);
1274 fTimeGraphWrapper
.getTimeGraphViewer().addRangeListener(new ITimeGraphRangeListener() {
1276 public void timeRangeUpdated(TimeGraphRangeUpdateEvent event
) {
1277 final long startTime
= event
.getStartTime();
1278 final long endTime
= event
.getEndTime();
1279 TmfTimeRange range
= new TmfTimeRange(new TmfNanoTimestamp(startTime
), new TmfNanoTimestamp(endTime
));
1280 broadcast(new TmfWindowRangeUpdatedSignal(AbstractTimeGraphView
.this, range
));
1281 startZoomThread(startTime
, endTime
);
1285 fTimeGraphWrapper
.getTimeGraphViewer().addTimeListener(new ITimeGraphTimeListener() {
1287 public void timeSelected(TimeGraphTimeEvent event
) {
1288 TmfNanoTimestamp startTime
= new TmfNanoTimestamp(event
.getBeginTime());
1289 TmfNanoTimestamp endTime
= new TmfNanoTimestamp(event
.getEndTime());
1290 broadcast(new TmfSelectionRangeUpdatedSignal(AbstractTimeGraphView
.this, startTime
, endTime
));
1294 fTimeGraphWrapper
.getTimeGraphViewer().addBookmarkListener(new ITimeGraphBookmarkListener() {
1296 public void bookmarkAdded(final TimeGraphBookmarkEvent event
) {
1298 ResourcesPlugin
.getWorkspace().run(new IWorkspaceRunnable() {
1300 public void run(IProgressMonitor monitor
) throws CoreException
{
1301 IMarkerEvent bookmark
= event
.getBookmark();
1302 IMarker marker
= fEditorFile
.createMarker(IMarker
.BOOKMARK
);
1303 marker
.setAttribute(IMarker
.MESSAGE
, bookmark
.getLabel());
1304 marker
.setAttribute(ITmfMarker
.MARKER_TIME
, Long
.toString(bookmark
.getTime()));
1305 if (bookmark
.getDuration() > 0) {
1306 marker
.setAttribute(ITmfMarker
.MARKER_DURATION
, Long
.toString(bookmark
.getDuration()));
1307 marker
.setAttribute(IMarker
.LOCATION
,
1308 NLS
.bind(org
.eclipse
.tracecompass
.internal
.tmf
.ui
.Messages
.TmfMarker_LocationTimeRange
,
1309 new TmfNanoTimestamp(bookmark
.getTime()),
1310 new TmfNanoTimestamp(bookmark
.getTime() + bookmark
.getDuration())));
1312 marker
.setAttribute(IMarker
.LOCATION
,
1313 NLS
.bind(org
.eclipse
.tracecompass
.internal
.tmf
.ui
.Messages
.TmfMarker_LocationTime
,
1314 new TmfNanoTimestamp(bookmark
.getTime())));
1316 marker
.setAttribute(ITmfMarker
.MARKER_COLOR
, bookmark
.getColor().toString());
1319 } catch (CoreException e
) {
1320 Activator
.getDefault().logError(e
.getMessage());
1325 public void bookmarkRemoved(TimeGraphBookmarkEvent event
) {
1327 IMarkerEvent bookmark
= event
.getBookmark();
1328 IMarker
[] markers
= fEditorFile
.findMarkers(IMarker
.BOOKMARK
, false, IResource
.DEPTH_ZERO
);
1329 for (IMarker marker
: markers
) {
1330 if (bookmark
.getLabel().equals(marker
.getAttribute(IMarker
.MESSAGE
)) &&
1331 Long
.toString(bookmark
.getTime()).equals(marker
.getAttribute(ITmfMarker
.MARKER_TIME
, (String
) null)) &&
1332 Long
.toString(bookmark
.getDuration()).equals(marker
.getAttribute(ITmfMarker
.MARKER_DURATION
, Long
.toString(0))) &&
1333 bookmark
.getColor().toString().equals(marker
.getAttribute(ITmfMarker
.MARKER_COLOR
))) {
1338 } catch (CoreException e
) {
1339 Activator
.getDefault().logError(e
.getMessage());
1344 fTimeGraphWrapper
.getTimeGraphViewer().setTimeFormat(TimeFormat
.CALENDAR
);
1346 IStatusLineManager statusLineManager
= getViewSite().getActionBars().getStatusLineManager();
1347 fTimeGraphWrapper
.getTimeGraphViewer().getTimeGraphControl().setStatusLineManager(statusLineManager
);
1349 // View Action Handling
1351 contributeToActionBars();
1353 ITmfTrace trace
= TmfTraceManager
.getInstance().getActiveTrace();
1354 if (trace
!= null) {
1355 traceSelected(new TmfTraceSelectedSignal(this, trace
));
1358 // make selection available to other views
1359 getSite().setSelectionProvider(fTimeGraphWrapper
.getSelectionProvider());
1361 ResourcesPlugin
.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent
.POST_CHANGE
);
1363 createContextMenu();
1364 fPartListener
= new TimeGraphPartListener();
1365 getSite().getPage().addPartListener(fPartListener
);
1369 public void setFocus() {
1370 fTimeGraphWrapper
.setFocus();
1374 public void dispose() {
1376 ResourcesPlugin
.getWorkspace().removeResourceChangeListener(this);
1377 getSite().getPage().removePartListener(fPartListener
);
1384 public void resourceChanged(final IResourceChangeEvent event
) {
1385 for (final IMarkerDelta delta
: event
.findMarkerDeltas(IMarker
.BOOKMARK
, false)) {
1386 if (delta
.getResource().equals(fEditorFile
)) {
1387 fTimeGraphWrapper
.getTimeGraphViewer().setBookmarks(refreshBookmarks(fEditorFile
));
1394 private static List
<IMarkerEvent
> refreshBookmarks(final IFile editorFile
) {
1395 List
<IMarkerEvent
> bookmarks
= new ArrayList
<>();
1396 if (editorFile
== null || !editorFile
.exists()) {
1400 IMarker
[] markers
= editorFile
.findMarkers(IMarker
.BOOKMARK
, false, IResource
.DEPTH_ZERO
);
1401 for (IMarker marker
: markers
) {
1402 String label
= marker
.getAttribute(IMarker
.MESSAGE
, (String
) null);
1403 String time
= marker
.getAttribute(ITmfMarker
.MARKER_TIME
, (String
) null);
1404 String duration
= marker
.getAttribute(ITmfMarker
.MARKER_DURATION
, Long
.toString(0));
1405 String rgba
= marker
.getAttribute(ITmfMarker
.MARKER_COLOR
, (String
) null);
1406 if (label
!= null && time
!= null && rgba
!= null) {
1407 Matcher matcher
= RGBA_PATTERN
.matcher(rgba
);
1408 if (matcher
.matches()) {
1410 int red
= Integer
.valueOf(matcher
.group(1));
1411 int green
= Integer
.valueOf(matcher
.group(2));
1412 int blue
= Integer
.valueOf(matcher
.group(3));
1413 int alpha
= Integer
.valueOf(matcher
.group(4));
1414 RGBA color
= new RGBA(red
, green
, blue
, alpha
);
1415 bookmarks
.add(new MarkerEvent(null, Long
.valueOf(time
), Long
.valueOf(duration
), IMarkerEvent
.BOOKMARKS
, color
, label
, true));
1416 } catch (NumberFormatException e
) {
1417 Activator
.getDefault().logError(e
.getMessage());
1422 } catch (CoreException e
) {
1423 Activator
.getDefault().logError(e
.getMessage());
1430 // ------------------------------------------------------------------------
1432 // ------------------------------------------------------------------------
1435 * Handler for the trace opened signal.
1438 * The incoming signal
1441 public void traceOpened(TmfTraceOpenedSignal signal
) {
1442 loadTrace(signal
.getTrace());
1446 * Handler for the trace selected signal
1449 * The incoming signal
1452 public void traceSelected(final TmfTraceSelectedSignal signal
) {
1453 if (signal
.getTrace() == fTrace
) {
1456 loadTrace(signal
.getTrace());
1460 * Trace is closed: clear the data structures and the view
1463 * the signal received
1466 public void traceClosed(final TmfTraceClosedSignal signal
) {
1467 synchronized (fBuildThreadMap
) {
1468 for (ITmfTrace trace
: getTracesToBuild(signal
.getTrace())) {
1469 BuildThread buildThread
= fBuildThreadMap
.remove(trace
);
1470 if (buildThread
!= null) {
1471 buildThread
.cancel();
1475 fMarkerEventSourcesMap
.remove(signal
.getTrace());
1476 synchronized (fEntryListMap
) {
1477 fEntryListMap
.remove(signal
.getTrace());
1479 fFiltersMap
.remove(signal
.getTrace());
1480 fViewContext
.remove(signal
.getTrace());
1481 if (signal
.getTrace() == fTrace
) {
1484 fStartTime
= SWT
.DEFAULT
;
1485 fEndTime
= SWT
.DEFAULT
;
1486 if (fZoomThread
!= null) {
1487 fZoomThread
.cancel();
1495 * Handler for the selection range signal.
1498 * The signal that's received
1502 public void selectionRangeUpdated(final TmfSelectionRangeUpdatedSignal signal
) {
1503 if (signal
.getSource() == this || fTrace
== null) {
1506 final long beginTime
= signal
.getBeginTime().toNanos();
1507 final long endTime
= signal
.getEndTime().toNanos();
1509 Display
.getDefault().asyncExec(new Runnable() {
1512 if (fTimeGraphWrapper
.isDisposed()) {
1515 if (beginTime
== endTime
) {
1516 fTimeGraphWrapper
.getTimeGraphViewer().setSelectedTime(beginTime
, true);
1518 fTimeGraphWrapper
.getTimeGraphViewer().setSelectionRange(beginTime
, endTime
, true);
1520 synchingToTime(fTimeGraphWrapper
.getTimeGraphViewer().getSelectionBegin());
1526 * Handler for the window range signal.
1529 * The signal that's received
1533 public void windowRangeUpdated(final TmfWindowRangeUpdatedSignal signal
) {
1534 if (signal
.getSource() == this || fTrace
== null) {
1537 if (signal
.getCurrentRange().getIntersection(fTrace
.getTimeRange()) == null) {
1540 final long startTime
= signal
.getCurrentRange().getStartTime().toNanos();
1541 final long endTime
= signal
.getCurrentRange().getEndTime().toNanos();
1542 Display
.getDefault().asyncExec(new Runnable() {
1545 if (fTimeGraphWrapper
.isDisposed()) {
1548 fTimeGraphWrapper
.getTimeGraphViewer().setStartFinishTime(startTime
, endTime
);
1549 startZoomThread(startTime
, endTime
);
1555 * @param signal the format of the timestamps was updated.
1558 public void updateTimeFormat( final TmfTimestampFormatUpdateSignal signal
){
1559 fTimeGraphWrapper
.refresh();
1562 // ------------------------------------------------------------------------
1564 // ------------------------------------------------------------------------
1566 private void loadTrace(final ITmfTrace trace
) {
1567 if (fZoomThread
!= null) {
1568 fZoomThread
.cancel();
1571 if (fTrace
!= null) {
1572 /* save the filters of the previous trace */
1573 fFiltersMap
.put(fTrace
, fTimeGraphWrapper
.getFilters());
1574 fViewContext
.put(fTrace
, new ViewContext(fCurrentSortColumn
, fSortDirection
, fTimeGraphWrapper
.getSelection()));
1577 restoreViewContext();
1578 fEditorFile
= TmfTraceManager
.getInstance().getTraceEditorFile(trace
);
1579 synchronized (fEntryListMap
) {
1580 fEntryList
= fEntryListMap
.get(fTrace
);
1581 if (fEntryList
== null) {
1584 fStartTime
= fTrace
.getStartTime().toNanos();
1585 fEndTime
= fTrace
.getEndTime().toNanos();
1592 * Forces a rebuild of the entries list, even if entries already exist for this trace
1594 protected void rebuild() {
1595 setStartTime(Long
.MAX_VALUE
);
1596 setEndTime(Long
.MIN_VALUE
);
1598 ITmfTrace viewTrace
= fTrace
;
1599 if (viewTrace
== null) {
1602 List
<IMarkerEventSource
> markerEventSources
= new ArrayList
<>();
1603 synchronized (fBuildThreadMap
) {
1604 for (ITmfTrace trace
: getTracesToBuild(viewTrace
)) {
1605 if (trace
== null) {
1608 markerEventSources
.addAll(TmfTraceAdapterManager
.getAdapters(trace
, IMarkerEventSource
.class));
1609 BuildThread buildThread
= new BuildThread(trace
, viewTrace
, getName());
1610 fBuildThreadMap
.put(trace
, buildThread
);
1611 buildThread
.start();
1614 fMarkerEventSourcesMap
.put(viewTrace
, markerEventSources
);
1618 * Method called when synching to a given timestamp. Inheriting classes can
1619 * perform actions here to update the view at the given timestamp.
1622 * The currently selected time
1624 protected void synchingToTime(long time
) {
1629 * Return the list of traces whose data or analysis results will be used to
1630 * populate the view. By default, if the trace is an experiment, the traces
1631 * under it will be returned, otherwise, the trace itself is returned.
1633 * A build thread will be started for each trace returned by this method,
1634 * some of which may receive events in live streaming mode.
1637 * The trace associated with this view
1638 * @return List of traces with data to display
1640 protected @NonNull Iterable
<ITmfTrace
> getTracesToBuild(@NonNull ITmfTrace trace
) {
1641 return TmfTraceManager
.getTraceSet(trace
);
1645 * Build the entry list to show in this time graph view.
1647 * Called from the BuildThread for each trace returned by
1648 * {@link #getTracesToBuild(ITmfTrace)}. The full event list is also
1649 * normally computed for every entry that is created.
1652 * The trace being built
1653 * @param parentTrace
1654 * The parent of the trace set, or the trace itself
1656 * The progress monitor object
1659 protected abstract void buildEntryList(@NonNull ITmfTrace trace
, @NonNull ITmfTrace parentTrace
, @NonNull IProgressMonitor monitor
);
1662 * Gets the list of event for an entry in a given time range.
1664 * Called from the ZoomThread for every entry to update the zoomed event
1665 * list. Can be an empty implementation if the view does not support zoomed
1666 * event lists. Can also be used to compute the full event list.
1669 * The entry to get events for
1671 * Start of the time range
1673 * End of the time range
1677 * The progress monitor object
1678 * @return The list of events for the entry
1680 protected abstract @Nullable List
<@NonNull ITimeEvent
> getEventList(@NonNull TimeGraphEntry entry
,
1681 long startTime
, long endTime
, long resolution
,
1682 @NonNull IProgressMonitor monitor
);
1685 * Gets the list of links (displayed as arrows) for a trace in a given
1686 * timerange. Default implementation returns an empty list.
1689 * Start of the time range
1691 * End of the time range
1695 * The progress monitor object
1696 * @return The list of link events
1698 protected @Nullable List
<@NonNull ILinkEvent
> getLinkList(long startTime
, long endTime
,
1699 long resolution
, @NonNull IProgressMonitor monitor
) {
1700 return new ArrayList
<>();
1704 * Gets the list of view-specific marker categories. Default implementation
1705 * returns an empty list.
1707 * @return The list of marker categories
1710 protected @NonNull List
<String
> getViewMarkerCategories() {
1711 return new ArrayList
<>();
1715 * Gets the list of view-specific markers for a trace in a given time range.
1716 * Default implementation returns an empty list.
1719 * Start of the time range
1721 * End of the time range
1725 * The progress monitor object
1726 * @return The list of marker events
1729 protected @NonNull List
<IMarkerEvent
> getViewMarkerList(long startTime
, long endTime
,
1730 long resolution
, @NonNull IProgressMonitor monitor
) {
1731 return new ArrayList
<>();
1735 * Gets the list of trace-specific markers for a trace in a given time range.
1738 * Start of the time range
1740 * End of the time range
1744 * The progress monitor object
1745 * @return The list of marker events
1748 protected @NonNull List
<IMarkerEvent
> getTraceMarkerList(long startTime
, long endTime
,
1749 long resolution
, @NonNull IProgressMonitor monitor
) {
1750 List
<IMarkerEvent
> markers
= new ArrayList
<>();
1751 for (IMarkerEventSource markerEventSource
: getMarkerEventSources(fTrace
)) {
1752 for (String category
: markerEventSource
.getMarkerCategories()) {
1753 if (monitor
.isCanceled()) {
1756 markers
.addAll(markerEventSource
.getMarkerList(category
, startTime
, endTime
, resolution
, monitor
));
1763 * Get the list of current marker categories.
1765 * @return The list of marker categories
1768 private @NonNull List
<String
> getMarkerCategories() {
1769 Set
<String
> categories
= new LinkedHashSet
<>(getViewMarkerCategories());
1770 for (IMarkerEventSource markerEventSource
: getMarkerEventSources(fTrace
)) {
1771 categories
.addAll(markerEventSource
.getMarkerCategories());
1773 return new ArrayList
<>(categories
);
1777 * Gets the list of marker event sources for a given trace.
1781 * @return The list of marker event sources
1784 private @NonNull List
<IMarkerEventSource
> getMarkerEventSources(ITmfTrace trace
) {
1785 List
<IMarkerEventSource
> markerEventSources
= fMarkerEventSourcesMap
.get(trace
);
1786 if (markerEventSources
== null) {
1787 markerEventSources
= Collections
.emptyList();
1789 return markerEventSources
;
1793 * Refresh the display
1795 protected void refresh() {
1796 final boolean zoomThread
= Thread
.currentThread() instanceof ZoomThread
;
1797 TmfUiRefreshHandler
.getInstance().queueUpdate(this, new Runnable() {
1800 if (fTimeGraphWrapper
.isDisposed()) {
1803 fDirty
.incrementAndGet();
1805 boolean hasEntries
= false;
1806 synchronized (fEntryListMap
) {
1807 fEntryList
= fEntryListMap
.get(fTrace
);
1808 if (fEntryList
== null) {
1809 fEntryList
= new CopyOnWriteArrayList
<>();
1810 } else if (fEntryComparator
!= null) {
1811 List
<TimeGraphEntry
> list
= new ArrayList
<>(fEntryList
);
1812 Collections
.sort(list
, fEntryComparator
);
1813 for (ITimeGraphEntry entry
: list
) {
1814 sortChildren(entry
, fEntryComparator
);
1817 fEntryList
.addAll(list
);
1819 hasEntries
= !fEntryList
.isEmpty();
1821 boolean inputChanged
= fEntryList
!= fTimeGraphWrapper
.getInput();
1822 TimeGraphCombo combo
= getTimeGraphCombo();
1824 // Set redraw to false to only draw once
1825 if (combo
!= null) {
1826 combo
.getTreeViewer().getTree().setRedraw(false);
1828 getTimeGraphViewer().getTimeGraphControl().setRedraw(false);
1830 fTimeGraphWrapper
.setInput(fEntryList
);
1831 /* restore the previously saved filters, if any */
1832 fTimeGraphWrapper
.setFilters(fFiltersMap
.get(fTrace
));
1833 fTimeGraphWrapper
.getTimeGraphViewer().setLinks(null);
1834 fTimeGraphWrapper
.getTimeGraphViewer().setBookmarks(refreshBookmarks(fEditorFile
));
1835 fTimeGraphWrapper
.getTimeGraphViewer().setMarkerCategories(getMarkerCategories());
1836 fTimeGraphWrapper
.getTimeGraphViewer().setMarkers(null);
1839 fTimeGraphWrapper
.refresh();
1842 if (fIsRevealSelection
) {
1843 fIsRevealSelection
= false;
1844 ITimeGraphEntry entry1
= fTimeGraphWrapper
.getSelection();
1845 fTimeGraphWrapper
.setSelection(entry1
);
1848 if (combo
!= null) {
1849 combo
.getTreeViewer().getTree().setRedraw(true);
1851 getTimeGraphViewer().getTimeGraphControl().setRedraw(true);
1853 long startBound
= (fStartTime
== Long
.MAX_VALUE ? SWT
.DEFAULT
: fStartTime
);
1854 long endBound
= (fEndTime
== Long
.MIN_VALUE ? SWT
.DEFAULT
: fEndTime
);
1855 fTimeGraphWrapper
.getTimeGraphViewer().setTimeBounds(startBound
, endBound
);
1857 TmfTraceContext ctx
= TmfTraceManager
.getInstance().getCurrentTraceContext();
1858 long selectionBeginTime
= fTrace
== null ? SWT
.DEFAULT
: ctx
.getSelectionRange().getStartTime().toNanos();
1859 long selectionEndTime
= fTrace
== null ? SWT
.DEFAULT
: ctx
.getSelectionRange().getEndTime().toNanos();
1860 long startTime
= fTrace
== null ? SWT
.DEFAULT
: ctx
.getWindowRange().getStartTime().toNanos();
1861 long endTime
= fTrace
== null ? SWT
.DEFAULT
: ctx
.getWindowRange().getEndTime().toNanos();
1862 startTime
= (fStartTime
== Long
.MAX_VALUE ? SWT
.DEFAULT
: Math
.max(startTime
, fStartTime
));
1863 endTime
= (fEndTime
== Long
.MIN_VALUE ? SWT
.DEFAULT
: Math
.min(endTime
, fEndTime
));
1864 fTimeGraphWrapper
.getTimeGraphViewer().setSelectionRange(selectionBeginTime
, selectionEndTime
, false);
1865 fTimeGraphWrapper
.getTimeGraphViewer().setStartFinishTime(startTime
, endTime
);
1867 if (inputChanged
&& selectionBeginTime
!= SWT
.DEFAULT
) {
1868 synchingToTime(selectionBeginTime
);
1871 if (fTimeGraphWrapper
instanceof TimeGraphComboWrapper
&& !fPackDone
) {
1872 for (TreeColumn column
: ((TimeGraphComboWrapper
) fTimeGraphWrapper
).getTreeViewer().getTree().getColumns()) {
1881 startZoomThread(startTime
, endTime
);
1883 fDirty
.decrementAndGet();
1891 protected void redraw() {
1892 synchronized (fSyncObj
) {
1893 if (fRedrawState
== State
.IDLE
) {
1894 fRedrawState
= State
.BUSY
;
1896 fRedrawState
= State
.PENDING
;
1900 Display
.getDefault().asyncExec(new Runnable() {
1903 if (fTimeGraphWrapper
.isDisposed()) {
1906 fTimeGraphWrapper
.redraw();
1907 fTimeGraphWrapper
.update();
1908 synchronized (fSyncObj
) {
1909 if (fRedrawState
== State
.PENDING
) {
1910 fRedrawState
= State
.IDLE
;
1913 fRedrawState
= State
.IDLE
;
1920 private void sortChildren(ITimeGraphEntry entry
, Comparator
<ITimeGraphEntry
> comparator
) {
1921 if (entry
instanceof TimeGraphEntry
) {
1922 ((TimeGraphEntry
) entry
).sortChildren(comparator
);
1924 for (ITimeGraphEntry child
: entry
.getChildren()) {
1925 sortChildren(child
, comparator
);
1930 * Start or restart the zoom thread.
1933 * the zoom start time
1938 protected final void startZoomThread(long startTime
, long endTime
) {
1939 long clampedStartTime
= Math
.min(Math
.max(startTime
, fStartTime
), fEndTime
);
1940 long clampedEndTime
= Math
.max(Math
.min(endTime
, fEndTime
), fStartTime
);
1941 fDirty
.incrementAndGet();
1942 boolean restart
= false;
1943 if (fZoomThread
!= null) {
1944 fZoomThread
.cancel();
1945 if (fZoomThread
.fZoomStartTime
== clampedStartTime
&& fZoomThread
.fZoomEndTime
== clampedEndTime
) {
1949 long resolution
= Math
.max(1, (clampedEndTime
- clampedStartTime
) / fDisplayWidth
);
1950 fZoomThread
= createZoomThread(clampedStartTime
, clampedEndTime
, resolution
, restart
);
1951 if (fZoomThread
!= null) {
1952 // Don't start a new thread right away if results are being applied
1953 // from an old ZoomThread. Otherwise, the old results might
1954 // overwrite the new results if it finishes after.
1955 synchronized (fZoomThreadResultLock
) {
1956 fZoomThread
.start();
1959 fDirty
.decrementAndGet();
1964 * Create a zoom thread.
1967 * the zoom start time
1973 * true if restarting zoom for the same time range
1974 * @return a zoom thread
1977 protected @Nullable ZoomThread
createZoomThread(long startTime
, long endTime
, long resolution
, boolean restart
) {
1978 final List
<TimeGraphEntry
> entryList
= fEntryList
;
1979 if (entryList
== null) {
1982 return new ZoomThreadByEntry(entryList
, startTime
, endTime
, resolution
);
1985 private void makeActions() {
1986 fPreviousResourceAction
= fTimeGraphWrapper
.getTimeGraphViewer().getPreviousItemAction();
1987 fPreviousResourceAction
.setText(getPrevText());
1988 fPreviousResourceAction
.setToolTipText(getPrevTooltip());
1989 fNextResourceAction
= fTimeGraphWrapper
.getTimeGraphViewer().getNextItemAction();
1990 fNextResourceAction
.setText(getNextText());
1991 fNextResourceAction
.setToolTipText(getNextTooltip());
1994 private void contributeToActionBars() {
1995 IActionBars bars
= getViewSite().getActionBars();
1996 fillLocalToolBar(bars
.getToolBarManager());
1997 fillLocalMenu(bars
.getMenuManager());
2001 * Add actions to local tool bar manager
2003 * @param manager the tool bar manager
2005 protected void fillLocalToolBar(IToolBarManager manager
) {
2006 if (fFilterColumns
!= null && fFilterLabelProvider
!= null && fFilterColumns
.length
> 0) {
2007 manager
.add(fTimeGraphWrapper
.getShowFilterDialogAction());
2009 manager
.add(fTimeGraphWrapper
.getTimeGraphViewer().getShowLegendAction());
2010 manager
.add(new Separator());
2011 manager
.add(fTimeGraphWrapper
.getTimeGraphViewer().getResetScaleAction());
2012 manager
.add(fTimeGraphWrapper
.getTimeGraphViewer().getPreviousEventAction());
2013 manager
.add(fTimeGraphWrapper
.getTimeGraphViewer().getNextEventAction());
2014 manager
.add(new Separator());
2015 manager
.add(fTimeGraphWrapper
.getTimeGraphViewer().getToggleBookmarkAction());
2016 manager
.add(fTimeGraphWrapper
.getTimeGraphViewer().getPreviousMarkerAction());
2017 manager
.add(fTimeGraphWrapper
.getTimeGraphViewer().getNextMarkerAction());
2018 manager
.add(new Separator());
2019 manager
.add(fPreviousResourceAction
);
2020 manager
.add(fNextResourceAction
);
2021 manager
.add(fTimeGraphWrapper
.getTimeGraphViewer().getZoomInAction());
2022 manager
.add(fTimeGraphWrapper
.getTimeGraphViewer().getZoomOutAction());
2023 manager
.add(new Separator());
2027 * Add actions to local menu manager
2029 * @param manager the tool bar manager
2032 protected void fillLocalMenu(IMenuManager manager
) {
2033 manager
.add(fTimeGraphWrapper
.getTimeGraphViewer().getMarkersMenu());
2040 public TmfTimeViewAlignmentInfo
getTimeViewAlignmentInfo() {
2041 if (fTimeGraphWrapper
== null) {
2044 return fTimeGraphWrapper
.getTimeViewAlignmentInfo();
2051 public int getAvailableWidth(int requestedOffset
) {
2052 if (fTimeGraphWrapper
== null) {
2055 return fTimeGraphWrapper
.getAvailableWidth(requestedOffset
);
2062 public void performAlign(int offset
, int width
) {
2063 if (fTimeGraphWrapper
!= null) {
2064 fTimeGraphWrapper
.performAlign(offset
, width
);
2069 * Returns whether or not the time graph view is dirty. The time graph view
2070 * is considered dirty if it has yet to completely update its model.
2072 * This method is meant to be used by tests in order to know when it is safe
2075 * Note: If a trace is smaller than the initial window range (see
2076 * {@link ITmfTrace#getInitialRangeOffset}) this method will return true
2079 * @return true if the time graph view has yet to completely update its
2080 * model, false otherwise
2083 public boolean isDirty() {
2084 if (fTrace
== null) {
2088 TmfTraceContext ctx
= TmfTraceManager
.getInstance().getCurrentTraceContext();
2089 long startTime
= ctx
.getWindowRange().getStartTime().toNanos();
2090 long endTime
= ctx
.getWindowRange().getEndTime().toNanos();
2092 // If the time graph control hasn't updated all the way to the end of
2093 // the window range then it's dirty. A refresh should happen later.
2094 if (fTimeGraphWrapper
.getTimeGraphViewer().getTime0() != startTime
|| fTimeGraphWrapper
.getTimeGraphViewer().getTime1() != endTime
) {
2098 if (fZoomThread
== null) {
2099 // The zoom thread is null but we might be just about to create it (refresh called).
2100 return fDirty
.get() != 0;
2102 // Dirty if the zoom thread is not done or if it hasn't zoomed all the
2103 // way to the end of the window range. In the latter case, there should be
2104 // a subsequent zoom thread that will be triggered.
2105 return fDirty
.get() != 0 || fZoomThread
.getZoomStartTime() != startTime
|| fZoomThread
.getZoomEndTime() != endTime
;
2108 private void createColumnSelectionListener(TreeViewer treeViewer
) {
2109 for (int i
= 0; i
< fColumnComparators
.length
; i
++) {
2110 final int index
= i
;
2111 final Comparator
<ITimeGraphEntry
> comp
= fColumnComparators
[index
];
2112 final Tree tree
= treeViewer
.getTree();
2113 final TreeColumn column
= tree
.getColumn(i
);
2116 column
.addSelectionListener(new SelectionAdapter() {
2118 public void widgetSelected(SelectionEvent e
) {
2119 TreeColumn prevSortcolumn
= tree
.getSortColumn();
2120 int direction
= tree
.getSortDirection();
2121 if (prevSortcolumn
== column
) {
2122 direction
= (direction
== SWT
.DOWN
) ? SWT
.UP
: SWT
.DOWN
;
2124 direction
= SWT
.DOWN
;
2126 tree
.setSortColumn(column
);
2127 tree
.setSortDirection(direction
);
2128 fSortDirection
= direction
;
2129 fCurrentSortColumn
= index
;
2130 Comparator
<ITimeGraphEntry
> comparator
= comp
;
2132 if (comparator
instanceof ITimeGraphEntryComparator
) {
2133 ((ITimeGraphEntryComparator
) comparator
).setDirection(direction
);
2135 if (direction
!= SWT
.DOWN
) {
2136 comparator
= checkNotNull(Collections
.reverseOrder(comparator
));
2138 setEntryComparator(comparator
);
2139 fIsRevealSelection
= true;
2140 if (fTimeGraphWrapper
instanceof TimeGraphComboWrapper
) {
2141 ((TimeGraphComboWrapper
) fTimeGraphWrapper
).getTreeViewer().getControl().setFocus();
2150 private void createDoubleClickListener(TreeViewer treeViewer
) {
2151 treeViewer
.addDoubleClickListener(event
-> {
2152 if (event
.getSelection() instanceof TreeSelection
) {
2153 TreeSelection selection
= (TreeSelection
) event
.getSelection();
2154 if (selection
.getFirstElement() instanceof ITimeGraphEntry
) {
2155 ITimeGraphEntry entry
= (ITimeGraphEntry
) selection
.getFirstElement();
2156 if (entry
.hasChildren()) {
2157 fTimeGraphWrapper
.setExpandedState(entry
, !fTimeGraphWrapper
.getExpandedState(entry
));
2165 private void restoreViewContext() {
2166 TimeGraphCombo combo
= getTimeGraphCombo();
2167 ViewContext viewContext
= fViewContext
.get(fTrace
);
2168 if (combo
!= null) {
2169 if (fColumnComparators
!= null) {
2170 // restore sort settings
2171 fSortDirection
= SWT
.DOWN
;
2172 fCurrentSortColumn
= fInitialSortColumn
;
2173 if (viewContext
!= null) {
2174 fSortDirection
= viewContext
.getSortDirection();
2175 fCurrentSortColumn
= viewContext
.getSortColumn();
2177 if ((fCurrentSortColumn
< fColumnComparators
.length
) && (fColumnComparators
[fCurrentSortColumn
] != null)) {
2178 Comparator
<ITimeGraphEntry
> comparator
= fColumnComparators
[fCurrentSortColumn
];
2179 if (comparator
instanceof ITimeGraphEntryComparator
) {
2180 ((ITimeGraphEntryComparator
) comparator
).setDirection(fSortDirection
);
2182 if (fSortDirection
!= SWT
.DOWN
) {
2183 comparator
= checkNotNull(Collections
.reverseOrder(comparator
));
2185 setEntryComparator(comparator
);
2191 private void applyViewContext() {
2192 TimeGraphCombo combo
= getTimeGraphCombo();
2193 ViewContext viewContext
= fViewContext
.get(fTrace
);
2194 if (combo
!= null) {
2195 TreeViewer treeViewer
= combo
.getTreeViewer();
2196 final Tree tree
= treeViewer
.getTree();
2197 final TreeColumn column
= tree
.getColumn(fCurrentSortColumn
);
2198 tree
.setSortDirection(fSortDirection
);
2199 tree
.setSortColumn(column
);
2200 combo
.getTreeViewer().getControl().setFocus();
2202 // restore and reveal selection
2203 if ((viewContext
!= null) && (viewContext
.getSelection() != null)) {
2204 fTimeGraphWrapper
.setSelection(viewContext
.getSelection());
2206 fViewContext
.remove(fTrace
);
2209 private static class ViewContext
{
2210 private int fSortColumnIndex
;
2211 private int fSortDirection
;
2212 private @Nullable ITimeGraphEntry fSelection
;
2214 ViewContext(int sortColunm
, int sortDirection
, ITimeGraphEntry selection
) {
2215 fSortColumnIndex
= sortColunm
;
2216 fSortDirection
= sortDirection
;
2217 fSelection
= selection
;
2220 * @return the sortColumn
2222 public int getSortColumn() {
2223 return fSortColumnIndex
;
2226 * @return the sortDirection
2228 public int getSortDirection() {
2229 return fSortDirection
;
2232 * @return the selection
2234 public ITimeGraphEntry
getSelection() {
2239 private void createContextMenu() {
2240 TimeGraphCombo combo
= getTimeGraphCombo();
2241 fEntryMenuManager
.setRemoveAllWhenShown(true);
2242 if (combo
!= null) {
2243 TreeViewer treeViewer
= combo
.getTreeViewer();
2244 Tree tree
= treeViewer
.getTree();
2245 Menu menu
= fEntryMenuManager
.createContextMenu(tree
);
2248 TimeGraphControl timeGraphControl
= getTimeGraphViewer().getTimeGraphControl();
2249 final Menu entryMenu
= fEntryMenuManager
.createContextMenu(timeGraphControl
);
2250 timeGraphControl
.addTimeGraphEntryMenuListener(new MenuDetectListener() {
2252 public void menuDetected(MenuDetectEvent event
) {
2253 Point p
= timeGraphControl
.toControl(event
.x
, event
.y
);
2255 * The TimeGraphControl will call the TimeGraphEntryMenuListener
2256 * before the TimeEventMenuListener. If the event is
2257 * triggered on the namespace then show the menu else
2260 if (p
.x
< getTimeGraphViewer().getNameSpace()) {
2261 timeGraphControl
.setMenu(entryMenu
);
2263 timeGraphControl
.setMenu(null);
2269 fEntryMenuManager
.addMenuListener(new IMenuListener() {
2271 public void menuAboutToShow(IMenuManager manager
) {
2272 fillTimeGraphEntryContextMenu(fEntryMenuManager
);
2273 fEntryMenuManager
.add(new GroupMarker(IWorkbenchActionConstants
.MB_ADDITIONS
));
2276 getSite().registerContextMenu(fEntryMenuManager
, fTimeGraphWrapper
.getSelectionProvider());
2282 * @param menuManager
2283 * a menuManager to fill
2286 protected void fillTimeGraphEntryContextMenu (@NonNull IMenuManager menuManager
) {
2290 * Inner classes used for searching
2293 public ITimeGraphEntry
getSelection() {
2294 return fTimeGraphWrapper
.getSelection();
2297 public void selectAndReveal(@NonNull ITimeGraphEntry entry
) {
2298 fTimeGraphWrapper
.selectAndReveal(entry
);
2301 public ITimeGraphEntry
[] getEntries() {
2302 TimeGraphViewer viewer
= getTimeGraphViewer();
2303 return viewer
.getTimeGraphContentProvider().getElements(viewer
.getInput());
2306 public Shell
getShell() {
2307 return getSite().getShell();
2311 class TimeGraphPartListener
implements IPartListener
{
2313 public void partActivated(IWorkbenchPart part
) {
2314 if (part
== AbstractTimeGraphView
.this) {
2315 synchronized (FIND_ACTION
) {
2316 if (fFindActionHandler
== null) {
2317 fFindActionHandler
= new ActionHandler(FIND_ACTION
);
2319 final Object service
= PlatformUI
.getWorkbench().getService(IHandlerService
.class);
2320 fFindHandlerActivation
= ((IHandlerService
) service
).activateHandler(ActionFactory
.FIND
.getCommandId(), fFindActionHandler
);
2323 // Notify action for all parts
2324 FIND_ACTION
.partActivated(part
);
2327 public void partDeactivated(IWorkbenchPart part
) {
2328 if ((part
== AbstractTimeGraphView
.this) && (fFindHandlerActivation
!= null)) {
2329 final Object service
= PlatformUI
.getWorkbench().getService(IHandlerService
.class);
2330 ((IHandlerService
) service
).deactivateHandler(fFindHandlerActivation
);
2334 public void partBroughtToTop(IWorkbenchPart part
) {
2337 public void partClosed(IWorkbenchPart part
) {
2340 public void partOpened(IWorkbenchPart part
) {