Bug 378402: Implementation of ControlFlow view and Resources view for
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.kernel.ui / src / org / eclipse / linuxtools / internal / lttng2 / kernel / ui / views / controlflow / ControlFlowView.java
index d46072a2c0d2b0bbcea5d61aca54a105e7e5bfe9..de11dcf625d3bc6c5b8f028b6495312344eb41d8 100644 (file)
@@ -14,6 +14,7 @@ package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.controlflow;
 \r
 import java.util.ArrayList;\r
 import java.util.Arrays;\r
+import java.util.Collections;\r
 import java.util.Comparator;\r
 import java.util.List;\r
 \r
@@ -224,6 +225,9 @@ public class ControlFlowView extends TmfView {
                 ControlFlowEntry entry1 = (ControlFlowEntry) o1;\r
                 ControlFlowEntry entry2 = (ControlFlowEntry) o2;\r
                 result = entry1.getTrace().getStartTime().compareTo(entry2.getTrace().getStartTime());\r
+                if (result == 0) {\r
+                    result = entry1.getTrace().getName().compareTo(entry2.getTrace().getName());\r
+                }\r
                 if (result == 0) {\r
                     result = entry1.getThreadId() < entry2.getThreadId() ? -1 : entry1.getThreadId() > entry2.getThreadId() ? 1 : 0;\r
                 }\r
@@ -507,9 +511,10 @@ public class ControlFlowView extends TmfView {
         fStartTime = Long.MAX_VALUE;\r
         fEndTime = Long.MIN_VALUE;\r
         fSelectedExperiment = (TmfExperiment<ITmfEvent>) experiment;\r
-        ArrayList<ControlFlowEntry> entryList = new ArrayList<ControlFlowEntry>();\r
+        ArrayList<ControlFlowEntry> rootList = new ArrayList<ControlFlowEntry>();\r
         for (ITmfTrace<?> trace : experiment.getTraces()) {\r
             if (trace instanceof CtfKernelTrace) {\r
+                ArrayList<ControlFlowEntry> entryList = new ArrayList<ControlFlowEntry>();\r
                 CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) trace;\r
                 IStateSystemQuerier ssq = ctfKernelTrace.getStateSystem();\r
                 long start = ssq.getStartTime();\r
@@ -566,19 +571,18 @@ public class ControlFlowView extends TmfView {
                         e.printStackTrace();\r
                     }\r
                 }\r
+                buildTree(entryList, rootList);\r
             }\r
-            buildTree(entryList);\r
+            Collections.sort(rootList, fControlFlowEntryComparator);\r
+            fEntryList = rootList;\r
             refresh(INITIAL_WINDOW_OFFSET);\r
-            ControlFlowEntry[] entries = fEntryList.toArray(new ControlFlowEntry[0]);\r
-            Arrays.sort(entries, fControlFlowEntryComparator);\r
-            for (ControlFlowEntry entry : entries) {\r
-                buildStatusEvents(entry);\r
-            }\r
+        }\r
+        for (ControlFlowEntry entry : rootList) {\r
+            buildStatusEvents(entry);\r
         }\r
     }\r
 \r
-    private void buildTree(ArrayList<ControlFlowEntry> entryList) {\r
-        ArrayList<ControlFlowEntry> rootList = new ArrayList<ControlFlowEntry>();\r
+    private void buildTree(ArrayList<ControlFlowEntry> entryList, ArrayList<ControlFlowEntry> rootList) {\r
         for (ControlFlowEntry entry : entryList) {\r
             boolean root = true;\r
             if (entry.getParentThreadId() > 0) {\r
@@ -596,7 +600,6 @@ public class ControlFlowView extends TmfView {
                 rootList.add(entry);\r
             }\r
         }\r
-        fEntryList = rootList;\r
     }\r
 \r
     private void buildStatusEvents(ControlFlowEntry entry) {\r
This page took 0.025046 seconds and 5 git commands to generate.