From: Marko Luukkainen Date: Mon, 28 Feb 2022 16:42:17 +0000 (+0200) Subject: Sort UpdateNodes X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F02%2F4902%2F1;p=simantics%2Finterop.git Sort UpdateNodes gitlab #40 Change-Id: Iddf111947d76982aa009fb724671b027e6d44fdc --- diff --git a/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateNode.java b/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateNode.java index f68f887..5bf0cd4 100644 --- a/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateNode.java +++ b/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateNode.java @@ -94,12 +94,25 @@ public class UpdateNode { public void sort() { if (children == null) return; - Collections.sort(this.children, new Comparator() { + Comparator comparator = new Comparator() { @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 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 {