]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java
Data corruption on editor startup.
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / editor / Plant3DEditor.java
index 273e1062d15ae6e805fbf1507007000df30a6673..2c94b5daea3fa4d191f7dda53dbc7960f350063d 100644 (file)
@@ -23,6 +23,7 @@ import org.simantics.db.common.request.ReadRequest;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.g3d.scenegraph.IG3DNode;
 import org.simantics.g3d.scenegraph.NodeMap;
+import org.simantics.g3d.scenegraph.RenderListener;
 import org.simantics.g3d.scenegraph.base.INode;
 import org.simantics.g3d.vtk.action.RemoveAction;
 import org.simantics.g3d.vtk.common.HoverHighlighter;
@@ -151,19 +152,25 @@ public class Plant3DEditor extends ResourceEditorPart {
                                @SuppressWarnings({ "rawtypes", "unchecked" })
                                @Override
                                public void run(ReadGraph graph) throws DatabaseException {
+                                   System.out.println("START PLANT3D LOAD");
                                        PipingRules.setEnabled(false);
                                        IMappingSchema<Resource, Object> schema = getSchema(graph);
                                        mapping = Mappings.createWithListening(schema);
                                        rootNode = (P3DRootNode)mapping.map(graph, input);
                                        // update control points.
                                        // TODO : this should be optimized.
+                                       
+                                       
+                                       
                                        try {
-                                               P3DUtil.finalizeDBLoad(rootNode);
-                                               
-                                       } catch (Exception e) {
-                                               throw new DatabaseException(e);
-                                       }
-                                       nodeMap = createNodeMap(getSession(), mapping, panel,rootNode);
+                                           P3DUtil.finalizeDBLoad(rootNode);
+                                           nodeMap = createNodeMap(getSession(), mapping, panel,rootNode);
+                                          
+                    } catch (Exception e) {
+                        throw new DatabaseException(e);
+                    }
+                                       
+                                       System.out.println("END PLANT3D LOAD");
                                }
                        });
                        
@@ -245,6 +252,27 @@ public class Plant3DEditor extends ResourceEditorPart {
                        @Override
                        public void run() {
                                nodeMap.populate();
+                               panel.addListener(new RenderListener() {
+                    
+                    @Override
+                    public void preRender() {
+                   
+                    }
+                    
+                    @Override
+                    public void postRender() {
+                        try {
+                            P3DUtil.finalizeDBLoad2(rootNode);
+                            if (nodeMap.isRangeModified());
+                                nodeMap.commit("Load sync");
+                        } catch (Exception e) {
+                            //throw new DatabaseException(e);
+                        }
+                        panel.removeListener(this);  
+                        
+                    }
+                });
+                               
                        }
                });