From: Hannu Niemistö Date: Tue, 5 Sep 2017 14:13:53 +0000 (+0300) Subject: (refs #7461) Fix to StructuralRVIResolver.getPossibleRVI X-Git-Tag: v1.31.0~198 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F18%2F918%2F1;p=simantics%2Fplatform.git (refs #7461) Fix to StructuralRVIResolver.getPossibleRVI Call getPossibleRVI instead of getRVI. Change-Id: I1638f0a08c78ac784f7c3d2e3a6f9ce4e9670f43 --- diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardRVIResolver.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardRVIResolver.java index 7c632f3f4..b01aeb32b 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardRVIResolver.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardRVIResolver.java @@ -32,9 +32,9 @@ public class StandardRVIResolver implements RVIResolver { @Override public RVI getRVI(ReadGraph graph, Variable variable) throws DatabaseException { - Databoard databoard = graph.getService( Databoard.class ); - Binding rviBinding = databoard.getBindingUnchecked( RVI.class ); if(Variables.isContext(graph, variable)) { + Databoard databoard = graph.getService( Databoard.class ); + Binding rviBinding = databoard.getBindingUnchecked( RVI.class ); return RVI.empty( rviBinding ); } else { Variable parent = variable.getParent(graph); @@ -49,9 +49,9 @@ public class StandardRVIResolver implements RVIResolver { @Override public RVI getPossibleRVI(ReadGraph graph, Variable variable) throws DatabaseException { - Databoard databoard = graph.getService( Databoard.class ); - Binding rviBinding = databoard.getBindingUnchecked( RVI.class ); if(Variables.isContext(graph, variable)) { + Databoard databoard = graph.getService( Databoard.class ); + Binding rviBinding = databoard.getBindingUnchecked( RVI.class ); return RVI.empty( rviBinding ); } else { Variable parent = variable.getParent(graph); diff --git a/bundles/org.simantics.structural2/src/org/simantics/structural2/StructuralRVIResolver.java b/bundles/org.simantics.structural2/src/org/simantics/structural2/StructuralRVIResolver.java index b2913f320..8cf61b3e0 100644 --- a/bundles/org.simantics.structural2/src/org/simantics/structural2/StructuralRVIResolver.java +++ b/bundles/org.simantics.structural2/src/org/simantics/structural2/StructuralRVIResolver.java @@ -40,10 +40,12 @@ 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 @@ -53,15 +55,19 @@ public class StructuralRVIResolver extends StandardRVIResolver { 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); + 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(); } - 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)