]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
If simulation turned back on, simulate to apply any changes
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 23 Feb 2010 15:24:23 +0000 (15:24 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 23 Feb 2010 15:24:23 +0000 (15:24 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@14358 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/actions/ToggleSimulation.java

index 23f4e1d7d9e7559787c2cd42f6cdfe4d080ff830..1b55968ea41b6e035f04968243c9f8bbc1677558 100644 (file)
@@ -5,11 +5,17 @@ import org.eclipse.core.commands.Command;
 import org.eclipse.core.commands.ExecutionEvent;\r
 import org.eclipse.core.commands.ExecutionException;\r
 import org.eclipse.core.commands.State;\r
+import org.eclipse.ui.IEditorInput;\r
+import org.eclipse.ui.IEditorPart;\r
 import org.eclipse.ui.PlatformUI;\r
 import org.eclipse.ui.commands.ICommandService;\r
+import org.simantics.sysdyn.manager.SysdynModel;\r
+import org.simantics.sysdyn.manager.SysdynModelManager;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.workbench.ResourceEditorInput;\r
 \r
 public class ToggleSimulation extends AbstractHandler {\r
-    \r
+\r
     public static final String COMMAND = "org.simantics.sysdyn.ui.simulate";\r
     public static final String STATE = "org.simantics.sysdyn.ui.simulate.state";\r
 \r
@@ -21,6 +27,17 @@ public class ToggleSimulation extends AbstractHandler {
         Boolean value = (Boolean) state.getValue();\r
         value = !value;\r
         state.setValue(value);\r
+        // If turned back on, simulate to apply any changes\r
+        if(value) {\r
+            IEditorPart editor = \r
+                PlatformUI.getWorkbench()\r
+                .getActiveWorkbenchWindow().getActivePage().getActiveEditor();\r
+            IEditorInput input =  editor.getEditorInput();\r
+            ResourceEditorInput rei = (ResourceEditorInput) input;\r
+            SysdynModelManager sdm = SysdynModelManager.getInstance(SimanticsUI.getSession());\r
+            SysdynModel model = sdm.getModel(rei.getResource());\r
+            model.domainModified();\r
+        }\r
         return null;\r
     }\r
 \r