]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@17518 ac1ea38d-2e2b...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 25 Aug 2010 07:32:54 +0000 (07:32 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 25 Aug 2010 07:32:54 +0000 (07:32 +0000)
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModelNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModuleTypeNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModelHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ShortcutTabWidget.java

index 7ced9908fa9ca1745394f32867949ff5e679aab1..ad0a5f54c578c0f5098765898fb56b4a335ee3b2 100644 (file)
@@ -7,20 +7,64 @@ import org.simantics.browsing.ui.common.node.IModifiableNode;
 import org.simantics.browsing.ui.content.Labeler.Modifier;\r
 import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
 import org.simantics.db.Builtins;\r
+import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.exception.CancelTransactionException;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.procedure.Listener;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.utils.ui.ExceptionUtils;\r
 \r
 public class ModelNode extends AbstractNode<Resource> implements IDeletableNode, IModifiableNode {\r
 \r
+       Listener<String> configurationNameSynchronizer;\r
+       private boolean disposed = false;\r
        \r
     public ModelNode(Resource resource) {\r
         super(resource);\r
+               \r
+        // Not the best solution for name sync\r
+        configurationNameSynchronizer = new Listener<String>() {\r
+\r
+               @Override\r
+                       public void execute(final String result) {\r
+                               SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+                                       \r
+                                       @Override\r
+                                       public void perform(WriteGraph graph) throws DatabaseException {\r
+                                               Builtins b = graph.getBuiltins();\r
+                                               SimulationResource sim = SimulationResource.getInstance(graph);\r
+                                               Resource configuration = graph.getPossibleObject(data, sim.HasConfiguration);\r
+                                               graph.claimValue(configuration, b.HasLabel, result);\r
+                                       }\r
+                               });\r
+                       }\r
+\r
+                       @Override\r
+                       public void exception(Throwable t) {\r
+                               t.printStackTrace();\r
+                       }\r
+\r
+                       @Override\r
+                       public boolean isDisposed() {\r
+                               return disposed;\r
+                       }\r
+               };\r
+               \r
+        SimanticsUI.getSession().asyncRequest(new Read<String>() {\r
+\r
+                       @Override\r
+                       public String perform(ReadGraph graph) throws DatabaseException {\r
+                               Builtins b = graph.getBuiltins();\r
+                               return graph.getRelatedValue(data, b.HasLabel);\r
+                       }\r
+               \r
+        }, configurationNameSynchronizer);\r
     }\r
 \r
     @Override\r
@@ -40,6 +84,7 @@ public class ModelNode extends AbstractNode<Resource> implements IDeletableNode,
 \r
     @Override\r
     public void delete() throws DeleteException {\r
+       disposed = true;\r
         try {\r
             SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
                 @Override\r
index 0e024004e79acb501dcd0fb4c4fd9ac87c2d075d..bb4890fb04baad904cf1c96572d6fc4326ed6edc 100644 (file)
@@ -17,6 +17,7 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
 import org.simantics.db.exception.ServiceException;\r
+import org.simantics.db.procedure.Listener;\r
 import org.simantics.db.request.Read;\r
 import org.simantics.modeling.ModelingResources;\r
 import org.simantics.simulation.ontology.SimulationResource;\r
@@ -25,8 +26,55 @@ import org.simantics.ui.SimanticsUI;
 \r
 public class ModuleTypeNode extends AbstractNode<Resource> implements IDeletableNode, IModifiableNode {\r
 \r
+       \r
+       Listener<String> configurationNameSynchronizer;\r
+       private boolean disposed = false;\r
+       \r
     public ModuleTypeNode(Resource resource) {\r
         super(resource);\r
+        \r
+        // Not the best solution for name sync\r
+        configurationNameSynchronizer = new Listener<String>() {\r
+\r
+               @Override\r
+                       public void execute(final String result) {\r
+                               SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+                                       \r
+                                       @Override\r
+                                       public void perform(WriteGraph graph) throws DatabaseException {\r
+                                               Builtins b = graph.getBuiltins();\r
+                               ModelingResources mr = ModelingResources.getInstance(graph);\r
+                               StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
+                               Resource type =  graph.getPossibleObject(data, mr.SymbolToComponentType);\r
+                               Resource configuration = graph.getPossibleObject(type, sr2.IsDefinedBy);\r
+                                               graph.claimValue(configuration, b.HasLabel, result);\r
+                                       }\r
+                               });\r
+                       }\r
+\r
+                       @Override\r
+                       public void exception(Throwable t) {\r
+                               t.printStackTrace();\r
+                       }\r
+\r
+                       @Override\r
+                       public boolean isDisposed() {\r
+                               return disposed;\r
+                       }\r
+               };\r
+               \r
+        SimanticsUI.getSession().asyncRequest(new Read<String>() {\r
+\r
+                       @Override\r
+                       public String perform(ReadGraph graph) throws DatabaseException {\r
+                Builtins b = graph.getBuiltins();\r
+                ModelingResources mr = ModelingResources.getInstance(graph);\r
+                Resource type =  graph.getPossibleObject(data, mr.SymbolToComponentType);\r
+                               return graph.getRelatedValue(type, b.HasName);\r
+                       }\r
+               \r
+        }, configurationNameSynchronizer);\r
+        \r
     }\r
 \r
     @Override\r
@@ -63,6 +111,7 @@ public class ModuleTypeNode extends AbstractNode<Resource> implements IDeletable
 \r
     @Override\r
     public void delete() throws DeleteException {\r
+       disposed = true;\r
         try {\r
             SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
 \r
index ba1b388279b3c4d124ac79e9d84012c353c0a6d4..5dcf74c5df804f2da144615a398be0bc12128b4d 100644 (file)
@@ -50,7 +50,7 @@ public class NewModelHandler extends AbstractHandler {
                 Resource conf = GraphUtils.create2(g,\r
                         sr.Configuration,\r
                         b.PartOf, model,\r
-                        b.HasName, modelName+"Configuration"\r
+                        b.HasName, modelName\r
                 );\r
 \r
                 g.claim(conf, mr.CompositeToDiagram, diagram);\r
index e08c29da9f014b6994fcdcfed342b80e4913659d..8ee3f6e0885c777acff60583af1c865c9103f8bd 100644 (file)
@@ -65,7 +65,7 @@ public class NewModuleNodeHandler extends AbstractHandler {
                 \r
                 Resource moduleSymbol = g.newResource();\r
                 g.claimValue(moduleSymbol, mu.b.HasName, name + " Symbol");\r
-                g.claimValue(moduleSymbol, mu.b.HasLabel, name + " SymbolLabel");\r
+                g.claimValue(moduleSymbol, mu.b.HasLabel, name);\r
                 g.claim(moduleSymbol, mu.b.Inherits, sr.ModuleSymbol);\r
                 g.claim(moduleSymbol, mu.mr.SymbolToComponentType, moduleType);\r
                 \r
index cc061e977c1687742194d97e569199719e5622c6..8767d3d831c2170a80f813c33fa8d66e52929082 100644 (file)
@@ -32,8 +32,8 @@ public class ConfigurationTab extends PropertyTabContributorImpl {
         label.setText("Name");\r
         \r
         TrackedText name = new TrackedText(composite, support, SWT.BORDER);\r
-        name.setTextFactory(new StringPropertyFactory(Builtins.URIs.HasName));\r
-        name.addModifyListener(new StringPropertyModifier(context, Builtins.URIs.HasName));\r
+        name.setTextFactory(new StringPropertyFactory(Builtins.URIs.HasLabel));\r
+        name.addModifyListener(new StringPropertyModifier(context, Builtins.URIs.HasLabel));\r
         name.setInputValidator(new IInputValidator() {\r
             \r
             @Override\r
index ad7a0e3ae9de7e9e33c74d8c560a82bcc71eef7c..2776d5b69c5c8279b04b6c9810d146618dfb7707 100644 (file)
@@ -69,10 +69,11 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                         r,\r
                 "Input"));\r
             }\r
-            if (backend.isInstanceOf(r, sr.Configuration) || (backend.isInstanceOf(r, sr.SysdynModel))) {\r
+            Resource represents = backend.getPossibleObject(r, b.Represents);\r
+            if ((represents != null && backend.isInstanceOf(represents, sr.Configuration)) || (backend.isInstanceOf(r, sr.SysdynModel))) {\r
                 Resource model;\r
-                if (backend.isInstanceOf(r, sr.Configuration))\r
-                    model = backend.getPossibleObject(r, SimulationResource.getInstance(backend).IsConfigurationOf);\r
+                if (represents != null)\r
+                    model = backend.getPossibleObject(represents, SimulationResource.getInstance(backend).IsConfigurationOf);\r
                 else\r
                     model = r;\r
                 if (model != null)\r
index d0142956cf1e5722b265c6a6b1423aed755fb55e..1c9fda3488cb7ef483aa75425c8df322ac68197e 100644 (file)
@@ -72,6 +72,9 @@ public class ShortcutTabWidget implements Widget {
         item = new TableItem(functionTable, SWT.NONE);\r
         item.setText("interpolate()");\r
         item.setData("interpolate( x, table)");     \r
+        item = new TableItem(functionTable, SWT.NONE);\r
+        item.setText("delay()");\r
+        item.setData("delay( expression, delayTime)");     \r
         functions.setControl(functionTable);\r
     }\r
 \r