From f6a9e4511441ecd2e9ba50da04645734276c63c2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jani=20M=C3=A4kinen?= Date: Tue, 28 Jul 2020 16:02:21 +0300 Subject: [PATCH] Models have no use for labels, remove gitlab #45 Change-Id: Ia267cbba172a2475c0a2debb3e0d52c937e8275d --- .../sysdyn/ui/properties/ConfigurationTab.java | 5 ++--- .../sysdyn/modelImport/model/Model.java | 1 - .../org/simantics/sysdyn/utils/ModelUtils.java | 1 - .../sysdyn/utils/imports/ImportUtils.java | 16 ++++++++++------ 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/bundles/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java b/bundles/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java index d0703cce..9e41c390 100644 --- a/bundles/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java +++ b/bundles/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java @@ -85,7 +85,6 @@ public class ConfigurationTab extends AdjustableTab { @Override public void applyText(WriteGraph graph, Resource issue, String text) throws DatabaseException { Layer0 l0 = Layer0.getInstance(graph); - graph.claimLiteral(issue, l0.HasLabel, text); String safeName = NameUtils.findFreshName(graph, text, graph.getSingleObject(issue, l0.PartOf), l0.ConsistsOf, "%s%d"); graph.claimLiteral(issue, l0.HasName, safeName); } @@ -103,8 +102,8 @@ public class ConfigurationTab extends AdjustableTab { nameLabel.setText("Name"); name = new TrackedText(composite, support, SWT.BORDER); - name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel)); - name.addModifyListener(new ModelLabelModifier(context, Layer0.URIs.HasLabel)); + name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasName)); + name.addModifyListener(new ModelLabelModifier(context, Layer0.URIs.HasName)); name.setInputValidator(new ModelNameInputValidator(support)); startTimeLabel = new Label(composite, SWT.NONE); diff --git a/bundles/org.simantics.sysdyn/src/org/simantics/sysdyn/modelImport/model/Model.java b/bundles/org.simantics.sysdyn/src/org/simantics/sysdyn/modelImport/model/Model.java index df0f0853..1591219d 100644 --- a/bundles/org.simantics.sysdyn/src/org/simantics/sysdyn/modelImport/model/Model.java +++ b/bundles/org.simantics.sysdyn/src/org/simantics/sysdyn/modelImport/model/Model.java @@ -222,7 +222,6 @@ public class Model implements IWriteableObject { Resource container = graph.getSingleObject(model, l0.PartOf); String freshName = NameUtils.findFreshName(graph, name, container, l0.ConsistsOf, "%s%d"); graph.claimLiteral(model, l0.HasName, freshName, Bindings.STRING); - graph.claimLiteral(model, l0.HasLabel, freshName, Bindings.STRING); // TODO: this must be updated if/when simulation parameters are moved // from model to experiment diff --git a/bundles/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/ModelUtils.java b/bundles/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/ModelUtils.java index e9379fa4..69619a9c 100644 --- a/bundles/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/ModelUtils.java +++ b/bundles/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/ModelUtils.java @@ -75,7 +75,6 @@ public class ModelUtils { sr.SysdynModel, l0.PartOf, project, l0.HasName, modelName, - l0.HasLabel, modelName, L0X.IsActivatedBy, project ); diff --git a/bundles/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/ImportUtils.java b/bundles/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/ImportUtils.java index bfbc6bad..902dbe8a 100644 --- a/bundles/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/ImportUtils.java +++ b/bundles/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/ImportUtils.java @@ -246,13 +246,17 @@ public class ImportUtils { return status; subTask(monitor, "Validate model"); - Collection confs = Simantics.getSession().syncRequest(new Read>() { + Collection confs = session.syncRequest((ReadGraph graph) -> findAllConfigurations(graph, ModelRoot)); - @Override - public Collection perform(ReadGraph graph) throws DatabaseException { - return findAllConfigurations(graph, ModelRoot); - } + session.syncRequest((WriteGraph graph) -> { + SysdynResource sr = SysdynResource.getInstance(graph); + Layer0 L0 = Layer0.getInstance(graph); + for(Resource r : findAllModelsAndModules(graph, ModelRoot)) { + if(graph.isInstanceOf(r, sr.SysdynModel)) { + graph.deny(r, L0.HasLabel); + } + } }); @@ -459,7 +463,7 @@ public class ImportUtils { return configurations; } - + private static Collection findAllModelsAndModules(ReadGraph graph, Resource modelRoot) throws DatabaseException { Layer0 L0 = Layer0.getInstance(graph); SysdynResource sr = SysdynResource.getInstance(graph); -- 2.47.1