tmf: Make TimeGraphEntry implementation less restrictive
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.kernel.ui / src / org / eclipse / linuxtools / internal / lttng2 / kernel / ui / views / resources / ResourcesView.java
index 5a501439b393e05c4b1a1643ce911a1f84894c6d..37011c90bbe9eedfdc2d530bd8391b278cc12907 100644 (file)
@@ -20,19 +20,22 @@ import java.util.List;
 import java.util.Map;
 
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;
 import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;
 import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources.ResourcesEntry.Type;
-import org.eclipse.linuxtools.lttng2.kernel.ui.analysis.LttngKernelAnalysisModule;
-import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
-import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException;
-import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
-import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;
-import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;
-import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
+import org.eclipse.linuxtools.lttng2.kernel.core.analysis.LttngKernelAnalysisModule;
+import org.eclipse.linuxtools.statesystem.core.ITmfStateSystem;
+import org.eclipse.linuxtools.statesystem.core.exceptions.AttributeNotFoundException;
+import org.eclipse.linuxtools.statesystem.core.exceptions.StateSystemDisposedException;
+import org.eclipse.linuxtools.statesystem.core.exceptions.StateValueTypeException;
+import org.eclipse.linuxtools.statesystem.core.exceptions.TimeRangeException;
+import org.eclipse.linuxtools.statesystem.core.interval.ITmfStateInterval;
+import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemAnalysisModule;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
 import org.eclipse.linuxtools.tmf.ui.views.timegraph.AbstractTimeGraphView;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.NullTimeEvent;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeEvent;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeGraphEntry;
@@ -92,13 +95,10 @@ public class ResourcesView extends AbstractTimeGraphView {
 
     @Override
     protected void buildEventList(ITmfTrace trace, ITmfTrace parentTrace, IProgressMonitor monitor) {
-        LttngKernelAnalysisModule module = trace.getAnalysisModuleOfClass(LttngKernelAnalysisModule.class, LttngKernelAnalysisModule.ID);
-        if (module == null) {
+        if (trace == null) {
             return;
         }
-        module.schedule();
-        module.waitForInitialization();
-        ITmfStateSystem ssq = module.getStateSystem();
+        ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, LttngKernelAnalysisModule.ID);
         if (ssq == null) {
             return;
         }
@@ -174,17 +174,20 @@ public class ResourcesView extends AbstractTimeGraphView {
                 refresh();
             }
             long resolution = Math.max(1, (endTime - ssq.getStartTime()) / getDisplayWidth());
-            for (TimeGraphEntry entry : traceEntry.getChildren()) {
+            for (ITimeGraphEntry child : traceEntry.getChildren()) {
                 if (monitor.isCanceled()) {
                     return;
                 }
-                List<ITimeEvent> eventList = getEventList(entry, start, endTime, resolution, monitor);
-                if (eventList != null) {
-                    for (ITimeEvent event : eventList) {
-                        entry.addEvent(event);
+                if (child instanceof TimeGraphEntry) {
+                    TimeGraphEntry entry = (TimeGraphEntry) child;
+                    List<ITimeEvent> eventList = getEventList(entry, start, endTime, resolution, monitor);
+                    if (eventList != null) {
+                        for (ITimeEvent event : eventList) {
+                            entry.addEvent(event);
+                        }
                     }
+                    redraw();
                 }
-                redraw();
             }
 
             start = end;
@@ -192,15 +195,11 @@ public class ResourcesView extends AbstractTimeGraphView {
     }
 
     @Override
-    protected List<ITimeEvent> getEventList(TimeGraphEntry entry,
+    protected @Nullable List<ITimeEvent> getEventList(TimeGraphEntry entry,
             long startTime, long endTime, long resolution,
             IProgressMonitor monitor) {
         ResourcesEntry resourcesEntry = (ResourcesEntry) entry;
-        LttngKernelAnalysisModule module = resourcesEntry.getTrace().getAnalysisModuleOfClass(LttngKernelAnalysisModule.class, LttngKernelAnalysisModule.ID);
-        if (module == null) {
-            return null;
-        }
-        ITmfStateSystem ssq = module.getStateSystem();
+        ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(resourcesEntry.getTrace(), LttngKernelAnalysisModule.ID);
         if (ssq == null) {
             return null;
         }
This page took 0.024826 seconds and 5 git commands to generate.