/*******************************************************************************
- * Copyright (c) 2014, 2015 École Polytechnique de Montréal and others.
+ * 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.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.model.ITmfXmlModelFactory;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.model.ITmfXmlStateAttribute;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.model.TmfXmlLocation;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.model.readonly.TmfXmlReadOnlyModelFactory;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.IXmlStateSystemContainer;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.XmlUtils;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.stateprovider.TmfXmlStrings;
import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.Activator;
import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.TmfXmlUiStrings;
import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.XmlViewInfo;
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.StateValueTypeException;
import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
-import org.eclipse.tracecompass.tmf.analysis.xml.core.model.ITmfXmlModelFactory;
-import org.eclipse.tracecompass.tmf.analysis.xml.core.model.ITmfXmlStateAttribute;
-import org.eclipse.tracecompass.tmf.analysis.xml.core.model.TmfXmlLocation;
-import org.eclipse.tracecompass.tmf.analysis.xml.core.model.readonly.TmfXmlReadOnlyModelFactory;
-import org.eclipse.tracecompass.tmf.analysis.xml.core.module.IXmlStateSystemContainer;
-import org.eclipse.tracecompass.tmf.analysis.xml.core.module.XmlUtils;
-import org.eclipse.tracecompass.tmf.analysis.xml.core.stateprovider.TmfXmlStrings;
import org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems;
-import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.linecharts.TmfCommonXLineChartViewer;
/** Timeout between updates in the updateData thread */
private static final long BUILD_UPDATE_TIMEOUT = 500;
- private static final Pattern WILDCARD_PATTERN = checkNotNull(Pattern.compile("\\*")); //$NON-NLS-1$
+ private static final Pattern WILDCARD_PATTERN = Pattern.compile("\\*"); //$NON-NLS-1$
private final ITmfXmlModelFactory fFactory = TmfXmlReadOnlyModelFactory.getInstance();
private final Map<Integer, SeriesData> fSeriesData = new HashMap<>();
private class SeriesData {
private final double[] fYValues;
- private final @Nullable double[] fYAbsoluteValues;
+ private final double @Nullable [] fYAbsoluteValues;
private final Integer fDisplayQuark;
private final String fName;
private final DisplayType fType;
}
@Override
- public @Nullable Iterable<TmfXmlLocation> getLocations() {
+ public @NonNull Iterable<@NonNull TmfXmlLocation> getLocations() {
return Collections.EMPTY_SET;
}
public List<Integer> getQuarks() {
/* Get the list of quarks to process with this path */
String[] paths = fPath.split(SPLIT_STRING);
- List<Integer> quarks = checkNotNull(Collections.singletonList(IXmlStateSystemContainer.ROOT_QUARK));
-
- try {
- for (String path : paths) {
- List<Integer> subQuarks = new LinkedList<>();
- /* Replace * by .* to have a regex string */
- String name = WILDCARD_PATTERN.matcher(path).replaceAll(".*"); //$NON-NLS-1$
- for (int relativeQuark : quarks) {
- subQuarks.addAll(fStateSystem.getSubAttributes(relativeQuark, false, name));
- }
- quarks = subQuarks;
+ List<Integer> quarks = Collections.singletonList(IXmlStateSystemContainer.ROOT_QUARK);
+
+ for (String path : paths) {
+ List<Integer> subQuarks = new LinkedList<>();
+ /* Replace * by .* to have a regex string */
+ String name = WILDCARD_PATTERN.matcher(path).replaceAll(".*"); //$NON-NLS-1$
+ for (int relativeQuark : quarks) {
+ subQuarks.addAll(fStateSystem.getSubAttributes(relativeQuark, false, name));
}
- } catch (AttributeNotFoundException e) {
- /*
- * We get all attributes from the state system itself, this
- * should not happen.
- */
- throw new IllegalStateException();
+ quarks = subQuarks;
}
return quarks;
}
if (seriesNameAttrib == null) {
seriesName = ss.getAttributeName(quark);
} else {
- int seriesNameQuark = seriesNameAttrib.getAttributeQuark(quark);
+ int seriesNameQuark = seriesNameAttrib.getAttributeQuark(quark, null);
try {
ITmfStateValue seriesNameValue = ss.querySingleState(start, seriesNameQuark).getStateValue();
if (!seriesNameValue.isNull()) {
seriesName = ss.getAttributeName(quark);
}
}
- fSeriesData.put(quark, new SeriesData(xvalues.length, display.getAttributeQuark(quark), seriesName, entry.getType()));
+ fSeriesData.put(quark, new SeriesData(xvalues.length, display.getAttributeQuark(quark, null), seriesName, entry.getType()));
}
- double yvalue = 0.0;
for (int i = 0; i < xvalues.length; i++) {
if (monitor != null && monitor.isCanceled()) {
return;
time = time > traceEnd ? traceEnd : time;
for (int quark : quarks) {
+ double yvalue = 0.0;
+ SeriesData data = checkNotNull(fSeriesData.get(quark));
try {
- yvalue = ss.querySingleState(time, fSeriesData.get(quark).getDisplayQuark()).getStateValue().unboxLong();
- fSeriesData.get(quark).setYValue(i, yvalue);
+ ITmfStateValue value = ss.querySingleState(time, data.getDisplayQuark()).getStateValue();
+ switch (value.getType()) {
+ case DOUBLE:
+ yvalue = value.unboxDouble();
+ break;
+ case LONG:
+ yvalue = value.unboxLong();
+ break;
+ case INTEGER:
+ yvalue = value.unboxInt();
+ break;
+ case NULL:
+ case STRING:
+ case CUSTOM:
+ default:
+ break;
+ }
+ data.setYValue(i, yvalue);
} catch (TimeRangeException e) {
- fSeriesData.get(quark).setYValue(i, 0);
+ data.setYValue(i, 0);
}
}
}
for (int quark : quarks) {
- setSeries(fSeriesData.get(quark).getSeriesName(), fSeriesData.get(quark).getYValues());
+ SeriesData data = checkNotNull(fSeriesData.get(quark));
+ setSeries(data.getSeriesName(), data.getYValues());
}
updateDisplay();
- } catch (AttributeNotFoundException | StateValueTypeException e) {
+ } catch (StateValueTypeException e) {
Activator.logError("Error updating the data of XML XY view", e); //$NON-NLS-1$
} catch (StateSystemDisposedException e) {
return;
}
} else {
for (String moduleId : analysisIds) {
- moduleId = checkNotNull(moduleId);
ITmfAnalysisModuleWithStateSystems module = TmfTraceUtils.getAnalysisModuleOfClass(trace, ITmfAnalysisModuleWithStateSystems.class, moduleId);
if (module != null) {
stateSystemModules.add(module);
if (!status.isOK()) {
return;
}
- if (module instanceof TmfStateSystemAnalysisModule) {
- ((TmfStateSystemAnalysisModule) module).waitForInitialization();
+ if (!module.waitForInitialization()) {
+ return;
}
for (ITmfStateSystem ssq : module.getStateSystems()) {
- if (ssq != null) {
- ss = ssq;
- break;
- }
+ ss = ssq;
+ break;
}
}
if (ss == null) {
fEntry = entry;
/* Get the display element to use */
- List<Element> displayElements = XmlUtils.getChildElements(entryElement, TmfXmlUiStrings.DISPLAY_ELEMENT);
+ List<@NonNull Element> displayElements = XmlUtils.getChildElements(entryElement, TmfXmlUiStrings.DISPLAY_ELEMENT);
if (displayElements.isEmpty()) {
Activator.logWarning(String.format("XML view: entry for %s should have a display element", path)); //$NON-NLS-1$
return;
}
Element displayElement = displayElements.get(0);
- if (displayElement == null) {
- throw new IllegalStateException();
- }
fDisplay = fFactory.createStateAttribute(displayElement, entry);
/* Get the series name element to use */
List<Element> seriesNameElements = XmlUtils.getChildElements(entryElement, TmfXmlUiStrings.NAME_ELEMENT);
if (!seriesNameElements.isEmpty()) {
Element seriesNameElement = seriesNameElements.get(0);
- if (seriesNameElement == null) {
- throw new IllegalStateException();
- }
fSeriesName = fFactory.createStateAttribute(seriesNameElement, entry);
}