-package org.simantics.selectionview;\r
-\r
-import java.util.List;\r
-\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.db.layer0.variable.Variables;\r
-import org.simantics.db.layer0.variable.Variables.Role;\r
-import org.simantics.scl.runtime.SCLContext;\r
-import org.simantics.scl.runtime.function.Function1;\r
-\r
-public class SelectionViewUtils {\r
-\r
- public static Variable getSpecialCategory(ReadGraph graph, Resource rule, Variable info) throws DatabaseException {\r
- \r
- SelectionViewResources SEL = SelectionViewResources.getInstance(graph);\r
- Resource categoryResource = info.getPossibleRepresents(graph);\r
- \r
- if(SEL.CategoryHidden.equals(categoryResource)) {\r
- \r
- Variable property = info.getParent(graph);\r
- Variable parent = property.getParent(graph);\r
- if(Role.PROPERTY.equals(parent.getPossibleRole(graph))) return null;\r
- \r
- Resource predicate = property.getPossiblePredicateResource(graph);\r
- Variable ruleVariable = Variables.getVariable(graph, rule);\r
-\r
- Function1<Object,List<?>> getSpecialCategory = ruleVariable.getPossiblePropertyValue(graph, SEL.getSpecialCategory);\r
- if(getSpecialCategory == null) return null;\r
-\r
- SCLContext sclContext = SCLContext.getCurrent();\r
- Object oldGraph = sclContext.get("graph");\r
- try {\r
- sclContext.put("graph", graph);\r
- Resource cat = (Resource)getSpecialCategory.apply(predicate);\r
- if(cat != null) return Variables.getVariable(graph, cat);\r
- } catch (Throwable t) {\r
- throw new DatabaseException(t);\r
- } finally {\r
- sclContext.put("graph", oldGraph);\r
- }\r
- }\r
- \r
- return null;\r
-\r
- }\r
-\r
-}\r
+package org.simantics.selectionview;
+
+import java.util.List;
+
+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.db.layer0.variable.Variables;
+import org.simantics.db.layer0.variable.Variables.Role;
+import org.simantics.scl.runtime.SCLContext;
+import org.simantics.scl.runtime.function.Function1;
+
+public class SelectionViewUtils {
+
+ public static Variable getSpecialCategory(ReadGraph graph, Resource rule, Variable info) throws DatabaseException {
+
+ SelectionViewResources SEL = SelectionViewResources.getInstance(graph);
+ Resource categoryResource = info.getPossibleRepresents(graph);
+
+ if(SEL.CategoryHidden.equals(categoryResource)) {
+
+ Variable property = info.getParent(graph);
+ Variable parent = property.getParent(graph);
+ if(Role.PROPERTY.equals(parent.getPossibleRole(graph))) return null;
+
+ Resource predicate = property.getPossiblePredicateResource(graph);
+ Variable ruleVariable = Variables.getVariable(graph, rule);
+
+ Function1<Object,List<?>> getSpecialCategory = ruleVariable.getPossiblePropertyValue(graph, SEL.getSpecialCategory);
+ if(getSpecialCategory == null) return null;
+
+ SCLContext sclContext = SCLContext.getCurrent();
+ Object oldGraph = sclContext.get("graph");
+ try {
+ sclContext.put("graph", graph);
+ Resource cat = (Resource)getSpecialCategory.apply(predicate);
+ if(cat != null) return Variables.getVariable(graph, cat);
+ } catch (Throwable t) {
+ throw new DatabaseException(t);
+ } finally {
+ sclContext.put("graph", oldGraph);
+ }
+ }
+
+ return null;
+
+ }
+
+}