]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scenegraph.profile/src/org/simantics/scenegraph/profile/request/RuntimeProfileActiveEntryResources.java
Better support for ontological profiles
[simantics/platform.git] / bundles / org.simantics.scenegraph.profile / src / org / simantics / scenegraph / profile / request / RuntimeProfileActiveEntryResources.java
index 5686024b0c702176352e73d34e0475b84903a5e2..f59c1d71a0978addc151df7c0705e23543ffbeb2 100644 (file)
@@ -21,6 +21,7 @@ import org.simantics.db.common.NamedResource;
 import org.simantics.db.common.request.ResourceRead;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.diagram.stubs.DiagramResource;
+import org.simantics.scenegraph.profile.ProfileUtils;
 
 /**
  * @author Antti Villberg
@@ -36,6 +37,9 @@ public class RuntimeProfileActiveEntryResources extends ResourceRead<Collection<
         DiagramResource DIA = DiagramResource.getInstance(graph);
 
         ArrayList<Resource> result = new ArrayList<Resource>();
+        
+        result.addAll(graph.syncRequest(new ProfileEntryContributions(resource)));
+
         Resource activeProfile = graph.getPossibleObject(resource, DIA.RuntimeDiagram_HasRuntimeProfile);
         if (activeProfile == null) {
                
@@ -45,12 +49,21 @@ public class RuntimeProfileActiveEntryResources extends ResourceRead<Collection<
                activeProfile = available.iterator().next().getResource();
             
         }
-
+        
         Resource rootEntries = graph.getPossibleObject(activeProfile, DIA.HasEntries);
         if (rootEntries == null)
             return result;
         
-        return graph.syncRequest(new ProfileActiveEntryResources(activeProfile, rootEntries));
+        if(graph.isImmutable(activeProfile)) {
+               Resource activationState = ProfileUtils.getPossibleProfileActivationState(graph, resource, activeProfile);
+               if(activationState != null) {
+                       result.addAll(graph.syncRequest(new ProfileActiveEntryResources(activationState, rootEntries)));
+               }
+        } else {
+               result.addAll(graph.syncRequest(new ProfileActiveEntryResources(activeProfile, rootEntries)));
+        }
+        
+        return result;
         
     }