]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
refs #5209
authorjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 22 Aug 2014 08:13:43 +0000 (08:13 +0000)
committerjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 22 Aug 2014 08:13:43 +0000 (08:13 +0000)
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

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SaveICHandler.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java

index de7383442f59c7e0ff0d6eea4f7a2c20c32121ef..b11fddffbf24edcf1efe3ae4928f34626a8ad65e 100644 (file)
@@ -25,7 +25,6 @@ import org.simantics.simulation.project.IExperimentManager;
 import org.simantics.sysdyn.manager.SysdynExperiment;\r
 import org.simantics.sysdyn.manager.SysdynExperiments;\r
 import org.simantics.sysdyn.ui.utils.HandlerUtils;\r
-import org.simantics.ui.SimanticsUI;\r
 \r
 public class SaveICHandler extends AbstractHandler {\r
 \r
@@ -34,7 +33,7 @@ public class SaveICHandler extends AbstractHandler {
         HandlerUtils.saveBeforeExperimentRun(event);\r
         \r
         IExperimentManager manager = \r
-            SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+            Simantics.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
         IExperiment experiment = manager.getActiveExperiment();\r
         if(experiment instanceof SysdynExperiment) {\r
             final SysdynExperiment exp = (SysdynExperiment)experiment;\r
@@ -44,7 +43,7 @@ public class SaveICHandler extends AbstractHandler {
                                        @Override\r
                                        public void perform(WriteGraph graph) throws DatabaseException {\r
                                                Variable v = Variables.getVariable(graph, exp.getResource());\r
-                                               SysdynExperiments.saveIC(graph, v, "IC");\r
+                                               SysdynExperiments.saveIC(graph, v);\r
                                        }\r
                                        \r
                                });\r
index b48628f246cc75b0af86664f346e87c0deb53ede..20f90f3c0ed9fa2b44e9fd927de4b8a5a6c60328 100644 (file)
@@ -14,6 +14,7 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
@@ -183,6 +184,13 @@ public class SysdynExperiments {
                        }\r
                }\r
        }\r
+       \r
+       public static Resource saveIC(WriteGraph graph, Variable input) throws DatabaseException {\r
+           Layer0 L0 = Layer0.getInstance(graph);\r
+           Resource model = Variables.getModel(graph, input);\r
+           String name = NameUtils.findFreshName(graph, "IC", model, L0.ConsistsOf);\r
+           return saveIC(graph, input, name);\r
+       }\r
 \r
     public static Resource saveIC(WriteGraph graph, Variable input, String name) throws DatabaseException {\r
         graph.markUndoPoint();\r