]> gerrit.simantics Code Review - simantics/interop.git/commitdiff
Sort UpdateNodes 02/4902/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 28 Feb 2022 16:42:17 +0000 (18:42 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 28 Feb 2022 16:42:17 +0000 (18:42 +0200)
gitlab #40

Change-Id: Iddf111947d76982aa009fb724671b027e6d44fdc

org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateNode.java

index f68f887dca33c98e925862c203dab27926ae5480..5bf0cd4ec8e298d963a0267bd434888032da78e0 100644 (file)
@@ -94,12 +94,25 @@ public class UpdateNode {
        public void sort() {
                if (children == null)
                        return;
-               Collections.sort(this.children, new Comparator<UpdateNode>() {
+               Comparator<UpdateNode> comparator = new Comparator<UpdateNode>() {
                        @Override
                        public int compare(UpdateNode o1, UpdateNode o2) {
                                return o1.getLabel().compareTo(o2.getLabel());
                        }
-               });
+               };
+               Collections.sort(this.children, comparator );
+               for (UpdateNode n : this.children) {
+                       n.sort(comparator);
+               }
+       }
+       
+       public void sort(Comparator<UpdateNode> comparator ) {
+               if (children == null)
+                       return;
+               Collections.sort(this.children, comparator );
+               for (UpdateNode n : this.children) {
+                       n.sort(comparator);
+               }
        }
 
        public ImageDescriptor getImage(ReadGraph graph) throws DatabaseException {