From: lempinen Date: Tue, 23 Feb 2010 15:24:23 +0000 (+0000) Subject: If simulation turned back on, simulate to apply any changes X-Git-Tag: simantics-1.0~62 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=4d023b1477e64e3168ccaf87848ce27317aae9d1;p=simantics%2Fsysdyn.git If simulation turned back on, simulate to apply any changes git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@14358 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/actions/ToggleSimulation.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/actions/ToggleSimulation.java index 23f4e1d7..1b55968e 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/actions/ToggleSimulation.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/actions/ToggleSimulation.java @@ -5,11 +5,17 @@ import org.eclipse.core.commands.Command; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.State; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.commands.ICommandService; +import org.simantics.sysdyn.manager.SysdynModel; +import org.simantics.sysdyn.manager.SysdynModelManager; +import org.simantics.ui.SimanticsUI; +import org.simantics.ui.workbench.ResourceEditorInput; public class ToggleSimulation extends AbstractHandler { - + public static final String COMMAND = "org.simantics.sysdyn.ui.simulate"; public static final String STATE = "org.simantics.sysdyn.ui.simulate.state"; @@ -21,6 +27,17 @@ public class ToggleSimulation extends AbstractHandler { Boolean value = (Boolean) state.getValue(); value = !value; state.setValue(value); + // If turned back on, simulate to apply any changes + if(value) { + IEditorPart editor = + PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage().getActiveEditor(); + IEditorInput input = editor.getEditorInput(); + ResourceEditorInput rei = (ResourceEditorInput) input; + SysdynModelManager sdm = SysdynModelManager.getInstance(SimanticsUI.getSession()); + SysdynModel model = sdm.getModel(rei.getResource()); + model.domainModified(); + } return null; }