]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Check in ToggleSimulation that the editor is actually available.
authorlehtonen <lehtonen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 16 Mar 2010 17:23:28 +0000 (17:23 +0000)
committerlehtonen <lehtonen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 16 Mar 2010 17:23:28 +0000 (17:23 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@14994 ac1ea38d-2e2b-0410-8846-a27921b304fc

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

index 4c8e03fffdb5f0662e619da861965f1c340f71b6..ff731f51935f702aa7305b2c3254daa653fc1be4 100644 (file)
@@ -22,6 +22,7 @@ import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.commands.ICommandService;\r
 import org.simantics.sysdyn.manager.SysdynModel;\r
 import org.simantics.sysdyn.manager.SysdynModelManager;\r
+import org.simantics.sysdyn.ui.editor.SysdynDiagramEditor;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.workbench.ResourceEditorInput;\r
 \r
@@ -40,14 +41,16 @@ public class ToggleSimulation extends AbstractHandler {
         state.setValue(value);\r
         // If turned back on, simulate to apply any changes\r
         if(value) {\r
-            IEditorPart editor = \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
+            if (editor instanceof SysdynDiagramEditor) {\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
         }\r
         return null;\r
     }\r