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
.Comparator
;
18 import java
.util
.List
;
20 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
21 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
22 import org
.eclipse
.jface
.action
.Action
;
23 import org
.eclipse
.jface
.action
.IToolBarManager
;
24 import org
.eclipse
.jface
.action
.Separator
;
25 import org
.eclipse
.jface
.viewers
.ILabelProviderListener
;
26 import org
.eclipse
.jface
.viewers
.ITableLabelProvider
;
27 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
28 import org
.eclipse
.jface
.viewers
.Viewer
;
29 import org
.eclipse
.linuxtools
.internal
.lttng2
.kernel
.core
.Attributes
;
30 import org
.eclipse
.linuxtools
.internal
.lttng2
.kernel
.ui
.Messages
;
31 import org
.eclipse
.linuxtools
.lttng2
.kernel
.core
.trace
.CtfKernelTrace
;
32 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfTimestamp
;
33 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
34 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimeRange
;
35 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimestamp
;
36 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.AttributeNotFoundException
;
37 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.StateValueTypeException
;
38 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TimeRangeException
;
39 import org
.eclipse
.linuxtools
.tmf
.core
.interval
.ITmfStateInterval
;
40 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfExperimentSelectedSignal
;
41 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfRangeSynchSignal
;
42 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalHandler
;
43 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfStateSystemBuildCompleted
;
44 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTimeSynchSignal
;
45 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.IStateSystemQuerier
;
46 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
47 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfExperiment
;
48 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.TmfView
;
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
.TimeGraphCombo
;
53 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.TimeGraphRangeUpdateEvent
;
54 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.TimeGraphSelectionEvent
;
55 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.TimeGraphTimeEvent
;
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
.model
.TimeEvent
;
59 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
.Utils
;
60 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
.Utils
.Resolution
;
61 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
.Utils
.TimeFormat
;
62 import org
.eclipse
.swt
.SWT
;
63 import org
.eclipse
.swt
.graphics
.Image
;
64 import org
.eclipse
.swt
.widgets
.Composite
;
65 import org
.eclipse
.swt
.widgets
.Display
;
66 import org
.eclipse
.swt
.widgets
.TreeColumn
;
67 import org
.eclipse
.ui
.IActionBars
;
69 public class ControlFlowView
extends TmfView
{
71 // ------------------------------------------------------------------------
73 // ------------------------------------------------------------------------
78 public static final String ID
= "org.eclipse.linuxtools.lttng2.kernel.ui.views.controlflow"; //$NON-NLS-1$
83 private static final long INITIAL_WINDOW_OFFSET
= (1L * 100 * 1000 * 1000); // .1sec
85 private static final String PROCESS_COLUMN
= Messages
.ControlFlowView_processColumn
;
86 private static final String TID_COLUMN
= Messages
.ControlFlowView_tidColumn
;
87 private static final String PTID_COLUMN
= Messages
.ControlFlowView_ptidColumn
;
88 private static final String BIRTH_TIME_COLUMN
= Messages
.ControlFlowView_birthTimeColumn
;
89 private static final String TRACE_COLUMN
= Messages
.ControlFlowView_traceColumn
;
91 private final String
[] COLUMN_NAMES
= new String
[] {
99 // ------------------------------------------------------------------------
101 // ------------------------------------------------------------------------
103 // The timegraph combo
104 private TimeGraphCombo fTimeGraphCombo
;
106 // The selected experiment
107 private TmfExperiment
<ITmfEvent
> fSelectedExperiment
;
109 // The timegraph entry list
110 private ArrayList
<ControlFlowEntry
> fEntryList
;
113 private long fStartTime
;
116 private long fEndTime
;
119 private int fDisplayWidth
;
122 private ZoomThread fZoomThread
;
124 // The next resource action
125 private Action fNextResourceAction
;
127 // The previous resource action
128 private Action fPreviousResourceAction
;
130 // A comparator class
131 private ControlFlowEntryComparator fControlFlowEntryComparator
= new ControlFlowEntryComparator();
133 // ------------------------------------------------------------------------
135 // ------------------------------------------------------------------------
137 private class TreeContentProvider
implements ITreeContentProvider
{
140 public void dispose() {
144 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {
148 public Object
[] getElements(Object inputElement
) {
149 return (ITimeGraphEntry
[]) inputElement
;
153 public Object
[] getChildren(Object parentElement
) {
154 ITimeGraphEntry entry
= (ITimeGraphEntry
) parentElement
;
155 return entry
.getChildren();
159 public Object
getParent(Object element
) {
160 ITimeGraphEntry entry
= (ITimeGraphEntry
) element
;
161 return entry
.getParent();
165 public boolean hasChildren(Object element
) {
166 ITimeGraphEntry entry
= (ITimeGraphEntry
) element
;
167 return entry
.hasChildren();
172 private class TreeLabelProvider
implements ITableLabelProvider
{
175 public void addListener(ILabelProviderListener listener
) {
179 public void dispose() {
183 public boolean isLabelProperty(Object element
, String property
) {
188 public void removeListener(ILabelProviderListener listener
) {
192 public Image
getColumnImage(Object element
, int columnIndex
) {
197 public String
getColumnText(Object element
, int columnIndex
) {
198 ControlFlowEntry entry
= (ControlFlowEntry
) element
;
199 if (columnIndex
== 0) {
200 return entry
.getName();
201 } else if (columnIndex
== 1) {
202 return Integer
.toString(entry
.getThreadId());
203 } else if (columnIndex
== 2) {
204 if (entry
.getParentThreadId() > 0) {
205 return Integer
.toString(entry
.getParentThreadId());
207 } else if (columnIndex
== 3) {
208 return Utils
.formatTime(entry
.getBirthTime(), TimeFormat
.ABSOLUTE
, Resolution
.NANOSEC
);
209 } else if (columnIndex
== 4) {
210 return entry
.getTrace().getName();
212 return ""; //$NON-NLS-1$
217 private static class ControlFlowEntryComparator
implements Comparator
<ITimeGraphEntry
> {
220 public int compare(ITimeGraphEntry o1
, ITimeGraphEntry o2
) {
223 if ((o1
instanceof ControlFlowEntry
) && (o2
instanceof ControlFlowEntry
)) {
224 ControlFlowEntry entry1
= (ControlFlowEntry
) o1
;
225 ControlFlowEntry entry2
= (ControlFlowEntry
) o2
;
226 result
= entry1
.getTrace().getStartTime().compareTo(entry2
.getTrace().getStartTime());
228 result
= entry1
.getThreadId() < entry2
.getThreadId() ?
-1 : entry1
.getThreadId() > entry2
.getThreadId() ?
1 : 0;
233 result
= o1
.getStartTime() < o2
.getStartTime() ?
-1 : o1
.getStartTime() > o2
.getStartTime() ?
1 : 0;
241 private class ZoomThread
extends Thread
{
242 private long fZoomStartTime
;
243 private long fZoomEndTime
;
244 private long fResolution
;
245 private IProgressMonitor fMonitor
;
247 public ZoomThread(long startTime
, long endTime
) {
248 super("ControlFlowView zoom"); //$NON-NLS-1$
249 fZoomStartTime
= startTime
;
250 fZoomEndTime
= endTime
;
251 fResolution
= Math
.max(1, (fZoomEndTime
- fZoomStartTime
) / fDisplayWidth
);
252 fMonitor
= new NullProgressMonitor();
257 ArrayList
<ControlFlowEntry
> entryList
= fEntryList
;
258 if (entryList
== null) {
261 for (ControlFlowEntry entry
: entryList
) {
262 if (fMonitor
.isCanceled()) {
265 zoom(entry
, fMonitor
);
270 private void zoom(ControlFlowEntry entry
, IProgressMonitor monitor
) {
271 if (fZoomStartTime
<= entry
.getStartTime() && fZoomEndTime
>= entry
.getEndTime()) {
272 entry
.setZoomedEventList(null);
275 List
<ITimeEvent
> zoomedEventList
= getEventList(entry
, fZoomStartTime
, fZoomEndTime
, fResolution
, monitor
);
276 if (fMonitor
.isCanceled()) {
279 entry
.setZoomedEventList(zoomedEventList
);
280 for (ControlFlowEntry child
: entry
.getChildren()) {
281 if (fMonitor
.isCanceled()) {
284 zoom(child
, monitor
);
288 public void cancel() {
289 fMonitor
.setCanceled(true);
293 // ------------------------------------------------------------------------
295 // ------------------------------------------------------------------------
297 public ControlFlowView() {
299 fDisplayWidth
= Display
.getDefault().getBounds().width
;
302 // ------------------------------------------------------------------------
304 // ------------------------------------------------------------------------
307 * @see org.eclipse.linuxtools.tmf.ui.views.TmfView#createPartControl(org.eclipse.swt.widgets.Composite)
310 public void createPartControl(Composite parent
) {
311 fTimeGraphCombo
= new TimeGraphCombo(parent
, SWT
.NONE
);
313 fTimeGraphCombo
.setTreeContentProvider(new TreeContentProvider());
315 fTimeGraphCombo
.setTreeLabelProvider(new TreeLabelProvider());
317 fTimeGraphCombo
.setTimeGraphProvider(new ControlFlowPresentationProvider());
319 fTimeGraphCombo
.setTreeColumns(COLUMN_NAMES
);
321 fTimeGraphCombo
.getTimeGraphViewer().addRangeListener(new ITimeGraphRangeListener() {
323 public void timeRangeUpdated(TimeGraphRangeUpdateEvent event
) {
324 final long startTime
= event
.getStartTime();
325 final long endTime
= event
.getEndTime();
326 TmfTimeRange range
= new TmfTimeRange(new CtfTmfTimestamp(startTime
), new CtfTmfTimestamp(endTime
));
327 TmfTimestamp time
= new CtfTmfTimestamp(fTimeGraphCombo
.getTimeGraphViewer().getSelectedTime());
328 broadcast(new TmfRangeSynchSignal(ControlFlowView
.this, range
, time
));
329 if (fZoomThread
!= null) {
330 fZoomThread
.cancel();
332 startZoomThread(startTime
, endTime
);
336 fTimeGraphCombo
.getTimeGraphViewer().addTimeListener(new ITimeGraphTimeListener() {
338 public void timeSelected(TimeGraphTimeEvent event
) {
339 long time
= event
.getTime();
340 broadcast(new TmfTimeSynchSignal(ControlFlowView
.this, new CtfTmfTimestamp(time
)));
344 fTimeGraphCombo
.addSelectionListener(new ITimeGraphSelectionListener() {
346 public void selectionChanged(TimeGraphSelectionEvent event
) {
347 //ITimeGraphEntry selection = event.getSelection();
351 fTimeGraphCombo
.getTimeGraphViewer().setTimeCalendarFormat(true);
353 final Thread thread
= new Thread("ControlFlowView build") { //$NON-NLS-1$
356 if (TmfExperiment
.getCurrentExperiment() != null) {
357 selectExperiment(TmfExperiment
.getCurrentExperiment());
363 // View Action Handling
365 contributeToActionBars();
369 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
372 public void setFocus() {
373 fTimeGraphCombo
.setFocus();
376 // ------------------------------------------------------------------------
378 // ------------------------------------------------------------------------
381 public void experimentSelected(final TmfExperimentSelectedSignal
<?
extends ITmfEvent
> signal
) {
382 if (signal
.getExperiment().equals(fSelectedExperiment
)) {
386 final Thread thread
= new Thread("ControlFlowView build") { //$NON-NLS-1$
389 selectExperiment(signal
.getExperiment());
396 public void synchToTime(final TmfTimeSynchSignal signal
) {
397 if (signal
.getSource() == this) {
400 final long time
= signal
.getCurrentTime().normalize(0, -9).getValue();
403 for (ITmfTrace
<?
> trace
: fSelectedExperiment
.getTraces()) {
407 if (trace
instanceof CtfKernelTrace
) {
408 CtfKernelTrace ctfKernelTrace
= (CtfKernelTrace
) trace
;
409 IStateSystemQuerier ssq
= ctfKernelTrace
.getStateSystem();
410 if (time
>= ssq
.getStartTime() && time
<= ssq
.getCurrentEndTime()) {
411 List
<Integer
> currentThreadQuarks
= ssq
.getQuarks(Attributes
.CPUS
, "*", Attributes
.CURRENT_THREAD
); //$NON-NLS-1$
412 for (int currentThreadQuark
: currentThreadQuarks
) {
414 ITmfStateInterval currentThreadInterval
= ssq
.querySingleState(time
, currentThreadQuark
);
415 int currentThread
= currentThreadInterval
.getStateValue().unboxInt();
416 if (currentThread
> 0) {
417 int statusQuark
= ssq
.getQuarkAbsolute(Attributes
.THREADS
, Integer
.toString(currentThread
), Attributes
.STATUS
);
418 ITmfStateInterval statusInterval
= ssq
.querySingleState(time
, statusQuark
);
419 if (statusInterval
.getStartTime() == time
) {
420 thread
= currentThread
;
424 } catch (AttributeNotFoundException e
) {
426 } catch (TimeRangeException e
) {
428 } catch (StateValueTypeException e
) {
435 final int selectedThread
= thread
;
437 Display
.getDefault().asyncExec(new Runnable() {
440 if (fTimeGraphCombo
.isDisposed()) {
443 fTimeGraphCombo
.getTimeGraphViewer().setSelectedTime(time
, true);
444 startZoomThread(fTimeGraphCombo
.getTimeGraphViewer().getTime0(), fTimeGraphCombo
.getTimeGraphViewer().getTime1());
446 if (selectedThread
> 0) {
447 for (Object element
: fTimeGraphCombo
.getTimeGraphViewer().getExpandedElements()) {
448 if (element
instanceof ControlFlowEntry
) {
449 ControlFlowEntry entry
= (ControlFlowEntry
) element
;
450 if (entry
.getThreadId() == selectedThread
) {
451 fTimeGraphCombo
.setSelection(entry
);
462 public void synchToRange(final TmfRangeSynchSignal signal
) {
463 if (signal
.getSource() == this) {
466 final long startTime
= signal
.getCurrentRange().getStartTime().normalize(0, -9).getValue();
467 final long endTime
= signal
.getCurrentRange().getEndTime().normalize(0, -9).getValue();
468 final long time
= signal
.getCurrentTime().normalize(0, -9).getValue();
469 Display
.getDefault().asyncExec(new Runnable() {
472 if (fTimeGraphCombo
.isDisposed()) {
475 fTimeGraphCombo
.getTimeGraphViewer().setStartFinishTime(startTime
, endTime
);
476 fTimeGraphCombo
.getTimeGraphViewer().setSelectedTime(time
, false);
477 startZoomThread(startTime
, endTime
);
483 public void stateSystemBuildCompleted (final TmfStateSystemBuildCompleted signal
) {
484 final TmfExperiment
<?
> selectedExperiment
= fSelectedExperiment
;
485 if (selectedExperiment
== null) {
488 for (ITmfTrace
<?
> trace
: selectedExperiment
.getTraces()) {
489 if (trace
== signal
.getTrace() && trace
instanceof CtfKernelTrace
) {
490 final Thread thread
= new Thread("ControlFlowView build") { //$NON-NLS-1$
494 selectExperiment(selectedExperiment
);
502 // ------------------------------------------------------------------------
504 // ------------------------------------------------------------------------
506 @SuppressWarnings("unchecked")
507 private void selectExperiment(TmfExperiment
<?
> experiment
) {
508 fStartTime
= Long
.MAX_VALUE
;
509 fEndTime
= Long
.MIN_VALUE
;
510 fSelectedExperiment
= (TmfExperiment
<ITmfEvent
>) experiment
;
511 ArrayList
<ControlFlowEntry
> entryList
= new ArrayList
<ControlFlowEntry
>();
512 for (ITmfTrace
<?
> trace
: experiment
.getTraces()) {
513 if (trace
instanceof CtfKernelTrace
) {
514 CtfKernelTrace ctfKernelTrace
= (CtfKernelTrace
) trace
;
515 IStateSystemQuerier ssq
= ctfKernelTrace
.getStateSystem();
516 long start
= ssq
.getStartTime();
517 long end
= ssq
.getCurrentEndTime() + 1;
518 fStartTime
= Math
.min(fStartTime
, start
);
519 fEndTime
= Math
.max(fEndTime
, end
);
520 List
<Integer
> threadQuarks
= ssq
.getQuarks(Attributes
.THREADS
, "*"); //$NON-NLS-1$
521 for (int threadQuark
: threadQuarks
) {
522 String threadName
= ssq
.getAttributeName(threadQuark
);
525 threadId
= Integer
.parseInt(threadName
);
526 } catch (NumberFormatException e1
) {
529 if (threadId
== 0) { // ignore the swapper thread
532 int execNameQuark
= -1;
535 execNameQuark
= ssq
.getQuarkRelative(threadQuark
, Attributes
.EXEC_NAME
);
536 } catch (AttributeNotFoundException e
) {
539 int ppidQuark
= ssq
.getQuarkRelative(threadQuark
, Attributes
.PPID
);
540 List
<ITmfStateInterval
> execNameIntervals
= ssq
.queryHistoryRange(execNameQuark
, start
, end
- 1);
542 for (ITmfStateInterval execNameInterval
: execNameIntervals
) {
543 if (!execNameInterval
.getStateValue().isNull() && execNameInterval
.getStateValue().getType() == 1) {
544 String execName
= execNameInterval
.getStateValue().unboxStr();
545 long startTime
= execNameInterval
.getStartTime();
546 long endTime
= execNameInterval
.getEndTime() + 1;
547 if (birthTime
== -1) {
548 birthTime
= startTime
;
551 if (ppidQuark
!= -1) {
552 ITmfStateInterval ppidInterval
= ssq
.querySingleState(startTime
, ppidQuark
);
553 ppid
= ppidInterval
.getStateValue().unboxInt();
555 ControlFlowEntry entry
= new ControlFlowEntry(threadQuark
, ctfKernelTrace
, execName
, threadId
, ppid
, birthTime
, startTime
, endTime
);
556 entryList
.add(entry
);
557 entry
.addEvent(new TimeEvent(entry
, startTime
, endTime
- startTime
));
562 } catch (AttributeNotFoundException e
) {
564 } catch (TimeRangeException e
) {
566 } catch (StateValueTypeException e
) {
571 buildTree(entryList
);
572 refresh(INITIAL_WINDOW_OFFSET
);
573 ControlFlowEntry
[] entries
= fEntryList
.toArray(new ControlFlowEntry
[0]);
574 Arrays
.sort(entries
, fControlFlowEntryComparator
);
575 for (ControlFlowEntry entry
: entries
) {
576 buildStatusEvents(entry
);
581 private void buildTree(ArrayList
<ControlFlowEntry
> entryList
) {
582 ArrayList
<ControlFlowEntry
> rootList
= new ArrayList
<ControlFlowEntry
>();
583 for (ControlFlowEntry entry
: entryList
) {
585 if (entry
.getParentThreadId() > 0) {
586 for (ControlFlowEntry parent
: entryList
) {
587 if (parent
.getThreadId() == entry
.getParentThreadId() &&
588 entry
.getStartTime() >= parent
.getStartTime() &&
589 entry
.getStartTime() <= parent
.getEndTime()) {
590 parent
.addChild(entry
);
600 fEntryList
= rootList
;
603 private void buildStatusEvents(ControlFlowEntry entry
) {
604 IStateSystemQuerier ssq
= entry
.getTrace().getStateSystem();
605 long start
= ssq
.getStartTime();
606 long end
= ssq
.getCurrentEndTime() + 1;
607 long resolution
= Math
.max(1, (end
- start
) / fDisplayWidth
);
608 List
<ITimeEvent
> eventList
= getEventList(entry
, entry
.getStartTime(), entry
.getEndTime(), resolution
, new NullProgressMonitor());
609 entry
.setEventList(eventList
);
611 for (ITimeGraphEntry child
: entry
.getChildren()) {
612 buildStatusEvents((ControlFlowEntry
) child
);
616 private List
<ITimeEvent
> getEventList(ControlFlowEntry entry
, long startTime
, long endTime
, long resolution
, IProgressMonitor monitor
) {
617 startTime
= Math
.max(startTime
, entry
.getStartTime());
618 endTime
= Math
.min(endTime
, entry
.getEndTime());
619 if (endTime
<= startTime
) {
622 IStateSystemQuerier ssq
= entry
.getTrace().getStateSystem();
623 List
<ITimeEvent
> eventList
= null;
625 int statusQuark
= ssq
.getQuarkRelative(entry
.getThreadQuark(), Attributes
.STATUS
);
626 List
<ITmfStateInterval
> statusIntervals
= ssq
.queryHistoryRange(statusQuark
, startTime
, endTime
- 1, resolution
);
627 eventList
= new ArrayList
<ITimeEvent
>(statusIntervals
.size());
628 long lastEndTime
= -1;
629 for (ITmfStateInterval statusInterval
: statusIntervals
) {
630 if (monitor
.isCanceled()) {
633 long time
= statusInterval
.getStartTime();
634 long duration
= statusInterval
.getEndTime() - time
+ 1;
637 status
= statusInterval
.getStateValue().unboxInt();
638 } catch (StateValueTypeException e
) {
641 if (lastEndTime
!= time
&& lastEndTime
!= -1) {
642 eventList
.add(new ControlFlowEvent(entry
, lastEndTime
, time
- lastEndTime
, 0));
644 eventList
.add(new ControlFlowEvent(entry
, time
, duration
, status
));
645 lastEndTime
= time
+ duration
;
647 } catch (AttributeNotFoundException e
) {
649 } catch (TimeRangeException e
) {
655 private void refresh(final long windowRange
) {
656 Display
.getDefault().asyncExec(new Runnable() {
659 if (fTimeGraphCombo
.isDisposed()) {
662 ITimeGraphEntry
[] entries
= fEntryList
.toArray(new ITimeGraphEntry
[0]);
663 Arrays
.sort(entries
, fControlFlowEntryComparator
);
664 fTimeGraphCombo
.setInput(entries
);
665 fTimeGraphCombo
.getTimeGraphViewer().setTimeBounds(fStartTime
, fEndTime
);
667 long endTime
= fStartTime
+ windowRange
;
669 if (fEndTime
< endTime
) {
672 fTimeGraphCombo
.getTimeGraphViewer().setStartFinishTime(fStartTime
, endTime
);
673 for (TreeColumn column
: fTimeGraphCombo
.getTreeViewer().getTree().getColumns()) {
677 startZoomThread(fStartTime
, endTime
);
682 private void redraw() {
683 Display
.getDefault().asyncExec(new Runnable() {
686 if (fTimeGraphCombo
.isDisposed()) {
689 fTimeGraphCombo
.redraw();
690 fTimeGraphCombo
.update();
695 private void startZoomThread(long startTime
, long endTime
) {
696 if (fZoomThread
!= null) {
697 fZoomThread
.cancel();
699 fZoomThread
= new ZoomThread(startTime
, endTime
);
703 private void makeActions() {
704 fPreviousResourceAction
= fTimeGraphCombo
.getTimeGraphViewer().getPreviousItemAction();
705 fPreviousResourceAction
.setText(Messages
.ControlFlowView_previousProcessActionNameText
);
706 fPreviousResourceAction
.setToolTipText(Messages
.ControlFlowView_previousProcessActionToolTipText
);
707 fNextResourceAction
= fTimeGraphCombo
.getTimeGraphViewer().getNextItemAction();
708 fNextResourceAction
.setText(Messages
.ControlFlowView_nextProcessActionNameText
);
709 fNextResourceAction
.setToolTipText(Messages
.ControlFlowView_nextProcessActionToolTipText
);
712 private void contributeToActionBars() {
713 IActionBars bars
= getViewSite().getActionBars();
714 fillLocalToolBar(bars
.getToolBarManager());
717 private void fillLocalToolBar(IToolBarManager manager
) {
718 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getShowLegendAction());
719 manager
.add(new Separator());
720 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getResetScaleAction());
721 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getPreviousEventAction());
722 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getNextEventAction());
723 manager
.add(fPreviousResourceAction
);
724 manager
.add(fNextResourceAction
);
725 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getZoomInAction());
726 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getZoomOutAction());
727 manager
.add(new Separator());