]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/ImmutableComponentVariableContentRequest.java
Work in progress
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / ImmutableComponentVariableContentRequest.java
index ac08c945e11ce52a9d7618ba95f1ed6bc03429e4..33daefbc4b72bbc660eb76cb6909ba2b569868d9 100644 (file)
@@ -12,8 +12,8 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.request.PropertyInfo;
 import org.simantics.db.layer0.request.UnescapedPropertyMapOfResource;
 import org.simantics.layer0.Layer0;
+import org.simantics.structural.stubs.StructuralResource2;
 import org.simantics.structural2.ConnectionImpl;
-import org.simantics.structural2.Functions.StructuralChildMapOfResource;
 import org.simantics.structural2.queries.ConnectionPointMapOfResource;
 
 public class ImmutableComponentVariableContentRequest extends ResourceRead<ImmutableComponentVariableContent> {
@@ -28,6 +28,11 @@ public class ImmutableComponentVariableContentRequest extends ResourceRead<Immut
                Layer0 L0 = Layer0.getInstance(graph);
                String name = graph.getRelatedValue(resource, L0.HasName, Bindings.STRING);
                ImmutableComponentVariableContent result = new ImmutableComponentVariableContent(resource, name);
+
+               StructuralResource2 STR = StructuralResource2.getInstance(graph);
+               Resource componentType = graph.getPossibleType(resource, STR.Component);
+               if(componentType != null)
+                       result.procedural = graph.isInstanceOf(componentType, STR.ProceduralComponentType); 
                
                Map<String,PropertyInfo> pis = graph.syncRequest(new UnescapedPropertyMapOfResource(resource));
                
@@ -53,7 +58,15 @@ public class ImmutableComponentVariableContentRequest extends ResourceRead<Immut
                }
                
                HashSet<Resource> childSet = null;
-               for(Resource child : graph.syncRequest(new StructuralChildMapOfResource(resource)).values()) {
+               
+               Resource container = resource;
+               Resource possibleType = graph.getPossibleType(resource, STR.Component);
+               if(possibleType != null) {
+                       Resource def = graph.getPossibleObject(possibleType, STR.IsDefinedBy);
+                       if(def != null) container = def;
+               }
+               
+               for(Resource child : graph.getChildren(container).values()) {
                        if(childSet == null)
                                childSet = new HashSet<>();
                        childSet.add(child);