From: jsimomaa Date: Fri, 22 Aug 2014 08:13:43 +0000 (+0000) Subject: refs #5209 X-Git-Tag: v1.29.0~219 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=ba6f13effe9b4e94596f7a57ca74b8d89431b0bc;p=simantics%2Fsysdyn.git refs #5209 SaveICHandler saves new InitialConditions with duplicate name "IC" git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@30119 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SaveICHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SaveICHandler.java index de738344..b11fddff 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SaveICHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SaveICHandler.java @@ -25,7 +25,6 @@ import org.simantics.simulation.project.IExperimentManager; import org.simantics.sysdyn.manager.SysdynExperiment; import org.simantics.sysdyn.manager.SysdynExperiments; import org.simantics.sysdyn.ui.utils.HandlerUtils; -import org.simantics.ui.SimanticsUI; public class SaveICHandler extends AbstractHandler { @@ -34,7 +33,7 @@ public class SaveICHandler extends AbstractHandler { HandlerUtils.saveBeforeExperimentRun(event); IExperimentManager manager = - SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER); + Simantics.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER); IExperiment experiment = manager.getActiveExperiment(); if(experiment instanceof SysdynExperiment) { final SysdynExperiment exp = (SysdynExperiment)experiment; @@ -44,7 +43,7 @@ public class SaveICHandler extends AbstractHandler { @Override public void perform(WriteGraph graph) throws DatabaseException { Variable v = Variables.getVariable(graph, exp.getResource()); - SysdynExperiments.saveIC(graph, v, "IC"); + SysdynExperiments.saveIC(graph, v); } }); diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java index b48628f2..20f90f3c 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java @@ -14,6 +14,7 @@ import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; import org.simantics.db.common.request.ObjectsWithType; +import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.util.Layer0Utils; import org.simantics.db.layer0.util.RemoverUtil; @@ -183,6 +184,13 @@ public class SysdynExperiments { } } } + + public static Resource saveIC(WriteGraph graph, Variable input) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(graph); + Resource model = Variables.getModel(graph, input); + String name = NameUtils.findFreshName(graph, "IC", model, L0.ConsistsOf); + return saveIC(graph, input, name); + } public static Resource saveIC(WriteGraph graph, Variable input, String name) throws DatabaseException { graph.markUndoPoint();