]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.selectionview.ui.ontology/src/org/simantics/selectionview/ui/ontology/SelectionViewUIResources.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.selectionview.ui.ontology / src / org / simantics / selectionview / ui / ontology / SelectionViewUIResources.java
diff --git a/bundles/org.simantics.selectionview.ui.ontology/src/org/simantics/selectionview/ui/ontology/SelectionViewUIResources.java b/bundles/org.simantics.selectionview.ui.ontology/src/org/simantics/selectionview/ui/ontology/SelectionViewUIResources.java
new file mode 100644 (file)
index 0000000..3cd94f9
--- /dev/null
@@ -0,0 +1,118 @@
+package org.simantics.selectionview.ui.ontology;\r
+\r
+import org.simantics.db.RequestProcessor;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.service.QueryControl;\r
+\r
+public class SelectionViewUIResources {\r
+    \r
+    public final Resource CategoryDecorationRule;\r
+    public final Resource CategoryNode;\r
+    public final Resource CategoryNodeLabelRule;\r
+    public final Resource PropertyColumn;\r
+    public final Resource StandardProperties;\r
+    public final Resource StandardPropertiesBase;\r
+    public final Resource StandardPropertiesBase_BrowseContext;\r
+    public final Resource StandardProperties_BrowseContextStandardChildren;\r
+    public final Resource StandardProperties_BrowseContextStandardChildren_Cat;\r
+    public final Resource StandardProperties_BrowseContextStandardChildren_Sorter;\r
+    public final Resource StandardProperties_BrowseContextStandardChildren_Var;\r
+    public final Resource StandardProperties_BrowseContextWithoutChildren;\r
+    public final Resource StandardPropertySorterRule;\r
+    public final Resource StandardPropertySorterRuleType;\r
+    public final Resource UnitColumn;\r
+    public final Resource ValueColumn;\r
+    public final Resource VariableColoringDecorationRule;\r
+    public final Resource VariableDecorationRule;\r
+    public final Resource VariablePropertyCategoryRule;\r
+    public final Resource VariablePropertyLabelRule;\r
+    public final Resource VariablePropertyModifierRule;\r
+        \r
+    public static class URIs {\r
+        public static final String CategoryDecorationRule = "http://www.simantics.org/SelectionViewUI-1.1/CategoryDecorationRule";\r
+        public static final String CategoryNode = "http://www.simantics.org/SelectionViewUI-1.1/CategoryNode";\r
+        public static final String CategoryNodeLabelRule = "http://www.simantics.org/SelectionViewUI-1.1/CategoryNodeLabelRule";\r
+        public static final String PropertyColumn = "http://www.simantics.org/SelectionViewUI-1.1/PropertyColumn";\r
+        public static final String StandardProperties = "http://www.simantics.org/SelectionViewUI-1.1/StandardProperties";\r
+        public static final String StandardPropertiesBase = "http://www.simantics.org/SelectionViewUI-1.1/StandardPropertiesBase";\r
+        public static final String StandardPropertiesBase_BrowseContext = "http://www.simantics.org/SelectionViewUI-1.1/StandardPropertiesBase/BrowseContext";\r
+        public static final String StandardProperties_BrowseContextStandardChildren = "http://www.simantics.org/SelectionViewUI-1.1/StandardProperties/BrowseContextStandardChildren";\r
+        public static final String StandardProperties_BrowseContextStandardChildren_Cat = "http://www.simantics.org/SelectionViewUI-1.1/StandardProperties/BrowseContextStandardChildren/Cat";\r
+        public static final String StandardProperties_BrowseContextStandardChildren_Sorter = "http://www.simantics.org/SelectionViewUI-1.1/StandardProperties/BrowseContextStandardChildren/Sorter";\r
+        public static final String StandardProperties_BrowseContextStandardChildren_Var = "http://www.simantics.org/SelectionViewUI-1.1/StandardProperties/BrowseContextStandardChildren/Var";\r
+        public static final String StandardProperties_BrowseContextWithoutChildren = "http://www.simantics.org/SelectionViewUI-1.1/StandardProperties/BrowseContextWithoutChildren";\r
+        public static final String StandardPropertySorterRule = "http://www.simantics.org/SelectionViewUI-1.1/StandardPropertySorterRule";\r
+        public static final String StandardPropertySorterRuleType = "http://www.simantics.org/SelectionViewUI-1.1/StandardPropertySorterRuleType";\r
+        public static final String UnitColumn = "http://www.simantics.org/SelectionViewUI-1.1/UnitColumn";\r
+        public static final String ValueColumn = "http://www.simantics.org/SelectionViewUI-1.1/ValueColumn";\r
+        public static final String VariableColoringDecorationRule = "http://www.simantics.org/SelectionViewUI-1.1/VariableColoringDecorationRule";\r
+        public static final String VariableDecorationRule = "http://www.simantics.org/SelectionViewUI-1.1/VariableDecorationRule";\r
+        public static final String VariablePropertyCategoryRule = "http://www.simantics.org/SelectionViewUI-1.1/VariablePropertyCategoryRule";\r
+        public static final String VariablePropertyLabelRule = "http://www.simantics.org/SelectionViewUI-1.1/VariablePropertyLabelRule";\r
+        public static final String VariablePropertyModifierRule = "http://www.simantics.org/SelectionViewUI-1.1/VariablePropertyModifierRule";\r
+    }\r
+    \r
+    public static Resource getResourceOrNull(ReadGraph graph, String uri) {\r
+        try {\r
+            return graph.getResource(uri);\r
+        } catch(DatabaseException e) {\r
+            System.err.println(e.getMessage());\r
+            return null;\r
+        }\r
+    }\r
+    \r
+    public SelectionViewUIResources(ReadGraph graph) {\r
+        CategoryDecorationRule = getResourceOrNull(graph, URIs.CategoryDecorationRule);\r
+        CategoryNode = getResourceOrNull(graph, URIs.CategoryNode);\r
+        CategoryNodeLabelRule = getResourceOrNull(graph, URIs.CategoryNodeLabelRule);\r
+        PropertyColumn = getResourceOrNull(graph, URIs.PropertyColumn);\r
+        StandardProperties = getResourceOrNull(graph, URIs.StandardProperties);\r
+        StandardPropertiesBase = getResourceOrNull(graph, URIs.StandardPropertiesBase);\r
+        StandardPropertiesBase_BrowseContext = getResourceOrNull(graph, URIs.StandardPropertiesBase_BrowseContext);\r
+        StandardProperties_BrowseContextStandardChildren = getResourceOrNull(graph, URIs.StandardProperties_BrowseContextStandardChildren);\r
+        StandardProperties_BrowseContextStandardChildren_Cat = getResourceOrNull(graph, URIs.StandardProperties_BrowseContextStandardChildren_Cat);\r
+        StandardProperties_BrowseContextStandardChildren_Sorter = getResourceOrNull(graph, URIs.StandardProperties_BrowseContextStandardChildren_Sorter);\r
+        StandardProperties_BrowseContextStandardChildren_Var = getResourceOrNull(graph, URIs.StandardProperties_BrowseContextStandardChildren_Var);\r
+        StandardProperties_BrowseContextWithoutChildren = getResourceOrNull(graph, URIs.StandardProperties_BrowseContextWithoutChildren);\r
+        StandardPropertySorterRule = getResourceOrNull(graph, URIs.StandardPropertySorterRule);\r
+        StandardPropertySorterRuleType = getResourceOrNull(graph, URIs.StandardPropertySorterRuleType);\r
+        UnitColumn = getResourceOrNull(graph, URIs.UnitColumn);\r
+        ValueColumn = getResourceOrNull(graph, URIs.ValueColumn);\r
+        VariableColoringDecorationRule = getResourceOrNull(graph, URIs.VariableColoringDecorationRule);\r
+        VariableDecorationRule = getResourceOrNull(graph, URIs.VariableDecorationRule);\r
+        VariablePropertyCategoryRule = getResourceOrNull(graph, URIs.VariablePropertyCategoryRule);\r
+        VariablePropertyLabelRule = getResourceOrNull(graph, URIs.VariablePropertyLabelRule);\r
+        VariablePropertyModifierRule = getResourceOrNull(graph, URIs.VariablePropertyModifierRule);\r
+    }\r
+    \r
+    public static SelectionViewUIResources getInstance(ReadGraph graph) {\r
+        Session session = graph.getSession();\r
+        SelectionViewUIResources ret = session.peekService(SelectionViewUIResources.class);\r
+        if(ret == null) {\r
+            QueryControl qc = graph.getService(QueryControl.class);\r
+            ret = new SelectionViewUIResources(qc.getIndependentGraph(graph));\r
+            session.registerService(SelectionViewUIResources.class, ret);\r
+        }\r
+        return ret;\r
+    }\r
+    \r
+    public static SelectionViewUIResources getInstance(RequestProcessor session) throws DatabaseException {\r
+        SelectionViewUIResources ret = session.peekService(SelectionViewUIResources.class);\r
+        if(ret == null) {\r
+            ret = session.syncRequest(new Read<SelectionViewUIResources>() {\r
+                public SelectionViewUIResources perform(ReadGraph graph) throws DatabaseException {\r
+                    QueryControl qc = graph.getService(QueryControl.class);\r
+                    return new SelectionViewUIResources(qc.getIndependentGraph(graph));\r
+                }\r
+            });\r
+            session.registerService(SelectionViewUIResources.class, ret);\r
+        }\r
+        return ret;\r
+    }\r
+    \r
+}\r
+\r