10
10
* Patrick Tasse - Initial API and implementation
11
* Geneviève Bastien - Move code to provide base classes for time graph views
11
12
*******************************************************************************/
13
14
package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources;
15
16
import java.util.ArrayList;
16
import java.util.Arrays;
17
import java.util.Comparator;
18
import java.util.Iterator;
19
17
import java.util.List;
21
19
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
20
import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;
27
21
import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;
28
22
import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources.ResourcesEntry.Type;
29
import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;
30
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTimestamp;
31
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
32
import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
33
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
34
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
23
import org.eclipse.linuxtools.lttng2.kernel.core.trace.LttngKernelTrace;
35
24
import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
25
import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException;
36
26
import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
37
27
import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;
38
28
import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;
39
import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;
40
import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
41
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
42
import org.eclipse.linuxtools.tmf.core.signal.TmfStateSystemBuildCompleted;
43
import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
44
import org.eclipse.linuxtools.tmf.core.statesystem.IStateSystemQuerier;
45
import org.eclipse.linuxtools.tmf.core.statesystem.IStateSystemQuerier2;
29
import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
46
30
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.ITimeGraphTimeListener;
51
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphRangeUpdateEvent;
52
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphTimeEvent;
53
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphViewer;
31
import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
32
import org.eclipse.linuxtools.tmf.ui.views.timegraph.AbstractTimeGraphView;
54
33
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
55
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
34
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.NullTimeEvent;
56
35
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeEvent;
57
import org.eclipse.swt.SWT;
58
import org.eclipse.swt.widgets.Composite;
59
import org.eclipse.swt.widgets.Display;
60
import org.eclipse.ui.IActionBars;
36
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeGraphEntry;
63
39
* Main implementation for the LTTng 2.0 kernel Resource view
65
41
* @author Patrick Tasse
67
public class ResourcesView extends TmfView {
69
// ------------------------------------------------------------------------
71
// ------------------------------------------------------------------------
43
public class ResourcesView extends AbstractTimeGraphView {
74
46
public static final String ID = "org.eclipse.linuxtools.lttng2.kernel.ui.views.resources"; //$NON-NLS-1$
76
/** Initial time range */
77
private static final long INITIAL_WINDOW_OFFSET = (1L * 100 * 1000 * 1000); // .1sec
82
private enum State { IDLE, BUSY, PENDING }
84
// ------------------------------------------------------------------------
86
// ------------------------------------------------------------------------
88
// The time graph viewer
89
TimeGraphViewer fTimeGraphViewer;
91
// The selected experiment
92
private TmfExperiment<ITmfEvent> fSelectedExperiment;
94
// The time graph entry list
95
private ArrayList<TraceEntry> fEntryList;
97
// The time graph entry list synchronization object
98
final private Object fEntryListSyncObj = new Object();
101
private long fStartTime;
104
private long fEndTime;
107
private final int fDisplayWidth;
109
// The next resource action
110
private Action fNextResourceAction;
112
// The previous resource action
113
private Action fPreviousResourceAction;
116
private ZoomThread fZoomThread;
118
// The redraw state used to prevent unnecessary queuing of display runnables
119
private State fRedrawState = State.IDLE;
121
// The redraw synchronization object
122
final private Object fSyncObj = new Object();
124
// ------------------------------------------------------------------------
126
// ------------------------------------------------------------------------
128
private class TraceEntry implements ITimeGraphEntry {
130
private final CtfKernelTrace fTrace;
132
private final long fTraceStartTime;
134
private final long fTraceEndTime;
135
// The children of the entry
136
private final ArrayList<ResourcesEntry> fChildren;
138
private final String fName;
140
public TraceEntry(CtfKernelTrace trace, String name, long startTime, long endTime) {
142
fChildren = new ArrayList<ResourcesEntry>();
144
fTraceStartTime = startTime;
145
fTraceEndTime = endTime;
149
public ITimeGraphEntry getParent() {
154
public boolean hasChildren() {
155
return fChildren != null && fChildren.size() > 0;
159
public ResourcesEntry[] getChildren() {
160
return fChildren.toArray(new ResourcesEntry[0]);
164
public String getName() {
169
public long getStartTime() {
170
return fTraceStartTime;
174
public long getEndTime() {
175
return fTraceEndTime;
179
public boolean hasTimeEvents() {
184
public Iterator<ITimeEvent> getTimeEventsIterator() {
189
public <T extends ITimeEvent> Iterator<T> getTimeEventsIterator(long startTime, long stopTime, long visibleDuration) {
193
public CtfKernelTrace getTrace() {
197
public void addChild(ResourcesEntry entry) {
199
for (index = 0; index < fChildren.size(); index++) {
200
ResourcesEntry other = fChildren.get(index);
201
if (entry.getType().compareTo(other.getType()) < 0) {
203
} else if (entry.getType().equals(other.getType())) {
204
if (entry.getId() < other.getId()) {
209
entry.setParent(this);
210
fChildren.add(index, entry);
214
private static class TraceEntryComparator implements Comparator<ITimeGraphEntry> {
216
public int compare(ITimeGraphEntry o1, ITimeGraphEntry o2) {
217
int result = o1.getStartTime() < o2.getStartTime() ? -1 : o1.getStartTime() > o2.getStartTime() ? 1 : 0;
219
result = o1.getName().compareTo(o2.getName());
225
private class ZoomThread extends Thread {
226
private final long fZoomStartTime;
227
private final long fZoomEndTime;
228
private final IProgressMonitor fMonitor;
230
public ZoomThread(long startTime, long endTime) {
231
super("ResourcesView zoom"); //$NON-NLS-1$
232
fZoomStartTime = startTime;
233
fZoomEndTime = endTime;
234
fMonitor = new NullProgressMonitor();
239
ArrayList<TraceEntry> entryList = null;
240
synchronized (fEntryListSyncObj) {
241
entryList = fEntryList;
243
if (entryList == null) {
246
long resolution = Math.max(1, (fZoomEndTime - fZoomStartTime) / fDisplayWidth);
247
for (TraceEntry traceEntry : entryList) {
248
for (ITimeGraphEntry child : traceEntry.getChildren()) {
249
if (fMonitor.isCanceled()) {
252
ResourcesEntry entry = (ResourcesEntry) child;
253
if (fZoomStartTime <= fStartTime && fZoomEndTime >= fEndTime) {
254
entry.setZoomedEventList(null);
256
List<ITimeEvent> zoomedEventList = getEventList(entry, fZoomStartTime, fZoomEndTime, resolution, true, fMonitor);
257
if (zoomedEventList != null) {
258
entry.setZoomedEventList(zoomedEventList);
266
public void cancel() {
267
fMonitor.setCanceled(true);
48
private static final String[] FILTER_COLUMN_NAMES = new String[] {
49
Messages.ResourcesView_stateTypeName
271
52
// ------------------------------------------------------------------------
276
57
* Default constructor
278
59
public ResourcesView() {
280
fDisplayWidth = Display.getDefault().getBounds().width;
283
// ------------------------------------------------------------------------
285
// ------------------------------------------------------------------------
288
* @see org.eclipse.linuxtools.tmf.ui.views.TmfView#createPartControl(org.eclipse.swt.widgets.Composite)
291
public void createPartControl(Composite parent) {
292
fTimeGraphViewer = new TimeGraphViewer(parent, SWT.NONE);
294
fTimeGraphViewer.setTimeGraphProvider(new ResourcesPresentationProvider());
296
fTimeGraphViewer.setTimeCalendarFormat(true);
298
fTimeGraphViewer.addRangeListener(new ITimeGraphRangeListener() {
300
public void timeRangeUpdated(TimeGraphRangeUpdateEvent event) {
301
long startTime = event.getStartTime();
302
long endTime = event.getEndTime();
303
TmfTimeRange range = new TmfTimeRange(new CtfTmfTimestamp(startTime), new CtfTmfTimestamp(endTime));
304
TmfTimestamp time = new CtfTmfTimestamp(fTimeGraphViewer.getSelectedTime());
305
broadcast(new TmfRangeSynchSignal(ResourcesView.this, range, time));
306
startZoomThread(startTime, endTime);
310
fTimeGraphViewer.addTimeListener(new ITimeGraphTimeListener() {
312
public void timeSelected(TimeGraphTimeEvent event) {
313
long time = event.getTime();
314
broadcast(new TmfTimeSynchSignal(ResourcesView.this, new CtfTmfTimestamp(time)));
318
final Thread thread = new Thread("ResourcesView build") { //$NON-NLS-1$
321
if (TmfExperiment.getCurrentExperiment() != null) {
322
selectExperiment(TmfExperiment.getCurrentExperiment());
328
// View Action Handling
330
contributeToActionBars();
334
* @see org.eclipse.ui.part.WorkbenchPart#setFocus()
337
public void setFocus() {
338
fTimeGraphViewer.setFocus();
341
// ------------------------------------------------------------------------
343
// ------------------------------------------------------------------------
346
* Handler for the ExperimentSelected signal
349
* The incoming signal
352
public void experimentSelected(final TmfExperimentSelectedSignal<? extends TmfEvent> signal) {
353
if (signal.getExperiment().equals(fSelectedExperiment)) {
357
final Thread thread = new Thread("ResourcesView build") { //$NON-NLS-1$
360
selectExperiment(signal.getExperiment());
367
* Handler for the TimeSynch signal
370
* The incoming signal
373
public void synchToTime(final TmfTimeSynchSignal signal) {
374
if (signal.getSource() == this || fSelectedExperiment == null) {
377
final long time = signal.getCurrentTime().normalize(0, -9).getValue();
378
Display.getDefault().asyncExec(new Runnable() {
381
if (fTimeGraphViewer.getControl().isDisposed()) {
384
fTimeGraphViewer.setSelectedTime(time, true);
385
startZoomThread(fTimeGraphViewer.getTime0(), fTimeGraphViewer.getTime1());
391
* Handler for the RangeSynch signal
394
* The incoming signal
397
public void synchToRange(final TmfRangeSynchSignal signal) {
398
if (signal.getSource() == this || fSelectedExperiment == null) {
401
final long startTime = signal.getCurrentRange().getStartTime().normalize(0, -9).getValue();
402
final long endTime = signal.getCurrentRange().getEndTime().normalize(0, -9).getValue();
403
final long time = signal.getCurrentTime().normalize(0, -9).getValue();
404
Display.getDefault().asyncExec(new Runnable() {
407
if (fTimeGraphViewer.getControl().isDisposed()) {
410
fTimeGraphViewer.setStartFinishTime(startTime, endTime);
411
fTimeGraphViewer.setSelectedTime(time, false);
412
startZoomThread(startTime, endTime);
418
* Handler for the StatesystemBuildCompleted signal
421
* The incoming signal
424
public void stateSystemBuildCompleted (final TmfStateSystemBuildCompleted signal) {
425
final TmfExperiment<?> selectedExperiment = fSelectedExperiment;
426
if (selectedExperiment == null || selectedExperiment.getTraces() == null) {
429
for (ITmfTrace<?> trace : selectedExperiment.getTraces()) {
430
if (trace == signal.getTrace() && trace instanceof CtfKernelTrace) {
431
final Thread thread = new Thread("ResourcesView build") { //$NON-NLS-1$
435
selectExperiment(selectedExperiment);
60
super(ID, new ResourcesPresentationProvider());
61
setFilterColumns(FILTER_COLUMN_NAMES);
65
protected String getNextText() {
66
return Messages.ResourcesView_nextResourceActionNameText;
70
protected String getNextTooltip() {
71
return Messages.ResourcesView_nextResourceActionToolTipText;
75
protected String getPrevText() {
76
return Messages.ResourcesView_previousResourceActionNameText;
80
protected String getPrevTooltip() {
81
return Messages.ResourcesView_previousResourceActionToolTipText;
443
84
// ------------------------------------------------------------------------
445
86
// ------------------------------------------------------------------------
447
@SuppressWarnings("unchecked")
448
private void selectExperiment(TmfExperiment<?> experiment) {
449
fStartTime = Long.MAX_VALUE;
450
fEndTime = Long.MIN_VALUE;
451
fSelectedExperiment = (TmfExperiment<ITmfEvent>) experiment;
452
ArrayList<TraceEntry> entryList = new ArrayList<TraceEntry>();
453
for (ITmfTrace<?> trace : experiment.getTraces()) {
454
if (trace instanceof CtfKernelTrace) {
455
CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) trace;
456
IStateSystemQuerier ssq = ctfKernelTrace.getStateSystem();
89
protected void buildEventList(ITmfTrace trace, IProgressMonitor monitor) {
90
setStartTime(Long.MAX_VALUE);
91
setEndTime(Long.MIN_VALUE);
93
ArrayList<ResourcesEntry> entryList = new ArrayList<ResourcesEntry>();
94
for (ITmfTrace aTrace : TmfTraceManager.getTraceSet(trace)) {
95
if (monitor.isCanceled()) {
98
if (aTrace instanceof LttngKernelTrace) {
99
LttngKernelTrace lttngKernelTrace = (LttngKernelTrace) aTrace;
100
ITmfStateSystem ssq = lttngKernelTrace.getStateSystems().get(LttngKernelTrace.STATE_ID);
101
if (!ssq.waitUntilBuilt()) {
457
104
long startTime = ssq.getStartTime();
458
105
long endTime = ssq.getCurrentEndTime() + 1;
459
TraceEntry groupEntry = new TraceEntry(ctfKernelTrace, trace.getName(), startTime, endTime);
106
ResourcesEntry groupEntry = new ResourcesEntry(lttngKernelTrace, aTrace.getName(), startTime, endTime, 0);
460
107
entryList.add(groupEntry);
461
fStartTime = Math.min(fStartTime, startTime);
462
fEndTime = Math.max(fEndTime, endTime);
108
setStartTime(Math.min(getStartTime(), startTime));
109
setEndTime(Math.max(getEndTime(), endTime));
463
110
List<Integer> cpuQuarks = ssq.getQuarks(Attributes.CPUS, "*"); //$NON-NLS-1$
464
111
ResourcesEntry[] cpuEntries = new ResourcesEntry[cpuQuarks.size()];
465
112
for (int i = 0; i < cpuQuarks.size(); i++) {
466
113
int cpuQuark = cpuQuarks.get(i);
467
114
int cpu = Integer.parseInt(ssq.getAttributeName(cpuQuark));
468
ResourcesEntry entry = new ResourcesEntry(cpuQuark, ctfKernelTrace, Type.CPU, cpu);
115
ResourcesEntry entry = new ResourcesEntry(cpuQuark, lttngKernelTrace, getStartTime(), getEndTime(), Type.CPU, cpu);
469
116
groupEntry.addChild(entry);
470
117
cpuEntries[i] = entry;
483
130
for (int i = 0; i < softIrqQuarks.size(); i++) {
484
131
int softIrqQuark = softIrqQuarks.get(i);
485
132
int softIrq = Integer.parseInt(ssq.getAttributeName(softIrqQuark));
486
ResourcesEntry entry = new ResourcesEntry(softIrqQuark, ctfKernelTrace, Type.SOFT_IRQ, softIrq);
133
ResourcesEntry entry = new ResourcesEntry(softIrqQuark, lttngKernelTrace, getStartTime(), getEndTime(), Type.SOFT_IRQ, softIrq);
487
134
groupEntry.addChild(entry);
488
135
softIrqEntries[i] = entry;
492
synchronized (fEntryListSyncObj) {
493
fEntryList = (ArrayList<TraceEntry>) entryList.clone();
139
putEntryList(trace, new ArrayList<TimeGraphEntry>(entryList));
141
if (trace.equals(getTrace())) {
495
refresh(INITIAL_WINDOW_OFFSET);
496
for (TraceEntry traceEntry : entryList) {
497
CtfKernelTrace ctfKernelTrace = traceEntry.getTrace();
498
IStateSystemQuerier ssq = ctfKernelTrace.getStateSystem();
144
for (ResourcesEntry traceEntry : entryList) {
145
if (monitor.isCanceled()) {
148
LttngKernelTrace lttngKernelTrace = traceEntry.getTrace();
149
ITmfStateSystem ssq = lttngKernelTrace.getStateSystems().get(LttngKernelTrace.STATE_ID);
499
150
long startTime = ssq.getStartTime();
500
151
long endTime = ssq.getCurrentEndTime() + 1;
501
long resolution = (endTime - startTime) / fDisplayWidth;
502
for (ResourcesEntry entry : traceEntry.getChildren()) {
503
List<ITimeEvent> eventList = getEventList(entry, startTime, endTime, resolution, false, new NullProgressMonitor());
152
long resolution = (endTime - startTime) / getDisplayWidth();
153
for (TimeGraphEntry entry : traceEntry.getChildren()) {
154
List<ITimeEvent> eventList = getEventList(entry, startTime, endTime, resolution, monitor);
504
155
entry.setEventList(eventList);
510
private static List<ITimeEvent> getEventList(ResourcesEntry entry,
511
long startTime, long endTime, long resolution, boolean includeNull,
162
protected List<ITimeEvent> getEventList(TimeGraphEntry entry,
163
long startTime, long endTime, long resolution,
512
164
IProgressMonitor monitor) {
513
IStateSystemQuerier2 ssq = (IStateSystemQuerier2) entry.getTrace().getStateSystem();
514
startTime = Math.max(startTime, ssq.getStartTime());
515
endTime = Math.min(endTime, ssq.getCurrentEndTime() + 1);
516
if (endTime <= startTime) {
165
ResourcesEntry resourcesEntry = (ResourcesEntry) entry;
166
ITmfStateSystem ssq = resourcesEntry.getTrace().getStateSystems().get(LttngKernelTrace.STATE_ID);
167
final long realStart = Math.max(startTime, ssq.getStartTime());
168
final long realEnd = Math.min(endTime, ssq.getCurrentEndTime() + 1);
169
if (realEnd <= realStart) {
519
172
List<ITimeEvent> eventList = null;
520
int quark = entry.getQuark();
173
int quark = resourcesEntry.getQuark();
522
if (entry.getType().equals(Type.CPU)) {
176
if (resourcesEntry.getType().equals(Type.CPU)) {
523
177
int statusQuark = ssq.getQuarkRelative(quark, Attributes.STATUS);
524
List<ITmfStateInterval> statusIntervals = ssq.queryHistoryRange(statusQuark, startTime, endTime - 1, resolution, monitor);
178
List<ITmfStateInterval> statusIntervals = ssq.queryHistoryRange(statusQuark, realStart, realEnd - 1, resolution, monitor);
525
179
eventList = new ArrayList<ITimeEvent>(statusIntervals.size());
526
180
long lastEndTime = -1;
527
181
for (ITmfStateInterval statusInterval : statusIntervals) {
556
209
long duration = irqInterval.getEndTime() - time + 1;
557
210
if (!irqInterval.getStateValue().isNull()) {
558
211
int cpu = irqInterval.getStateValue().unboxInt();
559
eventList.add(new ResourcesEvent(entry, time, duration, cpu));
212
eventList.add(new TimeEvent(entry, time, duration, cpu));
560
213
lastIsNull = false;
562
if (lastEndTime != time && lastEndTime != -1 && lastIsNull) {
563
eventList.add(new ResourcesEvent(entry, lastEndTime, time - lastEndTime, -1));
566
eventList.add(new ResourcesEvent(entry, time, duration));
215
if (lastEndTime == -1) {
216
// add null event if it intersects the start time
217
eventList.add(new NullTimeEvent(entry, time, duration));
219
if (lastEndTime != time && lastIsNull) {
220
/* This is a special case where we want to show IRQ_ACTIVE state but we don't know the CPU (it is between two null samples) */
221
eventList.add(new TimeEvent(entry, lastEndTime, time - lastEndTime, -1));
223
if (time + duration >= endTime) {
224
// add null event if it intersects the end time
225
eventList.add(new NullTimeEvent(entry, time, duration));
568
228
lastIsNull = true;
570
230
lastEndTime = time + duration;
572
} else if (entry.getType().equals(Type.SOFT_IRQ)) {
573
List<ITmfStateInterval> softIrqIntervals = ssq.queryHistoryRange(quark, startTime, endTime - 1, resolution, monitor);
232
} else if (resourcesEntry.getType().equals(Type.SOFT_IRQ)) {
233
List<ITmfStateInterval> softIrqIntervals = ssq.queryHistoryRange(quark, realStart, realEnd - 1, resolution, monitor);
574
234
eventList = new ArrayList<ITimeEvent>(softIrqIntervals.size());
575
235
long lastEndTime = -1;
576
236
boolean lastIsNull = true;
582
242
long duration = softIrqInterval.getEndTime() - time + 1;
583
243
if (!softIrqInterval.getStateValue().isNull()) {
584
244
int cpu = softIrqInterval.getStateValue().unboxInt();
585
eventList.add(new ResourcesEvent(entry, time, duration, cpu));
245
eventList.add(new TimeEvent(entry, time, duration, cpu));
587
if (lastEndTime != time && lastEndTime != -1 && lastIsNull) {
588
eventList.add(new ResourcesEvent(entry, lastEndTime, time - lastEndTime, -1));
591
eventList.add(new ResourcesEvent(entry, time, duration));
247
if (lastEndTime == -1) {
248
// add null event if it intersects the start time
249
eventList.add(new NullTimeEvent(entry, time, duration));
251
if (lastEndTime != time && lastIsNull) {
252
/* This is a special case where we want to show IRQ_ACTIVE state but we don't know the CPU (it is between two null samples) */
253
eventList.add(new TimeEvent(entry, lastEndTime, time - lastEndTime, -1));
255
if (time + duration >= endTime) {
256
// add null event if it intersects the end time
257
eventList.add(new NullTimeEvent(entry, time, duration));
593
260
lastIsNull = true;
595
262
lastEndTime = time + duration;
598
266
} catch (AttributeNotFoundException e) {
599
267
e.printStackTrace();
600
268
} catch (TimeRangeException e) {
601
269
e.printStackTrace();
602
270
} catch (StateValueTypeException e) {
603
271
e.printStackTrace();
272
} catch (StateSystemDisposedException e) {
605
275
return eventList;
608
private void refresh(final long windowRange) {
609
Display.getDefault().asyncExec(new Runnable() {
612
if (fTimeGraphViewer.getControl().isDisposed()) {
615
ITimeGraphEntry[] entries = null;
616
synchronized (fEntryListSyncObj) {
617
entries = fEntryList.toArray(new ITimeGraphEntry[0]);
619
Arrays.sort(entries, new TraceEntryComparator());
620
fTimeGraphViewer.setInput(entries);
621
fTimeGraphViewer.setTimeBounds(fStartTime, fEndTime);
623
long endTime = fStartTime + windowRange;
625
if (fEndTime < endTime) {
628
fTimeGraphViewer.setStartFinishTime(fStartTime, endTime);
630
startZoomThread(fStartTime, endTime);
636
private void redraw() {
637
synchronized (fSyncObj) {
638
if (fRedrawState == State.IDLE) {
639
fRedrawState = State.BUSY;
641
fRedrawState = State.PENDING;
645
Display.getDefault().asyncExec(new Runnable() {
648
if (fTimeGraphViewer.getControl().isDisposed()) {
651
fTimeGraphViewer.getControl().redraw();
652
fTimeGraphViewer.getControl().update();
653
synchronized (fSyncObj) {
654
if (fRedrawState == State.PENDING) {
655
fRedrawState = State.IDLE;
658
fRedrawState = State.IDLE;
665
private void startZoomThread(long startTime, long endTime) {
666
if (fZoomThread != null) {
667
fZoomThread.cancel();
669
fZoomThread = new ZoomThread(startTime, endTime);
673
private void makeActions() {
674
fPreviousResourceAction = fTimeGraphViewer.getPreviousItemAction();
675
fPreviousResourceAction.setText(Messages.ResourcesView_previousResourceActionNameText);
676
fPreviousResourceAction.setToolTipText(Messages.ResourcesView_previousResourceActionToolTipText);
677
fNextResourceAction = fTimeGraphViewer.getNextItemAction();
678
fNextResourceAction.setText(Messages.ResourcesView_nextResourceActionNameText);
679
fNextResourceAction.setToolTipText(Messages.ResourcesView_previousResourceActionToolTipText);
682
private void contributeToActionBars() {
683
IActionBars bars = getViewSite().getActionBars();
684
fillLocalToolBar(bars.getToolBarManager());
687
private void fillLocalToolBar(IToolBarManager manager) {
688
manager.add(fTimeGraphViewer.getShowLegendAction());
689
manager.add(new Separator());
690
manager.add(fTimeGraphViewer.getResetScaleAction());
691
manager.add(fTimeGraphViewer.getPreviousEventAction());
692
manager.add(fTimeGraphViewer.getNextEventAction());
693
manager.add(fPreviousResourceAction);
694
manager.add(fNextResourceAction);
695
manager.add(fTimeGraphViewer.getZoomInAction());
696
manager.add(fTimeGraphViewer.getZoomOutAction());
697
manager.add(new Separator());