]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Avoid extra write transactions when opening Plant3D editor 27/4127/1
authorReino Ruusu <reino.ruusu@semantum.fi>
Tue, 21 Apr 2020 15:29:01 +0000 (18:29 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Tue, 21 Apr 2020 17:07:51 +0000 (17:07 +0000)
gitlab #122

Change-Id: I2e20e8e460a3d7e8d4b0fb786d77166fb8c9dbd5
(cherry picked from commit d7128a534435161910ce5865db60c7874091df74)

org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java

index af7a67f5f96f8e21221c8197c81179fb6b4b0a5e..b4448e670749caef8e30b8685d33422eb922cb55 100644 (file)
@@ -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<vtkProp3D> 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<vtkProp3D> props = new ArrayList<>();
+                                               collectProps(rootNode, props);
+                                               fitToWindow(props);
+                                       }
+                               });
                        }
                });
-               
+
        }
 
+       /**
+        * This can be overridden by clients to perform extra initialization tasks
+        */
+       protected void onEditorInitializationComplete() {
+       }
+       
        protected IMappingSchema<Resource, INode> getSchema(ReadGraph graph) throws DatabaseException {
                IMappingSchema<Resource,INode> schema = SchemaBuilder.getSchema(graph);
                return schema;