]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.diagram/src/org/simantics/diagram/symbolcontribution/CompositeSymbolGroup.java
Use AlphaNum sorter in Symbol Library
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / symbolcontribution / CompositeSymbolGroup.java
index 27d286f8779ec10c2f9086dfc20ed5c1e591adb0..c217de2f9591de468a42244fe5dc1f17d42fc761 100644 (file)
@@ -1,61 +1,62 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.diagram.symbolcontribution;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-import java.util.Comparator;\r
-\r
-import org.simantics.diagram.symbollibrary.ISymbolGroup;\r
-import org.simantics.diagram.symbollibrary.ISymbolItem;\r
-\r
-/**\r
- * @author Hannu Niemistö\r
- */\r
-public class CompositeSymbolGroup extends ModifiableSymbolGroup {\r
-\r
-    Collection<ISymbolGroup> groups = new ArrayList<ISymbolGroup>(4);\r
-\r
-    public CompositeSymbolGroup(Object identification, String name, String description) {\r
-        super(identification, name, description);\r
-    }\r
-\r
-    public void add(ISymbolGroup group) {\r
-        groups.add(group);\r
-    }\r
-\r
-    public Collection<ISymbolGroup> getGroups() {\r
-        return groups;\r
-    }\r
-\r
-    @Override\r
-    public ISymbolItem[] getItems() {\r
-        ArrayList<ISymbolItem> items = new ArrayList<ISymbolItem>();\r
-        for(ISymbolGroup group : groups)\r
-            for(ISymbolItem item : group.getItems())\r
-                items.add(new GroupProxySymbolItem(item,  this));\r
-        Collections.sort(items, new Comparator<ISymbolItem>() {\r
-            @Override\r
-            public int compare(ISymbolItem o1, ISymbolItem o2) {\r
-                return o1.getName().compareTo(o2.getName());\r
-            }\r
-        });\r
-        return items.toArray(new ISymbolItem[items.size()]);\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return super.toString() + "[composed group count=" + groups.size() + "]";\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.diagram.symbolcontribution;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+
+import org.simantics.diagram.symbollibrary.ISymbolGroup;
+import org.simantics.diagram.symbollibrary.ISymbolItem;
+import org.simantics.utils.strings.AlphanumComparator;
+
+/**
+ * @author Hannu Niemist&ouml;
+ */
+public class CompositeSymbolGroup extends ModifiableSymbolGroup {
+
+    Collection<ISymbolGroup> groups = new ArrayList<ISymbolGroup>(4);
+
+    public CompositeSymbolGroup(Object identification, String name, String description) {
+        super(identification, name, description);
+    }
+
+    public void add(ISymbolGroup group) {
+        groups.add(group);
+    }
+
+    public Collection<ISymbolGroup> getGroups() {
+        return groups;
+    }
+
+    @Override
+    public ISymbolItem[] getItems() {
+        ArrayList<ISymbolItem> items = new ArrayList<ISymbolItem>();
+        for(ISymbolGroup group : groups)
+            for(ISymbolItem item : group.getItems())
+                items.add(new GroupProxySymbolItem(item,  this));
+        Collections.sort(items, new Comparator<ISymbolItem>() {
+            @Override
+            public int compare(ISymbolItem o1, ISymbolItem o2) {
+                return AlphanumComparator.COMPARATOR.compare(o1.getName(),o2.getName());
+            }
+        });
+        return items.toArray(new ISymbolItem[items.size()]);
+    }
+
+    @Override
+    public String toString() {
+        return super.toString() + "[composed group count=" + groups.size() + "]";
+    }
+
+}