changeset 5944:0d24fac99293

Ensemble8: Part #2 of fix for RT-34006 Simplify Ensemble8 categories
author Alexander Kouznetsov
date Mon, 09 Dec 2013 20:36:09 -0800
parents 8f0a6f77ec8f
children 674968d9c3b6
files apps/samples/Ensemble8/src/app/java/ensemble/SamplePopoverTreeList.java
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/apps/samples/Ensemble8/src/app/java/ensemble/SamplePopoverTreeList.java	Mon Dec 09 20:19:44 2013 -0800
+++ b/apps/samples/Ensemble8/src/app/java/ensemble/SamplePopoverTreeList.java	Mon Dec 09 20:36:09 2013 -0800
@@ -34,6 +34,7 @@
 import ensemble.control.Popover;
 import ensemble.control.PopoverTreeList;
 import ensemble.generated.Samples;
+import java.util.Comparator;
 import javafx.event.EventHandler;
 import javafx.geometry.Bounds;
 import javafx.scene.Node;
@@ -57,6 +58,23 @@
         this.pageBrowser = pageBrowser;
         if (category.subCategories!=null) getItems().addAll((Object[])category.subCategories);
         if (category.samples!=null) getItems().addAll((Object[])category.samples);
+        getItems().sort(new Comparator() {
+            
+            private String getName(Object o) {
+                if (o instanceof SampleCategory) {
+                    return ((SampleCategory) o).name;
+                } else if (o instanceof SampleInfo) {
+                    return ((SampleInfo) o).name;
+                } else {
+                    return "";
+                }
+            }
+
+            @Override
+            public int compare(Object o1, Object o2) {
+                return getName(o1).compareTo(getName(o2));
+            }
+        });
     }
     
     @Override public ListCell call(ListView p) {