1 package org.simantics.selectionview.ui.ontology;
3 import org.simantics.db.RequestProcessor;
4 import org.simantics.db.Resource;
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.request.Read;
7 import org.simantics.db.Session;
8 import org.simantics.db.exception.DatabaseException;
9 import org.simantics.db.service.QueryControl;
11 public class SelectionViewUIResources {
13 public final Resource CategoryDecorationRule;
14 public final Resource CategoryNode;
15 public final Resource CategoryNodeLabelRule;
16 public final Resource PropertyColumn;
17 public final Resource SCLMain;
18 public final Resource StandardProperties;
19 public final Resource StandardPropertiesBase;
20 public final Resource StandardPropertiesBase_BrowseContext;
21 public final Resource StandardProperties_BrowseContextStandardChildren;
22 public final Resource StandardProperties_BrowseContextStandardChildren_Cat;
23 public final Resource StandardProperties_BrowseContextStandardChildren_Sorter;
24 public final Resource StandardProperties_BrowseContextStandardChildren_Var;
25 public final Resource StandardProperties_BrowseContextWithoutChildren;
26 public final Resource StandardPropertySorterRule;
27 public final Resource StandardPropertySorterRuleType;
28 public final Resource UnitColumn;
29 public final Resource ValueColumn;
30 public final Resource VariableColoringDecorationRule;
31 public final Resource VariableDecorationRule;
32 public final Resource VariablePropertyCategoryRule;
33 public final Resource VariablePropertyLabelRule;
34 public final Resource VariablePropertyModifierRule;
36 public static class URIs {
37 public static final String CategoryDecorationRule = "http://www.simantics.org/SelectionViewUI-1.1/CategoryDecorationRule";
38 public static final String CategoryNode = "http://www.simantics.org/SelectionViewUI-1.1/CategoryNode";
39 public static final String CategoryNodeLabelRule = "http://www.simantics.org/SelectionViewUI-1.1/CategoryNodeLabelRule";
40 public static final String PropertyColumn = "http://www.simantics.org/SelectionViewUI-1.1/PropertyColumn";
41 public static final String SCLMain = "http://www.simantics.org/SelectionViewUI-1.1/SCLMain";
42 public static final String StandardProperties = "http://www.simantics.org/SelectionViewUI-1.1/StandardProperties";
43 public static final String StandardPropertiesBase = "http://www.simantics.org/SelectionViewUI-1.1/StandardPropertiesBase";
44 public static final String StandardPropertiesBase_BrowseContext = "http://www.simantics.org/SelectionViewUI-1.1/StandardPropertiesBase/BrowseContext";
45 public static final String StandardProperties_BrowseContextStandardChildren = "http://www.simantics.org/SelectionViewUI-1.1/StandardProperties/BrowseContextStandardChildren";
46 public static final String StandardProperties_BrowseContextStandardChildren_Cat = "http://www.simantics.org/SelectionViewUI-1.1/StandardProperties/BrowseContextStandardChildren/Cat";
47 public static final String StandardProperties_BrowseContextStandardChildren_Sorter = "http://www.simantics.org/SelectionViewUI-1.1/StandardProperties/BrowseContextStandardChildren/Sorter";
48 public static final String StandardProperties_BrowseContextStandardChildren_Var = "http://www.simantics.org/SelectionViewUI-1.1/StandardProperties/BrowseContextStandardChildren/Var";
49 public static final String StandardProperties_BrowseContextWithoutChildren = "http://www.simantics.org/SelectionViewUI-1.1/StandardProperties/BrowseContextWithoutChildren";
50 public static final String StandardPropertySorterRule = "http://www.simantics.org/SelectionViewUI-1.1/StandardPropertySorterRule";
51 public static final String StandardPropertySorterRuleType = "http://www.simantics.org/SelectionViewUI-1.1/StandardPropertySorterRuleType";
52 public static final String UnitColumn = "http://www.simantics.org/SelectionViewUI-1.1/UnitColumn";
53 public static final String ValueColumn = "http://www.simantics.org/SelectionViewUI-1.1/ValueColumn";
54 public static final String VariableColoringDecorationRule = "http://www.simantics.org/SelectionViewUI-1.1/VariableColoringDecorationRule";
55 public static final String VariableDecorationRule = "http://www.simantics.org/SelectionViewUI-1.1/VariableDecorationRule";
56 public static final String VariablePropertyCategoryRule = "http://www.simantics.org/SelectionViewUI-1.1/VariablePropertyCategoryRule";
57 public static final String VariablePropertyLabelRule = "http://www.simantics.org/SelectionViewUI-1.1/VariablePropertyLabelRule";
58 public static final String VariablePropertyModifierRule = "http://www.simantics.org/SelectionViewUI-1.1/VariablePropertyModifierRule";
61 public static Resource getResourceOrNull(ReadGraph graph, String uri) {
63 return graph.getResource(uri);
64 } catch(DatabaseException e) {
65 System.err.println(e.getMessage());
70 public SelectionViewUIResources(ReadGraph graph) {
71 CategoryDecorationRule = getResourceOrNull(graph, URIs.CategoryDecorationRule);
72 CategoryNode = getResourceOrNull(graph, URIs.CategoryNode);
73 CategoryNodeLabelRule = getResourceOrNull(graph, URIs.CategoryNodeLabelRule);
74 PropertyColumn = getResourceOrNull(graph, URIs.PropertyColumn);
75 SCLMain = getResourceOrNull(graph, URIs.SCLMain);
76 StandardProperties = getResourceOrNull(graph, URIs.StandardProperties);
77 StandardPropertiesBase = getResourceOrNull(graph, URIs.StandardPropertiesBase);
78 StandardPropertiesBase_BrowseContext = getResourceOrNull(graph, URIs.StandardPropertiesBase_BrowseContext);
79 StandardProperties_BrowseContextStandardChildren = getResourceOrNull(graph, URIs.StandardProperties_BrowseContextStandardChildren);
80 StandardProperties_BrowseContextStandardChildren_Cat = getResourceOrNull(graph, URIs.StandardProperties_BrowseContextStandardChildren_Cat);
81 StandardProperties_BrowseContextStandardChildren_Sorter = getResourceOrNull(graph, URIs.StandardProperties_BrowseContextStandardChildren_Sorter);
82 StandardProperties_BrowseContextStandardChildren_Var = getResourceOrNull(graph, URIs.StandardProperties_BrowseContextStandardChildren_Var);
83 StandardProperties_BrowseContextWithoutChildren = getResourceOrNull(graph, URIs.StandardProperties_BrowseContextWithoutChildren);
84 StandardPropertySorterRule = getResourceOrNull(graph, URIs.StandardPropertySorterRule);
85 StandardPropertySorterRuleType = getResourceOrNull(graph, URIs.StandardPropertySorterRuleType);
86 UnitColumn = getResourceOrNull(graph, URIs.UnitColumn);
87 ValueColumn = getResourceOrNull(graph, URIs.ValueColumn);
88 VariableColoringDecorationRule = getResourceOrNull(graph, URIs.VariableColoringDecorationRule);
89 VariableDecorationRule = getResourceOrNull(graph, URIs.VariableDecorationRule);
90 VariablePropertyCategoryRule = getResourceOrNull(graph, URIs.VariablePropertyCategoryRule);
91 VariablePropertyLabelRule = getResourceOrNull(graph, URIs.VariablePropertyLabelRule);
92 VariablePropertyModifierRule = getResourceOrNull(graph, URIs.VariablePropertyModifierRule);
95 public static SelectionViewUIResources getInstance(ReadGraph graph) {
96 Session session = graph.getSession();
97 SelectionViewUIResources ret = session.peekService(SelectionViewUIResources.class);
99 QueryControl qc = graph.getService(QueryControl.class);
100 ret = new SelectionViewUIResources(qc.getIndependentGraph(graph));
101 session.registerService(SelectionViewUIResources.class, ret);
106 public static SelectionViewUIResources getInstance(RequestProcessor session) throws DatabaseException {
107 SelectionViewUIResources ret = session.peekService(SelectionViewUIResources.class);
109 ret = session.syncRequest(new Read<SelectionViewUIResources>() {
110 public SelectionViewUIResources perform(ReadGraph graph) throws DatabaseException {
111 QueryControl qc = graph.getService(QueryControl.class);
112 return new SelectionViewUIResources(qc.getIndependentGraph(graph));
115 session.registerService(SelectionViewUIResources.class, ret);