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
.signal
.TmfEventFilterAppliedSignal
;
29 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfEventSearchAppliedSignal
;
30 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfRangeSynchSignal
;
31 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalHandler
;
32 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTimeSynchSignal
;
33 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceClosedSignal
;
34 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceOpenedSignal
;
35 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceSelectedSignal
;
36 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceUpdatedSignal
;
37 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.ITmfTimestamp
;
38 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.TmfTimeRange
;
39 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.TmfTimestamp
;
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
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
.TimeGraphColorScheme
;
59 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
.TimeGraphControl
;
60 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
.Utils
.TimeFormat
;
61 import org
.eclipse
.swt
.SWT
;
62 import org
.eclipse
.swt
.graphics
.GC
;
63 import org
.eclipse
.swt
.graphics
.Rectangle
;
64 import org
.eclipse
.swt
.widgets
.Composite
;
65 import org
.eclipse
.swt
.widgets
.Display
;
66 import org
.eclipse
.ui
.IEditorPart
;
67 import org
.eclipse
.ui
.IEditorReference
;
70 * Generic Time Chart view, which is similar to a Gantt chart for trace analysis
73 * @author Patrick Tasse
75 public class TimeChartView
extends TmfView
implements ITimeGraphRangeListener
, ITimeGraphSelectionListener
, ITimeGraphTimeListener
, IColorSettingsListener
, IResourceChangeListener
{
77 /** TimeChartView's ID */
78 public static final String ID
= "org.eclipse.linuxtools.tmf.ui.views.timechart"; //$NON-NLS-1$
80 private static final int TIMESTAMP_SCALE
= -9;
82 private final int fDisplayWidth
;
83 private TimeGraphViewer fViewer
;
84 private final ArrayList
<TimeChartAnalysisEntry
> fTimeAnalysisEntries
= new ArrayList
<TimeChartAnalysisEntry
>();
85 private final Map
<ITmfTrace
, TimeChartDecorationProvider
> fDecorationProviders
= new HashMap
<ITmfTrace
, TimeChartDecorationProvider
>();
86 private ArrayList
<DecorateThread
> fDecorateThreads
;
87 private long fStartTime
= 0;
88 private long fStopTime
= Long
.MAX_VALUE
;
89 private boolean fRefreshBusy
= false;
90 private boolean fRefreshPending
= false;
91 private boolean fRedrawBusy
= false;
92 private boolean fRedrawPending
= false;
93 private final Object fSyncObj
= new Object();
94 private ITimeGraphPresentationProvider fPresentationProvider
;
97 * TimeChartViewer extends TimeGraphViewer to use a TimeGraphControl that overrides drawState
98 * to inhibit drawing of filtered-out events.
100 private class TimeChartViewer
extends TimeGraphViewer
{
102 public TimeChartViewer(Composite parent
, int style
) {
103 super(parent
, style
);
107 protected TimeGraphControl
createTimeGraphControl(Composite parent
, TimeGraphColorScheme colorScheme
) {
108 return new TimeGraphControl(parent
, colorScheme
) {
110 protected void drawState(TimeGraphColorScheme colors
, ITimeEvent event
, Rectangle rect
, GC gc
, boolean selected
, boolean timeSelected
) {
111 if (! ((TimeChartEvent
) event
).isVisible()) {
114 super.drawState(colors
, event
, rect
, gc
, selected
, timeSelected
);
121 * Default constructor
123 public TimeChartView() {
124 super("Time Chart"); //$NON-NLS-1$
125 fDisplayWidth
= Display
.getDefault().getBounds().width
;
129 public void createPartControl(Composite parent
) {
130 fViewer
= new TimeChartViewer(parent
, SWT
.NONE
);
131 fPresentationProvider
= new TimeChartAnalysisProvider();
132 fViewer
.setTimeGraphProvider(fPresentationProvider
);
133 fViewer
.setTimeFormat(TimeFormat
.CALENDAR
);
134 fViewer
.addTimeListener(this);
135 fViewer
.addRangeListener(this);
136 fViewer
.addSelectionListener(this);
137 fViewer
.setMinimumItemWidth(1);
139 IEditorReference
[] editorReferences
= getSite().getPage().getEditorReferences();
140 for (IEditorReference editorReference
: editorReferences
) {
141 IEditorPart editor
= editorReference
.getEditor(false);
142 if (editor
instanceof ITmfTraceEditor
) {
143 ITmfTrace trace
= ((ITmfTraceEditor
) editor
).getTrace();
145 IFile bookmarksFile
= ((ITmfTraceEditor
) editor
).getBookmarksFile();
146 TimeChartAnalysisEntry timeAnalysisEntry
= new TimeChartAnalysisEntry(trace
, fDisplayWidth
* 2);
147 fTimeAnalysisEntries
.add(timeAnalysisEntry
);
148 fDecorationProviders
.put(trace
, new TimeChartDecorationProvider(bookmarksFile
));
149 Thread thread
= new ProcessTraceThread(timeAnalysisEntry
);
154 fViewer
.setInput(fTimeAnalysisEntries
.toArray(new TimeChartAnalysisEntry
[0]));
156 fDecorateThreads
= new ArrayList
<DecorateThread
>();
157 ColorSettingsManager
.addColorSettingsListener(this);
158 ResourcesPlugin
.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent
.POST_CHANGE
);
162 public void dispose() {
163 ResourcesPlugin
.getWorkspace().removeResourceChangeListener(this);
164 for (DecorateThread thread
: fDecorateThreads
) {
167 ColorSettingsManager
.removeColorSettingsListener(this);
172 public void setFocus() {
176 private class ProcessTraceThread
extends Thread
{
178 private final TimeChartAnalysisEntry fTimeAnalysisEntry
;
180 public ProcessTraceThread(TimeChartAnalysisEntry timeAnalysisEntry
) {
181 super("ProcessTraceJob:" + timeAnalysisEntry
.getName()); //$NON-NLS-1$
182 fTimeAnalysisEntry
= timeAnalysisEntry
;
187 updateTraceEntry(fTimeAnalysisEntry
, Long
.MAX_VALUE
, 0, Long
.MAX_VALUE
);
191 private void updateTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry
, long stopRank
, long startTime
, long stopTime
) {
192 ITmfTrace trace
= timeAnalysisEntry
.getTrace();
193 TimeChartDecorationProvider decorationProvider
= fDecorationProviders
.get(trace
);
194 if (decorationProvider
== null) {
195 return; // the trace has been closed
197 ITmfContext context
= null;
198 // TmfTimestamp lastTimestamp = null;
199 boolean done
= false;
201 synchronized (timeAnalysisEntry
) {
202 if (timeAnalysisEntry
.getLastRank() >= trace
.getNbEvents()) {
206 if (context
== null || context
.getRank() != timeAnalysisEntry
.getLastRank()) {
207 if (context
!= null) {
210 if (timeAnalysisEntry
.getLastRank() != -1) {
211 context
= trace
.seekEvent(timeAnalysisEntry
.getLastRank());
213 // context = trace.seekLocation(null);
214 context
= trace
.seekEvent(0);
218 long rank
= context
.getRank();
219 ITmfEvent event
= trace
.getNext(context
);
224 // if (!event.getTimestamp().equals(lastTimestamp)) {
225 TimeChartEvent timeEvent
= new TimeChartEvent(timeAnalysisEntry
, event
, rank
, decorationProvider
);
226 if (timeEvent
.getTime() >= startTime
&& timeEvent
.getTime() <= stopTime
) {
227 timeAnalysisEntry
.addTraceEvent(timeEvent
);
229 // lastTimestamp = event.getTimestamp();
230 // } *** commented out so that color setting priority gets
231 // set even if the event has same time
232 if (context
.getRank() == trace
.getNbEvents() || context
.getRank() == stopRank
) {
236 if (context
.getRank() % trace
.getCacheSize() == 1) {
237 // break for UI refresh
241 // timeAnalysisEntry.setLastRank(Math.min(trace.getNbEvents(),
243 timeAnalysisEntry
.setLastRank(context
.getRank());
247 if (context
!= null) {
252 private void refreshViewer() {
253 synchronized (fSyncObj
) {
255 fRefreshPending
= true;
260 // Perform the refresh on the UI thread
261 Display
.getDefault().asyncExec(new Runnable() {
264 if (fViewer
.getControl().isDisposed()) {
267 fViewer
.setInput(fTimeAnalysisEntries
.toArray(new TimeChartAnalysisEntry
[0]));
268 fViewer
.resetStartFinishTime();
269 synchronized (fSyncObj
) {
270 fRefreshBusy
= false;
271 if (fRefreshPending
) {
272 fRefreshPending
= false;
280 private void redrawViewer(boolean resetTimeIntervals
) {
281 synchronized (fSyncObj
) {
283 fRedrawPending
= true;
288 final boolean reset
= resetTimeIntervals
;
289 // Perform the refresh on the UI thread
290 Display
.getDefault().asyncExec(new Runnable() {
293 if (fViewer
.getControl().isDisposed()) {
297 fViewer
.setTimeRange(fTimeAnalysisEntries
.toArray(new TimeChartAnalysisEntry
[0]));
298 fViewer
.setTimeBounds();
300 fViewer
.getControl().redraw();
301 fViewer
.getControl().update();
302 synchronized (fSyncObj
) {
304 if (fRedrawPending
) {
305 fRedrawPending
= false;
313 private void itemize(long startTime
, long stopTime
) {
314 for (int i
= 0; i
< fTimeAnalysisEntries
.size(); i
++) {
315 Thread thread
= new ItemizeThread(fTimeAnalysisEntries
.get(i
), startTime
, stopTime
);
320 private class ItemizeThread
extends Thread
{
322 private final TimeChartAnalysisEntry fTimeAnalysisEntry
;
323 private final long startTime
;
324 private final long stopTime
;
325 private final long fMaxDuration
;
327 private ItemizeThread(TimeChartAnalysisEntry timeAnalysisEntry
, long startTime
, long stopTime
) {
328 super("Itemize Thread:" + timeAnalysisEntry
.getName()); //$NON-NLS-1$
329 fTimeAnalysisEntry
= timeAnalysisEntry
;
330 this.startTime
= startTime
;
331 this.stopTime
= stopTime
;
332 fMaxDuration
= 3 * (stopTime
- startTime
) / fDisplayWidth
;
337 itemizeTraceEntry(fTimeAnalysisEntry
);
340 public void itemizeTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry
) {
341 Iterator
<ITimeEvent
> iterator
= timeAnalysisEntry
.getTimeEventsIterator();
342 TimeChartEvent event
= null;
343 boolean hasNext
= true;
345 synchronized (timeAnalysisEntry
) {
346 while ((hasNext
= iterator
.hasNext()) == true) {
347 event
= (TimeChartEvent
) iterator
.next();
348 if (event
.getTime() + event
.getDuration() > startTime
&& event
.getTime() < stopTime
&& event
.getDuration() > fMaxDuration
349 && event
.getNbEvents() > 1) {
354 if (hasNext
&& event
!= null) {
355 if (event
.getItemizedEntry() == null) {
358 itemizeTraceEntry(event
.getItemizedEntry());
364 public void itemizeEvent(TimeChartEvent event
) {
365 synchronized (event
) {
366 if (event
.isItemizing()) {
369 event
.setItemizing(true);
371 TimeChartAnalysisEntry timeAnalysisEntry
= new TimeChartAnalysisEntry(fTimeAnalysisEntry
.getTrace(), (int) Math
.min(
372 event
.getNbEvents() + 1, fDisplayWidth
* 2));
373 synchronized (event
.getRankRangeList()) {
374 for (RankRange range
: event
.getRankRangeList()) {
375 timeAnalysisEntry
.setLastRank(range
.getFirstRank());
376 updateTraceEntry(timeAnalysisEntry
, range
.getLastRank() + 1, event
.getTime(), event
.getTime() + event
.getDuration());
379 event
.setItemizedEntry(timeAnalysisEntry
);
381 itemizeTraceEntry(timeAnalysisEntry
);
382 synchronized (event
) {
383 event
.setItemizing(false);
388 private void redecorate() {
389 synchronized (fDecorateThreads
) {
390 for (DecorateThread thread
: fDecorateThreads
) {
393 fDecorateThreads
.clear();
394 for (int i
= 0; i
< fTimeAnalysisEntries
.size(); i
++) {
395 DecorateThread thread
= new DecorateThread(fTimeAnalysisEntries
.get(i
));
397 fDecorateThreads
.add(thread
);
402 private class DecorateThread
extends Thread
{
403 private volatile boolean interrupted
= false;
404 private final TimeChartAnalysisEntry fTimeAnalysisEntry
;
405 private final TimeChartDecorationProvider fDecorationProvider
;
406 private ITmfContext fContext
;
407 private int fCount
= 0;
409 private DecorateThread(TimeChartAnalysisEntry timeAnalysisEntry
) {
410 super("Decorate Thread:" + timeAnalysisEntry
.getName()); //$NON-NLS-1$
411 fTimeAnalysisEntry
= timeAnalysisEntry
;
412 fDecorationProvider
= fDecorationProviders
.get(timeAnalysisEntry
.getTrace());
417 resetTraceEntry(fTimeAnalysisEntry
);
419 decorateTraceEntry(fTimeAnalysisEntry
, null);
421 synchronized (fDecorateThreads
) {
422 fDecorateThreads
.remove(this);
424 if (fContext
!= null) {
429 public void resetTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry
) {
430 Iterator
<ITimeEvent
> iterator
= timeAnalysisEntry
.getTimeEventsIterator();
431 TimeChartEvent event
= null;
432 boolean hasNext
= true;
433 while (!interrupted
&& hasNext
) {
434 synchronized (timeAnalysisEntry
) {
435 while ((hasNext
= iterator
.hasNext()) == true) {
436 event
= (TimeChartEvent
) iterator
.next();
440 if (hasNext
&& event
!= null) {
441 // TODO possible concurrency problem here with ItemizeJob
442 event
.setColorSettingPriority(ColorSettingsManager
.PRIORITY_NONE
);
443 if (event
.getItemizedEntry() != null) {
444 resetTraceEntry(event
.getItemizedEntry());
450 public void decorateTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry
, TimeChartEvent parentEvent
) {
451 // Set max duration high to ensure iterator does not consider
453 Iterator
<ITimeEvent
> iterator
= timeAnalysisEntry
.getTimeEventsIterator(0, Long
.MAX_VALUE
, Long
.MAX_VALUE
);
454 TimeChartEvent event
= null;
455 int entryPriority
= ColorSettingsManager
.PRIORITY_NONE
;
456 boolean entryIsBookmarked
= false;
457 boolean entryIsVisible
= false;
458 boolean entryIsSearchMatch
= false;
459 boolean hasNext
= true;
460 while (!interrupted
&& hasNext
) {
461 synchronized (timeAnalysisEntry
) {
462 while ((hasNext
= iterator
.hasNext()) == true) {
463 event
= (TimeChartEvent
) iterator
.next();
467 if (hasNext
&& event
!= null) {
468 // TODO possible concurrency problem here with ItemizeJob
469 if (event
.getItemizedEntry() == null) {
470 decorateEvent(event
);
472 decorateTraceEntry(event
.getItemizedEntry(), event
);
474 entryPriority
= Math
.min(entryPriority
, event
.getColorSettingPriority());
475 entryIsBookmarked
|= event
.isBookmarked();
476 entryIsVisible
|= event
.isVisible();
477 entryIsSearchMatch
|= event
.isSearchMatch();
478 if (++fCount
% timeAnalysisEntry
.getTrace().getCacheSize() == 0) {
483 if (parentEvent
!= null) {
484 parentEvent
.setColorSettingPriority(entryPriority
);
485 parentEvent
.setIsBookmarked(entryIsBookmarked
);
486 parentEvent
.setIsVisible(entryIsVisible
);
487 parentEvent
.setIsSearchMatch(entryIsSearchMatch
);
491 public void decorateEvent(TimeChartEvent timeChartEvent
) {
492 // TODO possible concurrency problem here with ItemizeJob
493 TimeChartAnalysisEntry timeAnalysisEntry
= (TimeChartAnalysisEntry
) timeChartEvent
.getEntry();
494 ITmfTrace trace
= timeAnalysisEntry
.getTrace();
495 int priority
= ColorSettingsManager
.PRIORITY_NONE
;
496 boolean isBookmarked
= false;
497 boolean isVisible
= false;
498 boolean isSearchMatch
= false;
499 synchronized (timeChartEvent
.getRankRangeList()) {
500 for (RankRange range
: timeChartEvent
.getRankRangeList()) {
504 if (fContext
== null || fContext
.getRank() != range
.getFirstRank()) {
505 if (fContext
!= null) {
508 fContext
= trace
.seekEvent(range
.getFirstRank());
509 fContext
.setRank(range
.getFirstRank());
515 long rank
= fContext
.getRank();
516 ITmfEvent event
= trace
.getNext(fContext
);
520 long eventTime
= event
.getTimestamp().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
521 if (eventTime
>= timeChartEvent
.getTime() && eventTime
<= timeChartEvent
.getTime() + timeChartEvent
.getDuration()) {
522 priority
= Math
.min(priority
, ColorSettingsManager
.getColorSettingPriority(event
));
524 isBookmarked
|= fDecorationProvider
.isBookmark(rank
);
525 isVisible
|= fDecorationProvider
.isVisible(event
);
526 isSearchMatch
|= fDecorationProvider
.isSearchMatch(event
);
527 if (fContext
.getRank() > range
.getLastRank()) {
533 timeChartEvent
.setColorSettingPriority(priority
);
534 timeChartEvent
.setIsBookmarked(isBookmarked
);
535 timeChartEvent
.setIsVisible(isVisible
);
536 timeChartEvent
.setIsSearchMatch(isSearchMatch
);
539 public void cancel() {
544 // ------------------------------------------------------------------------
546 // ------------------------------------------------------------------------
549 public void timeRangeUpdated(TimeGraphRangeUpdateEvent event
) {
550 fStartTime
= event
.getStartTime();
551 fStopTime
= event
.getEndTime();
552 itemize(fStartTime
, fStopTime
);
553 final ITmfTimestamp startTimestamp
= new TmfTimestamp(event
.getStartTime(), ITmfTimestamp
.NANOSECOND_SCALE
);
554 final ITmfTimestamp endTimestamp
= new TmfTimestamp(event
.getEndTime(), ITmfTimestamp
.NANOSECOND_SCALE
);
555 TmfTimeRange range
= new TmfTimeRange(startTimestamp
, endTimestamp
);
556 TmfTimestamp timestamp
= new TmfTimestamp(fViewer
.getSelectedTime(), ITmfTimestamp
.NANOSECOND_SCALE
);
557 broadcast(new TmfRangeSynchSignal(this, range
, timestamp
));
561 public void selectionChanged(TimeGraphSelectionEvent event
) {
562 ITimeGraphEntry timeAnalysisEntry
= null;
563 if (event
.getSelection() instanceof TimeChartAnalysisEntry
) {
564 timeAnalysisEntry
= event
.getSelection();
565 } else if (event
.getSelection() instanceof TimeChartEvent
) {
566 timeAnalysisEntry
= ((TimeChartEvent
) event
.getSelection()).getEntry();
568 if (timeAnalysisEntry
instanceof TimeChartAnalysisEntry
) {
569 broadcast(new TmfTraceSelectedSignal(this, ((TimeChartAnalysisEntry
) timeAnalysisEntry
).getTrace()));
574 public void timeSelected(TimeGraphTimeEvent event
) {
575 broadcast(new TmfTimeSynchSignal(this, new TmfTimestamp(event
.getTime(), TIMESTAMP_SCALE
)));
579 public void colorSettingsChanged(ColorSetting
[] colorSettings
) {
580 // Set presentation provider again to trigger re-creation of new color settings which are stored
581 // in the TimeGraphControl class
582 fViewer
.setTimeGraphProvider(fPresentationProvider
);
587 public void resourceChanged(IResourceChangeEvent event
) {
588 for (IMarkerDelta delta
: event
.findMarkerDeltas(IMarker
.BOOKMARK
, false)) {
589 for (TimeChartDecorationProvider provider
: fDecorationProviders
.values()) {
590 if (delta
.getResource().equals(provider
.getBookmarksFile())) {
591 if (delta
.getKind() == IResourceDelta
.CHANGED
&& delta
.getMarker().getAttribute(IMarker
.LOCATION
, -1) != -1) {
592 provider
.refreshBookmarks();
593 } else if (delta
.getKind() == IResourceDelta
.REMOVED
) {
594 provider
.refreshBookmarks();
602 // ------------------------------------------------------------------------
604 // ------------------------------------------------------------------------
607 * Handler for the Trace Opened signal
610 * The incoming signal
614 public void traceOpened(TmfTraceOpenedSignal signal
) {
615 final ITmfTrace trace
= signal
.getTrace();
616 final IFile bookmarksFile
= signal
.getBookmarksFile();
617 TimeChartAnalysisEntry timeAnalysisEntry
= null;
618 for (int i
= 0; i
< fTimeAnalysisEntries
.size(); i
++) {
619 if (fTimeAnalysisEntries
.get(i
).getTrace().equals(trace
)) {
620 timeAnalysisEntry
= fTimeAnalysisEntries
.get(i
);
624 if (timeAnalysisEntry
== null) {
625 timeAnalysisEntry
= new TimeChartAnalysisEntry(trace
, fDisplayWidth
* 2);
626 fTimeAnalysisEntries
.add(timeAnalysisEntry
);
627 fDecorationProviders
.put(trace
, new TimeChartDecorationProvider(bookmarksFile
));
628 Thread thread
= new ProcessTraceThread(timeAnalysisEntry
);
635 * Handler for the Trace Closed signal
638 * The incoming signal
642 public void traceClosed(TmfTraceClosedSignal signal
) {
643 final ITmfTrace trace
= signal
.getTrace();
644 for (int i
= 0; i
< fTimeAnalysisEntries
.size(); i
++) {
645 if (fTimeAnalysisEntries
.get(i
).getTrace().equals(trace
)) {
646 fTimeAnalysisEntries
.remove(i
);
647 fDecorationProviders
.remove(trace
);
648 synchronized (fDecorateThreads
) {
649 for (DecorateThread thread
: fDecorateThreads
) {
650 if (thread
.fTimeAnalysisEntry
.getTrace() == trace
) {
652 fDecorateThreads
.remove(thread
);
664 * Handler for the Trace Selected signal
667 * The incoming signal
670 public void traceSelected(TmfTraceSelectedSignal signal
) {
671 if (signal
.getSource() != this) {
672 ITmfTrace trace
= signal
.getTrace();
673 for (int i
= 0; i
< fTimeAnalysisEntries
.size(); i
++) {
674 if (fTimeAnalysisEntries
.get(i
).getTrace().equals(trace
)) {
675 fViewer
.setSelection(fTimeAnalysisEntries
.get(i
));
679 fViewer
.setSelectedTime(trace
.getCurrentTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue(), false);
684 * Handler for the Trace Updated signal
687 * The incoming signal
690 public void traceUpdated(TmfTraceUpdatedSignal signal
) {
691 final ITmfTrace trace
= signal
.getTrace();
692 for (int i
= 0; i
< fTimeAnalysisEntries
.size(); i
++) {
693 TimeChartAnalysisEntry timeAnalysisEntry
= fTimeAnalysisEntries
.get(i
);
694 if (timeAnalysisEntry
.getTrace().equals(trace
)) {
695 updateTraceEntry(timeAnalysisEntry
, Long
.MAX_VALUE
, 0, Long
.MAX_VALUE
);
702 * Handler for the Time Synch signal
705 * The incoming signal
708 public void currentTimeUpdated(TmfTimeSynchSignal signal
) {
709 final long time
= signal
.getCurrentTime().normalize(0, TIMESTAMP_SCALE
).getValue();
710 Display
.getDefault().asyncExec(new Runnable() {
713 fViewer
.setSelectedTime(time
, true);
719 * Handler for the Time Range Synch signal
722 * The incoming signal
726 public void synchToRange(final TmfRangeSynchSignal signal
) {
727 if (signal
.getSource() == this) {
730 final long startTime
= signal
.getCurrentRange().getStartTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
731 final long endTime
= signal
.getCurrentRange().getEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
732 final long time
= signal
.getCurrentTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
733 Display
.getDefault().asyncExec(new Runnable() {
736 fStartTime
= startTime
;
738 itemize(fStartTime
, fStopTime
);
739 fViewer
.setStartFinishTime(startTime
, endTime
);
740 fViewer
.setSelectedTime(time
, false);
746 * Handler for the Event Filter Applied signal
749 * The incoming signal
753 public void filterApplied(TmfEventFilterAppliedSignal signal
) {
754 TimeChartDecorationProvider decorationProvider
= fDecorationProviders
.get(signal
.getTrace());
755 if (decorationProvider
== null) {
758 decorationProvider
.filterApplied(signal
.getEventFilter());
763 * Handler for the Event Search Applied signal
766 * The incoming signal
770 public void searchApplied(TmfEventSearchAppliedSignal signal
) {
771 TimeChartDecorationProvider decorationProvider
= fDecorationProviders
.get(signal
.getTrace());
772 if (decorationProvider
== null) {
775 decorationProvider
.searchApplied(signal
.getSearchFilter());