From d38bdbc0a40ea4ec10d6886b4a701ff13db95a26 Mon Sep 17 00:00:00 2001 From: lehtonen Date: Tue, 16 Mar 2010 17:23:28 +0000 Subject: [PATCH] Check in ToggleSimulation that the editor is actually available. git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@14994 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sysdyn/ui/actions/ToggleSimulation.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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 4c8e03ff..ff731f51 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 @@ -22,6 +22,7 @@ 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.sysdyn.ui.editor.SysdynDiagramEditor; import org.simantics.ui.SimanticsUI; import org.simantics.ui.workbench.ResourceEditorInput; @@ -40,14 +41,16 @@ public class ToggleSimulation extends AbstractHandler { state.setValue(value); // If turned back on, simulate to apply any changes if(value) { - IEditorPart editor = + 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(); + if (editor instanceof SysdynDiagramEditor) { + IEditorInput input = editor.getEditorInput(); + ResourceEditorInput rei = (ResourceEditorInput) input; + SysdynModelManager sdm = SysdynModelManager.getInstance(SimanticsUI.getSession()); + SysdynModel model = sdm.getModel(rei.getResource()); + model.domainModified(); + } } return null; } -- 2.47.1