X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.selectionview.ui.ontology%2Fsrc%2Forg%2Fsimantics%2Fselectionview%2Fui%2Fontology%2FSelectionViewUIResources.java;fp=bundles%2Forg.simantics.selectionview.ui.ontology%2Fsrc%2Forg%2Fsimantics%2Fselectionview%2Fui%2Fontology%2FSelectionViewUIResources.java;h=3cd94f9c331ee557f402577c7cee7eee54094832;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git 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 index 000000000..3cd94f9c3 --- /dev/null +++ b/bundles/org.simantics.selectionview.ui.ontology/src/org/simantics/selectionview/ui/ontology/SelectionViewUIResources.java @@ -0,0 +1,118 @@ +package org.simantics.selectionview.ui.ontology; + +import org.simantics.db.RequestProcessor; +import org.simantics.db.Resource; +import org.simantics.db.ReadGraph; +import org.simantics.db.request.Read; +import org.simantics.db.Session; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.service.QueryControl; + +public class SelectionViewUIResources { + + public final Resource CategoryDecorationRule; + public final Resource CategoryNode; + public final Resource CategoryNodeLabelRule; + public final Resource PropertyColumn; + public final Resource StandardProperties; + public final Resource StandardPropertiesBase; + public final Resource StandardPropertiesBase_BrowseContext; + public final Resource StandardProperties_BrowseContextStandardChildren; + public final Resource StandardProperties_BrowseContextStandardChildren_Cat; + public final Resource StandardProperties_BrowseContextStandardChildren_Sorter; + public final Resource StandardProperties_BrowseContextStandardChildren_Var; + public final Resource StandardProperties_BrowseContextWithoutChildren; + public final Resource StandardPropertySorterRule; + public final Resource StandardPropertySorterRuleType; + public final Resource UnitColumn; + public final Resource ValueColumn; + public final Resource VariableColoringDecorationRule; + public final Resource VariableDecorationRule; + public final Resource VariablePropertyCategoryRule; + public final Resource VariablePropertyLabelRule; + public final Resource VariablePropertyModifierRule; + + public static class URIs { + public static final String CategoryDecorationRule = "http://www.simantics.org/SelectionViewUI-1.1/CategoryDecorationRule"; + public static final String CategoryNode = "http://www.simantics.org/SelectionViewUI-1.1/CategoryNode"; + public static final String CategoryNodeLabelRule = "http://www.simantics.org/SelectionViewUI-1.1/CategoryNodeLabelRule"; + public static final String PropertyColumn = "http://www.simantics.org/SelectionViewUI-1.1/PropertyColumn"; + public static final String StandardProperties = "http://www.simantics.org/SelectionViewUI-1.1/StandardProperties"; + public static final String StandardPropertiesBase = "http://www.simantics.org/SelectionViewUI-1.1/StandardPropertiesBase"; + public static final String StandardPropertiesBase_BrowseContext = "http://www.simantics.org/SelectionViewUI-1.1/StandardPropertiesBase/BrowseContext"; + public static final String StandardProperties_BrowseContextStandardChildren = "http://www.simantics.org/SelectionViewUI-1.1/StandardProperties/BrowseContextStandardChildren"; + public static final String StandardProperties_BrowseContextStandardChildren_Cat = "http://www.simantics.org/SelectionViewUI-1.1/StandardProperties/BrowseContextStandardChildren/Cat"; + public static final String StandardProperties_BrowseContextStandardChildren_Sorter = "http://www.simantics.org/SelectionViewUI-1.1/StandardProperties/BrowseContextStandardChildren/Sorter"; + public static final String StandardProperties_BrowseContextStandardChildren_Var = "http://www.simantics.org/SelectionViewUI-1.1/StandardProperties/BrowseContextStandardChildren/Var"; + public static final String StandardProperties_BrowseContextWithoutChildren = "http://www.simantics.org/SelectionViewUI-1.1/StandardProperties/BrowseContextWithoutChildren"; + public static final String StandardPropertySorterRule = "http://www.simantics.org/SelectionViewUI-1.1/StandardPropertySorterRule"; + public static final String StandardPropertySorterRuleType = "http://www.simantics.org/SelectionViewUI-1.1/StandardPropertySorterRuleType"; + public static final String UnitColumn = "http://www.simantics.org/SelectionViewUI-1.1/UnitColumn"; + public static final String ValueColumn = "http://www.simantics.org/SelectionViewUI-1.1/ValueColumn"; + public static final String VariableColoringDecorationRule = "http://www.simantics.org/SelectionViewUI-1.1/VariableColoringDecorationRule"; + public static final String VariableDecorationRule = "http://www.simantics.org/SelectionViewUI-1.1/VariableDecorationRule"; + public static final String VariablePropertyCategoryRule = "http://www.simantics.org/SelectionViewUI-1.1/VariablePropertyCategoryRule"; + public static final String VariablePropertyLabelRule = "http://www.simantics.org/SelectionViewUI-1.1/VariablePropertyLabelRule"; + public static final String VariablePropertyModifierRule = "http://www.simantics.org/SelectionViewUI-1.1/VariablePropertyModifierRule"; + } + + public static Resource getResourceOrNull(ReadGraph graph, String uri) { + try { + return graph.getResource(uri); + } catch(DatabaseException e) { + System.err.println(e.getMessage()); + return null; + } + } + + public SelectionViewUIResources(ReadGraph graph) { + CategoryDecorationRule = getResourceOrNull(graph, URIs.CategoryDecorationRule); + CategoryNode = getResourceOrNull(graph, URIs.CategoryNode); + CategoryNodeLabelRule = getResourceOrNull(graph, URIs.CategoryNodeLabelRule); + PropertyColumn = getResourceOrNull(graph, URIs.PropertyColumn); + StandardProperties = getResourceOrNull(graph, URIs.StandardProperties); + StandardPropertiesBase = getResourceOrNull(graph, URIs.StandardPropertiesBase); + StandardPropertiesBase_BrowseContext = getResourceOrNull(graph, URIs.StandardPropertiesBase_BrowseContext); + StandardProperties_BrowseContextStandardChildren = getResourceOrNull(graph, URIs.StandardProperties_BrowseContextStandardChildren); + StandardProperties_BrowseContextStandardChildren_Cat = getResourceOrNull(graph, URIs.StandardProperties_BrowseContextStandardChildren_Cat); + StandardProperties_BrowseContextStandardChildren_Sorter = getResourceOrNull(graph, URIs.StandardProperties_BrowseContextStandardChildren_Sorter); + StandardProperties_BrowseContextStandardChildren_Var = getResourceOrNull(graph, URIs.StandardProperties_BrowseContextStandardChildren_Var); + StandardProperties_BrowseContextWithoutChildren = getResourceOrNull(graph, URIs.StandardProperties_BrowseContextWithoutChildren); + StandardPropertySorterRule = getResourceOrNull(graph, URIs.StandardPropertySorterRule); + StandardPropertySorterRuleType = getResourceOrNull(graph, URIs.StandardPropertySorterRuleType); + UnitColumn = getResourceOrNull(graph, URIs.UnitColumn); + ValueColumn = getResourceOrNull(graph, URIs.ValueColumn); + VariableColoringDecorationRule = getResourceOrNull(graph, URIs.VariableColoringDecorationRule); + VariableDecorationRule = getResourceOrNull(graph, URIs.VariableDecorationRule); + VariablePropertyCategoryRule = getResourceOrNull(graph, URIs.VariablePropertyCategoryRule); + VariablePropertyLabelRule = getResourceOrNull(graph, URIs.VariablePropertyLabelRule); + VariablePropertyModifierRule = getResourceOrNull(graph, URIs.VariablePropertyModifierRule); + } + + public static SelectionViewUIResources getInstance(ReadGraph graph) { + Session session = graph.getSession(); + SelectionViewUIResources ret = session.peekService(SelectionViewUIResources.class); + if(ret == null) { + QueryControl qc = graph.getService(QueryControl.class); + ret = new SelectionViewUIResources(qc.getIndependentGraph(graph)); + session.registerService(SelectionViewUIResources.class, ret); + } + return ret; + } + + public static SelectionViewUIResources getInstance(RequestProcessor session) throws DatabaseException { + SelectionViewUIResources ret = session.peekService(SelectionViewUIResources.class); + if(ret == null) { + ret = session.syncRequest(new Read() { + public SelectionViewUIResources perform(ReadGraph graph) throws DatabaseException { + QueryControl qc = graph.getService(QueryControl.class); + return new SelectionViewUIResources(qc.getIndependentGraph(graph)); + } + }); + session.registerService(SelectionViewUIResources.class, ret); + } + return ret; + } + +} +