From: Tuukka Lehtonen Date: Thu, 7 May 2020 20:32:43 +0000 (+0300) Subject: Fix GetComponentLocation to work with procedural UC instances X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=d8f1f7da4d84424402812f1aa5deed6112f4c665;p=simantics%2Fplatform.git Fix GetComponentLocation to work with procedural UC instances Previously it would return ComponentLocation.isInsideStructure = false for Variables representing the insides of a procedural UC instance. gitlab #532 Change-Id: I26ae30c8e4217e7c4cde03b884604ee59aa7e85b --- diff --git a/bundles/org.simantics.structural2/src/org/simantics/structural2/queries/GetComponentLocation.java b/bundles/org.simantics.structural2/src/org/simantics/structural2/queries/GetComponentLocation.java index df6e1598c..e109f59e8 100644 --- a/bundles/org.simantics.structural2/src/org/simantics/structural2/queries/GetComponentLocation.java +++ b/bundles/org.simantics.structural2/src/org/simantics/structural2/queries/GetComponentLocation.java @@ -66,10 +66,16 @@ public class GetComponentLocation extends UnaryRead Variable firstRepresentedParent = findFirstParentWithRepresentation(graph, parameter, STR); if (firstRepresentedParent == null) return null; - Resource realParentComposite = graph.getPossibleObject(firstRepresentedParent.getRepresents(graph), L0.PartOf); - if (realParentComposite == null) - return null; - isInsideStructure = graph.hasStatement(realParentComposite, STR.Defines); + Resource representedParent = firstRepresentedParent.getRepresents(graph); + Resource representedParentType = graph.getPossibleType(representedParent, STR.Component); + if (representedParentType != null && graph.isInstanceOf(representedParentType, STR.ProceduralComponentType)) { + isInsideStructure = !parameter.equals(firstRepresentedParent); + } else { + Resource realParentComposite = graph.getPossibleObject(representedParent, L0.PartOf); + if (realParentComposite == null) + return null; + isInsideStructure = graph.hasStatement(realParentComposite, STR.Defines); + } Variable firstParentComposite = findFirstParentComposite(graph, firstRepresentedParent, STR); if (firstParentComposite != null) {