]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.selectionview/src/org/simantics/selectionview/StandardPropertySorterRule.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.selectionview / src / org / simantics / selectionview / StandardPropertySorterRule.java
index 03dae726a40635402b23ab53d49d2903f68dc2b0..1414aa10795e49df4e4c2f838ccbed17827df56d 100644 (file)
@@ -1,98 +1,98 @@
-/*******************************************************************************\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.selectionview;\r
-\r
-import org.simantics.browsing.ui.BuiltinKeys;\r
-import org.simantics.browsing.ui.NodeContext;\r
-import org.simantics.browsing.ui.common.ColumnKeys;\r
-import org.simantics.browsing.ui.model.browsecontexts.BrowseContext;\r
-import org.simantics.browsing.ui.model.sorters.AbstractSorter;\r
-import org.simantics.browsing.ui.model.sorters.Sorter;\r
-import org.simantics.browsing.ui.model.sorters.SorterRule;\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.variable.Variable;\r
-import org.simantics.utils.datastructures.ComparablePair;\r
-\r
-public class StandardPropertySorterRule implements SorterRule {    \r
-    \r
-       final private Sorter sorter;\r
-       \r
-       public StandardPropertySorterRule(Resource rule) {\r
-               this.sorter = new StandardSorter(rule);\r
-       }\r
-       \r
-       static class StandardSorter extends AbstractSorter<ComparablePair<String, String>> {\r
-               \r
-               final private Resource rule;\r
-               \r
-               public StandardSorter(Resource rule) {\r
-                       this.rule = rule;\r
-               }\r
-\r
-               @Override\r
-               public ComparablePair<String, String> getSortingCriterion(ReadGraph graph, BrowseContext context, NodeContext node) throws DatabaseException {\r
-\r
-                       Object content = node.getConstant(BuiltinKeys.INPUT);\r
-                       if(content instanceof Variable) {\r
-                               Variable var = (Variable)content;\r
-                       Variable info = var.getPossibleProperty(graph, SelectionVariables.PROPERTY_INFO);\r
-                       // FIXME: what is this block ??\r
-                       if(info == null) { \r
-//                             System.err.println("null info for " + ((Variable)content).getURI(graph));\r
-//                             info = ((Variable)content).getPossiblePropertyValue(graph, SelectionVariables.PROPERTY_INFO);\r
-                               return ComparablePair.make("", ((Variable)content).getName(graph));\r
-                       }\r
-                       \r
-                       Variable special = SelectionViewUtils.getSpecialCategory(graph, rule, info);\r
-                       if(special != null) info = special;\r
-                       \r
-                       String cat = info.getPossiblePropertyValue(graph, SelectionVariables.CATEGORY_SORTING_NAME, Bindings.STRING);\r
-                       if(cat == null) {\r
-                               cat = info.getPossiblePropertyValue(graph, SelectionVariables.CATEGORY_NAME, Bindings.STRING);\r
-                               if(cat == null) cat = "";\r
-                       }\r
-                       String label = ((Variable)content).getPossiblePropertyValue(graph, SelectionVariables.PROPERTY_SORTING_NAME, Bindings.STRING);\r
-                       if(label == null) label = ((Variable)content).getPossiblePropertyValue(graph, ColumnKeys.DISPLAY_PROPERTY, Bindings.STRING);\r
-                       if(label == null) label = "Invalid label for " + ((Variable)content).getURI(graph); \r
-                       return ComparablePair.make(cat,label);\r
-                               \r
-                       } else if (content instanceof CategoryNode) {\r
-                               return ComparablePair.make(((CategoryNode)content).getSortingName(), "");\r
-                       }\r
-                       \r
-                       throw new IllegalArgumentException("Content type should be Variable or CategoryNode");\r
-                       \r
-               }\r
-\r
-               @Override\r
-               public int compare(ComparablePair<String, String> a, ComparablePair<String, String> b) {\r
-                       return a.compareTo(b);\r
-               }\r
-               \r
-       };\r
-       \r
-       \r
-    @Override\r
-    public boolean isCompatible(Class<?> contentType) {\r
-        return contentType.equals(Variable.class);\r
-    }\r
-\r
-    @Override\r
-    public Sorter getSorter(ReadGraph graph, Object content)\r
-            throws DatabaseException {\r
-        return sorter;\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.selectionview;
+
+import org.simantics.browsing.ui.BuiltinKeys;
+import org.simantics.browsing.ui.NodeContext;
+import org.simantics.browsing.ui.common.ColumnKeys;
+import org.simantics.browsing.ui.model.browsecontexts.BrowseContext;
+import org.simantics.browsing.ui.model.sorters.AbstractSorter;
+import org.simantics.browsing.ui.model.sorters.Sorter;
+import org.simantics.browsing.ui.model.sorters.SorterRule;
+import org.simantics.databoard.Bindings;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.variable.Variable;
+import org.simantics.utils.datastructures.ComparablePair;
+
+public class StandardPropertySorterRule implements SorterRule {    
+    
+       final private Sorter sorter;
+       
+       public StandardPropertySorterRule(Resource rule) {
+               this.sorter = new StandardSorter(rule);
+       }
+       
+       static class StandardSorter extends AbstractSorter<ComparablePair<String, String>> {
+               
+               final private Resource rule;
+               
+               public StandardSorter(Resource rule) {
+                       this.rule = rule;
+               }
+
+               @Override
+               public ComparablePair<String, String> getSortingCriterion(ReadGraph graph, BrowseContext context, NodeContext node) throws DatabaseException {
+
+                       Object content = node.getConstant(BuiltinKeys.INPUT);
+                       if(content instanceof Variable) {
+                               Variable var = (Variable)content;
+                       Variable info = var.getPossibleProperty(graph, SelectionVariables.PROPERTY_INFO);
+                       // FIXME: what is this block ??
+                       if(info == null) { 
+//                             System.err.println("null info for " + ((Variable)content).getURI(graph));
+//                             info = ((Variable)content).getPossiblePropertyValue(graph, SelectionVariables.PROPERTY_INFO);
+                               return ComparablePair.make("", ((Variable)content).getName(graph));
+                       }
+                       
+                       Variable special = SelectionViewUtils.getSpecialCategory(graph, rule, info);
+                       if(special != null) info = special;
+                       
+                       String cat = info.getPossiblePropertyValue(graph, SelectionVariables.CATEGORY_SORTING_NAME, Bindings.STRING);
+                       if(cat == null) {
+                               cat = info.getPossiblePropertyValue(graph, SelectionVariables.CATEGORY_NAME, Bindings.STRING);
+                               if(cat == null) cat = "";
+                       }
+                       String label = ((Variable)content).getPossiblePropertyValue(graph, SelectionVariables.PROPERTY_SORTING_NAME, Bindings.STRING);
+                       if(label == null) label = ((Variable)content).getPossiblePropertyValue(graph, ColumnKeys.DISPLAY_PROPERTY, Bindings.STRING);
+                       if(label == null) label = "Invalid label for " + ((Variable)content).getURI(graph); 
+                       return ComparablePair.make(cat,label);
+                               
+                       } else if (content instanceof CategoryNode) {
+                               return ComparablePair.make(((CategoryNode)content).getSortingName(), "");
+                       }
+                       
+                       throw new IllegalArgumentException("Content type should be Variable or CategoryNode");
+                       
+               }
+
+               @Override
+               public int compare(ComparablePair<String, String> a, ComparablePair<String, String> b) {
+                       return a.compareTo(b);
+               }
+               
+       };
+       
+       
+    @Override
+    public boolean isCompatible(Class<?> contentType) {
+        return contentType.equals(Variable.class);
+    }
+
+    @Override
+    public Sorter getSorter(ReadGraph graph, Object content)
+            throws DatabaseException {
+        return sorter;
+    }
+
+}