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
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