lttng: Bug 487163: Resources view traces are unsorted
authorPatrick Tasse <patrick.tasse@gmail.com>
Wed, 3 Feb 2016 19:04:32 +0000 (14:04 -0500)
committerPatrick Tasse <patrick.tasse@gmail.com>
Wed, 3 Feb 2016 22:43:16 +0000 (17:43 -0500)
When an experiment is opened, its traces are now sorted alphabetically.

Change-Id: Idae538a53182d661d066f82b676a8b3a14442c2b
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/65836
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/resources/ResourcesView.java

index 1801fcf5f1f25ee7f7272752aa041dc01772d029..7e0acd49a47bb88cb5fdbbbebfd8379d647b9ce9 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012, 2015 Ericsson, École Polytechnique de Montréal
+ * Copyright (c) 2012, 2016 Ericsson, École Polytechnique de Montréal
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -67,6 +67,21 @@ public class ResourcesView extends AbstractStateSystemTimeGraphView {
         super(ID, new ResourcesPresentationProvider());
         setFilterColumns(FILTER_COLUMN_NAMES);
         setFilterLabelProvider(new ResourcesFilterLabelProvider());
+        setEntryComparator(new ResourcesEntryComparator());
+    }
+
+    private static class ResourcesEntryComparator implements Comparator<ITimeGraphEntry> {
+        @Override
+        public int compare(ITimeGraphEntry o1, ITimeGraphEntry o2) {
+            ResourcesEntry entry1 = (ResourcesEntry) o1;
+            ResourcesEntry entry2 = (ResourcesEntry) o2;
+            if (entry1.getType() == Type.NULL && entry2.getType() == Type.NULL) {
+                /* sort trace entries alphabetically */
+                return entry1.getName().compareTo(entry2.getName());
+            }
+            /* sort resource entries by their defined order */
+            return entry1.compareTo(entry2);
+        }
     }
 
     private static class ResourcesFilterLabelProvider extends TreeLabelProvider {
@@ -111,12 +126,6 @@ public class ResourcesView extends AbstractStateSystemTimeGraphView {
         if (ssq == null) {
             return;
         }
-        Comparator<ITimeGraphEntry> comparator = new Comparator<ITimeGraphEntry>() {
-            @Override
-            public int compare(ITimeGraphEntry o1, ITimeGraphEntry o2) {
-                return ((ResourcesEntry) o1).compareTo(o2);
-            }
-        };
 
         Map<Integer, ResourcesEntry> entryMap = new HashMap<>();
         TimeGraphEntry traceEntry = null;
@@ -142,7 +151,6 @@ public class ResourcesView extends AbstractStateSystemTimeGraphView {
 
             if (traceEntry == null) {
                 traceEntry = new ResourcesEntry(trace, trace.getName(), startTime, endTime, 0);
-                traceEntry.sortChildren(comparator);
                 List<TimeGraphEntry> entryList = Collections.singletonList(traceEntry);
                 addToEntryList(parentTrace, ssq, entryList);
             } else {
This page took 0.025151 seconds and 5 git commands to generate.