Introduce new DiagramViewer.getRuntimeFromManager() 44/3544/2
authorjsimomaa <jani.simomaa@gmail.com>
Sat, 16 Nov 2019 07:45:43 +0000 (09:45 +0200)
committerJani Simomaa <jani.simomaa@semantum.fi>
Sun, 24 Nov 2019 18:25:29 +0000 (18:25 +0000)
* The original DiagramViewer.getRuntime() returns cached version of the
runtime diagram resource

gitlab #416

Change-Id: Id2723f5deb94cdba15e815229d9a1931482ace16

bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewer.java

index a0f504030675d1b9129a6548550ef524b8f762fe..409aecbea26dc04ef73d9851b5fa31f9eb0eb234 100644 (file)
@@ -236,6 +236,7 @@ public class DiagramViewer
     protected GridSnapAdvisor            snapAdvisor;
 
     private RuntimeDiagramManager        runtimeDiagramManager;
+    private Resource                     runtimeDiagramResourceCache;
     private HasDiagramSourceListener     hasDiagramSourceListener;
 
     /**
@@ -245,11 +246,18 @@ public class DiagramViewer
      */
     protected WorkbenchSelectionProvider selectionProvider;
 
-    public Resource getRuntime() {
+    protected Resource getRuntimeFromManager() {
         RuntimeDiagramManager rtdm = runtimeDiagramManager;
         return (rtdm == null) ? null : rtdm.getRuntimeDiagram();
     }
 
+    public Resource getRuntime() {
+        if (runtimeDiagramResourceCache != null)
+            return runtimeDiagramResourceCache;
+        runtimeDiagramResourceCache = getRuntimeFromManager();
+        return runtimeDiagramResourceCache;
+    }
+
     public ParametrizedRead<IResourceEditorInput, Boolean> getInputValidator() {
         return INPUT_VALIDATOR;
     }