]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.common/src/org/simantics/browsing/ui/common/processors/DefaultFinalChildrenProcessor.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.common / src / org / simantics / browsing / ui / common / processors / DefaultFinalChildrenProcessor.java
index a01e6f513621ddbaf3b2830ddcc4cc466c1a3948..185845c9f3f37e1a3df6516395275f3af590ed18 100644 (file)
@@ -1,84 +1,84 @@
-/*******************************************************************************\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.browsing.ui.common.processors;\r
-\r
-import java.util.Arrays;\r
-\r
-import org.simantics.browsing.ui.BuiltinKeys;\r
-import org.simantics.browsing.ui.GraphExplorer;\r
-import org.simantics.browsing.ui.NodeContext;\r
-import org.simantics.browsing.ui.NodeContext.QueryKey;\r
-import org.simantics.browsing.ui.NodeQueryManager;\r
-import org.simantics.browsing.ui.content.ComparableContext;\r
-import org.simantics.browsing.ui.content.PrunedChildrenResult;\r
-\r
-public class DefaultFinalChildrenProcessor extends AbstractNodeQueryProcessor<NodeContext[]> {\r
-\r
-    private final GraphExplorer explorer;\r
-\r
-    public DefaultFinalChildrenProcessor(GraphExplorer explorer) {\r
-        this.explorer = explorer;\r
-    }\r
-\r
-    @Override\r
-    public QueryKey<NodeContext[]> getIdentifier() {\r
-        return BuiltinKeys.FINAL_CHILDREN;\r
-    }\r
-\r
-    @Override\r
-    public NodeContext[] query(NodeQueryManager manager, NodeContext context) {\r
-        int maxChildren = Integer.MAX_VALUE;\r
-        if (explorer != null)\r
-            maxChildren = explorer.getMaxChildren(manager, context);\r
-\r
-        ComparableContext[] comparables = manager.query(context, BuiltinKeys.COMPARABLE_CHILDREN);\r
-        if (comparables == null) {\r
-            // Could not make the children comparable which means we cannot sort them.\r
-            // Just take the pruned children and truncate them to the child node limit.\r
-\r
-            PrunedChildrenResult pruned = manager.query(context, BuiltinKeys.PRUNED_CHILDREN);\r
-            int length = Math.min(pruned.getPrunedChildren().length, maxChildren);\r
-            if (length < pruned.getPrunedChildren().length) {\r
-                NodeContext[] truncated = new NodeContext[length];\r
-                System.arraycopy(pruned.getPrunedChildren(), 0, truncated, 0, length);\r
-                return truncated;\r
-            } else {\r
-                return pruned.getPrunedChildren();\r
-            }\r
-        }\r
-\r
-        // Optimize away unnecessary work and allocations for trivial 0/1 child cases.\r
-        if (comparables.length == 0)\r
-            return NodeContext.NONE;\r
-        if (comparables.length == 1)\r
-            return new NodeContext[] { comparables[0].getContext() };\r
-\r
-        // Sort the comparable children and truncate them to the child node limit.\r
-//        long startTime = System.nanoTime();\r
-//        new Exception("FINAL CHILDREN for " + comparables.length + " comparables").printStackTrace();\r
-        Arrays.sort(comparables);\r
-        int length = Math.min(comparables.length, maxChildren);\r
-        NodeContext[] result = new NodeContext[length];\r
-        for (int i = 0; i < length; i++)\r
-            result[i] = comparables[i].getContext();\r
-//        long endTime = System.nanoTime();\r
-//        System.out.println("ARRAY SORT: (" + maxChildren + "/" + comparables.length + "): " + (endTime-startTime)*1e-6 + " ms");\r
-        return result;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return "FinalChildrenProcessor";\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.browsing.ui.common.processors;
+
+import java.util.Arrays;
+
+import org.simantics.browsing.ui.BuiltinKeys;
+import org.simantics.browsing.ui.GraphExplorer;
+import org.simantics.browsing.ui.NodeContext;
+import org.simantics.browsing.ui.NodeContext.QueryKey;
+import org.simantics.browsing.ui.NodeQueryManager;
+import org.simantics.browsing.ui.content.ComparableContext;
+import org.simantics.browsing.ui.content.PrunedChildrenResult;
+
+public class DefaultFinalChildrenProcessor extends AbstractNodeQueryProcessor<NodeContext[]> {
+
+    private final GraphExplorer explorer;
+
+    public DefaultFinalChildrenProcessor(GraphExplorer explorer) {
+        this.explorer = explorer;
+    }
+
+    @Override
+    public QueryKey<NodeContext[]> getIdentifier() {
+        return BuiltinKeys.FINAL_CHILDREN;
+    }
+
+    @Override
+    public NodeContext[] query(NodeQueryManager manager, NodeContext context) {
+        int maxChildren = Integer.MAX_VALUE;
+        if (explorer != null)
+            maxChildren = explorer.getMaxChildren(manager, context);
+
+        ComparableContext[] comparables = manager.query(context, BuiltinKeys.COMPARABLE_CHILDREN);
+        if (comparables == null) {
+            // Could not make the children comparable which means we cannot sort them.
+            // Just take the pruned children and truncate them to the child node limit.
+
+            PrunedChildrenResult pruned = manager.query(context, BuiltinKeys.PRUNED_CHILDREN);
+            int length = Math.min(pruned.getPrunedChildren().length, maxChildren);
+            if (length < pruned.getPrunedChildren().length) {
+                NodeContext[] truncated = new NodeContext[length];
+                System.arraycopy(pruned.getPrunedChildren(), 0, truncated, 0, length);
+                return truncated;
+            } else {
+                return pruned.getPrunedChildren();
+            }
+        }
+
+        // Optimize away unnecessary work and allocations for trivial 0/1 child cases.
+        if (comparables.length == 0)
+            return NodeContext.NONE;
+        if (comparables.length == 1)
+            return new NodeContext[] { comparables[0].getContext() };
+
+        // Sort the comparable children and truncate them to the child node limit.
+//        long startTime = System.nanoTime();
+//        new Exception("FINAL CHILDREN for " + comparables.length + " comparables").printStackTrace();
+        Arrays.sort(comparables);
+        int length = Math.min(comparables.length, maxChildren);
+        NodeContext[] result = new NodeContext[length];
+        for (int i = 0; i < length; i++)
+            result[i] = comparables[i].getContext();
+//        long endTime = System.nanoTime();
+//        System.out.println("ARRAY SORT: (" + maxChildren + "/" + comparables.length + "): " + (endTime-startTime)*1e-6 + " ms");
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        return "FinalChildrenProcessor";
+    }
+
+
 }
\ No newline at end of file