]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.structural2/src/org/simantics/structural2/StructuralRVIResolver.java
Removed graph compilation nature from org.simantics.jdbc
[simantics/platform.git] / bundles / org.simantics.structural2 / src / org / simantics / structural2 / StructuralRVIResolver.java
index f27356b9f2c403bdef0e25feddea8dd3e4a03778..672edfca65c4bfc6995654fdd6b935e4cdb886e4 100644 (file)
@@ -40,10 +40,34 @@ public class StructuralRVIResolver extends StandardRVIResolver {
             Binding rviBinding = databoard.getBindingUnchecked( RVI.class );
             return RVI.empty(rviBinding);
         }
-        Variable base = variable.getParent(graph);
-        while(!isRVIBase(graph, base)) base = base.getParent(graph);
-        RVIPart part = getRVIPart(graph, variable);
-        return new RVIBuilder(base.getRVI(graph)).append(part).toRVI();
+        else {
+            Variable base = variable.getParent(graph);
+            while(!isRVIBase(graph, base)) base = base.getParent(graph);
+            RVIPart part = getRVIPart(graph, variable);
+            return new RVIBuilder(base.getRVI(graph)).append(part).toRVI();
+        }
+    }
+    
+    @Override
+    public RVI getPossibleRVI(ReadGraph graph, Variable variable) throws DatabaseException {
+        if (Variables.isContext(graph, variable)) {
+            Databoard databoard = graph.getService( Databoard.class );
+            Binding rviBinding = databoard.getBindingUnchecked( RVI.class );
+            return RVI.empty(rviBinding);
+        }
+        else {
+            Variable base = variable.getParent(graph);
+            if(base == null) return null;
+            while(!isRVIBase(graph, base)) {
+                base = base.getParent(graph);
+                if(base == null) return null;
+            }
+            RVIPart part = getRVIPart(graph, variable);
+            if(part == null) return null;
+            RVI baseRVI = base.getPossibleRVI(graph);
+            if(baseRVI == null) return null;
+            return new RVIBuilder(baseRVI).append(part).toRVI();
+        }
     }
 
     protected boolean isPartOfComponentType(ReadGraph graph, Resource resource)
@@ -103,16 +127,20 @@ public class StructuralRVIResolver extends StandardRVIResolver {
     @Override
     protected Variable resolveChild(ReadGraph graph, Variable variable, Resource resource) throws DatabaseException {
         Collection<Resource> path = getRVIPath(graph, variable, resource);
-        if(path == null) throw new MissingVariableException("Didn't find a variable related to " + resource + ".", resource);
-        for(Resource r : path) variable = variable.browse(graph, r);
+        if (path == null)
+            throw new MissingVariableException("Didn't find a variable related to " + resource + ".", resource);
+        for (Resource r : path)
+            variable = variable.browse(graph, r);
         return variable;
     }
-    
+
     @Override
     protected Variable resolveChild(ReadGraph graph, Variable variable, GuidRVIPart part) throws DatabaseException {
         Collection<Resource> path = getRVIPath(graph, variable, part);
-        if(path == null) throw new MissingVariableException("Didn't find a variable related to " + part + ".");
-        for(Resource r : path) variable = variable.browse(graph, r);
+        if (path == null)
+            throw new MissingVariableException("Didn't find a variable related to " + part + ".", variable.getPossibleRepresents(graph));
+        for (Resource r : path)
+            variable = variable.browse(graph, r);
         return variable;
     }