]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.ui/src/org/simantics/ui/workbench/e4/E4ResourceEditorInput2.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.ui / src / org / simantics / ui / workbench / e4 / E4ResourceEditorInput2.java
index c67fc68b6103822fd6ad93bcd38ababde67b1658..61dad8225a27c66f2c44615e0d12841780a0f022 100644 (file)
-package org.simantics.ui.workbench.e4;\r
-\r
-import org.simantics.Simantics;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.UniqueRead;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.variable.RVI;\r
-import org.simantics.db.layer0.variable.Variable;\r
-import org.simantics.db.layer0.variable.Variables;\r
-import org.simantics.ui.workbench.IResourceEditorInput2;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- * @since 1.22\r
- */\r
-public class E4ResourceEditorInput2 extends E4ResourceEditorInput implements IResourceEditorInput2 {\r
-\r
-    protected final Resource model;\r
-    protected final String rvi;\r
-    protected transient Variable variable;\r
-\r
-    public E4ResourceEditorInput2(Resource resource, Resource model, String rvi) {\r
-        super(resource);\r
-        this.model = model;\r
-        this.rvi = rvi;\r
-    }\r
-\r
-    @Override\r
-    public void dispose() {\r
-        // Nullify to prevent the class from keeping unnecessary references to\r
-        // possible Variable implementation backend resources.\r
-        variable = null;\r
-    }\r
-\r
-    @Override\r
-    public Resource getModel(ReadGraph graph) {\r
-        return model;\r
-    }\r
-\r
-    @Override\r
-    public String getRVI() {\r
-        return rvi;\r
-    }\r
-\r
-    @Override\r
-    public boolean exists(ReadGraph graph) throws DatabaseException {\r
-        if (!super.exists(graph))\r
-            return false;\r
-\r
-        if (model != null) {\r
-            boolean modelExists = graph.hasStatement(model);\r
-            if (!modelExists)\r
-                return false;\r
-        }\r
-\r
-        if(rvi != null) {\r
-            Variable context = Variables.getPossibleConfigurationContext(graph, model);\r
-            if (context == null)\r
-                return false;\r
-            RVI rvi_ = RVI.fromResourceFormat(graph, rvi);\r
-            Variable variable = rvi_.resolvePossible(graph, context);\r
-            if (variable == null)\r
-                return false;\r
-        }\r
-\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public Variable getVariable() throws DatabaseException {\r
-        if (variable != null)\r
-            return variable;\r
-        return Simantics.getSession().syncRequest(new UniqueRead<Variable>() {\r
-            @Override\r
-            public Variable perform(ReadGraph graph) throws DatabaseException {\r
-                return getVariable(graph);\r
-            }\r
-        });\r
-    }\r
-\r
-    protected Variable getVariable0(ReadGraph graph) throws DatabaseException {\r
-        Resource model = getModel(graph);\r
-        String rvi = getRVI();\r
-        // Model + RVI\r
-        if (rvi != null) {\r
-            Variable configuration = Variables.getConfigurationContext(graph, model);\r
-            RVI rrvi = RVI.fromResourceFormat(graph, rvi);\r
-            return rrvi.resolve(graph, configuration);\r
-        }\r
-        // Absolute URI\r
-        else {\r
-            return Variables.getVariable(graph, model);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public Variable getVariable(ReadGraph graph) throws DatabaseException {\r
-        Variable v = getVariable0(graph);\r
-        this.variable = v;\r
-        return v;\r
-    }\r
-\r
-}\r
+package org.simantics.ui.workbench.e4;
+
+import org.simantics.Simantics;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.request.UniqueRead;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.variable.RVI;
+import org.simantics.db.layer0.variable.Variable;
+import org.simantics.db.layer0.variable.Variables;
+import org.simantics.ui.workbench.IResourceEditorInput2;
+
+/**
+ * @author Tuukka Lehtonen
+ * @since 1.22
+ */
+public class E4ResourceEditorInput2 extends E4ResourceEditorInput implements IResourceEditorInput2 {
+
+    protected final Resource model;
+    protected final String rvi;
+    protected transient Variable variable;
+
+    public E4ResourceEditorInput2(Resource resource, Resource model, String rvi) {
+        super(resource);
+        this.model = model;
+        this.rvi = rvi;
+    }
+
+    @Override
+    public void dispose() {
+        // Nullify to prevent the class from keeping unnecessary references to
+        // possible Variable implementation backend resources.
+        variable = null;
+    }
+
+    @Override
+    public Resource getModel(ReadGraph graph) {
+        return model;
+    }
+
+    @Override
+    public String getRVI() {
+        return rvi;
+    }
+
+    @Override
+    public boolean exists(ReadGraph graph) throws DatabaseException {
+        if (!super.exists(graph))
+            return false;
+
+        if (model != null) {
+            boolean modelExists = graph.hasStatement(model);
+            if (!modelExists)
+                return false;
+        }
+
+        if(rvi != null) {
+            Variable context = Variables.getPossibleConfigurationContext(graph, model);
+            if (context == null)
+                return false;
+            RVI rvi_ = RVI.fromResourceFormat(graph, rvi);
+            Variable variable = rvi_.resolvePossible(graph, context);
+            if (variable == null)
+                return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public Variable getVariable() throws DatabaseException {
+        if (variable != null)
+            return variable;
+        return Simantics.getSession().syncRequest(new UniqueRead<Variable>() {
+            @Override
+            public Variable perform(ReadGraph graph) throws DatabaseException {
+                return getVariable(graph);
+            }
+        });
+    }
+
+    protected Variable getVariable0(ReadGraph graph) throws DatabaseException {
+        Resource model = getModel(graph);
+        String rvi = getRVI();
+        // Model + RVI
+        if (rvi != null) {
+            Variable configuration = Variables.getConfigurationContext(graph, model);
+            RVI rrvi = RVI.fromResourceFormat(graph, rvi);
+            return rrvi.resolve(graph, configuration);
+        }
+        // Absolute URI
+        else {
+            return Variables.getVariable(graph, model);
+        }
+    }
+
+    @Override
+    public Variable getVariable(ReadGraph graph) throws DatabaseException {
+        Variable v = getVariable0(graph);
+        this.variable = v;
+        return v;
+    }
+
+}