]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Implemented DiagramEditor resource disposal/reinitialization based on Eclipse IPartLi...
authorlehtonen <lehtonen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 13 Feb 2012 07:52:33 +0000 (07:52 +0000)
committerlehtonen <lehtonen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 13 Feb 2012 07:52:33 +0000 (07:52 +0000)
partHidden/partVisible callbacks.

The important developer-visible changes are:
* Diagram editor  should now use the class org.simantics.modeling.ui.diagramEditor.DiagramEditor as the editor class.
* DiagramEditor extension class attributes require a *viewer=clazz* argument after the *org.simantics.modeling.ui.diagramEditor.DiagramEditor:* class string, where clazz is something inherited from *org.simantics.modeling.ui.diagramEditor.DiagramViewer.
* DiagramViewer.getInputValidator() is now public
* Eclipse command handlers or any other code comparing EditorPart instances to *org.simantics.modeling.ui.diagramEditor.DiagramViewer* must be changed to compare to *org.simantics.modeling.ui.diagramEditor.DiagramEditor* and get the viewer through DiagramEditor.getViewer().

fixes #3213

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@24212 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ShowModuleHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/listeners/SysdynPlaybackExperimentListener.java

index f5d42d97d8ca053b18e0964b637019a84e1c75ef..7a9e43c2d7f86e0c6dddc46a1e8519df0afd399e 100644 (file)
@@ -16,7 +16,7 @@
    <extension\r
          point="org.eclipse.ui.editors">\r
       <editor\r
-            class="org.simantics.sysdyn.ui.editor.DiagramViewer"\r
+            class="org.simantics.modeling.ui.diagramEditor.DiagramEditor:viewer=org.simantics.sysdyn.ui.editor.DiagramViewer"\r
             default="false"\r
             icon="platform:/plugin/com.famfamfam.silk/icons/plugin.png"\r
             id="org.simantics.sysdyn.ui.diagramViewer"\r
index 5a35e5385de562564c281dbc46a40296cbadee32..b2478e0c2e6bf95111d0d8a80b949bbf4d829803 100644 (file)
@@ -15,6 +15,7 @@ import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;\r
 import org.eclipse.core.commands.ExecutionException;\r
 import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ui.IEditorPart;\r
 import org.eclipse.ui.PartInitException;\r
 import org.eclipse.ui.PlatformUI;\r
 import org.eclipse.ui.handlers.HandlerUtil;\r
@@ -29,6 +30,7 @@ import org.simantics.db.layer0.variable.Variables;
 import org.simantics.diagram.stubs.DiagramResource;\r
 import org.simantics.modeling.ComponentUtils;\r
 import org.simantics.modeling.ModelingResources;\r
+import org.simantics.modeling.ui.diagramEditor.DiagramEditor;\r
 import org.simantics.structural.stubs.StructuralResource2;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.editor.DiagramViewer;\r
@@ -47,7 +49,12 @@ public class ShowModuleHandler extends AbstractHandler {
                \r
                ISelection s = HandlerUtil.getCurrentSelectionChecked(event);\r
                final Resource resources[] = ResourceAdaptionUtils.toResources(s);\r
-               final DiagramViewer viewer = (DiagramViewer)HandlerUtil.getActiveEditor(event);\r
+               IEditorPart editor = (IEditorPart)HandlerUtil.getActiveEditor(event);\r
+               if (!(editor instanceof DiagramEditor))\r
+                       return null;\r
+               final DiagramViewer viewer = (DiagramViewer) ((DiagramEditor) editor).getViewer();\r
+               if (viewer == null)\r
+                       return null;\r
                \r
                SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
                        \r
index 8c678caca80bf870328d8c02e05c51596c69427d..a0c89f82dd2818e15859b727cf76a505bce46efa 100644 (file)
@@ -29,6 +29,7 @@ import org.simantics.db.service.VirtualGraphSupport;
 import org.simantics.diagram.profile.Profiles;\r
 import org.simantics.diagram.stubs.DiagramResource;\r
 import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ui.diagramEditor.DiagramEditor;\r
 import org.simantics.project.IProject;\r
 import org.simantics.simulation.experiment.ExperimentState;\r
 import org.simantics.simulation.experiment.IExperiment;\r
@@ -148,13 +149,16 @@ public class SysdynPlaybackExperimentListener implements IExperimentListener {
         for(IWorkbenchPage page : pages) {\r
             for(IEditorReference reference : page.getEditorReferences()) {\r
                 IEditorPart iep = reference.getEditor(false);\r
-                if(iep instanceof DiagramViewer) {\r
-                    DiagramViewer viewer = (DiagramViewer) iep;\r
-                    Resource runtime = viewer.getRuntime();\r
-                    String modelUri = viewer.getResourceInput2().getModelURI();\r
-                    DiagramInfo info = new DiagramInfo();\r
-                    info.modelURI = modelUri;\r
-                    runtimeDiagramsAndModelUris.put(runtime, info);\r
+                if(iep instanceof DiagramEditor) {\r
+                    DiagramEditor editor = (DiagramEditor) iep;\r
+                    if (editor.getViewer() instanceof DiagramViewer) {\r
+                        DiagramViewer viewer = (DiagramViewer) editor.getViewer();\r
+                        Resource runtime = viewer.getRuntime();\r
+                        String modelUri = viewer.getResourceInput2().getModelURI();\r
+                        DiagramInfo info = new DiagramInfo();\r
+                        info.modelURI = modelUri;\r
+                        runtimeDiagramsAndModelUris.put(runtime, info);\r
+                    }\r
                 }\r
             }\r
         }\r