analysis: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.analysis.xml.ui / src / org / eclipse / tracecompass / tmf / analysis / xml / ui / views / timegraph / XmlTimeGraphView.java
index ae54e2b0935fc16d59e0356691ca7d426f9a5040..74bdaeba40523366ef1fb29cb1897dce7bab12a9 100644 (file)
@@ -13,6 +13,8 @@
 
 package org.eclipse.tracecompass.tmf.analysis.xml.ui.views.timegraph;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -24,6 +26,7 @@ import java.util.Set;
 import java.util.TreeSet;
 
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
@@ -32,6 +35,7 @@ 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.StateSystemUtils;
 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
 import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
 import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
@@ -48,6 +52,7 @@ import org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithState
 import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
 import org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider2;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ILinkEvent;
@@ -242,6 +247,7 @@ public class XmlTimeGraphView extends AbstractTimeGraphView {
         List<Element> entries = XmlUtils.getChildElements(viewElement, TmfXmlUiStrings.ENTRY_ELEMENT);
         Set<XmlEntry> entryList = new TreeSet<>(getEntryComparator());
         for (ITmfTrace aTrace : TmfTraceManager.getTraceSet(trace)) {
+            aTrace = checkNotNull(aTrace);
             if (monitor.isCanceled()) {
                 return;
             }
@@ -251,12 +257,13 @@ public class XmlTimeGraphView extends AbstractTimeGraphView {
                 /*
                  * No analysis specified, take all state system analysis modules
                  */
-                for (ITmfAnalysisModuleWithStateSystems module : aTrace.getAnalysisModulesOfClass(ITmfAnalysisModuleWithStateSystems.class)) {
+                for (ITmfAnalysisModuleWithStateSystems module : TmfTraceUtils.getAnalysisModulesOfClass(aTrace, ITmfAnalysisModuleWithStateSystems.class)) {
                     stateSystemModules.add(module);
                 }
             } else {
                 for (String moduleId : analysisIds) {
-                    ITmfAnalysisModuleWithStateSystems module = aTrace.getAnalysisModuleOfClass(ITmfAnalysisModuleWithStateSystems.class, moduleId);
+                    moduleId = checkNotNull(moduleId);
+                    ITmfAnalysisModuleWithStateSystems module = TmfTraceUtils.getAnalysisModuleOfClass(aTrace, ITmfAnalysisModuleWithStateSystems.class, moduleId);
                     if (module != null) {
                         stateSystemModules.add(module);
                     }
@@ -264,7 +271,10 @@ public class XmlTimeGraphView extends AbstractTimeGraphView {
             }
 
             for (ITmfAnalysisModuleWithStateSystems module : stateSystemModules) {
-                module.schedule();
+                IStatus status = module.schedule();
+                if (!status.isOK()) {
+                    return;
+                }
                 if (module instanceof TmfStateSystemAnalysisModule) {
                     ((TmfStateSystemAnalysisModule) module).waitForInitialization();
                 }
@@ -371,7 +381,7 @@ public class XmlTimeGraphView extends AbstractTimeGraphView {
     }
 
     private XmlEntry processEntry(@NonNull Element entryElement, @NonNull Element displayEl,
-            XmlEntry parentEntry, int quark, ITmfStateSystem ss) {
+            @NonNull XmlEntry parentEntry, int quark, ITmfStateSystem ss) {
         /*
          * Get the start time and end time of this entry from the display
          * attribute
@@ -418,7 +428,7 @@ public class XmlTimeGraphView extends AbstractTimeGraphView {
                 entryStart, entryEnd, EntryDisplayType.DISPLAY, ss, entryElement);
     }
 
-    private void buildStatusEvent(XmlEntry traceEntry, IProgressMonitor monitor, long start, long end) {
+    private void buildStatusEvent(XmlEntry traceEntry, @NonNull IProgressMonitor monitor, long start, long end) {
         long resolution = (end - start) / getDisplayWidth();
         long startTime = Math.max(start, traceEntry.getStartTime());
         long endTime = Math.min(end + 1, traceEntry.getEndTime());
@@ -444,9 +454,17 @@ public class XmlTimeGraphView extends AbstractTimeGraphView {
             boolean root = true;
             if (!entry.getParentId().isEmpty()) {
                 XmlEntry parent = entryMap.get(entry.getParentId());
+                /*
+                 * Associate the parent entry only if their time overlap. A
+                 * child entry may start before its parent, for example at the
+                 * beginning of the trace if a parent has not yet appeared in
+                 * the state system. We just want to make sure that the entry
+                 * didn't start after the parent ended or ended before the
+                 * parent started.
+                 */
                 if (parent != null &&
-                        entry.getStartTime() >= parent.getStartTime() &&
-                        entry.getStartTime() <= parent.getEndTime()) {
+                        !(entry.getStartTime() > parent.getEndTime() ||
+                        entry.getEndTime() < parent.getStartTime())) {
                     parent.addChild(entry);
                     root = false;
                 }
@@ -475,7 +493,7 @@ public class XmlTimeGraphView extends AbstractTimeGraphView {
         try {
             if (xmlEntry.getType() == EntryDisplayType.DISPLAY) {
 
-                List<ITmfStateInterval> statusIntervals = ssq.queryHistoryRange(quark, realStart, realEnd - 1, resolution, monitor);
+                List<ITmfStateInterval> statusIntervals = StateSystemUtils.queryHistoryRange(ssq, quark, realStart, realEnd - 1, resolution, monitor);
                 eventList = new ArrayList<>(statusIntervals.size());
                 long lastEndTime = -1;
                 for (ITmfStateInterval statusInterval : statusIntervals) {
This page took 0.026778 seconds and 5 git commands to generate.