]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.structural2/src/org/simantics/structural2/queries/GetComponentLocation.java
Fix GetComponentLocation to work with procedural UC instances
[simantics/platform.git] / bundles / org.simantics.structural2 / src / org / simantics / structural2 / queries / GetComponentLocation.java
index df6e1598c2649312442e3acae4c7186b4bc329c3..e109f59e89538b3574f2abe73c67b39355674a56 100644 (file)
@@ -66,10 +66,16 @@ public class GetComponentLocation extends UnaryRead<Variable, ComponentLocation>
         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) {