From d7128a534435161910ce5865db60c7874091df74 Mon Sep 17 00:00:00 2001 From: Reino Ruusu Date: Tue, 21 Apr 2020 18:29:01 +0300 Subject: [PATCH] Avoid extra write transactions when opening Plant3D editor gitlab #122 Change-Id: I2e20e8e460a3d7e8d4b0fb786d77166fb8c9dbd5 --- .../plant3d/editor/Plant3DEditor.java | 58 +++++++++++-------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java b/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java index af7a67f5..b4448e67 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java @@ -304,36 +304,46 @@ public class Plant3DEditor extends ResourceEditorPart { @Override public void run() { + nodeMap.setChangeTracking(false); nodeMap.populate(); + nodeMap.setChangeTracking(true); panel.addListener(new RenderListener() { - - @Override - public void preRender() { - - } - - @Override - public void postRender() { - panel.removeListener(this); - - try { - P3DUtil.finalizeDBLoad2(rootNode); - if (nodeMap.isRangeModified()); - nodeMap.commit("Load sync"); - } catch (Exception e) { - ExceptionUtils.logAndShowError("Failed to load model correctly", e); - } - - List props = new ArrayList<>(); - collectProps(rootNode, props); - fitToWindow(props); - } - }); + + @Override + public void preRender() { + + } + + @Override + public void postRender() { + panel.removeListener(this); + + try { + P3DUtil.finalizeDBLoad2(rootNode); + if (nodeMap.getMapping().isRangeModified()) + nodeMap.commit("Load sync"); + } catch (Exception e) { + ExceptionUtils.logAndShowError("Failed to load model correctly", e); + } + + onEditorInitializationComplete(); + + List props = new ArrayList<>(); + collectProps(rootNode, props); + fitToWindow(props); + } + }); } }); - + } + /** + * This can be overridden by clients to perform extra initialization tasks + */ + protected void onEditorInitializationComplete() { + } + protected IMappingSchema getSchema(ReadGraph graph) throws DatabaseException { IMappingSchema schema = SchemaBuilder.getSchema(graph); return schema; -- 2.47.1