1 /*******************************************************************************
2 * Copyright (c) 2010 Ericsson
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 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.timechart
;
15 import java
.util
.ArrayList
;
16 import java
.util
.HashMap
;
17 import java
.util
.Iterator
;
20 import org
.eclipse
.core
.resources
.IFile
;
21 import org
.eclipse
.core
.resources
.IMarker
;
22 import org
.eclipse
.core
.resources
.IMarkerDelta
;
23 import org
.eclipse
.core
.resources
.IResourceChangeEvent
;
24 import org
.eclipse
.core
.resources
.IResourceChangeListener
;
25 import org
.eclipse
.core
.resources
.IResourceDelta
;
26 import org
.eclipse
.core
.resources
.ResourcesPlugin
;
27 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
28 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfTimestamp
;
29 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimeRange
;
30 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimestamp
;
31 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfEventFilterAppliedSignal
;
32 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfEventSearchAppliedSignal
;
33 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfRangeSynchSignal
;
34 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalHandler
;
35 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTimeSynchSignal
;
36 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceClosedSignal
;
37 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceOpenedSignal
;
38 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceSelectedSignal
;
39 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceUpdatedSignal
;
40 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfContext
;
41 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
42 import org
.eclipse
.linuxtools
.tmf
.ui
.editors
.ITmfTraceEditor
;
43 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.TmfView
;
44 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.colors
.ColorSetting
;
45 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.colors
.ColorSettingsManager
;
46 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.colors
.IColorSettingsListener
;
47 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.timechart
.TimeChartEvent
.RankRange
;
48 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.ITimeGraphPresentationProvider
;
49 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.ITimeGraphRangeListener
;
50 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.ITimeGraphSelectionListener
;
51 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.ITimeGraphTimeListener
;
52 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.TimeGraphRangeUpdateEvent
;
53 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.TimeGraphSelectionEvent
;
54 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.TimeGraphTimeEvent
;
55 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.TimeGraphViewer
;
56 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.model
.ITimeEvent
;
57 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.model
.ITimeGraphEntry
;
58 import org
.eclipse
.swt
.SWT
;
59 import org
.eclipse
.swt
.widgets
.Composite
;
60 import org
.eclipse
.swt
.widgets
.Display
;
61 import org
.eclipse
.ui
.IEditorPart
;
62 import org
.eclipse
.ui
.IEditorReference
;
65 * Generic Time Chart view, which is similar to a Gantt chart for trace analysis
68 * @author Patrick Tasse
70 public class TimeChartView
extends TmfView
implements ITimeGraphRangeListener
, ITimeGraphSelectionListener
, ITimeGraphTimeListener
, IColorSettingsListener
, IResourceChangeListener
{
72 /** TimeChartView's ID */
73 public static final String ID
= "org.eclipse.linuxtools.tmf.ui.views.timechart"; //$NON-NLS-1$
75 private static final int TIMESTAMP_SCALE
= -9;
77 private final int fDisplayWidth
;
78 private TimeGraphViewer fViewer
;
79 private final ArrayList
<TimeChartAnalysisEntry
> fTimeAnalysisEntries
= new ArrayList
<TimeChartAnalysisEntry
>();
80 private final Map
<ITmfTrace
, TimeChartDecorationProvider
> fDecorationProviders
= new HashMap
<ITmfTrace
, TimeChartDecorationProvider
>();
81 private ArrayList
<DecorateThread
> fDecorateThreads
;
82 private long fStartTime
= 0;
83 private long fStopTime
= Long
.MAX_VALUE
;
84 private boolean fRefreshBusy
= false;
85 private boolean fRefreshPending
= false;
86 private boolean fRedrawBusy
= false;
87 private boolean fRedrawPending
= false;
88 private final Object fSyncObj
= new Object();
89 private ITimeGraphPresentationProvider fPresentationProvider
;
94 public TimeChartView() {
95 super("Time Chart"); //$NON-NLS-1$
96 fDisplayWidth
= Display
.getDefault().getBounds().width
;
100 public void createPartControl(Composite parent
) {
101 fViewer
= new TimeGraphViewer(parent
, SWT
.NONE
);
102 fPresentationProvider
= new TimeChartAnalysisProvider();
103 fViewer
.setTimeGraphProvider(fPresentationProvider
);
104 fViewer
.setTimeCalendarFormat(true);
105 fViewer
.addTimeListener(this);
106 fViewer
.addRangeListener(this);
107 fViewer
.addSelectionListener(this);
108 fViewer
.setMinimumItemWidth(1);
110 IEditorReference
[] editorReferences
= getSite().getPage().getEditorReferences();
111 for (IEditorReference editorReference
: editorReferences
) {
112 IEditorPart editor
= editorReference
.getEditor(false);
113 if (editor
instanceof ITmfTraceEditor
) {
114 ITmfTrace trace
= ((ITmfTraceEditor
) editor
).getTrace();
116 IFile bookmarksFile
= ((ITmfTraceEditor
) editor
).getBookmarksFile();
117 TimeChartAnalysisEntry timeAnalysisEntry
= new TimeChartAnalysisEntry(trace
, fDisplayWidth
* 2);
118 fTimeAnalysisEntries
.add(timeAnalysisEntry
);
119 fDecorationProviders
.put(trace
, new TimeChartDecorationProvider(bookmarksFile
));
120 Thread thread
= new ProcessTraceThread(timeAnalysisEntry
);
125 fViewer
.setInput(fTimeAnalysisEntries
.toArray(new TimeChartAnalysisEntry
[0]));
127 fDecorateThreads
= new ArrayList
<DecorateThread
>();
128 ColorSettingsManager
.addColorSettingsListener(this);
129 ResourcesPlugin
.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent
.POST_CHANGE
);
133 public void dispose() {
134 ResourcesPlugin
.getWorkspace().removeResourceChangeListener(this);
135 for (DecorateThread thread
: fDecorateThreads
) {
138 ColorSettingsManager
.removeColorSettingsListener(this);
143 public void setFocus() {
147 private class ProcessTraceThread
extends Thread
{
149 private final TimeChartAnalysisEntry fTimeAnalysisEntry
;
151 public ProcessTraceThread(TimeChartAnalysisEntry timeAnalysisEntry
) {
152 super("ProcessTraceJob:" + timeAnalysisEntry
.getName()); //$NON-NLS-1$
153 fTimeAnalysisEntry
= timeAnalysisEntry
;
158 updateTraceEntry(fTimeAnalysisEntry
, Long
.MAX_VALUE
, 0, Long
.MAX_VALUE
);
162 private void updateTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry
, long stopRank
, long startTime
, long stopTime
) {
163 ITmfTrace trace
= timeAnalysisEntry
.getTrace();
164 TimeChartDecorationProvider decorationProvider
= fDecorationProviders
.get(trace
);
165 if (decorationProvider
== null) {
166 return; // the trace has been closed
168 ITmfContext context
= null;
169 // TmfTimestamp lastTimestamp = null;
170 boolean done
= false;
172 synchronized (timeAnalysisEntry
) {
173 if (timeAnalysisEntry
.getLastRank() >= trace
.getNbEvents()) {
177 if (context
== null || context
.getRank() != timeAnalysisEntry
.getLastRank()) {
178 if (context
!= null) {
181 if (timeAnalysisEntry
.getLastRank() != -1) {
182 context
= trace
.seekEvent(timeAnalysisEntry
.getLastRank());
184 // context = trace.seekLocation(null);
185 context
= trace
.seekEvent(0);
189 long rank
= context
.getRank();
190 ITmfEvent event
= trace
.getNext(context
);
195 // if (!event.getTimestamp().equals(lastTimestamp)) {
196 TimeChartEvent timeEvent
= new TimeChartEvent(timeAnalysisEntry
, event
, rank
, decorationProvider
);
197 if (timeEvent
.getTime() >= startTime
&& timeEvent
.getTime() <= stopTime
) {
198 timeAnalysisEntry
.addTraceEvent(timeEvent
);
200 // lastTimestamp = event.getTimestamp();
201 // } *** commented out so that color setting priority gets
202 // set even if the event has same time
203 if (context
.getRank() == trace
.getNbEvents() || context
.getRank() == stopRank
) {
207 if (context
.getRank() % trace
.getCacheSize() == 1) {
208 // break for UI refresh
212 // timeAnalysisEntry.setLastRank(Math.min(trace.getNbEvents(),
214 timeAnalysisEntry
.setLastRank(context
.getRank());
218 if (context
!= null) {
223 private void refreshViewer() {
224 synchronized (fSyncObj
) {
226 fRefreshPending
= true;
231 // Perform the refresh on the UI thread
232 Display
.getDefault().asyncExec(new Runnable() {
235 if (fViewer
.getControl().isDisposed()) {
238 fViewer
.setInput(fTimeAnalysisEntries
.toArray(new TimeChartAnalysisEntry
[0]));
239 fViewer
.resetStartFinishTime();
240 synchronized (fSyncObj
) {
241 fRefreshBusy
= false;
242 if (fRefreshPending
) {
243 fRefreshPending
= false;
251 private void redrawViewer(boolean resetTimeIntervals
) {
252 synchronized (fSyncObj
) {
254 fRedrawPending
= true;
259 final boolean reset
= resetTimeIntervals
;
260 // Perform the refresh on the UI thread
261 Display
.getDefault().asyncExec(new Runnable() {
264 if (fViewer
.getControl().isDisposed()) {
268 fViewer
.setTimeRange(fTimeAnalysisEntries
.toArray(new TimeChartAnalysisEntry
[0]));
269 fViewer
.setTimeBounds();
271 fViewer
.getControl().redraw();
272 fViewer
.getControl().update();
273 synchronized (fSyncObj
) {
275 if (fRedrawPending
) {
276 fRedrawPending
= false;
284 private void itemize(long startTime
, long stopTime
) {
285 for (int i
= 0; i
< fTimeAnalysisEntries
.size(); i
++) {
286 Thread thread
= new ItemizeThread(fTimeAnalysisEntries
.get(i
), startTime
, stopTime
);
291 private class ItemizeThread
extends Thread
{
293 private final TimeChartAnalysisEntry fTimeAnalysisEntry
;
294 private final long fStartTime
;
295 private final long fStopTime
;
296 private final long fMaxDuration
;
298 private ItemizeThread(TimeChartAnalysisEntry timeAnalysisEntry
, long startTime
, long stopTime
) {
299 super("Itemize Thread:" + timeAnalysisEntry
.getName()); //$NON-NLS-1$
300 fTimeAnalysisEntry
= timeAnalysisEntry
;
301 fStartTime
= startTime
;
302 fStopTime
= stopTime
;
303 fMaxDuration
= 3 * (fStopTime
- fStartTime
) / fDisplayWidth
;
308 itemizeTraceEntry(fTimeAnalysisEntry
);
311 public void itemizeTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry
) {
312 Iterator
<ITimeEvent
> iterator
= timeAnalysisEntry
.getTimeEventsIterator();
313 TimeChartEvent event
= null;
314 boolean hasNext
= true;
316 synchronized (timeAnalysisEntry
) {
317 while (hasNext
= iterator
.hasNext()) {
318 event
= (TimeChartEvent
) iterator
.next();
319 if (event
.getTime() + event
.getDuration() > fStartTime
&& event
.getTime() < fStopTime
&& event
.getDuration() > fMaxDuration
320 && event
.getNbEvents() > 1) {
326 if (event
.getItemizedEntry() == null) {
329 itemizeTraceEntry(event
.getItemizedEntry());
335 public void itemizeEvent(TimeChartEvent event
) {
336 synchronized (event
) {
337 if (event
.isItemizing()) {
340 event
.setItemizing(true);
342 TimeChartAnalysisEntry timeAnalysisEntry
= new TimeChartAnalysisEntry(fTimeAnalysisEntry
.getTrace(), (int) Math
.min(
343 event
.getNbEvents() + 1, fDisplayWidth
* 2));
344 synchronized (event
.getRankRangeList()) {
345 for (RankRange range
: event
.getRankRangeList()) {
346 timeAnalysisEntry
.setLastRank(range
.getFirstRank());
347 updateTraceEntry(timeAnalysisEntry
, range
.getLastRank() + 1, event
.getTime(), event
.getTime() + event
.getDuration());
350 event
.setItemizedEntry(timeAnalysisEntry
);
352 itemizeTraceEntry(timeAnalysisEntry
);
353 synchronized (event
) {
354 event
.setItemizing(false);
359 private void redecorate() {
360 synchronized (fDecorateThreads
) {
361 for (DecorateThread thread
: fDecorateThreads
) {
364 fDecorateThreads
.clear();
365 for (int i
= 0; i
< fTimeAnalysisEntries
.size(); i
++) {
366 DecorateThread thread
= new DecorateThread(fTimeAnalysisEntries
.get(i
));
368 fDecorateThreads
.add(thread
);
373 private class DecorateThread
extends Thread
{
374 private volatile boolean interrupted
= false;
375 private final TimeChartAnalysisEntry fTimeAnalysisEntry
;
376 private final TimeChartDecorationProvider fDecorationProvider
;
377 private ITmfContext fContext
;
378 private int fCount
= 0;
380 private DecorateThread(TimeChartAnalysisEntry timeAnalysisEntry
) {
381 super("Decorate Thread:" + timeAnalysisEntry
.getName()); //$NON-NLS-1$
382 fTimeAnalysisEntry
= timeAnalysisEntry
;
383 fDecorationProvider
= fDecorationProviders
.get(timeAnalysisEntry
.getTrace());
388 resetTraceEntry(fTimeAnalysisEntry
);
390 decorateTraceEntry(fTimeAnalysisEntry
, null);
392 synchronized (fDecorateThreads
) {
393 fDecorateThreads
.remove(this);
395 if (fContext
!= null) {
400 public void resetTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry
) {
401 Iterator
<ITimeEvent
> iterator
= timeAnalysisEntry
.getTimeEventsIterator();
402 TimeChartEvent event
= null;
403 boolean hasNext
= true;
404 while (!interrupted
&& hasNext
) {
405 synchronized (timeAnalysisEntry
) {
406 while (hasNext
= iterator
.hasNext()) {
407 event
= (TimeChartEvent
) iterator
.next();
412 // TODO possible concurrency problem here with ItemizeJob
413 event
.setColorSettingPriority(ColorSettingsManager
.PRIORITY_NONE
);
414 if (event
.getItemizedEntry() != null) {
415 resetTraceEntry(event
.getItemizedEntry());
421 public void decorateTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry
, TimeChartEvent parentEvent
) {
422 // Set max duration high to ensure iterator does not consider
424 Iterator
<ITimeEvent
> iterator
= timeAnalysisEntry
.getTimeEventsIterator(0, Long
.MAX_VALUE
, Long
.MAX_VALUE
);
425 TimeChartEvent event
= null;
426 int entryPriority
= ColorSettingsManager
.PRIORITY_NONE
;
427 boolean entryIsBookmarked
= false;
428 boolean entryIsVisible
= false;
429 boolean entryIsSearchMatch
= false;
430 boolean hasNext
= true;
431 while (!interrupted
&& hasNext
) {
432 synchronized (timeAnalysisEntry
) {
433 while (hasNext
= iterator
.hasNext()) {
434 event
= (TimeChartEvent
) iterator
.next();
439 // TODO possible concurrency problem here with ItemizeJob
440 if (event
.getItemizedEntry() == null) {
441 decorateEvent(event
);
443 decorateTraceEntry(event
.getItemizedEntry(), event
);
445 entryPriority
= Math
.min(entryPriority
, event
.getColorSettingPriority());
446 entryIsBookmarked
|= event
.isBookmarked();
447 entryIsVisible
|= event
.isVisible();
448 entryIsSearchMatch
|= event
.isSearchMatch();
449 if (++fCount
% timeAnalysisEntry
.getTrace().getCacheSize() == 0) {
454 if (parentEvent
!= null) {
455 parentEvent
.setColorSettingPriority(entryPriority
);
456 parentEvent
.setIsBookmarked(entryIsBookmarked
);
457 parentEvent
.setIsVisible(entryIsVisible
);
458 parentEvent
.setIsSearchMatch(entryIsSearchMatch
);
462 public void decorateEvent(TimeChartEvent timeChartEvent
) {
463 // TODO possible concurrency problem here with ItemizeJob
464 TimeChartAnalysisEntry timeAnalysisEntry
= (TimeChartAnalysisEntry
) timeChartEvent
.getEntry();
465 ITmfTrace trace
= timeAnalysisEntry
.getTrace();
466 int priority
= ColorSettingsManager
.PRIORITY_NONE
;
467 boolean isBookmarked
= false;
468 boolean isVisible
= false;
469 boolean isSearchMatch
= false;
470 synchronized (timeChartEvent
.getRankRangeList()) {
471 for (RankRange range
: timeChartEvent
.getRankRangeList()) {
475 if (fContext
== null || fContext
.getRank() != range
.getFirstRank()) {
476 if (fContext
!= null) {
479 fContext
= trace
.seekEvent(range
.getFirstRank());
480 fContext
.setRank(range
.getFirstRank());
486 long rank
= fContext
.getRank();
487 ITmfEvent event
= trace
.getNext(fContext
);
491 long eventTime
= event
.getTimestamp().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
492 if (eventTime
>= timeChartEvent
.getTime() && eventTime
<= timeChartEvent
.getTime() + timeChartEvent
.getDuration()) {
493 priority
= Math
.min(priority
, ColorSettingsManager
.getColorSettingPriority(event
));
495 isBookmarked
|= fDecorationProvider
.isBookmark(rank
);
496 isVisible
|= fDecorationProvider
.isVisible(event
);
497 isSearchMatch
|= fDecorationProvider
.isSearchMatch(event
);
498 if (fContext
.getRank() > range
.getLastRank()) {
504 timeChartEvent
.setColorSettingPriority(priority
);
505 timeChartEvent
.setIsBookmarked(isBookmarked
);
506 timeChartEvent
.setIsVisible(isVisible
);
507 timeChartEvent
.setIsSearchMatch(isSearchMatch
);
510 public void cancel() {
515 // ------------------------------------------------------------------------
517 // ------------------------------------------------------------------------
520 public void timeRangeUpdated(TimeGraphRangeUpdateEvent event
) {
521 fStartTime
= event
.getStartTime();
522 fStopTime
= event
.getEndTime();
523 itemize(fStartTime
, fStopTime
);
524 final ITmfTimestamp startTimestamp
= new TmfTimestamp(event
.getStartTime(), ITmfTimestamp
.NANOSECOND_SCALE
);
525 final ITmfTimestamp endTimestamp
= new TmfTimestamp(event
.getEndTime(), ITmfTimestamp
.NANOSECOND_SCALE
);
526 TmfTimeRange range
= new TmfTimeRange(startTimestamp
, endTimestamp
);
527 TmfTimestamp timestamp
= new TmfTimestamp(fViewer
.getSelectedTime(), ITmfTimestamp
.NANOSECOND_SCALE
);
528 broadcast(new TmfRangeSynchSignal(this, range
, timestamp
));
532 public void selectionChanged(TimeGraphSelectionEvent event
) {
533 ITimeGraphEntry timeAnalysisEntry
= null;
534 if (event
.getSelection() instanceof TimeChartAnalysisEntry
) {
535 timeAnalysisEntry
= event
.getSelection();
536 } else if (event
.getSelection() instanceof TimeChartEvent
) {
537 timeAnalysisEntry
= ((TimeChartEvent
) event
.getSelection()).getEntry();
539 if (timeAnalysisEntry
instanceof TimeChartAnalysisEntry
) {
540 broadcast(new TmfTraceSelectedSignal(this, ((TimeChartAnalysisEntry
) timeAnalysisEntry
).getTrace()));
545 public void timeSelected(TimeGraphTimeEvent event
) {
546 broadcast(new TmfTimeSynchSignal(this, new TmfTimestamp(event
.getTime(), TIMESTAMP_SCALE
)));
550 public void colorSettingsChanged(ColorSetting
[] colorSettings
) {
551 // Set presentation provider again to trigger re-creation of new color settings which are stored
552 // in the TimeGraphControl class
553 fViewer
.setTimeGraphProvider(fPresentationProvider
);
558 public void resourceChanged(IResourceChangeEvent event
) {
559 for (IMarkerDelta delta
: event
.findMarkerDeltas(IMarker
.BOOKMARK
, false)) {
560 for (TimeChartDecorationProvider provider
: fDecorationProviders
.values()) {
561 if (delta
.getResource().equals(provider
.getBookmarksFile())) {
562 if (delta
.getKind() == IResourceDelta
.CHANGED
&& delta
.getMarker().getAttribute(IMarker
.LOCATION
, -1) != -1) {
563 provider
.refreshBookmarks();
564 } else if (delta
.getKind() == IResourceDelta
.REMOVED
) {
565 provider
.refreshBookmarks();
573 // ------------------------------------------------------------------------
575 // ------------------------------------------------------------------------
578 * Handler for the Trace Opened signal
581 * The incoming signal
585 public void traceOpened(TmfTraceOpenedSignal signal
) {
586 if (fTimeAnalysisEntries
== null) {
589 final ITmfTrace trace
= signal
.getTrace();
590 final IFile bookmarksFile
= signal
.getBookmarksFile();
591 TimeChartAnalysisEntry timeAnalysisEntry
= null;
592 for (int i
= 0; i
< fTimeAnalysisEntries
.size(); i
++) {
593 if (fTimeAnalysisEntries
.get(i
).getTrace().equals(trace
)) {
594 timeAnalysisEntry
= fTimeAnalysisEntries
.get(i
);
598 if (timeAnalysisEntry
== null) {
599 timeAnalysisEntry
= new TimeChartAnalysisEntry(trace
, fDisplayWidth
* 2);
600 fTimeAnalysisEntries
.add(timeAnalysisEntry
);
601 fDecorationProviders
.put(trace
, new TimeChartDecorationProvider(bookmarksFile
));
602 Thread thread
= new ProcessTraceThread(timeAnalysisEntry
);
609 * Handler for the Trace Closed signal
612 * The incoming signal
616 public void traceClosed(TmfTraceClosedSignal signal
) {
617 if (fTimeAnalysisEntries
== null) {
620 final ITmfTrace trace
= signal
.getTrace();
621 for (int i
= 0; i
< fTimeAnalysisEntries
.size(); i
++) {
622 if (fTimeAnalysisEntries
.get(i
).getTrace().equals(trace
)) {
623 fTimeAnalysisEntries
.remove(i
);
624 fDecorationProviders
.remove(trace
);
625 synchronized (fDecorateThreads
) {
626 for (DecorateThread thread
: fDecorateThreads
) {
627 if (thread
.fTimeAnalysisEntry
.getTrace() == trace
) {
629 fDecorateThreads
.remove(thread
);
641 * Handler for the Trace Selected signal
644 * The incoming signal
647 public void traceSelected(TmfTraceSelectedSignal signal
) {
648 if (signal
.getSource() != this && fTimeAnalysisEntries
!= null) {
649 ITmfTrace trace
= signal
.getTrace();
650 for (int i
= 0; i
< fTimeAnalysisEntries
.size(); i
++) {
651 if (fTimeAnalysisEntries
.get(i
).getTrace().equals(trace
)) {
652 fViewer
.setSelection(fTimeAnalysisEntries
.get(i
));
660 * Handler for the Trace Updated signal
663 * The incoming signal
666 public void traceUpdated(TmfTraceUpdatedSignal signal
) {
667 if (fTimeAnalysisEntries
== null) {
670 final ITmfTrace trace
= signal
.getTrace();
671 for (int i
= 0; i
< fTimeAnalysisEntries
.size(); i
++) {
672 TimeChartAnalysisEntry timeAnalysisEntry
= fTimeAnalysisEntries
.get(i
);
673 if (timeAnalysisEntry
.getTrace().equals(trace
)) {
674 updateTraceEntry(timeAnalysisEntry
, Long
.MAX_VALUE
, 0, Long
.MAX_VALUE
);
681 * Handler for the Time Synch signal
684 * The incoming signal
687 public void currentTimeUpdated(TmfTimeSynchSignal signal
) {
688 final long time
= signal
.getCurrentTime().normalize(0, TIMESTAMP_SCALE
).getValue();
689 Display
.getDefault().asyncExec(new Runnable() {
692 fViewer
.setSelectedTime(time
, true);
698 * Handler for the Time Range Synch signal
701 * The incoming signal
705 public void synchToRange(final TmfRangeSynchSignal signal
) {
706 if (signal
.getSource() == this) {
709 final long startTime
= signal
.getCurrentRange().getStartTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
710 final long endTime
= signal
.getCurrentRange().getEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
711 final long time
= signal
.getCurrentTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
712 Display
.getDefault().asyncExec(new Runnable() {
715 fStartTime
= startTime
;
717 itemize(fStartTime
, fStopTime
);
718 fViewer
.setStartFinishTime(startTime
, endTime
);
719 fViewer
.setSelectedTime(time
, false);
725 * Handler for the Event Filter Applied signal
728 * The incoming signal
732 public void filterApplied(TmfEventFilterAppliedSignal signal
) {
733 TimeChartDecorationProvider decorationProvider
= fDecorationProviders
.get(signal
.getTrace());
734 if (decorationProvider
== null) {
737 decorationProvider
.filterApplied(signal
.getEventFilter());
742 * Handler for the Event Search Applied signal
745 * The incoming signal
749 public void searchApplied(TmfEventSearchAppliedSignal signal
) {
750 TimeChartDecorationProvider decorationProvider
= fDecorationProviders
.get(signal
.getTrace());
751 if (decorationProvider
== null) {
754 decorationProvider
.searchApplied(signal
.getSearchFilter());