/*******************************************************************************
- * Copyright (c) 2010 Ericsson
+ * Copyright (c) 2010, 2013 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.signal.TmfEventFilterAppliedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfEventSearchAppliedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.ui.editors.ITmfTraceEditor;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphViewer;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphColorScheme;
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils.TimeFormat;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
private final Object fSyncObj = new Object();
private ITimeGraphPresentationProvider fPresentationProvider;
- /**
- * TimeChartViewer extends TimeGraphViewer to use a TimeGraphControl that overrides drawState
- * to inhibit drawing of filtered-out events.
- */
- private class TimeChartViewer extends TimeGraphViewer {
-
- public TimeChartViewer(Composite parent, int style) {
- super(parent, style);
- }
-
- @Override
- protected TimeGraphControl createTimeGraphControl(Composite parent, TimeGraphColorScheme colorScheme) {
- return new TimeGraphControl(parent, colorScheme) {
- @Override
- protected void drawState(TimeGraphColorScheme colors, ITimeEvent event, Rectangle rect, GC gc, boolean selected, boolean timeSelected) {
- if (! ((TimeChartEvent) event).isVisible()) {
- return;
- }
- super.drawState(colors, event, rect, gc, selected, timeSelected);
- }
- };
- }
- }
-
/**
* Default constructor
*/
@Override
public void createPartControl(Composite parent) {
- fViewer = new TimeChartViewer(parent, SWT.NONE);
+ fViewer = new TimeGraphViewer(parent, SWT.NONE);
fPresentationProvider = new TimeChartAnalysisProvider();
fViewer.setTimeGraphProvider(fPresentationProvider);
- fViewer.setTimeCalendarFormat(true);
+ fViewer.setTimeFormat(TimeFormat.CALENDAR);
fViewer.addTimeListener(this);
fViewer.addRangeListener(this);
fViewer.addSelectionListener(this);
private class ItemizeThread extends Thread {
private final TimeChartAnalysisEntry fTimeAnalysisEntry;
- private final long fStartTime;
- private final long fStopTime;
+ private final long startTime;
+ private final long stopTime;
private final long fMaxDuration;
private ItemizeThread(TimeChartAnalysisEntry timeAnalysisEntry, long startTime, long stopTime) {
super("Itemize Thread:" + timeAnalysisEntry.getName()); //$NON-NLS-1$
fTimeAnalysisEntry = timeAnalysisEntry;
- fStartTime = startTime;
- fStopTime = stopTime;
- fMaxDuration = 3 * (fStopTime - fStartTime) / fDisplayWidth;
+ this.startTime = startTime;
+ this.stopTime = stopTime;
+ fMaxDuration = 3 * (stopTime - startTime) / fDisplayWidth;
}
@Override
boolean hasNext = true;
while (hasNext) {
synchronized (timeAnalysisEntry) {
- while (hasNext = iterator.hasNext()) {
+ while ((hasNext = iterator.hasNext()) == true) {
event = (TimeChartEvent) iterator.next();
- if (event.getTime() + event.getDuration() > fStartTime && event.getTime() < fStopTime && event.getDuration() > fMaxDuration
+ if (event.getTime() + event.getDuration() > startTime && event.getTime() < stopTime && event.getDuration() > fMaxDuration
&& event.getNbEvents() > 1) {
break;
}
}
}
- if (hasNext) {
+ if (hasNext && event != null) {
if (event.getItemizedEntry() == null) {
itemizeEvent(event);
} else {
boolean hasNext = true;
while (!interrupted && hasNext) {
synchronized (timeAnalysisEntry) {
- while (hasNext = iterator.hasNext()) {
+ while ((hasNext = iterator.hasNext()) == true) {
event = (TimeChartEvent) iterator.next();
break;
}
}
- if (hasNext) {
+ if (hasNext && event != null) {
// TODO possible concurrency problem here with ItemizeJob
event.setColorSettingPriority(ColorSettingsManager.PRIORITY_NONE);
if (event.getItemizedEntry() != null) {
boolean hasNext = true;
while (!interrupted && hasNext) {
synchronized (timeAnalysisEntry) {
- while (hasNext = iterator.hasNext()) {
+ while ((hasNext = iterator.hasNext()) == true) {
event = (TimeChartEvent) iterator.next();
break;
}
}
- if (hasNext) {
+ if (hasNext && event != null) {
// TODO possible concurrency problem here with ItemizeJob
if (event.getItemizedEntry() == null) {
decorateEvent(event);
*/
@TmfSignalHandler
public void traceOpened(TmfTraceOpenedSignal signal) {
- if (fTimeAnalysisEntries == null) {
- return;
- }
final ITmfTrace trace = signal.getTrace();
final IFile bookmarksFile = signal.getBookmarksFile();
TimeChartAnalysisEntry timeAnalysisEntry = null;
*/
@TmfSignalHandler
public void traceClosed(TmfTraceClosedSignal signal) {
- if (fTimeAnalysisEntries == null) {
- return;
- }
final ITmfTrace trace = signal.getTrace();
for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {
if (fTimeAnalysisEntries.get(i).getTrace().equals(trace)) {
*/
@TmfSignalHandler
public void traceSelected(TmfTraceSelectedSignal signal) {
- if (signal.getSource() != this && fTimeAnalysisEntries != null) {
+ if (signal.getSource() != this) {
ITmfTrace trace = signal.getTrace();
for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {
if (fTimeAnalysisEntries.get(i).getTrace().equals(trace)) {
*/
@TmfSignalHandler
public void traceUpdated(TmfTraceUpdatedSignal signal) {
- if (fTimeAnalysisEntries == null) {
- return;
- }
final ITmfTrace trace = signal.getTrace();
for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {
TimeChartAnalysisEntry timeAnalysisEntry = fTimeAnalysisEntries.get(i);