X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.structural2%2Fsrc%2Forg%2Fsimantics%2Fstructural2%2FStructuralRVIResolver.java;h=672edfca65c4bfc6995654fdd6b935e4cdb886e4;hb=ec70c03d4ce3f68b71de5eeadce3d008620c5521;hp=b2913f3203eccc550c799d3632282c2372fd7d6c;hpb=90c1f0db31b0b505e065e4781cfdc1c3ed3d274d;p=simantics%2Fplatform.git 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..672edfca6 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) @@ -121,16 +127,20 @@ public class StructuralRVIResolver extends StandardRVIResolver { @Override protected Variable resolveChild(ReadGraph graph, Variable variable, Resource resource) throws DatabaseException { Collection 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 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; }