/*******************************************************************************
- * Copyright (c) 2014 École Polytechnique de Montréal
+ * Copyright (c) 2014, 2016 École Polytechnique de Montréal and others.
*
* 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.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
-import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
+import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
import org.eclipse.tracecompass.tmf.core.signal.TmfTimestampFormatUpdateSignal;
import org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
-import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
import org.eclipse.tracecompass.tmf.ui.viewers.tree.AbstractTmfTreeViewer;
import org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeColumnDataProvider;
import org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeViewerEntry;
TmfTreeViewerEntry rootEntry = new TmfTreeViewerEntry("root"); //$NON-NLS-1$
for (final ITmfTrace trace : TmfTraceManager.getTraceSetWithExperiment(getTrace())) {
- if (trace != null) {
- rootEntry.addChild(createTraceEntry(trace));
- }
+ rootEntry.addChild(createTraceEntry(trace));
}
return rootEntry;
}
private static TmfTreeViewerEntry createTraceEntry(ITmfTrace trace) {
TmfTreeViewerEntry traceEntry = new TmfTreeViewerEntry(trace.getName());
- Iterable<ITmfAnalysisModuleWithStateSystems> modules = TmfTraceUtils.getAnalysisModulesOfClass(trace, ITmfAnalysisModuleWithStateSystems.class);
- for (ITmfAnalysisModuleWithStateSystems module : modules) {
- /* Just schedule the module, the data will be filled when available */
- module.schedule();
- module.waitForInitialization();
- for (ITmfStateSystem ss : module.getStateSystems()) {
- traceEntry.addChild(new StateSystemEntry(ss));
+ Iterable<IAnalysisModule> modules = trace.getAnalysisModules();
+ for (IAnalysisModule module : modules) {
+ if (module instanceof ITmfAnalysisModuleWithStateSystems) {
+ ITmfAnalysisModuleWithStateSystems moduleWithStateSystem = (ITmfAnalysisModuleWithStateSystems) module;
+ /*
+ * Just schedule the module, the data will be filled when
+ * available
+ */
+ moduleWithStateSystem.schedule();
+ if (!moduleWithStateSystem.waitForInitialization()) {
+ continue;
+ }
+ for (ITmfStateSystem ss : moduleWithStateSystem.getStateSystems()) {
+ traceEntry.addChild(new StateSystemEntry(ss));
+ }
}
}
return traceEntry;
private boolean updateStateEntries(ITmfStateSystem ss, List<ITmfStateInterval> fullState, TmfTreeViewerEntry parent, int parentQuark, long timestamp) {
boolean changed = false;
- try {
- for (int quark : ss.getSubAttributes(parentQuark, false)) {
- if (quark >= fullState.size()) {
- // attribute was created after the full state query
- continue;
- }
- ITmfStateInterval interval = fullState.get(quark);
- StateEntry stateEntry = findStateEntry(parent, quark);
- if (stateEntry == null) {
- boolean modified = fFilterStatus ?
- interval.getStartTime() == timestamp :
- !interval.getStateValue().isNull();
- stateEntry = new StateEntry(ss.getAttributeName(quark), quark, ss.getFullAttributePath(quark),
- interval.getStateValue(),
- new TmfTimestamp(interval.getStartTime(), ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(interval.getEndTime(), ITmfTimestamp.NANOSECOND_SCALE),
- modified);
-
- // update children first to know if parent is really needed
- updateStateEntries(ss, fullState, stateEntry, quark, timestamp);
-
- /*
- * Add this entry to parent if filtering is off, or
- * if the entry has children to display, or
- * if there is a state change at the current timestamp
- */
- if (!fFilterStatus || stateEntry.hasChildren() || interval.getStartTime() == timestamp) {
- parent.addChild(stateEntry);
- changed = true;
- }
- } else {
- stateEntry.update(interval.getStateValue(),
- new TmfTimestamp(interval.getStartTime(), ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(interval.getEndTime(), ITmfTimestamp.NANOSECOND_SCALE));
-
- // update children recursively
- updateStateEntries(ss, fullState, stateEntry, quark, timestamp);
+ for (int quark : ss.getSubAttributes(parentQuark, false)) {
+ if (quark >= fullState.size()) {
+ // attribute was created after the full state query
+ continue;
+ }
+ ITmfStateInterval interval = fullState.get(quark);
+ StateEntry stateEntry = findStateEntry(parent, quark);
+ if (stateEntry == null) {
+ boolean modified = fFilterStatus ?
+ interval.getStartTime() == timestamp :
+ !interval.getStateValue().isNull();
+ stateEntry = new StateEntry(ss.getAttributeName(quark), quark, ss.getFullAttributePath(quark),
+ interval.getStateValue(),
+ TmfTimestamp.fromNanos(interval.getStartTime()),
+ TmfTimestamp.fromNanos(interval.getEndTime()),
+ modified);
+
+ // update children first to know if parent is really needed
+ updateStateEntries(ss, fullState, stateEntry, quark, timestamp);
+
+ /*
+ * Add this entry to parent if filtering is off, or
+ * if the entry has children to display, or
+ * if there is a state change at the current timestamp
+ */
+ if (!fFilterStatus || stateEntry.hasChildren() || interval.getStartTime() == timestamp) {
+ parent.addChild(stateEntry);
+ changed = true;
}
+ } else {
+ stateEntry.update(interval.getStateValue(),
+ TmfTimestamp.fromNanos(interval.getStartTime()),
+ TmfTimestamp.fromNanos(interval.getEndTime()));
+ // update children recursively
+ updateStateEntries(ss, fullState, stateEntry, quark, timestamp);
}
- } catch (AttributeNotFoundException e) {
- /* Should not happen, we're iterating on known attributes */
+
}
return changed;
}
private final int fQuark;
private final String fFullPath;
- private @NonNull TmfTimestamp fStart;
- private @NonNull TmfTimestamp fEnd;
+ private @NonNull ITmfTimestamp fStart;
+ private @NonNull ITmfTimestamp fEnd;
private ITmfStateValue fValue;
private boolean fModified;
private boolean fOutOfRange = false;
- public StateEntry(String name, int quark, String fullPath, ITmfStateValue value, @NonNull TmfTimestamp start, @NonNull TmfTimestamp end, boolean modified) {
+ public StateEntry(String name, int quark, String fullPath, ITmfStateValue value, @NonNull ITmfTimestamp start, @NonNull ITmfTimestamp end, boolean modified) {
super(name);
fQuark = quark;
fFullPath = fullPath;
case LONG:
case DOUBLE:
case STRING:
+ case CUSTOM:
return fValue.toString();
case NULL:
default:
return Messages.TypeDouble;
case STRING:
return Messages.TypeString;
+ case CUSTOM:
+ return Messages.TypeCustom;
case NULL:
default:
return EMPTY_STRING;
return fModified;
}
- public void update(ITmfStateValue value, @NonNull TmfTimestamp start, @NonNull TmfTimestamp end) {
+ public void update(ITmfStateValue value, @NonNull ITmfTimestamp start, @NonNull ITmfTimestamp end) {
fModified = false;
fOutOfRange = false;
if (!start.equals(fStart)) {