import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
import org.eclipse.linuxtools.tmf.ui.views.TmfView;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphRangeListener;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphSelectionListener;
final long time = signal.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
int thread = -1;
- ITmfTrace[] traces;
- if (fTrace instanceof TmfExperiment) {
- TmfExperiment experiment = (TmfExperiment) fTrace;
- traces = experiment.getTraces();
- } else {
- traces = new ITmfTrace[] { fTrace };
- }
- for (ITmfTrace trace : traces) {
+ for (ITmfTrace trace : fTrace.getTraces()) {
if (thread > 0) {
break;
}
private void buildEventList(final ITmfTrace trace, IProgressMonitor monitor) {
fStartTime = Long.MAX_VALUE;
fEndTime = Long.MIN_VALUE;
- ITmfTrace[] traces;
- if (trace instanceof TmfExperiment) {
- TmfExperiment experiment = (TmfExperiment) trace;
- traces = experiment.getTraces();
- } else {
- traces = new ITmfTrace[] { trace };
- }
ArrayList<ControlFlowEntry> rootList = new ArrayList<ControlFlowEntry>();
- for (ITmfTrace aTrace : traces) {
+ for (ITmfTrace aTrace : trace.getTraces()) {
if (monitor.isCanceled()) {
return;
}
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
import org.eclipse.linuxtools.tmf.ui.views.TmfView;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphRangeListener;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphTimeListener;
private void buildEventList(final ITmfTrace trace, IProgressMonitor monitor) {
fStartTime = Long.MAX_VALUE;
fEndTime = Long.MIN_VALUE;
- ITmfTrace[] traces;
- if (trace instanceof TmfExperiment) {
- TmfExperiment experiment = (TmfExperiment) trace;
- traces = experiment.getTraces();
- } else {
- traces = new ITmfTrace[] { trace };
- }
ArrayList<TraceEntry> entryList = new ArrayList<TraceEntry>();
- for (ITmfTrace aTrace : traces) {
+ for (ITmfTrace aTrace : trace.getTraces()) {
if (monitor.isCanceled()) {
return;
}
import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystemBuilder;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
/**
* This is the high-level wrapper around the State History and its input and
*/
@TmfSignalHandler
public void traceRangeUpdated(final TmfTraceRangeUpdatedSignal signal) {
- ITmfTrace trace = signal.getTrace();
- if (signal.getTrace() instanceof TmfExperiment) {
- TmfExperiment experiment = (TmfExperiment) signal.getTrace();
- for (ITmfTrace expTrace : experiment.getTraces()) {
- if (expTrace == sci.getTrace()) {
- trace = expTrace;
- break;
- }
+ /*
+ * Check if this signal is for this trace, or for an experiment
+ * containing this trace.
+ */
+ ITmfTrace sender = signal.getTrace();
+ ITmfTrace target = null;
+ for (ITmfTrace trace : sender.getTraces()) {
+ if (trace == sci.getTrace()) {
+ target = trace;
+ break;
}
}
- if (trace != sci.getTrace()) {
+
+ if (target == null) {
return;
}
- /* the signal is for this trace or for an experiment containing this trace */
if (!started) {
started = true;
StateSystemBuildRequest request = new StateSystemBuildRequest(this);
- trace = signal.getTrace();
- trace.sendRequest(request);
+ sender.sendRequest(request);
}
}
*/
@TmfSignalHandler
public void traceClosed(TmfTraceClosedSignal signal) {
- ITmfTrace trace = signal.getTrace();
- if (signal.getTrace() instanceof TmfExperiment) {
- TmfExperiment experiment = (TmfExperiment) signal.getTrace();
- for (ITmfTrace expTrace : experiment.getTraces()) {
- if (expTrace == sci.getTrace()) {
- trace = expTrace;
- break;
- }
+ /*
+ * Check if this signal is for this trace, or for an experiment
+ * containing this trace.
+ */
+ boolean found = false;
+ for (ITmfTrace trace : signal.getTrace().getTraces()) {
+ if (trace == sci.getTrace()) {
+ found = true;
+ break;
}
}
- if (trace != sci.getTrace()) {
- return;
- }
- /* the signal is for this trace or for an experiment containing this trace */
- if (!started) {
+ if (found && !started) {
close(true);
}
}
// Basic getters
// ------------------------------------------------------------------------
+ /**
+ * If this trace is used as a container for sub-traces, this can be used to
+ * get the sub-traces themselves. If the trace is stand-alone, this should
+ * return an array with only "this" inside. For this reason, be careful if
+ * calling this recursively.
+ *
+ * This offers a standard way of iterating through compound traces (like
+ * experiments).
+ *
+ * @return The array of sub-traces.
+ * @since 2.0
+ */
+ public ITmfTrace[] getTraces();
+
/**
* @return the trace event type
*/
// Accessors
// ------------------------------------------------------------------------
- /**
- * Get the list of traces. Handle with care...
- *
- * @return the experiment traces
- */
+ @Override
public ITmfTrace[] getTraces() {
return fTraces;
}
// ITmfTrace - Basic getters
// ------------------------------------------------------------------------
+ /**
+ * @since 2.0
+ */
+ @Override
+ public ITmfTrace[] getTraces() {
+ return new ITmfTrace[] { this };
+ }
+
/* (non-Javadoc)
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getEventType()
*/
*/
@TmfSignalHandler
public void traceOpened(TmfTraceOpenedSignal signal) {
- ITmfTrace trace = signal.getTrace();
- if (signal.getTrace() instanceof TmfExperiment) {
- TmfExperiment experiment = (TmfExperiment) signal.getTrace();
- for (ITmfTrace expTrace : experiment.getTraces()) {
- if (expTrace == this) {
- trace = expTrace;
- break;
- }
+ ITmfTrace trace = null;
+ for (ITmfTrace expTrace : signal.getTrace().getTraces()) {
+ if (expTrace == this) {
+ trace = expTrace;
+ break;
}
}
- if (trace == this) {
- /* the signal is for this trace or for an experiment containing this trace */
- try {
- buildStatistics();
- } catch (TmfTraceException e) {
- e.printStackTrace();
- }
- try {
- buildStateSystem();
- } catch (TmfTraceException e) {
- e.printStackTrace();
- }
- /* Refresh the project, so it can pick up new files that got created. */
- try {
- if (fResource != null) {
- fResource.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
- }
- } catch (CoreException e) {
- e.printStackTrace();
+ if (trace == null) {
+ /* This signal is not for us */
+ return;
+ }
+
+ /*
+ * The signal is for this trace, or for an experiment containing
+ * this trace.
+ */
+ try {
+ buildStatistics();
+ buildStateSystem();
+ } catch (TmfTraceException e) {
+ e.printStackTrace();
+ }
+
+ /* Refresh the project, so it can pick up new files that got created. */
+ try {
+ if (fResource != null) {
+ fResource.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
}
+ } catch (CoreException e) {
+ e.printStackTrace();
}
+
if (signal.getTrace() == this) {
- /* the signal is for this trace or experiment */
+ /* Additionally, the signal is directly for this trace or experiment. */
if (getNbEvents() == 0) {
return;
}
// Checks if the trace is already in the statistics tree.
int numNodeTraces = statisticsTreeNode.getNbChildren();
- int numTraces = 1;
- ITmfTrace[] trace = { fTrace };
- // For experiment, gets all the traces within it
- if (fTrace instanceof TmfExperiment) {
- TmfExperiment experiment = (TmfExperiment) fTrace;
- numTraces = experiment.getTraces().length;
- trace = experiment.getTraces();
- }
+ ITmfTrace[] traces = fTrace.getTraces();
+ int numTraces = traces.length;
if (numTraces == numNodeTraces) {
boolean same = true;
* previously selected.
*/
for (int i = 0; i < numTraces; i++) {
- String traceName = trace[i].getName();
+ String traceName = traces[i].getName();
if (!statisticsTreeNode.containsChild(traceName)) {
same = false;
break;
statTree.resetTimeRangeValue();
}
- ITmfTrace[] traces;
- if (trace instanceof TmfExperiment) {
- TmfExperiment experiment = (TmfExperiment) trace;
- traces = experiment.getTraces();
- } else {
- traces = new ITmfTrace[] { trace };
- }
+ ITmfTrace[] traces = trace.getTraces();
for (final ITmfTrace aTrace : traces) {
if (!isListeningTo(aTrace)) {
continue;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceClosedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
import org.eclipse.linuxtools.tmf.ui.views.TmfView;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
return;
}
- ITmfTrace[] traces;
- if (fTrace instanceof TmfExperiment) {
- TmfExperiment experiment = (TmfExperiment) fTrace;
- traces = experiment.getTraces();
- } else {
- traces = new ITmfTrace[] { fTrace };
- }
+ ITmfTrace[] traces = fTrace.getTraces();
for (ITmfTrace trace : traces) {
if (trace instanceof CtfTmfTrace) {
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceRangeUpdatedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceType;
import org.eclipse.linuxtools.tmf.ui.viewers.ITmfViewer;
import org.eclipse.linuxtools.tmf.ui.viewers.statistics.TmfStatisticsViewer;
String traceName;
IResource traceResource;
- ITmfTrace[] traces;
- if (fTrace instanceof TmfExperiment) {
- TmfExperiment experiment = (TmfExperiment) fTrace;
- traces = experiment.getTraces();
- } else {
- traces = new ITmfTrace[] { fTrace };
- }
+ ITmfTrace[] traces = fTrace.getTraces();
// Creates a statistics viewer for each trace.
for (ITmfTrace trace : traces) {
traceName = trace.getName();