1 /*******************************************************************************
2 * Copyright (c) 2012 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
.internal
.lttng2
.kernel
.ui
.views
.controlflow
;
15 import java
.util
.ArrayList
;
16 import java
.util
.Arrays
;
17 import java
.util
.Collections
;
18 import java
.util
.Comparator
;
19 import java
.util
.List
;
21 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
22 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
23 import org
.eclipse
.jface
.action
.Action
;
24 import org
.eclipse
.jface
.action
.IToolBarManager
;
25 import org
.eclipse
.jface
.action
.Separator
;
26 import org
.eclipse
.jface
.viewers
.ILabelProviderListener
;
27 import org
.eclipse
.jface
.viewers
.ITableLabelProvider
;
28 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
29 import org
.eclipse
.jface
.viewers
.Viewer
;
30 import org
.eclipse
.linuxtools
.internal
.lttng2
.kernel
.core
.Attributes
;
31 import org
.eclipse
.linuxtools
.internal
.lttng2
.kernel
.ui
.Messages
;
32 import org
.eclipse
.linuxtools
.lttng2
.kernel
.core
.trace
.CtfKernelTrace
;
33 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfTimestamp
;
34 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
35 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimeRange
;
36 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimestamp
;
37 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.AttributeNotFoundException
;
38 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.StateValueTypeException
;
39 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TimeRangeException
;
40 import org
.eclipse
.linuxtools
.tmf
.core
.interval
.ITmfStateInterval
;
41 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfExperimentSelectedSignal
;
42 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfRangeSynchSignal
;
43 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalHandler
;
44 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfStateSystemBuildCompleted
;
45 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTimeSynchSignal
;
46 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.IStateSystemQuerier
;
47 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
48 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfExperiment
;
49 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.TmfView
;
50 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.ITimeGraphRangeListener
;
51 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.ITimeGraphSelectionListener
;
52 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.ITimeGraphTimeListener
;
53 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.TimeGraphCombo
;
54 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.TimeGraphRangeUpdateEvent
;
55 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.TimeGraphSelectionEvent
;
56 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.TimeGraphTimeEvent
;
57 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.model
.ITimeEvent
;
58 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.model
.ITimeGraphEntry
;
59 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.model
.TimeEvent
;
60 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
.Utils
;
61 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
.Utils
.Resolution
;
62 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
.Utils
.TimeFormat
;
63 import org
.eclipse
.swt
.SWT
;
64 import org
.eclipse
.swt
.graphics
.Image
;
65 import org
.eclipse
.swt
.widgets
.Composite
;
66 import org
.eclipse
.swt
.widgets
.Display
;
67 import org
.eclipse
.swt
.widgets
.TreeColumn
;
68 import org
.eclipse
.ui
.IActionBars
;
71 * The Control Flow view main object
74 public class ControlFlowView
extends TmfView
{
76 // ------------------------------------------------------------------------
78 // ------------------------------------------------------------------------
83 public static final String ID
= "org.eclipse.linuxtools.lttng2.kernel.ui.views.controlflow"; //$NON-NLS-1$
88 private static final long INITIAL_WINDOW_OFFSET
= (1L * 100 * 1000 * 1000); // .1sec
90 private static final String PROCESS_COLUMN
= Messages
.ControlFlowView_processColumn
;
91 private static final String TID_COLUMN
= Messages
.ControlFlowView_tidColumn
;
92 private static final String PTID_COLUMN
= Messages
.ControlFlowView_ptidColumn
;
93 private static final String BIRTH_TIME_COLUMN
= Messages
.ControlFlowView_birthTimeColumn
;
94 private static final String TRACE_COLUMN
= Messages
.ControlFlowView_traceColumn
;
96 private final String
[] COLUMN_NAMES
= new String
[] {
104 // ------------------------------------------------------------------------
106 // ------------------------------------------------------------------------
108 // The timegraph combo
109 private TimeGraphCombo fTimeGraphCombo
;
111 // The selected experiment
112 private TmfExperiment
<ITmfEvent
> fSelectedExperiment
;
114 // The timegraph entry list
115 private ArrayList
<ControlFlowEntry
> fEntryList
;
117 // The time graph entry list synchronization object
118 final private Object fEntryListSyncObj
= new Object();
121 private long fStartTime
;
124 private long fEndTime
;
127 private final int fDisplayWidth
;
130 private ZoomThread fZoomThread
;
132 // The next resource action
133 private Action fNextResourceAction
;
135 // The previous resource action
136 private Action fPreviousResourceAction
;
138 // A comparator class
139 private final ControlFlowEntryComparator fControlFlowEntryComparator
= new ControlFlowEntryComparator();
141 // ------------------------------------------------------------------------
143 // ------------------------------------------------------------------------
145 private class TreeContentProvider
implements ITreeContentProvider
{
148 public void dispose() {
152 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {
156 public Object
[] getElements(Object inputElement
) {
157 return (ITimeGraphEntry
[]) inputElement
;
161 public Object
[] getChildren(Object parentElement
) {
162 ITimeGraphEntry entry
= (ITimeGraphEntry
) parentElement
;
163 return entry
.getChildren();
167 public Object
getParent(Object element
) {
168 ITimeGraphEntry entry
= (ITimeGraphEntry
) element
;
169 return entry
.getParent();
173 public boolean hasChildren(Object element
) {
174 ITimeGraphEntry entry
= (ITimeGraphEntry
) element
;
175 return entry
.hasChildren();
180 private class TreeLabelProvider
implements ITableLabelProvider
{
183 public void addListener(ILabelProviderListener listener
) {
187 public void dispose() {
191 public boolean isLabelProperty(Object element
, String property
) {
196 public void removeListener(ILabelProviderListener listener
) {
200 public Image
getColumnImage(Object element
, int columnIndex
) {
205 public String
getColumnText(Object element
, int columnIndex
) {
206 ControlFlowEntry entry
= (ControlFlowEntry
) element
;
207 if (columnIndex
== 0) {
208 return entry
.getName();
209 } else if (columnIndex
== 1) {
210 return Integer
.toString(entry
.getThreadId());
211 } else if (columnIndex
== 2) {
212 if (entry
.getParentThreadId() > 0) {
213 return Integer
.toString(entry
.getParentThreadId());
215 } else if (columnIndex
== 3) {
216 return Utils
.formatTime(entry
.getBirthTime(), TimeFormat
.ABSOLUTE
, Resolution
.NANOSEC
);
217 } else if (columnIndex
== 4) {
218 return entry
.getTrace().getName();
220 return ""; //$NON-NLS-1$
225 private static class ControlFlowEntryComparator
implements Comparator
<ITimeGraphEntry
> {
228 public int compare(ITimeGraphEntry o1
, ITimeGraphEntry o2
) {
231 if ((o1
instanceof ControlFlowEntry
) && (o2
instanceof ControlFlowEntry
)) {
232 ControlFlowEntry entry1
= (ControlFlowEntry
) o1
;
233 ControlFlowEntry entry2
= (ControlFlowEntry
) o2
;
234 result
= entry1
.getTrace().getStartTime().compareTo(entry2
.getTrace().getStartTime());
236 result
= entry1
.getTrace().getName().compareTo(entry2
.getTrace().getName());
239 result
= entry1
.getThreadId() < entry2
.getThreadId() ?
-1 : entry1
.getThreadId() > entry2
.getThreadId() ?
1 : 0;
244 result
= o1
.getStartTime() < o2
.getStartTime() ?
-1 : o1
.getStartTime() > o2
.getStartTime() ?
1 : 0;
252 private class ZoomThread
extends Thread
{
253 private final long fZoomStartTime
;
254 private final long fZoomEndTime
;
255 private final long fResolution
;
256 private final IProgressMonitor fMonitor
;
258 public ZoomThread(long startTime
, long endTime
) {
259 super("ControlFlowView zoom"); //$NON-NLS-1$
260 fZoomStartTime
= startTime
;
261 fZoomEndTime
= endTime
;
262 fResolution
= Math
.max(1, (fZoomEndTime
- fZoomStartTime
) / fDisplayWidth
);
263 fMonitor
= new NullProgressMonitor();
268 ArrayList
<ControlFlowEntry
> entryList
= null;
269 synchronized (fEntryListSyncObj
) {
270 entryList
= fEntryList
;
272 if (entryList
== null) {
275 for (ControlFlowEntry entry
: entryList
) {
276 if (fMonitor
.isCanceled()) {
279 zoom(entry
, fMonitor
);
284 private void zoom(ControlFlowEntry entry
, IProgressMonitor monitor
) {
285 if (fZoomStartTime
<= fStartTime
&& fZoomEndTime
>= fEndTime
) {
286 entry
.setZoomedEventList(null);
288 List
<ITimeEvent
> zoomedEventList
= getEventList(entry
, fZoomStartTime
, fZoomEndTime
, fResolution
, monitor
);
289 if (zoomedEventList
!= null) {
290 entry
.setZoomedEventList(zoomedEventList
);
293 for (ControlFlowEntry child
: entry
.getChildren()) {
294 if (fMonitor
.isCanceled()) {
297 zoom(child
, monitor
);
301 public void cancel() {
302 fMonitor
.setCanceled(true);
306 // ------------------------------------------------------------------------
308 // ------------------------------------------------------------------------
313 public ControlFlowView() {
315 fDisplayWidth
= Display
.getDefault().getBounds().width
;
318 // ------------------------------------------------------------------------
320 // ------------------------------------------------------------------------
323 * @see org.eclipse.linuxtools.tmf.ui.views.TmfView#createPartControl(org.eclipse.swt.widgets.Composite)
326 public void createPartControl(Composite parent
) {
327 fTimeGraphCombo
= new TimeGraphCombo(parent
, SWT
.NONE
);
329 fTimeGraphCombo
.setTreeContentProvider(new TreeContentProvider());
331 fTimeGraphCombo
.setTreeLabelProvider(new TreeLabelProvider());
333 fTimeGraphCombo
.setTimeGraphProvider(new ControlFlowPresentationProvider());
335 fTimeGraphCombo
.setTreeColumns(COLUMN_NAMES
);
337 fTimeGraphCombo
.getTimeGraphViewer().addRangeListener(new ITimeGraphRangeListener() {
339 public void timeRangeUpdated(TimeGraphRangeUpdateEvent event
) {
340 final long startTime
= event
.getStartTime();
341 final long endTime
= event
.getEndTime();
342 TmfTimeRange range
= new TmfTimeRange(new CtfTmfTimestamp(startTime
), new CtfTmfTimestamp(endTime
));
343 TmfTimestamp time
= new CtfTmfTimestamp(fTimeGraphCombo
.getTimeGraphViewer().getSelectedTime());
344 broadcast(new TmfRangeSynchSignal(ControlFlowView
.this, range
, time
));
345 if (fZoomThread
!= null) {
346 fZoomThread
.cancel();
348 startZoomThread(startTime
, endTime
);
352 fTimeGraphCombo
.getTimeGraphViewer().addTimeListener(new ITimeGraphTimeListener() {
354 public void timeSelected(TimeGraphTimeEvent event
) {
355 long time
= event
.getTime();
356 broadcast(new TmfTimeSynchSignal(ControlFlowView
.this, new CtfTmfTimestamp(time
)));
360 fTimeGraphCombo
.addSelectionListener(new ITimeGraphSelectionListener() {
362 public void selectionChanged(TimeGraphSelectionEvent event
) {
363 //ITimeGraphEntry selection = event.getSelection();
367 fTimeGraphCombo
.getTimeGraphViewer().setTimeCalendarFormat(true);
369 final Thread thread
= new Thread("ControlFlowView build") { //$NON-NLS-1$
372 if (TmfExperiment
.getCurrentExperiment() != null) {
373 selectExperiment(TmfExperiment
.getCurrentExperiment());
379 // View Action Handling
381 contributeToActionBars();
385 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
388 public void setFocus() {
389 fTimeGraphCombo
.setFocus();
392 // ------------------------------------------------------------------------
394 // ------------------------------------------------------------------------
397 * Handler for the experiment selected signal
400 * The signal that's received
403 public void experimentSelected(final TmfExperimentSelectedSignal
<?
extends ITmfEvent
> signal
) {
404 if (signal
.getExperiment().equals(fSelectedExperiment
)) {
408 final Thread thread
= new Thread("ControlFlowView build") { //$NON-NLS-1$
411 selectExperiment(signal
.getExperiment());
418 * Handler for the synch signal
421 * The signal that's received
424 public void synchToTime(final TmfTimeSynchSignal signal
) {
425 if (signal
.getSource() == this || fSelectedExperiment
== null) {
428 final long time
= signal
.getCurrentTime().normalize(0, -9).getValue();
431 for (ITmfTrace
<?
> trace
: fSelectedExperiment
.getTraces()) {
435 if (trace
instanceof CtfKernelTrace
) {
436 CtfKernelTrace ctfKernelTrace
= (CtfKernelTrace
) trace
;
437 IStateSystemQuerier ssq
= ctfKernelTrace
.getStateSystem();
438 if (time
>= ssq
.getStartTime() && time
<= ssq
.getCurrentEndTime()) {
439 List
<Integer
> currentThreadQuarks
= ssq
.getQuarks(Attributes
.CPUS
, "*", Attributes
.CURRENT_THREAD
); //$NON-NLS-1$
440 for (int currentThreadQuark
: currentThreadQuarks
) {
442 ITmfStateInterval currentThreadInterval
= ssq
.querySingleState(time
, currentThreadQuark
);
443 int currentThread
= currentThreadInterval
.getStateValue().unboxInt();
444 if (currentThread
> 0) {
445 int statusQuark
= ssq
.getQuarkAbsolute(Attributes
.THREADS
, Integer
.toString(currentThread
), Attributes
.STATUS
);
446 ITmfStateInterval statusInterval
= ssq
.querySingleState(time
, statusQuark
);
447 if (statusInterval
.getStartTime() == time
) {
448 thread
= currentThread
;
452 } catch (AttributeNotFoundException e
) {
454 } catch (TimeRangeException e
) {
456 } catch (StateValueTypeException e
) {
463 final int selectedThread
= thread
;
465 Display
.getDefault().asyncExec(new Runnable() {
468 if (fTimeGraphCombo
.isDisposed()) {
471 fTimeGraphCombo
.getTimeGraphViewer().setSelectedTime(time
, true);
472 startZoomThread(fTimeGraphCombo
.getTimeGraphViewer().getTime0(), fTimeGraphCombo
.getTimeGraphViewer().getTime1());
474 if (selectedThread
> 0) {
475 for (Object element
: fTimeGraphCombo
.getTimeGraphViewer().getExpandedElements()) {
476 if (element
instanceof ControlFlowEntry
) {
477 ControlFlowEntry entry
= (ControlFlowEntry
) element
;
478 if (entry
.getThreadId() == selectedThread
) {
479 fTimeGraphCombo
.setSelection(entry
);
490 * Handler for the range sync signal
493 * The signal that's received
496 public void synchToRange(final TmfRangeSynchSignal signal
) {
497 if (signal
.getSource() == this || fSelectedExperiment
== null) {
500 final long startTime
= signal
.getCurrentRange().getStartTime().normalize(0, -9).getValue();
501 final long endTime
= signal
.getCurrentRange().getEndTime().normalize(0, -9).getValue();
502 final long time
= signal
.getCurrentTime().normalize(0, -9).getValue();
503 Display
.getDefault().asyncExec(new Runnable() {
506 if (fTimeGraphCombo
.isDisposed()) {
509 fTimeGraphCombo
.getTimeGraphViewer().setStartFinishTime(startTime
, endTime
);
510 fTimeGraphCombo
.getTimeGraphViewer().setSelectedTime(time
, false);
511 startZoomThread(startTime
, endTime
);
517 * Handler for the state system build completed signal
520 * The signal that's received
523 public void stateSystemBuildCompleted (final TmfStateSystemBuildCompleted signal
) {
524 final TmfExperiment
<?
> selectedExperiment
= fSelectedExperiment
;
525 if (selectedExperiment
== null) {
528 for (ITmfTrace
<?
> trace
: selectedExperiment
.getTraces()) {
529 if (trace
== signal
.getTrace() && trace
instanceof CtfKernelTrace
) {
530 final Thread thread
= new Thread("ControlFlowView build") { //$NON-NLS-1$
534 selectExperiment(selectedExperiment
);
542 // ------------------------------------------------------------------------
544 // ------------------------------------------------------------------------
546 @SuppressWarnings("unchecked")
547 private void selectExperiment(TmfExperiment
<?
> experiment
) {
548 fStartTime
= Long
.MAX_VALUE
;
549 fEndTime
= Long
.MIN_VALUE
;
550 fSelectedExperiment
= (TmfExperiment
<ITmfEvent
>) experiment
;
551 ArrayList
<ControlFlowEntry
> rootList
= new ArrayList
<ControlFlowEntry
>();
552 for (ITmfTrace
<?
> trace
: experiment
.getTraces()) {
553 if (trace
instanceof CtfKernelTrace
) {
554 ArrayList
<ControlFlowEntry
> entryList
= new ArrayList
<ControlFlowEntry
>();
555 CtfKernelTrace ctfKernelTrace
= (CtfKernelTrace
) trace
;
556 IStateSystemQuerier ssq
= ctfKernelTrace
.getStateSystem();
557 long start
= ssq
.getStartTime();
558 long end
= ssq
.getCurrentEndTime() + 1;
559 fStartTime
= Math
.min(fStartTime
, start
);
560 fEndTime
= Math
.max(fEndTime
, end
);
561 List
<Integer
> threadQuarks
= ssq
.getQuarks(Attributes
.THREADS
, "*"); //$NON-NLS-1$
562 for (int threadQuark
: threadQuarks
) {
563 String threadName
= ssq
.getAttributeName(threadQuark
);
566 threadId
= Integer
.parseInt(threadName
);
567 } catch (NumberFormatException e1
) {
570 if (threadId
== 0) { // ignore the swapper thread
573 int execNameQuark
= -1;
576 execNameQuark
= ssq
.getQuarkRelative(threadQuark
, Attributes
.EXEC_NAME
);
577 } catch (AttributeNotFoundException e
) {
580 int ppidQuark
= ssq
.getQuarkRelative(threadQuark
, Attributes
.PPID
);
581 List
<ITmfStateInterval
> execNameIntervals
= ssq
.queryHistoryRange(execNameQuark
, start
, end
- 1);
583 for (ITmfStateInterval execNameInterval
: execNameIntervals
) {
584 if (!execNameInterval
.getStateValue().isNull() && execNameInterval
.getStateValue().getType() == 1) {
585 String execName
= execNameInterval
.getStateValue().unboxStr();
586 long startTime
= execNameInterval
.getStartTime();
587 long endTime
= execNameInterval
.getEndTime() + 1;
588 if (birthTime
== -1) {
589 birthTime
= startTime
;
592 if (ppidQuark
!= -1) {
593 ITmfStateInterval ppidInterval
= ssq
.querySingleState(startTime
, ppidQuark
);
594 ppid
= ppidInterval
.getStateValue().unboxInt();
596 ControlFlowEntry entry
= new ControlFlowEntry(threadQuark
, ctfKernelTrace
, execName
, threadId
, ppid
, birthTime
, startTime
, endTime
);
597 entryList
.add(entry
);
598 entry
.addEvent(new TimeEvent(entry
, startTime
, endTime
- startTime
));
603 } catch (AttributeNotFoundException e
) {
605 } catch (TimeRangeException e
) {
607 } catch (StateValueTypeException e
) {
611 buildTree(entryList
, rootList
);
613 Collections
.sort(rootList
, fControlFlowEntryComparator
);
614 synchronized (fEntryListSyncObj
) {
615 fEntryList
= (ArrayList
<ControlFlowEntry
>) rootList
.clone();
617 refresh(INITIAL_WINDOW_OFFSET
);
619 for (ControlFlowEntry entry
: rootList
) {
620 buildStatusEvents(entry
);
624 private static void buildTree(ArrayList
<ControlFlowEntry
> entryList
,
625 ArrayList
<ControlFlowEntry
> rootList
) {
626 for (ControlFlowEntry entry
: entryList
) {
628 if (entry
.getParentThreadId() > 0) {
629 for (ControlFlowEntry parent
: entryList
) {
630 if (parent
.getThreadId() == entry
.getParentThreadId() &&
631 entry
.getStartTime() >= parent
.getStartTime() &&
632 entry
.getStartTime() <= parent
.getEndTime()) {
633 parent
.addChild(entry
);
645 private void buildStatusEvents(ControlFlowEntry entry
) {
646 IStateSystemQuerier ssq
= entry
.getTrace().getStateSystem();
647 long start
= ssq
.getStartTime();
648 long end
= ssq
.getCurrentEndTime() + 1;
649 long resolution
= Math
.max(1, (end
- start
) / fDisplayWidth
);
650 List
<ITimeEvent
> eventList
= getEventList(entry
, entry
.getStartTime(), entry
.getEndTime(), resolution
, new NullProgressMonitor());
651 entry
.setEventList(eventList
);
653 for (ITimeGraphEntry child
: entry
.getChildren()) {
654 buildStatusEvents((ControlFlowEntry
) child
);
658 private static List
<ITimeEvent
> getEventList(ControlFlowEntry entry
,
659 long startTime
, long endTime
, long resolution
,
660 IProgressMonitor monitor
) {
661 startTime
= Math
.max(startTime
, entry
.getStartTime());
662 endTime
= Math
.min(endTime
, entry
.getEndTime());
663 if (endTime
<= startTime
) {
666 IStateSystemQuerier ssq
= entry
.getTrace().getStateSystem();
667 List
<ITimeEvent
> eventList
= null;
669 int statusQuark
= ssq
.getQuarkRelative(entry
.getThreadQuark(), Attributes
.STATUS
);
670 List
<ITmfStateInterval
> statusIntervals
= ssq
.queryHistoryRange(statusQuark
, startTime
, endTime
- 1, resolution
);
671 eventList
= new ArrayList
<ITimeEvent
>(statusIntervals
.size());
672 long lastEndTime
= -1;
673 for (ITmfStateInterval statusInterval
: statusIntervals
) {
674 if (monitor
.isCanceled()) {
677 long time
= statusInterval
.getStartTime();
678 long duration
= statusInterval
.getEndTime() - time
+ 1;
681 status
= statusInterval
.getStateValue().unboxInt();
682 } catch (StateValueTypeException e
) {
685 if (lastEndTime
!= time
&& lastEndTime
!= -1) {
686 eventList
.add(new ControlFlowEvent(entry
, lastEndTime
, time
- lastEndTime
, 0));
688 eventList
.add(new ControlFlowEvent(entry
, time
, duration
, status
));
689 lastEndTime
= time
+ duration
;
691 } catch (AttributeNotFoundException e
) {
693 } catch (TimeRangeException e
) {
699 private void refresh(final long windowRange
) {
700 Display
.getDefault().asyncExec(new Runnable() {
703 if (fTimeGraphCombo
.isDisposed()) {
706 ITimeGraphEntry
[] entries
= null;
707 synchronized (fEntryListSyncObj
) {
708 entries
= fEntryList
.toArray(new ITimeGraphEntry
[0]);
710 Arrays
.sort(entries
, fControlFlowEntryComparator
);
711 fTimeGraphCombo
.setInput(entries
);
712 fTimeGraphCombo
.getTimeGraphViewer().setTimeBounds(fStartTime
, fEndTime
);
714 long endTime
= fStartTime
+ windowRange
;
716 if (fEndTime
< endTime
) {
719 fTimeGraphCombo
.getTimeGraphViewer().setStartFinishTime(fStartTime
, endTime
);
720 for (TreeColumn column
: fTimeGraphCombo
.getTreeViewer().getTree().getColumns()) {
724 startZoomThread(fStartTime
, endTime
);
729 private void redraw() {
730 Display
.getDefault().asyncExec(new Runnable() {
733 if (fTimeGraphCombo
.isDisposed()) {
736 fTimeGraphCombo
.redraw();
737 fTimeGraphCombo
.update();
742 private void startZoomThread(long startTime
, long endTime
) {
743 if (fZoomThread
!= null) {
744 fZoomThread
.cancel();
746 fZoomThread
= new ZoomThread(startTime
, endTime
);
750 private void makeActions() {
751 fPreviousResourceAction
= fTimeGraphCombo
.getTimeGraphViewer().getPreviousItemAction();
752 fPreviousResourceAction
.setText(Messages
.ControlFlowView_previousProcessActionNameText
);
753 fPreviousResourceAction
.setToolTipText(Messages
.ControlFlowView_previousProcessActionToolTipText
);
754 fNextResourceAction
= fTimeGraphCombo
.getTimeGraphViewer().getNextItemAction();
755 fNextResourceAction
.setText(Messages
.ControlFlowView_nextProcessActionNameText
);
756 fNextResourceAction
.setToolTipText(Messages
.ControlFlowView_nextProcessActionToolTipText
);
759 private void contributeToActionBars() {
760 IActionBars bars
= getViewSite().getActionBars();
761 fillLocalToolBar(bars
.getToolBarManager());
764 private void fillLocalToolBar(IToolBarManager manager
) {
765 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getShowLegendAction());
766 manager
.add(new Separator());
767 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getResetScaleAction());
768 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getPreviousEventAction());
769 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getNextEventAction());
770 manager
.add(fPreviousResourceAction
);
771 manager
.add(fNextResourceAction
);
772 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getZoomInAction());
773 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getZoomOutAction());
774 manager
.add(new Separator());