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 0a7938ff3c20870b61f5c957a1dd5f0f4a362dba..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;
@@ -50,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;
@@ -244,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;
             }
@@ -253,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);
                     }
@@ -376,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
@@ -423,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());
@@ -449,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;
                 }
This page took 0.026778 seconds and 5 git commands to generate.