From 783fa64557dda496b20c53088b343cf251e6b83e Mon Sep 17 00:00:00 2001 From: lempinen Date: Thu, 12 Aug 2010 09:37:15 +0000 Subject: [PATCH] git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@17142 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../ui/handlers/NewExperimentNodeHandler.java | 7 +++++-- .../sysdyn/ui/handlers/NewModelHandler.java | 13 +++++++------ .../sysdyn/ui/handlers/NewModuleNodeHandler.java | 13 ++++++++----- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewExperimentNodeHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewExperimentNodeHandler.java index 3b101a20..14616261 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewExperimentNodeHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewExperimentNodeHandler.java @@ -33,10 +33,13 @@ public class NewExperimentNodeHandler extends AbstractHandler { public void perform(WriteGraph g) throws DatabaseException { Builtins b = g.getBuiltins(); Resource report = GraphUtils.create2(g, b.Report, b.HasDocumentation, "===Report==="); + + String name = GraphUtils.findFreshName(g, "Experiment", model, b.ConsistsOf, "%s%d"); + @SuppressWarnings("unused") Resource experiment = GraphUtils.create2(g, b.Experiment, - b.HasName, "Experiment", - b.HasLabel, "Experiment", + b.HasName, name, + b.HasLabel, name, b.HasReportFactory, report, b.PartOf, model); } 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 b4c6265c..43d47443 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 @@ -33,9 +33,11 @@ public class NewModelHandler extends AbstractHandler { ModelingResources mr = ModelingResources.getInstance(g); ModelingUtils mu = new ModelingUtils(g); + String modelName = GraphUtils.findFreshName(g, "Model", SimanticsUI.getProject().get(), b.ConsistsOf, "%s%d"); + Resource model = g.newResource(); - g.claimValue(model, b.HasName, "Model1"); - g.claimValue(model, b.HasLabel, "Model1"); + g.claimValue(model, b.HasName, modelName); + g.claimValue(model, b.HasLabel, modelName); g.claim(model, b.InstanceOf, sr.SysdynModel); g.claim(model, b.PartOf, SimanticsUI.getProject().get()); @@ -48,9 +50,8 @@ public class NewModelHandler extends AbstractHandler { Resource conf = GraphUtils.create2(g, sr.Configuration, b.PartOf, model, - b.HasName, "Configuration", - sr.HasStartTime, 0.0, - sr.HasStopTime, 10.0); + b.HasName, modelName+"Configuration" + ); g.claim(conf, mr.CompositeToDiagram, diagram); g.claim(model, b.HasConfiguration, conf); @@ -61,7 +62,7 @@ public class NewModelHandler extends AbstractHandler { Resource report = GraphUtils.create2(g, mu.b.Report, mu.b.HasDocumentation, "===Report==="); - Resource experiment = GraphUtils.create2(g, mu.b.Experiment, + GraphUtils.create2(g, mu.b.Experiment, mu.b.HasName, "Experiment", mu.b.HasLabel, "Experiment", mu.b.HasReportFactory, report, 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 cd1484ed..8145cd07 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 @@ -39,8 +39,10 @@ public class NewModuleNodeHandler extends AbstractHandler { SysdynResource sr = SysdynResource.getInstance(g); ModelingUtils mu = new ModelingUtils(g); + String name = GraphUtils.findFreshName(g, "Module type", model, mu.b.ConsistsOf, "%s %d"); + Resource moduleType = g.newResource(); - g.claimValue(moduleType, mu.b.HasName, "New Module Type"); + g.claimValue(moduleType, mu.b.HasName, name); g.claim(moduleType, mu.b.Inherits, sr.Module); g.claim(moduleType, mu.b.PartOf, model); @@ -54,15 +56,16 @@ public class NewModuleNodeHandler extends AbstractHandler { Resource configuration = GraphUtils.create2(g, sr.Configuration, - mu.b.HasName, "ModuuliConffi", - mu.mr.CompositeToDiagram, diagram); + mu.b.HasName, name.trim().replace(" ", ""), + mu.mr.CompositeToDiagram, diagram, + mu.b.PartOf, model); g.claim(moduleType, mu.sr.IsDefinedBy , configuration); Resource moduleSymbol = g.newResource(); - g.claimValue(moduleSymbol, mu.b.HasName, "ModuuliSymboli"); - g.claimValue(moduleSymbol, mu.b.HasLabel, "ModuuliSymboliLabel"); + g.claimValue(moduleSymbol, mu.b.HasName, name + " Symbol"); + g.claimValue(moduleSymbol, mu.b.HasLabel, name + " SymbolLabel"); g.claim(moduleSymbol, mu.b.Inherits, sr.ModuleSymbol); g.claim(moduleSymbol, mu.mr.SymbolToComponentType, moduleType); -- 2.47.1