]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ComponentTypeViewer.java
Added some enforcement of immutability to structural user component UI's.
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / componentTypeEditor / ComponentTypeViewer.java
index 3cc4bbbf3ce68aa6d08f2b99438fad0190e134bc..f88ad39fa5bd351732044e6feaa028624068ac71 100644 (file)
@@ -45,9 +45,9 @@ import org.simantics.db.common.NamedResource;
 import org.simantics.db.common.request.UniqueRead;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.procedure.Listener;\r
 import org.simantics.db.request.Read;\r
-import org.simantics.db.service.XSupport;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.modeling.ui.Activator;\r
 import org.simantics.operation.Layer0X;\r
@@ -173,6 +173,12 @@ public class ComponentTypeViewer {
                 Layer0 L0 = Layer0.getInstance(graph);\r
                 Layer0X L0X = Layer0X.getInstance(graph);\r
                 StructuralResource2 STR = StructuralResource2.getInstance(graph);\r
+\r
+                boolean typeIsImmutable = graph.isImmutable(data.componentType)\r
+                        || graph.hasStatement(data.componentType, STR.ComponentType_Locked)\r
+                        || Layer0Utils.isPublished(graph, data.componentType)\r
+                        || Layer0Utils.isContainerPublished(graph, data.componentType);\r
+\r
                 for(Resource relation : graph.getObjects(data.componentType, L0.DomainOf)) {\r
                     if(graph.isSubrelationOf(relation, L0.HasProperty)) {\r
                         String name = graph.getRelatedValue(relation, L0.HasName);\r
@@ -216,7 +222,7 @@ public class ComponentTypeViewer {
                         \r
                         String valid = expression != null ? DerivedPropertiesSection.validateMonitorExpression(graph, data.componentType, relation, expression) : null; \r
 \r
-                        boolean immutable = graph.isImmutable(relation);\r
+                        boolean immutable = typeIsImmutable || graph.isImmutable(relation);\r
                         ComponentTypeViewerPropertyInfo info =\r
                                 new ComponentTypeViewerPropertyInfo(relation, name, type, defaultValue, numberType, unit, label, description, expression, valid, immutable);\r
                         \r
@@ -242,9 +248,7 @@ public class ComponentTypeViewer {
                     }\r
                 }\r
                 Collections.sort(result);\r
-                XSupport xs = graph.peekService(XSupport.class);\r
-                boolean immutable = xs != null ? xs.getImmutable(data.componentType) : false;\r
-                return new ComponentTypePropertiesResult(result, connectionPoints, immutable);\r
+                return new ComponentTypePropertiesResult(result, connectionPoints, typeIsImmutable);\r
             }\r
         }, new Listener<ComponentTypePropertiesResult>() {\r
             @Override\r