]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java
White space clean-up
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / editor / Plant3DEditor.java
index 159a239d9ff649eb772517f2f2acaa220b16a23e..ba56f2f9201d0d1ca3d0c09dada69d7ee2284888 100644 (file)
@@ -158,39 +158,8 @@ public class Plant3DEditor extends ResourceEditorPart {
                                        // update control points.
                                        // TODO : this should be optimized.
                                        try {
-                                               for (INode node : rootNode.getChild()) {
-                                                       if (node instanceof PipeRun) {
-                                                               for (PipelineComponent pc : ((PipeRun) node).getChild())
-                                                                       pc.sync();
-                                                       } else if (node instanceof Equipment) {
-                                                               for (PipelineComponent pc : ((Equipment) node).getChild())
-                                                                       pc.sync();
-                                                       }
-                                               }
+                                               P3DUtil.finalizeDBLoad(rootNode);
                                                
-                                               for (INode node : rootNode.getChild()) {
-                                                       if (node instanceof PipeRun) {
-                                                               for (PipelineComponent pc : ((PipeRun) node).getChild())
-                                                                       pc.sync2();
-                                                       } else if (node instanceof Equipment) {
-                                                               for (PipelineComponent pc : ((Equipment) node).getChild())
-                                                                       pc.sync2();
-                                                       }
-                                               }
-                                               for (INode node : rootNode.getChild()) {
-                                                       if (node instanceof PipeRun) {
-                                                               PipingRules.validate((PipeRun)node);
-                                                       }
-                                               }
-                                               PipingRules.setEnabled(true);
-                                               for (INode node : rootNode.getChild()) {
-                                                       if (node instanceof PipeRun) {
-                                                               PipeRun run = (PipeRun)node;
-                                                               for (PipeControlPoint pcp : run.getControlPoints())
-                                                                       PipingRules.positionUpdate(pcp);
-                                                                       
-                                                       }
-                                               }
                                        } catch (Exception e) {
                                                throw new DatabaseException(e);
                                        }
@@ -235,6 +204,11 @@ public class Plant3DEditor extends ResourceEditorPart {
                        return;
                }
                
+               createActions();
+               
+       }
+       
+       protected void createActions() {
                translateAction = new TranslateAction(panel,nodeMap);
                translateInlineAction = new TranslateInlineAction(panel, nodeMap);
                rotateAction = new RotateAction(panel,nodeMap);
@@ -247,7 +221,6 @@ public class Plant3DEditor extends ResourceEditorPart {
                };
                routePipeAction = new RoutePipeAction(panel,rootNode);
                addComponentAction = new AddComponentAction(panel, rootNode);
-               
        }
        
        public void populate() {
@@ -267,7 +240,7 @@ public class Plant3DEditor extends ResourceEditorPart {
        }
        
        protected P3DNodeMap createNodeMap(Session session, IMapping<Resource, Object> mapping, VtkView panel, P3DRootNode rootNode) {
-                return new P3DNodeMap(session, mapping, panel,rootNode);
+               return new P3DNodeMap(session, mapping, panel,rootNode);
        }
        
        @Override
@@ -310,30 +283,30 @@ public class Plant3DEditor extends ResourceEditorPart {
                ren1.SetBackground(0.9,0.9,0.9);
                ren1.SetGradientBackground(true);
 
-          // vtkActor grid = vtkShape.createGridActor(8,1.0,1|2|4);
-           vtkActor grid = vtkShape.createGridActor(8,1.0, 2 );
-           grid.SetPickable(0);
-           ren1.AddActor(grid);
-           panel.addDeletable(grid);
-           
-           AxesDisplay axesDisplay = new AxesDisplay(panel);
-           axesDisplay.show();
+               // vtkActor grid = vtkShape.createGridActor(8,1.0,1|2|4);
+               vtkActor grid = vtkShape.createGridActor(8,1.0, 2 );
+               grid.SetPickable(0);
+               ren1.AddActor(grid);
+               panel.addDeletable(grid);
+               
+               AxesDisplay axesDisplay = new AxesDisplay(panel);
+               axesDisplay.show();
                
        }
        
        protected Menu contextMenu;
        
        protected void hookContextMenu() {
-        MenuManager menuMgr = new MenuManager("#PopupMenu");
-        menuMgr.setRemoveAllWhenShown(true);
-        menuMgr.addMenuListener(new IMenuListener() {
-            public void menuAboutToShow(IMenuManager manager) {                
-               createContextMenu(manager);
-            }
-        });
+               MenuManager menuMgr = new MenuManager("#PopupMenu");
+               menuMgr.setRemoveAllWhenShown(true);
+               menuMgr.addMenuListener(new IMenuListener() {
+                       public void menuAboutToShow(IMenuManager manager) {             
+                               createContextMenu(manager);
+                       }
+               });
 
-        contextMenu = menuMgr.createContextMenu(parent);
-    }
+               contextMenu = menuMgr.createContextMenu(parent);
+       }
        
        protected void createContextMenu(IMenuManager m) {
                List<IG3DNode> selected = selectionProvider.getSelectedNodes();
@@ -353,11 +326,11 @@ public class Plant3DEditor extends ResourceEditorPart {
                                                m.add(add);
                                        }
                                } else if (node instanceof Nozzle) {
-                                   Nozzle nozzle = (Nozzle)node;
-                                   if (!nozzle.isFixed()) {
-                                       m.add(translateAction);
-                           m.add(rotateAction);
-                                   }
+                                       Nozzle nozzle = (Nozzle)node;
+                                       if (!nozzle.isFixed()) {
+                                               m.add(translateAction);
+                                               m.add(rotateAction);
+                                       }
                                        m.add(routePipeAction);
                                        routePipeAction.setComponent(nozzle);
                                        routePipeAction.setEnabled(nozzle.getNext() == null && nozzle.getPrevious() == null);
@@ -393,8 +366,8 @@ public class Plant3DEditor extends ResourceEditorPart {
                                
                        } 
                } catch (DatabaseException e) {
-               ExceptionUtils.logAndShowError(e);
-       }
+                       ExceptionUtils.logAndShowError(e);
+               }
        }
        
        private IContentOutlinePage createOutline() {