]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/sorters/AbstractSorter.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.model / src / org / simantics / browsing / ui / model / sorters / AbstractSorter.java
index cfba1833454b5ced047968ca80d4147df9acfe26..6de1f1cb93310c5c1ebfe8c40660feebaf19fc13 100644 (file)
@@ -1,58 +1,58 @@
-/*******************************************************************************\r
- * Copyright (c) 2010, 2011 Association for Decentralized Information Management in\r
- * 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.browsing.ui.model.sorters;\r
-\r
-import java.util.Arrays;\r
-import java.util.Comparator;\r
-import java.util.List;\r
-\r
-import org.simantics.browsing.ui.NodeContext;\r
-import org.simantics.browsing.ui.model.browsecontexts.BrowseContext;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-\r
-public abstract class AbstractSorter<T> implements Sorter {\r
-\r
-    public abstract T getSortingCriterion(ReadGraph graph, BrowseContext context, NodeContext node) throws DatabaseException;\r
-    public abstract int compare(T a, T b);\r
-    \r
-    static class OrderNodeContext<T> {\r
-        public final NodeContext node;\r
-        public final T criterion;\r
-        \r
-        public OrderNodeContext(NodeContext node, T criterion) {        \r
-            this.node = node;\r
-            this.criterion = criterion;\r
-        }\r
-    }\r
-    \r
-    Comparator<OrderNodeContext<T>> comparator = new Comparator<OrderNodeContext<T>>() {\r
-        @Override\r
-        public int compare(OrderNodeContext<T> o1, OrderNodeContext<T> o2) {\r
-            return AbstractSorter.this.compare(o1.criterion, o2.criterion);\r
-        }        \r
-    };\r
-    \r
-    @Override\r
-    public void sort(ReadGraph graph, BrowseContext context, List<NodeContext> nodes) throws DatabaseException {\r
-        @SuppressWarnings("unchecked")\r
-        OrderNodeContext<T>[] orderNodes = new OrderNodeContext[nodes.size()];\r
-        for (int i = 0; i < orderNodes.length; i++) {\r
-            NodeContext node = nodes.get(i);\r
-            orderNodes[i] = new OrderNodeContext<T>(node, getSortingCriterion(graph, context, node));\r
-        }\r
-        Arrays.sort(orderNodes, comparator);\r
-        for (int i = 0; i < orderNodes.length; i++)\r
-            nodes.set(i, orderNodes[i].node);\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 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.browsing.ui.model.sorters;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+
+import org.simantics.browsing.ui.NodeContext;
+import org.simantics.browsing.ui.model.browsecontexts.BrowseContext;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.exception.DatabaseException;
+
+public abstract class AbstractSorter<T> implements Sorter {
+
+    public abstract T getSortingCriterion(ReadGraph graph, BrowseContext context, NodeContext node) throws DatabaseException;
+    public abstract int compare(T a, T b);
+    
+    static class OrderNodeContext<T> {
+        public final NodeContext node;
+        public final T criterion;
+        
+        public OrderNodeContext(NodeContext node, T criterion) {        
+            this.node = node;
+            this.criterion = criterion;
+        }
+    }
+    
+    Comparator<OrderNodeContext<T>> comparator = new Comparator<OrderNodeContext<T>>() {
+        @Override
+        public int compare(OrderNodeContext<T> o1, OrderNodeContext<T> o2) {
+            return AbstractSorter.this.compare(o1.criterion, o2.criterion);
+        }        
+    };
+    
+    @Override
+    public void sort(ReadGraph graph, BrowseContext context, List<NodeContext> nodes) throws DatabaseException {
+        @SuppressWarnings("unchecked")
+        OrderNodeContext<T>[] orderNodes = new OrderNodeContext[nodes.size()];
+        for (int i = 0; i < orderNodes.length; i++) {
+            NodeContext node = nodes.get(i);
+            orderNodes[i] = new OrderNodeContext<T>(node, getSortingCriterion(graph, context, node));
+        }
+        Arrays.sort(orderNodes, comparator);
+        for (int i = 0; i < orderNodes.length; i++)
+            nodes.set(i, orderNodes[i].node);
+    }
+
+}