]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/sorters/LinkedListSorter.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.model / src / org / simantics / browsing / ui / model / sorters / LinkedListSorter.java
index ed27b7165c75f0f96e2de39bc9713ca1cb6ad195..2a39e924368a5f1fe36930b46487e442393e1608 100644 (file)
@@ -1,60 +1,60 @@
-/*******************************************************************************\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.HashMap;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Set;\r
-\r
-import org.simantics.browsing.ui.BuiltinKeys;\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.Resource;\r
-import org.simantics.db.common.utils.ListUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-\r
-public class LinkedListSorter implements Sorter {\r
-\r
-    public static final LinkedListSorter INSTANCE = new LinkedListSorter();\r
-    \r
-    private LinkedListSorter() {}\r
-\r
-       @Override\r
-       public void sort(ReadGraph graph, BrowseContext context, List<NodeContext> nodes) throws DatabaseException {\r
-\r
-               Layer0 L0 = Layer0.getInstance(graph);\r
-               Set<Resource> parents = new HashSet<Resource>();\r
-               Map<Resource, NodeContext> map = new HashMap<Resource, NodeContext>();\r
-               for(NodeContext node : nodes) {\r
-                       Resource r = (Resource)node.getConstant(BuiltinKeys.INPUT);\r
-                       Resource parent = graph.getPossibleObject(r, L0.PartOf);\r
-                       parents.add(parent);\r
-                       map.put(r, node);\r
-               }\r
-               \r
-               if(parents.contains(null)) return;\r
-               if(parents.size() != 1) return;\r
-\r
-               Resource parent = parents.iterator().next();\r
-               nodes.clear();\r
-               for(Resource r : ListUtils.toList(graph, parent))  {\r
-                       NodeContext ctx = map.get(r);\r
-                       if(ctx != null) nodes.add(ctx);\r
-               }\r
-       \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.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.simantics.browsing.ui.BuiltinKeys;
+import org.simantics.browsing.ui.NodeContext;
+import org.simantics.browsing.ui.model.browsecontexts.BrowseContext;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.utils.ListUtils;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.layer0.Layer0;
+
+public class LinkedListSorter implements Sorter {
+
+    public static final LinkedListSorter INSTANCE = new LinkedListSorter();
+    
+    private LinkedListSorter() {}
+
+       @Override
+       public void sort(ReadGraph graph, BrowseContext context, List<NodeContext> nodes) throws DatabaseException {
+
+               Layer0 L0 = Layer0.getInstance(graph);
+               Set<Resource> parents = new HashSet<Resource>();
+               Map<Resource, NodeContext> map = new HashMap<Resource, NodeContext>();
+               for(NodeContext node : nodes) {
+                       Resource r = (Resource)node.getConstant(BuiltinKeys.INPUT);
+                       Resource parent = graph.getPossibleObject(r, L0.PartOf);
+                       parents.add(parent);
+                       map.put(r, node);
+               }
+               
+               if(parents.contains(null)) return;
+               if(parents.size() != 1) return;
+
+               Resource parent = parents.iterator().next();
+               nodes.clear();
+               for(Resource r : ListUtils.toList(graph, parent))  {
+                       NodeContext ctx = map.get(r);
+                       if(ctx != null) nodes.add(ctx);
+               }
+       
+    }
+
+}