From: lempinen Date: Wed, 25 Aug 2010 07:32:54 +0000 (+0000) Subject: git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@17518 ac1ea38d-2e2b... X-Git-Tag: simantics-1.2.0~81 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=5cc7cd890d8820ddd08e3696a8656293d3c4d76a;p=simantics%2Fsysdyn.git git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@17518 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModelNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModelNode.java index 7ced9908..ad0a5f54 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModelNode.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModelNode.java @@ -7,20 +7,64 @@ import org.simantics.browsing.ui.common.node.IModifiableNode; import org.simantics.browsing.ui.content.Labeler.Modifier; import org.simantics.browsing.ui.graph.impl.LabelModifier; import org.simantics.db.Builtins; +import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; import org.simantics.db.common.request.WriteRequest; import org.simantics.db.exception.CancelTransactionException; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.procedure.Listener; +import org.simantics.db.request.Read; +import org.simantics.simulation.ontology.SimulationResource; import org.simantics.sysdyn.SysdynResource; import org.simantics.ui.SimanticsUI; import org.simantics.utils.ui.ExceptionUtils; public class ModelNode extends AbstractNode implements IDeletableNode, IModifiableNode { + Listener configurationNameSynchronizer; + private boolean disposed = false; public ModelNode(Resource resource) { super(resource); + + // Not the best solution for name sync + configurationNameSynchronizer = new Listener() { + + @Override + public void execute(final String result) { + SimanticsUI.getSession().asyncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + Builtins b = graph.getBuiltins(); + SimulationResource sim = SimulationResource.getInstance(graph); + Resource configuration = graph.getPossibleObject(data, sim.HasConfiguration); + graph.claimValue(configuration, b.HasLabel, result); + } + }); + } + + @Override + public void exception(Throwable t) { + t.printStackTrace(); + } + + @Override + public boolean isDisposed() { + return disposed; + } + }; + + SimanticsUI.getSession().asyncRequest(new Read() { + + @Override + public String perform(ReadGraph graph) throws DatabaseException { + Builtins b = graph.getBuiltins(); + return graph.getRelatedValue(data, b.HasLabel); + } + + }, configurationNameSynchronizer); } @Override @@ -40,6 +84,7 @@ public class ModelNode extends AbstractNode implements IDeletableNode, @Override public void delete() throws DeleteException { + disposed = true; try { SimanticsUI.getSession().syncRequest(new WriteRequest() { @Override diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModuleTypeNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModuleTypeNode.java index 0e024004..bb4890fb 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModuleTypeNode.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModuleTypeNode.java @@ -17,6 +17,7 @@ import org.simantics.db.common.request.WriteRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.ManyObjectsForFunctionalRelationException; import org.simantics.db.exception.ServiceException; +import org.simantics.db.procedure.Listener; import org.simantics.db.request.Read; import org.simantics.modeling.ModelingResources; import org.simantics.simulation.ontology.SimulationResource; @@ -25,8 +26,55 @@ import org.simantics.ui.SimanticsUI; public class ModuleTypeNode extends AbstractNode implements IDeletableNode, IModifiableNode { + + Listener configurationNameSynchronizer; + private boolean disposed = false; + public ModuleTypeNode(Resource resource) { super(resource); + + // Not the best solution for name sync + configurationNameSynchronizer = new Listener() { + + @Override + public void execute(final String result) { + SimanticsUI.getSession().asyncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + Builtins b = graph.getBuiltins(); + ModelingResources mr = ModelingResources.getInstance(graph); + StructuralResource2 sr2 = StructuralResource2.getInstance(graph); + Resource type = graph.getPossibleObject(data, mr.SymbolToComponentType); + Resource configuration = graph.getPossibleObject(type, sr2.IsDefinedBy); + graph.claimValue(configuration, b.HasLabel, result); + } + }); + } + + @Override + public void exception(Throwable t) { + t.printStackTrace(); + } + + @Override + public boolean isDisposed() { + return disposed; + } + }; + + SimanticsUI.getSession().asyncRequest(new Read() { + + @Override + public String perform(ReadGraph graph) throws DatabaseException { + Builtins b = graph.getBuiltins(); + ModelingResources mr = ModelingResources.getInstance(graph); + Resource type = graph.getPossibleObject(data, mr.SymbolToComponentType); + return graph.getRelatedValue(type, b.HasName); + } + + }, configurationNameSynchronizer); + } @Override @@ -63,6 +111,7 @@ public class ModuleTypeNode extends AbstractNode implements IDeletable @Override public void delete() throws DeleteException { + disposed = true; try { SimanticsUI.getSession().syncRequest(new WriteRequest() { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModelHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModelHandler.java index ba1b3882..5dcf74c5 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModelHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModelHandler.java @@ -50,7 +50,7 @@ public class NewModelHandler extends AbstractHandler { Resource conf = GraphUtils.create2(g, sr.Configuration, b.PartOf, model, - b.HasName, modelName+"Configuration" + b.HasName, modelName ); g.claim(conf, mr.CompositeToDiagram, diagram); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java index e08c29da..8ee3f6e0 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java @@ -65,7 +65,7 @@ public class NewModuleNodeHandler extends AbstractHandler { Resource moduleSymbol = g.newResource(); g.claimValue(moduleSymbol, mu.b.HasName, name + " Symbol"); - g.claimValue(moduleSymbol, mu.b.HasLabel, name + " SymbolLabel"); + g.claimValue(moduleSymbol, mu.b.HasLabel, name); g.claim(moduleSymbol, mu.b.Inherits, sr.ModuleSymbol); g.claim(moduleSymbol, mu.mr.SymbolToComponentType, moduleType); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java index cc061e97..8767d3d8 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java @@ -32,8 +32,8 @@ public class ConfigurationTab extends PropertyTabContributorImpl { label.setText("Name"); TrackedText name = new TrackedText(composite, support, SWT.BORDER); - name.setTextFactory(new StringPropertyFactory(Builtins.URIs.HasName)); - name.addModifyListener(new StringPropertyModifier(context, Builtins.URIs.HasName)); + name.setTextFactory(new StringPropertyFactory(Builtins.URIs.HasLabel)); + name.addModifyListener(new StringPropertyModifier(context, Builtins.URIs.HasLabel)); name.setInputValidator(new IInputValidator() { @Override diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java index ad7a0e3a..2776d5b6 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java @@ -69,10 +69,11 @@ public class ResourceSelectionProcessor implements SelectionProcessor