X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=tmf%2Forg.eclipse.tracecompass.tmf.ui%2Fsrc%2Forg%2Feclipse%2Ftracecompass%2Ftmf%2Fui%2Fviews%2Fstatesystem%2FTmfStateSystemViewer.java;h=7d803b447fc7596a22865a29408e902bdeec185e;hb=bcd8d4b12d6c8e7de2b48064e4bd629714047341;hp=34205de860a219cc28ee71e313348a6c98f68f65;hpb=4c4e281658452fd4f899727b4267f478201a2654;p=deliverable%2Ftracecompass.git diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemViewer.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemViewer.java index 34205de860..7d803b447f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemViewer.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * 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 @@ -29,21 +29,19 @@ import org.eclipse.swt.graphics.Color; 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.statesystem.TmfStateSystemAnalysisModule; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; 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; @@ -170,7 +168,7 @@ public class TmfStateSystemViewer extends AbstractTmfTreeViewer { fSelection = start; } else { TmfTraceContext ctx = TmfTraceManager.getInstance().getCurrentTraceContext(); - fSelection = ctx.getSelectionRange().getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue(); + fSelection = ctx.getSelectionRange().getStartTime().toNanos(); } if (getTrace() == null) { @@ -199,25 +197,28 @@ public class TmfStateSystemViewer extends AbstractTmfTreeViewer { 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 modules = TmfTraceUtils.getAnalysisModulesOfClass(trace, ITmfAnalysisModuleWithStateSystems.class); - for (ITmfAnalysisModuleWithStateSystems module : modules) { - /* Just schedule the module, the data will be filled when available */ - module.schedule(); - if (module instanceof TmfStateSystemAnalysisModule) { - // TODO: add this method to ITmfAnalysisModuleWithStateSystems - ((TmfStateSystemAnalysisModule) module).waitForInitialization(); - } - for (ITmfStateSystem ss : module.getStateSystems()) { - traceEntry.addChild(new StateSystemEntry(ss)); + Iterable 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; @@ -253,48 +254,44 @@ public class TmfStateSystemViewer extends AbstractTmfTreeViewer { private boolean updateStateEntries(ITmfStateSystem ss, List 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; } @@ -367,13 +364,13 @@ public class TmfStateSystemViewer extends AbstractTmfTreeViewer { 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; @@ -414,6 +411,7 @@ public class TmfStateSystemViewer extends AbstractTmfTreeViewer { case LONG: case DOUBLE: case STRING: + case CUSTOM: return fValue.toString(); case NULL: default: @@ -434,6 +432,8 @@ public class TmfStateSystemViewer extends AbstractTmfTreeViewer { return Messages.TypeDouble; case STRING: return Messages.TypeString; + case CUSTOM: + return Messages.TypeCustom; case NULL: default: return EMPTY_STRING; @@ -444,7 +444,7 @@ public class TmfStateSystemViewer extends AbstractTmfTreeViewer { 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)) {