From: jsimomaa Date: Sat, 16 Nov 2019 07:45:43 +0000 (+0200) Subject: Introduce new DiagramViewer.getRuntimeFromManager() X-Git-Tag: v1.43.0~136^2~28 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F44%2F3544%2F2;p=simantics%2Fplatform.git Introduce new DiagramViewer.getRuntimeFromManager() * The original DiagramViewer.getRuntime() returns cached version of the runtime diagram resource gitlab #416 Change-Id: Id2723f5deb94cdba15e815229d9a1931482ace16 --- diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewer.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewer.java index a0f504030..409aecbea 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewer.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewer.java @@ -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 getInputValidator() { return INPUT_VALIDATOR; }