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
;
70 public class ControlFlowView
extends TmfView
{
72 // ------------------------------------------------------------------------
74 // ------------------------------------------------------------------------
79 public static final String ID
= "org.eclipse.linuxtools.lttng2.kernel.ui.views.controlflow"; //$NON-NLS-1$
84 private static final long INITIAL_WINDOW_OFFSET
= (1L * 100 * 1000 * 1000); // .1sec
86 private static final String PROCESS_COLUMN
= Messages
.ControlFlowView_processColumn
;
87 private static final String TID_COLUMN
= Messages
.ControlFlowView_tidColumn
;
88 private static final String PTID_COLUMN
= Messages
.ControlFlowView_ptidColumn
;
89 private static final String BIRTH_TIME_COLUMN
= Messages
.ControlFlowView_birthTimeColumn
;
90 private static final String TRACE_COLUMN
= Messages
.ControlFlowView_traceColumn
;
92 private final String
[] COLUMN_NAMES
= new String
[] {
100 // ------------------------------------------------------------------------
102 // ------------------------------------------------------------------------
104 // The timegraph combo
105 private TimeGraphCombo fTimeGraphCombo
;
107 // The selected experiment
108 private TmfExperiment
<ITmfEvent
> fSelectedExperiment
;
110 // The timegraph entry list
111 private ArrayList
<ControlFlowEntry
> fEntryList
;
114 private long fStartTime
;
117 private long fEndTime
;
120 private int fDisplayWidth
;
123 private ZoomThread fZoomThread
;
125 // The next resource action
126 private Action fNextResourceAction
;
128 // The previous resource action
129 private Action fPreviousResourceAction
;
131 // A comparator class
132 private ControlFlowEntryComparator fControlFlowEntryComparator
= new ControlFlowEntryComparator();
134 // ------------------------------------------------------------------------
136 // ------------------------------------------------------------------------
138 private class TreeContentProvider
implements ITreeContentProvider
{
141 public void dispose() {
145 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {
149 public Object
[] getElements(Object inputElement
) {
150 return (ITimeGraphEntry
[]) inputElement
;
154 public Object
[] getChildren(Object parentElement
) {
155 ITimeGraphEntry entry
= (ITimeGraphEntry
) parentElement
;
156 return entry
.getChildren();
160 public Object
getParent(Object element
) {
161 ITimeGraphEntry entry
= (ITimeGraphEntry
) element
;
162 return entry
.getParent();
166 public boolean hasChildren(Object element
) {
167 ITimeGraphEntry entry
= (ITimeGraphEntry
) element
;
168 return entry
.hasChildren();
173 private class TreeLabelProvider
implements ITableLabelProvider
{
176 public void addListener(ILabelProviderListener listener
) {
180 public void dispose() {
184 public boolean isLabelProperty(Object element
, String property
) {
189 public void removeListener(ILabelProviderListener listener
) {
193 public Image
getColumnImage(Object element
, int columnIndex
) {
198 public String
getColumnText(Object element
, int columnIndex
) {
199 ControlFlowEntry entry
= (ControlFlowEntry
) element
;
200 if (columnIndex
== 0) {
201 return entry
.getName();
202 } else if (columnIndex
== 1) {
203 return Integer
.toString(entry
.getThreadId());
204 } else if (columnIndex
== 2) {
205 if (entry
.getParentThreadId() > 0) {
206 return Integer
.toString(entry
.getParentThreadId());
208 } else if (columnIndex
== 3) {
209 return Utils
.formatTime(entry
.getBirthTime(), TimeFormat
.ABSOLUTE
, Resolution
.NANOSEC
);
210 } else if (columnIndex
== 4) {
211 return entry
.getTrace().getName();
213 return ""; //$NON-NLS-1$
218 private static class ControlFlowEntryComparator
implements Comparator
<ITimeGraphEntry
> {
221 public int compare(ITimeGraphEntry o1
, ITimeGraphEntry o2
) {
224 if ((o1
instanceof ControlFlowEntry
) && (o2
instanceof ControlFlowEntry
)) {
225 ControlFlowEntry entry1
= (ControlFlowEntry
) o1
;
226 ControlFlowEntry entry2
= (ControlFlowEntry
) o2
;
227 result
= entry1
.getTrace().getStartTime().compareTo(entry2
.getTrace().getStartTime());
229 result
= entry1
.getTrace().getName().compareTo(entry2
.getTrace().getName());
232 result
= entry1
.getThreadId() < entry2
.getThreadId() ?
-1 : entry1
.getThreadId() > entry2
.getThreadId() ?
1 : 0;
237 result
= o1
.getStartTime() < o2
.getStartTime() ?
-1 : o1
.getStartTime() > o2
.getStartTime() ?
1 : 0;
245 private class ZoomThread
extends Thread
{
246 private long fZoomStartTime
;
247 private long fZoomEndTime
;
248 private long fResolution
;
249 private IProgressMonitor fMonitor
;
251 public ZoomThread(long startTime
, long endTime
) {
252 super("ControlFlowView zoom"); //$NON-NLS-1$
253 fZoomStartTime
= startTime
;
254 fZoomEndTime
= endTime
;
255 fResolution
= Math
.max(1, (fZoomEndTime
- fZoomStartTime
) / fDisplayWidth
);
256 fMonitor
= new NullProgressMonitor();
261 ArrayList
<ControlFlowEntry
> entryList
= fEntryList
;
262 if (entryList
== null) {
265 for (ControlFlowEntry entry
: entryList
) {
266 if (fMonitor
.isCanceled()) {
269 zoom(entry
, fMonitor
);
274 private void zoom(ControlFlowEntry entry
, IProgressMonitor monitor
) {
275 if (fZoomStartTime
<= fStartTime
&& fZoomEndTime
>= fEndTime
) {
276 entry
.setZoomedEventList(null);
278 List
<ITimeEvent
> zoomedEventList
= getEventList(entry
, fZoomStartTime
, fZoomEndTime
, fResolution
, monitor
);
279 if (zoomedEventList
!= null) {
280 entry
.setZoomedEventList(zoomedEventList
);
283 for (ControlFlowEntry child
: entry
.getChildren()) {
284 if (fMonitor
.isCanceled()) {
287 zoom(child
, monitor
);
291 public void cancel() {
292 fMonitor
.setCanceled(true);
296 // ------------------------------------------------------------------------
298 // ------------------------------------------------------------------------
300 public ControlFlowView() {
302 fDisplayWidth
= Display
.getDefault().getBounds().width
;
305 // ------------------------------------------------------------------------
307 // ------------------------------------------------------------------------
310 * @see org.eclipse.linuxtools.tmf.ui.views.TmfView#createPartControl(org.eclipse.swt.widgets.Composite)
313 public void createPartControl(Composite parent
) {
314 fTimeGraphCombo
= new TimeGraphCombo(parent
, SWT
.NONE
);
316 fTimeGraphCombo
.setTreeContentProvider(new TreeContentProvider());
318 fTimeGraphCombo
.setTreeLabelProvider(new TreeLabelProvider());
320 fTimeGraphCombo
.setTimeGraphProvider(new ControlFlowPresentationProvider());
322 fTimeGraphCombo
.setTreeColumns(COLUMN_NAMES
);
324 fTimeGraphCombo
.getTimeGraphViewer().addRangeListener(new ITimeGraphRangeListener() {
326 public void timeRangeUpdated(TimeGraphRangeUpdateEvent event
) {
327 final long startTime
= event
.getStartTime();
328 final long endTime
= event
.getEndTime();
329 TmfTimeRange range
= new TmfTimeRange(new CtfTmfTimestamp(startTime
), new CtfTmfTimestamp(endTime
));
330 TmfTimestamp time
= new CtfTmfTimestamp(fTimeGraphCombo
.getTimeGraphViewer().getSelectedTime());
331 broadcast(new TmfRangeSynchSignal(ControlFlowView
.this, range
, time
));
332 if (fZoomThread
!= null) {
333 fZoomThread
.cancel();
335 startZoomThread(startTime
, endTime
);
339 fTimeGraphCombo
.getTimeGraphViewer().addTimeListener(new ITimeGraphTimeListener() {
341 public void timeSelected(TimeGraphTimeEvent event
) {
342 long time
= event
.getTime();
343 broadcast(new TmfTimeSynchSignal(ControlFlowView
.this, new CtfTmfTimestamp(time
)));
347 fTimeGraphCombo
.addSelectionListener(new ITimeGraphSelectionListener() {
349 public void selectionChanged(TimeGraphSelectionEvent event
) {
350 //ITimeGraphEntry selection = event.getSelection();
354 fTimeGraphCombo
.getTimeGraphViewer().setTimeCalendarFormat(true);
356 final Thread thread
= new Thread("ControlFlowView build") { //$NON-NLS-1$
359 if (TmfExperiment
.getCurrentExperiment() != null) {
360 selectExperiment(TmfExperiment
.getCurrentExperiment());
366 // View Action Handling
368 contributeToActionBars();
372 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
375 public void setFocus() {
376 fTimeGraphCombo
.setFocus();
379 // ------------------------------------------------------------------------
381 // ------------------------------------------------------------------------
384 public void experimentSelected(final TmfExperimentSelectedSignal
<?
extends ITmfEvent
> signal
) {
385 if (signal
.getExperiment().equals(fSelectedExperiment
)) {
389 final Thread thread
= new Thread("ControlFlowView build") { //$NON-NLS-1$
392 selectExperiment(signal
.getExperiment());
399 public void synchToTime(final TmfTimeSynchSignal signal
) {
400 if (signal
.getSource() == this || fSelectedExperiment
== null) {
403 final long time
= signal
.getCurrentTime().normalize(0, -9).getValue();
406 for (ITmfTrace
<?
> trace
: fSelectedExperiment
.getTraces()) {
410 if (trace
instanceof CtfKernelTrace
) {
411 CtfKernelTrace ctfKernelTrace
= (CtfKernelTrace
) trace
;
412 IStateSystemQuerier ssq
= ctfKernelTrace
.getStateSystem();
413 if (time
>= ssq
.getStartTime() && time
<= ssq
.getCurrentEndTime()) {
414 List
<Integer
> currentThreadQuarks
= ssq
.getQuarks(Attributes
.CPUS
, "*", Attributes
.CURRENT_THREAD
); //$NON-NLS-1$
415 for (int currentThreadQuark
: currentThreadQuarks
) {
417 ITmfStateInterval currentThreadInterval
= ssq
.querySingleState(time
, currentThreadQuark
);
418 int currentThread
= currentThreadInterval
.getStateValue().unboxInt();
419 if (currentThread
> 0) {
420 int statusQuark
= ssq
.getQuarkAbsolute(Attributes
.THREADS
, Integer
.toString(currentThread
), Attributes
.STATUS
);
421 ITmfStateInterval statusInterval
= ssq
.querySingleState(time
, statusQuark
);
422 if (statusInterval
.getStartTime() == time
) {
423 thread
= currentThread
;
427 } catch (AttributeNotFoundException e
) {
429 } catch (TimeRangeException e
) {
431 } catch (StateValueTypeException e
) {
438 final int selectedThread
= thread
;
440 Display
.getDefault().asyncExec(new Runnable() {
443 if (fTimeGraphCombo
.isDisposed()) {
446 fTimeGraphCombo
.getTimeGraphViewer().setSelectedTime(time
, true);
447 startZoomThread(fTimeGraphCombo
.getTimeGraphViewer().getTime0(), fTimeGraphCombo
.getTimeGraphViewer().getTime1());
449 if (selectedThread
> 0) {
450 for (Object element
: fTimeGraphCombo
.getTimeGraphViewer().getExpandedElements()) {
451 if (element
instanceof ControlFlowEntry
) {
452 ControlFlowEntry entry
= (ControlFlowEntry
) element
;
453 if (entry
.getThreadId() == selectedThread
) {
454 fTimeGraphCombo
.setSelection(entry
);
465 public void synchToRange(final TmfRangeSynchSignal signal
) {
466 if (signal
.getSource() == this || fSelectedExperiment
== null) {
469 final long startTime
= signal
.getCurrentRange().getStartTime().normalize(0, -9).getValue();
470 final long endTime
= signal
.getCurrentRange().getEndTime().normalize(0, -9).getValue();
471 final long time
= signal
.getCurrentTime().normalize(0, -9).getValue();
472 Display
.getDefault().asyncExec(new Runnable() {
475 if (fTimeGraphCombo
.isDisposed()) {
478 fTimeGraphCombo
.getTimeGraphViewer().setStartFinishTime(startTime
, endTime
);
479 fTimeGraphCombo
.getTimeGraphViewer().setSelectedTime(time
, false);
480 startZoomThread(startTime
, endTime
);
486 public void stateSystemBuildCompleted (final TmfStateSystemBuildCompleted signal
) {
487 final TmfExperiment
<?
> selectedExperiment
= fSelectedExperiment
;
488 if (selectedExperiment
== null) {
491 for (ITmfTrace
<?
> trace
: selectedExperiment
.getTraces()) {
492 if (trace
== signal
.getTrace() && trace
instanceof CtfKernelTrace
) {
493 final Thread thread
= new Thread("ControlFlowView build") { //$NON-NLS-1$
497 selectExperiment(selectedExperiment
);
505 // ------------------------------------------------------------------------
507 // ------------------------------------------------------------------------
509 @SuppressWarnings("unchecked")
510 private void selectExperiment(TmfExperiment
<?
> experiment
) {
511 fStartTime
= Long
.MAX_VALUE
;
512 fEndTime
= Long
.MIN_VALUE
;
513 fSelectedExperiment
= (TmfExperiment
<ITmfEvent
>) experiment
;
514 ArrayList
<ControlFlowEntry
> rootList
= new ArrayList
<ControlFlowEntry
>();
515 for (ITmfTrace
<?
> trace
: experiment
.getTraces()) {
516 if (trace
instanceof CtfKernelTrace
) {
517 ArrayList
<ControlFlowEntry
> entryList
= new ArrayList
<ControlFlowEntry
>();
518 CtfKernelTrace ctfKernelTrace
= (CtfKernelTrace
) trace
;
519 IStateSystemQuerier ssq
= ctfKernelTrace
.getStateSystem();
520 long start
= ssq
.getStartTime();
521 long end
= ssq
.getCurrentEndTime() + 1;
522 fStartTime
= Math
.min(fStartTime
, start
);
523 fEndTime
= Math
.max(fEndTime
, end
);
524 List
<Integer
> threadQuarks
= ssq
.getQuarks(Attributes
.THREADS
, "*"); //$NON-NLS-1$
525 for (int threadQuark
: threadQuarks
) {
526 String threadName
= ssq
.getAttributeName(threadQuark
);
529 threadId
= Integer
.parseInt(threadName
);
530 } catch (NumberFormatException e1
) {
533 if (threadId
== 0) { // ignore the swapper thread
536 int execNameQuark
= -1;
539 execNameQuark
= ssq
.getQuarkRelative(threadQuark
, Attributes
.EXEC_NAME
);
540 } catch (AttributeNotFoundException e
) {
543 int ppidQuark
= ssq
.getQuarkRelative(threadQuark
, Attributes
.PPID
);
544 List
<ITmfStateInterval
> execNameIntervals
= ssq
.queryHistoryRange(execNameQuark
, start
, end
- 1);
546 for (ITmfStateInterval execNameInterval
: execNameIntervals
) {
547 if (!execNameInterval
.getStateValue().isNull() && execNameInterval
.getStateValue().getType() == 1) {
548 String execName
= execNameInterval
.getStateValue().unboxStr();
549 long startTime
= execNameInterval
.getStartTime();
550 long endTime
= execNameInterval
.getEndTime() + 1;
551 if (birthTime
== -1) {
552 birthTime
= startTime
;
555 if (ppidQuark
!= -1) {
556 ITmfStateInterval ppidInterval
= ssq
.querySingleState(startTime
, ppidQuark
);
557 ppid
= ppidInterval
.getStateValue().unboxInt();
559 ControlFlowEntry entry
= new ControlFlowEntry(threadQuark
, ctfKernelTrace
, execName
, threadId
, ppid
, birthTime
, startTime
, endTime
);
560 entryList
.add(entry
);
561 entry
.addEvent(new TimeEvent(entry
, startTime
, endTime
- startTime
));
566 } catch (AttributeNotFoundException e
) {
568 } catch (TimeRangeException e
) {
570 } catch (StateValueTypeException e
) {
574 buildTree(entryList
, rootList
);
576 Collections
.sort(rootList
, fControlFlowEntryComparator
);
577 fEntryList
= rootList
;
578 refresh(INITIAL_WINDOW_OFFSET
);
580 for (ControlFlowEntry entry
: rootList
) {
581 buildStatusEvents(entry
);
585 private void buildTree(ArrayList
<ControlFlowEntry
> entryList
, ArrayList
<ControlFlowEntry
> rootList
) {
586 for (ControlFlowEntry entry
: entryList
) {
588 if (entry
.getParentThreadId() > 0) {
589 for (ControlFlowEntry parent
: entryList
) {
590 if (parent
.getThreadId() == entry
.getParentThreadId() &&
591 entry
.getStartTime() >= parent
.getStartTime() &&
592 entry
.getStartTime() <= parent
.getEndTime()) {
593 parent
.addChild(entry
);
605 private void buildStatusEvents(ControlFlowEntry entry
) {
606 IStateSystemQuerier ssq
= entry
.getTrace().getStateSystem();
607 long start
= ssq
.getStartTime();
608 long end
= ssq
.getCurrentEndTime() + 1;
609 long resolution
= Math
.max(1, (end
- start
) / fDisplayWidth
);
610 List
<ITimeEvent
> eventList
= getEventList(entry
, entry
.getStartTime(), entry
.getEndTime(), resolution
, new NullProgressMonitor());
611 entry
.setEventList(eventList
);
613 for (ITimeGraphEntry child
: entry
.getChildren()) {
614 buildStatusEvents((ControlFlowEntry
) child
);
618 private List
<ITimeEvent
> getEventList(ControlFlowEntry entry
, long startTime
, long endTime
, long resolution
, IProgressMonitor monitor
) {
619 startTime
= Math
.max(startTime
, entry
.getStartTime());
620 endTime
= Math
.min(endTime
, entry
.getEndTime());
621 if (endTime
<= startTime
) {
624 IStateSystemQuerier ssq
= entry
.getTrace().getStateSystem();
625 List
<ITimeEvent
> eventList
= null;
627 int statusQuark
= ssq
.getQuarkRelative(entry
.getThreadQuark(), Attributes
.STATUS
);
628 List
<ITmfStateInterval
> statusIntervals
= ssq
.queryHistoryRange(statusQuark
, startTime
, endTime
- 1, resolution
);
629 eventList
= new ArrayList
<ITimeEvent
>(statusIntervals
.size());
630 long lastEndTime
= -1;
631 for (ITmfStateInterval statusInterval
: statusIntervals
) {
632 if (monitor
.isCanceled()) {
635 long time
= statusInterval
.getStartTime();
636 long duration
= statusInterval
.getEndTime() - time
+ 1;
639 status
= statusInterval
.getStateValue().unboxInt();
640 } catch (StateValueTypeException e
) {
643 if (lastEndTime
!= time
&& lastEndTime
!= -1) {
644 eventList
.add(new ControlFlowEvent(entry
, lastEndTime
, time
- lastEndTime
, 0));
646 eventList
.add(new ControlFlowEvent(entry
, time
, duration
, status
));
647 lastEndTime
= time
+ duration
;
649 } catch (AttributeNotFoundException e
) {
651 } catch (TimeRangeException e
) {
657 private void refresh(final long windowRange
) {
658 Display
.getDefault().asyncExec(new Runnable() {
661 if (fTimeGraphCombo
.isDisposed()) {
664 ITimeGraphEntry
[] entries
= fEntryList
.toArray(new ITimeGraphEntry
[0]);
665 Arrays
.sort(entries
, fControlFlowEntryComparator
);
666 fTimeGraphCombo
.setInput(entries
);
667 fTimeGraphCombo
.getTimeGraphViewer().setTimeBounds(fStartTime
, fEndTime
);
669 long endTime
= fStartTime
+ windowRange
;
671 if (fEndTime
< endTime
) {
674 fTimeGraphCombo
.getTimeGraphViewer().setStartFinishTime(fStartTime
, endTime
);
675 for (TreeColumn column
: fTimeGraphCombo
.getTreeViewer().getTree().getColumns()) {
679 startZoomThread(fStartTime
, endTime
);
684 private void redraw() {
685 Display
.getDefault().asyncExec(new Runnable() {
688 if (fTimeGraphCombo
.isDisposed()) {
691 fTimeGraphCombo
.redraw();
692 fTimeGraphCombo
.update();
697 private void startZoomThread(long startTime
, long endTime
) {
698 if (fZoomThread
!= null) {
699 fZoomThread
.cancel();
701 fZoomThread
= new ZoomThread(startTime
, endTime
);
705 private void makeActions() {
706 fPreviousResourceAction
= fTimeGraphCombo
.getTimeGraphViewer().getPreviousItemAction();
707 fPreviousResourceAction
.setText(Messages
.ControlFlowView_previousProcessActionNameText
);
708 fPreviousResourceAction
.setToolTipText(Messages
.ControlFlowView_previousProcessActionToolTipText
);
709 fNextResourceAction
= fTimeGraphCombo
.getTimeGraphViewer().getNextItemAction();
710 fNextResourceAction
.setText(Messages
.ControlFlowView_nextProcessActionNameText
);
711 fNextResourceAction
.setToolTipText(Messages
.ControlFlowView_nextProcessActionToolTipText
);
714 private void contributeToActionBars() {
715 IActionBars bars
= getViewSite().getActionBars();
716 fillLocalToolBar(bars
.getToolBarManager());
719 private void fillLocalToolBar(IToolBarManager manager
) {
720 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getShowLegendAction());
721 manager
.add(new Separator());
722 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getResetScaleAction());
723 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getPreviousEventAction());
724 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getNextEventAction());
725 manager
.add(fPreviousResourceAction
);
726 manager
.add(fNextResourceAction
);
727 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getZoomInAction());
728 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getZoomOutAction());
729 manager
.add(new Separator());