]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@17142 ac1ea38d-2e2b...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 12 Aug 2010 09:37:15 +0000 (09:37 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 12 Aug 2010 09:37:15 +0000 (09:37 +0000)
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewExperimentNodeHandler.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

index 3b101a203d722e0056e6a563b77150bcfd456671..146162610e575685d2c648872fcd6e2268f40572 100644 (file)
@@ -33,10 +33,13 @@ public class NewExperimentNodeHandler extends AbstractHandler {
             public void perform(WriteGraph g) throws DatabaseException {\r
                 Builtins b = g.getBuiltins();\r
                 Resource report = GraphUtils.create2(g, b.Report,  b.HasDocumentation, "===Report===");\r
+                \r
+                String name = GraphUtils.findFreshName(g, "Experiment", model, b.ConsistsOf, "%s%d");\r
+                \r
                 @SuppressWarnings("unused")\r
                 Resource experiment = GraphUtils.create2(g, b.Experiment,\r
-                        b.HasName, "Experiment",\r
-                        b.HasLabel, "Experiment",\r
+                        b.HasName, name,\r
+                        b.HasLabel, name,\r
                         b.HasReportFactory, report,\r
                         b.PartOf, model);\r
             }\r
index b4c6265c68738b63fb299d23f4480aeec1d86160..43d4744321beeba9c5a4a3906d7937b70e1f248c 100644 (file)
@@ -33,9 +33,11 @@ public class NewModelHandler extends AbstractHandler {
                 ModelingResources mr = ModelingResources.getInstance(g);\r
                 ModelingUtils mu = new ModelingUtils(g);\r
                 \r
+                String modelName = GraphUtils.findFreshName(g, "Model", SimanticsUI.getProject().get(), b.ConsistsOf, "%s%d");\r
+                \r
                 Resource model = g.newResource();\r
-                g.claimValue(model, b.HasName, "Model1");\r
-                g.claimValue(model, b.HasLabel, "Model1");\r
+                g.claimValue(model, b.HasName, modelName);\r
+                g.claimValue(model, b.HasLabel, modelName);\r
                 g.claim(model, b.InstanceOf, sr.SysdynModel);\r
                 g.claim(model, b.PartOf, SimanticsUI.getProject().get());\r
                 \r
@@ -48,9 +50,8 @@ public class NewModelHandler extends AbstractHandler {
                 Resource conf = GraphUtils.create2(g, \r
                         sr.Configuration,\r
                         b.PartOf, model,\r
-                        b.HasName, "Configuration",\r
-                        sr.HasStartTime, 0.0,\r
-                        sr.HasStopTime, 10.0);\r
+                        b.HasName, modelName+"Configuration"\r
+                        );\r
 \r
                 g.claim(conf, mr.CompositeToDiagram, diagram);\r
                 g.claim(model, b.HasConfiguration, conf);\r
@@ -61,7 +62,7 @@ public class NewModelHandler extends AbstractHandler {
                 \r
                 Resource report = GraphUtils.create2(g, mu.b.Report,  mu.b.HasDocumentation, "===Report===");\r
 \r
-                Resource experiment = GraphUtils.create2(g, mu.b.Experiment,\r
+                GraphUtils.create2(g, mu.b.Experiment,\r
                         mu.b.HasName, "Experiment",\r
                         mu.b.HasLabel, "Experiment",\r
                         mu.b.HasReportFactory, report,\r
index cd1484ed4d75fc4267db7badce56321ea8f0a4d9..8145cd07c68470c68c83bb4bc8049d8540014acd 100644 (file)
@@ -39,8 +39,10 @@ public class NewModuleNodeHandler extends AbstractHandler {
                 SysdynResource sr = SysdynResource.getInstance(g);\r
                 ModelingUtils mu = new ModelingUtils(g);\r
                 \r
+                String name = GraphUtils.findFreshName(g, "Module type", model, mu.b.ConsistsOf, "%s %d");\r
+                \r
                 Resource moduleType = g.newResource();\r
-                g.claimValue(moduleType, mu.b.HasName, "New Module Type");\r
+                g.claimValue(moduleType, mu.b.HasName, name);\r
                 g.claim(moduleType, mu.b.Inherits, sr.Module);\r
                 g.claim(moduleType, mu.b.PartOf, model);\r
                 \r
@@ -54,15 +56,16 @@ public class NewModuleNodeHandler extends AbstractHandler {
                 \r
                 Resource configuration = GraphUtils.create2(g, \r
                         sr.Configuration,\r
-                        mu.b.HasName, "ModuuliConffi",\r
-                        mu.mr.CompositeToDiagram, diagram);\r
+                        mu.b.HasName, name.trim().replace(" ", ""),\r
+                        mu.mr.CompositeToDiagram, diagram,\r
+                        mu.b.PartOf, model);\r
                 \r
                 g.claim(moduleType, mu.sr.IsDefinedBy , configuration);\r
                 \r
                 \r
                 Resource moduleSymbol = g.newResource();\r
-                g.claimValue(moduleSymbol, mu.b.HasName, "ModuuliSymboli");\r
-                g.claimValue(moduleSymbol, mu.b.HasLabel, "ModuuliSymboliLabel");\r
+                g.claimValue(moduleSymbol, mu.b.HasName, name + " Symbol");\r
+                g.claimValue(moduleSymbol, mu.b.HasLabel, name + " SymbolLabel");\r
                 g.claim(moduleSymbol, mu.b.Inherits, sr.ModuleSymbol);\r
                 g.claim(moduleSymbol, mu.mr.SymbolToComponentType, moduleType);\r
                 \r