analysis: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.analysis.xml.ui / src / org / eclipse / tracecompass / internal / tmf / analysis / xml / ui / views / xychart / XmlXYViewer.java
index 10f29cb8bdaddfb06e52717512c27d03abb656c8..a25103168374c614bc399d75592d7e3eceecc7a9 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2014 École Polytechnique de Montréal
+ * Copyright (c) 2014, 2015 É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
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.xychart;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedList;
@@ -20,7 +22,7 @@ import java.util.Map;
 import java.util.regex.Pattern;
 
 import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.Activator;
@@ -42,6 +44,7 @@ import org.eclipse.tracecompass.tmf.analysis.xml.core.stateprovider.TmfXmlString
 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;
 import org.w3c.dom.Element;
 
@@ -59,8 +62,7 @@ public class XmlXYViewer extends TmfCommonXLineChartViewer {
     /** Timeout between updates in the updateData thread */
     private static final long BUILD_UPDATE_TIMEOUT = 500;
 
-    @SuppressWarnings("null")
-    private static final @NonNull Pattern WILDCARD_PATTERN = Pattern.compile("\\*"); //$NON-NLS-1$
+    private static final Pattern WILDCARD_PATTERN = checkNotNull(Pattern.compile("\\*")); //$NON-NLS-1$
 
     private final ITmfXmlModelFactory fFactory = TmfXmlReadOnlyModelFactory.getInstance();
     private final Map<Integer, SeriesData> fSeriesData = new HashMap<>();
@@ -186,8 +188,7 @@ public class XmlXYViewer extends TmfCommonXLineChartViewer {
         public List<Integer> getQuarks() {
             /* Get the list of quarks to process with this path */
             String[] paths = fPath.split(SPLIT_STRING);
-            @SuppressWarnings("null")
-            @NonNull List<Integer> quarks = Collections.singletonList(IXmlStateSystemContainer.ROOT_QUARK);
+            List<Integer> quarks = checkNotNull(Collections.singletonList(IXmlStateSystemContainer.ROOT_QUARK));
 
             try {
                 for (String path : paths) {
@@ -276,9 +277,6 @@ public class XmlXYViewer extends TmfCommonXLineChartViewer {
                             seriesName = ss.getAttributeName(quark);
                         }
                     }
-                    if (seriesName == null) {
-                        throw new IllegalStateException();
-                    }
                     fSeriesData.put(quark, new SeriesData(xvalues.length, display.getAttributeQuark(quark), seriesName, entry.getType()));
                 }
                 double yvalue = 0.0;
@@ -336,13 +334,13 @@ public class XmlXYViewer extends TmfCommonXLineChartViewer {
             /*
              * No analysis specified, take all state system analysis modules
              */
-            for (ITmfAnalysisModuleWithStateSystems module : trace.getAnalysisModulesOfClass(ITmfAnalysisModuleWithStateSystems.class)) {
+            for (ITmfAnalysisModuleWithStateSystems module : TmfTraceUtils.getAnalysisModulesOfClass(trace, ITmfAnalysisModuleWithStateSystems.class)) {
                 stateSystemModules.add(module);
             }
         } else {
             for (String moduleId : analysisIds) {
-                @SuppressWarnings("resource")
-                ITmfAnalysisModuleWithStateSystems module = trace.getAnalysisModuleOfClass(ITmfAnalysisModuleWithStateSystems.class, moduleId);
+                moduleId = checkNotNull(moduleId);
+                ITmfAnalysisModuleWithStateSystems module = TmfTraceUtils.getAnalysisModuleOfClass(trace, ITmfAnalysisModuleWithStateSystems.class, moduleId);
                 if (module != null) {
                     stateSystemModules.add(module);
                 }
@@ -357,7 +355,10 @@ public class XmlXYViewer extends TmfCommonXLineChartViewer {
 
         /* Schedule all state systems */
         for (ITmfAnalysisModuleWithStateSystems module : stateSystemModules) {
-            module.schedule();
+            IStatus status = module.schedule();
+            if (!status.isOK()) {
+                return;
+            }
             if (module instanceof TmfStateSystemAnalysisModule) {
                 ((TmfStateSystemAnalysisModule) module).waitForInitialization();
             }
@@ -392,12 +393,18 @@ public class XmlXYViewer extends TmfCommonXLineChartViewer {
             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);
         }
 
This page took 0.032999 seconds and 5 git commands to generate.