]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Models have no use for labels, remove 48/4348/8
authorJani Mäkinen <jani.makinen@semantum.fi>
Tue, 28 Jul 2020 13:02:21 +0000 (16:02 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Tue, 25 Aug 2020 09:52:15 +0000 (09:52 +0000)
gitlab #45

Change-Id: Ia267cbba172a2475c0a2debb3e0d52c937e8275d

bundles/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java
bundles/org.simantics.sysdyn/src/org/simantics/sysdyn/modelImport/model/Model.java
bundles/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/ModelUtils.java
bundles/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/ImportUtils.java

index d0703cce4937cea8af877e9c821da8b1339b9506..9e41c390b933544b162032f5604971d68b5a6bdf 100644 (file)
@@ -85,7 +85,6 @@ public class ConfigurationTab extends AdjustableTab {
        @Override\r
        public void applyText(WriteGraph graph, Resource issue, String text) throws DatabaseException {\r
                Layer0 l0 = Layer0.getInstance(graph);\r
-            graph.claimLiteral(issue, l0.HasLabel, text);\r
             String safeName = NameUtils.findFreshName(graph, text, graph.getSingleObject(issue, l0.PartOf), l0.ConsistsOf, "%s%d");\r
             graph.claimLiteral(issue, l0.HasName, safeName);\r
        }\r
@@ -103,8 +102,8 @@ public class ConfigurationTab extends AdjustableTab {
         nameLabel.setText("Name");\r
         \r
         name = new TrackedText(composite, support, SWT.BORDER);\r
-        name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel));\r
-        name.addModifyListener(new ModelLabelModifier(context, Layer0.URIs.HasLabel));\r
+        name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasName));\r
+        name.addModifyListener(new ModelLabelModifier(context, Layer0.URIs.HasName));\r
         name.setInputValidator(new ModelNameInputValidator(support));\r
 \r
         startTimeLabel = new Label(composite, SWT.NONE);\r
index df0f0853ee2fa6e0b31303543f850383c10f029a..1591219dad67d28cd8c46c4ed814def3809b4690 100644 (file)
@@ -222,7 +222,6 @@ public class Model implements IWriteableObject {
                Resource container = graph.getSingleObject(model, l0.PartOf);\r
                String freshName = NameUtils.findFreshName(graph, name, container, l0.ConsistsOf, "%s%d");\r
                graph.claimLiteral(model, l0.HasName, freshName, Bindings.STRING);\r
-               graph.claimLiteral(model, l0.HasLabel, freshName, Bindings.STRING);\r
                \r
                // TODO: this must be updated if/when simulation parameters are moved \r
                // from model to experiment\r
index e9379fa43e29f5b9082166b402c153329daecdd6..69619a9c20fccbedb14a29c74f508e1e019d3653 100644 (file)
@@ -75,7 +75,6 @@ public class ModelUtils {
                     sr.SysdynModel,
                     l0.PartOf, project,
                     l0.HasName, modelName,
-                    l0.HasLabel, modelName,
                     L0X.IsActivatedBy, project
                     );
 
index bfbc6bad6f03d8c979f702532f1f7773b98151f1..902dbe8a9e9fc5960b893277c2f893212a53fb17 100644 (file)
@@ -246,13 +246,17 @@ public class ImportUtils {
                     return status;\r
 \r
                 subTask(monitor, "Validate model");\r
-                Collection<Resource> confs = Simantics.getSession().syncRequest(new Read<Collection<Resource>>() {\r
+                Collection<Resource> confs = session.syncRequest((ReadGraph graph) -> findAllConfigurations(graph, ModelRoot));\r
 \r
-                    @Override\r
-                    public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {\r
-                        return findAllConfigurations(graph, ModelRoot);\r
-                    }\r
+                session.syncRequest((WriteGraph graph) -> {\r
+                    SysdynResource sr = SysdynResource.getInstance(graph);\r
+                    Layer0 L0 = Layer0.getInstance(graph);\r
 \r
+                    for(Resource r : findAllModelsAndModules(graph, ModelRoot)) {\r
+                        if(graph.isInstanceOf(r, sr.SysdynModel)) {\r
+                            graph.deny(r, L0.HasLabel);\r
+                        }\r
+                    }\r
                 });\r
 \r
 \r
@@ -459,7 +463,7 @@ public class ImportUtils {
 \r
         return configurations;\r
     }\r
-\r
+    \r
     private static Collection<Resource> findAllModelsAndModules(ReadGraph graph, Resource modelRoot) throws DatabaseException {\r
         Layer0 L0 = Layer0.getInstance(graph);\r
         SysdynResource sr = SysdynResource.getInstance(graph);\r