]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
(refs #7461) Implemented StructuralRVIResolver.getPossibleRVI 12/912/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Mon, 4 Sep 2017 15:42:48 +0000 (18:42 +0300)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Mon, 4 Sep 2017 15:42:48 +0000 (18:42 +0300)
Change-Id: I451d37af2cc532332c8de3d7c6401afda23bd969

bundles/org.simantics.structural2/src/org/simantics/structural2/StructuralRVIResolver.java

index f27356b9f2c403bdef0e25feddea8dd3e4a03778..b2913f3203eccc550c799d3632282c2372fd7d6c 100644 (file)
@@ -45,6 +45,24 @@ public class StructuralRVIResolver extends StandardRVIResolver {
         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);
+        }
+        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;
+        return new RVIBuilder(base.getRVI(graph)).append(part).toRVI();
+    }
 
     protected boolean isPartOfComponentType(ReadGraph graph, Resource resource)
             throws DatabaseException {