From: Reino Ruusu Date: Tue, 21 Apr 2020 15:29:01 +0000 (+0300) Subject: Avoid extra write transactions when opening Plant3D editor X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F76%2F4176%2F1;p=simantics%2F3d.git Avoid extra write transactions when opening Plant3D editor gitlab #122 Change-Id: I2e20e8e460a3d7e8d4b0fb786d77166fb8c9dbd5 --- 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;