]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.structural2/src/org/simantics/structural2/utils/StructuralUtils.java
StructuralUtils.isImmutable now takes L0.readOnly of input into account
[simantics/platform.git] / bundles / org.simantics.structural2 / src / org / simantics / structural2 / utils / StructuralUtils.java
index 584b4acf73f924f4ab57de7de12764fc39548ec3..aac19a7f176b663c9297e9e3b820e86e44392992 100644 (file)
@@ -308,11 +308,13 @@ public class StructuralUtils {
     }
 
     public static boolean isImmutable(ReadGraph graph, Resource r) throws DatabaseException {
+        // Marking a resource L0.readOnly also makes it immutable
+        if (graph.isImmutable(r) || Layer0Utils.isMarkedReadOnly(graph, r))
+            return true;
         StructuralResource2 STR = StructuralResource2.getInstance(graph);
         Resource uc = graph.syncRequest(new PossibleTypedParent(r, STR.ComponentType));
-        return graph.isImmutable(r)
-                // Anything under a published or locked user component is published as well
-                || (uc != null && (Layer0Utils.isPublished(graph, uc)
+        return  // Anything under a published or locked user component is published as well
+                (uc != null && (Layer0Utils.isPublished(graph, uc)
                          || graph.hasStatement(uc, STR.ComponentType_Locked)))
                 // Anything under a published container (shared library) is published as well
                 || Layer0Utils.isContainerPublished(graph, r)
@@ -325,16 +327,22 @@ public class StructuralUtils {
     
     public static Resource structuralTypeResource(ReadGraph graph, Variable component, Resource baseType) throws DatabaseException {
         StructuralOverrideData od = StructuralOverrideData.compute(graph, component);
-        return od.type();
+        if (od != null)
+            return od.type();
+        return null;
     }
     
     public static Resource getComponentType(ReadGraph graph, Variable configuration, Resource component) throws DatabaseException {
-
         Variable componentVariable = configuration.browse(graph, component);
         return componentVariable.getType(graph);
-
     }
 
+    public static Resource getPossibleComponentType(ReadGraph graph, Variable configuration, Resource component) throws DatabaseException {
+        Variable componentVariable = configuration.browsePossible(graph, component);
+        if(componentVariable == null) return null;
+        StructuralResource2 STR = StructuralResource2.getInstance(graph);
+        return componentVariable.getPossibleType(graph, STR.Component);
+    }
 
 
 }