]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java
Remove/Split action removes pipeline components without reconnecting
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / editor / Plant3DEditor.java
index ba56f2f9201d0d1ca3d0c09dada69d7ee2284888..8387650bb68d5cf7410a53862a2963580d5885bc 100644 (file)
@@ -42,6 +42,7 @@ import org.simantics.objmap.graph.schema.IMappingSchema;
 import org.simantics.plant3d.actions.AddComponentAction;
 import org.simantics.plant3d.actions.AddEquipmentAction;
 import org.simantics.plant3d.actions.AddNozzleAction;
+import org.simantics.plant3d.actions.RemoveAndSplitAction;
 import org.simantics.plant3d.actions.RoutePipeAction;
 import org.simantics.plant3d.actions.TranslateInlineAction;
 import org.simantics.plant3d.scenegraph.EndComponent;
@@ -50,12 +51,10 @@ import org.simantics.plant3d.scenegraph.IP3DNode;
 import org.simantics.plant3d.scenegraph.InlineComponent;
 import org.simantics.plant3d.scenegraph.Nozzle;
 import org.simantics.plant3d.scenegraph.P3DRootNode;
-import org.simantics.plant3d.scenegraph.PipeRun;
 import org.simantics.plant3d.scenegraph.PipelineComponent;
 import org.simantics.plant3d.scenegraph.SchemaBuilder;
 import org.simantics.plant3d.scenegraph.TurnComponent;
 import org.simantics.plant3d.scenegraph.controlpoint.ControlPointFactory;
-import org.simantics.plant3d.scenegraph.controlpoint.PipeControlPoint;
 import org.simantics.plant3d.scenegraph.controlpoint.PipingRules;
 import org.simantics.plant3d.utils.ComponentUtils;
 import org.simantics.plant3d.utils.Item;
@@ -94,6 +93,7 @@ public class Plant3DEditor extends ResourceEditorPart {
        private TranslateInlineAction translateInlineAction;
        private RotateAction rotateAction;
        private RemoveAction removeAction;
+       private RemoveAndSplitAction removeSplitAction;
        private RoutePipeAction routePipeAction;
        private AddComponentAction addComponentAction;
        
@@ -215,10 +215,10 @@ public class Plant3DEditor extends ResourceEditorPart {
                removeAction = new RemoveAction(nodeMap) {
                        public void setNode(IG3DNode node) {
                                super.setNode(node);
-                               
-                               
                        }
                };
+               
+               removeSplitAction = new RemoveAndSplitAction(nodeMap);
                routePipeAction = new RoutePipeAction(panel,rootNode);
                addComponentAction = new AddComponentAction(panel, rootNode);
        }
@@ -325,6 +325,7 @@ public class Plant3DEditor extends ResourceEditorPart {
                                                add.setEquipment((Equipment)node);
                                                m.add(add);
                                        }
+                                       m.add(removeAction);
                                } else if (node instanceof Nozzle) {
                                        Nozzle nozzle = (Nozzle)node;
                                        if (!nozzle.isFixed()) {
@@ -336,6 +337,7 @@ public class Plant3DEditor extends ResourceEditorPart {
                                        routePipeAction.setEnabled(nozzle.getNext() == null && nozzle.getPrevious() == null);
                                        m.add(addComponentAction);
                                        addComponentAction.setComponent(nozzle);
+                                       m.add(removeAction);
                                } else if (node instanceof TurnComponent) {
                                        m.add(translateAction);
                                        TurnComponent component = (TurnComponent)node;
@@ -344,10 +346,14 @@ public class Plant3DEditor extends ResourceEditorPart {
                                        routePipeAction.setEnabled(component.getNext() == null || component.getPrevious() == null);
                                        m.add(addComponentAction);
                                        addComponentAction.setComponent(component);
+                                       m.add(removeAction);
+                                       m.add(removeSplitAction);
+                                       removeSplitAction.setNode(node);
                                } else if (node instanceof EndComponent) {
                                        m.add(translateAction);
                                        m.add(addComponentAction);
                                        addComponentAction.setComponent((PipelineComponent)node);
+                                       m.add(removeAction);
                                } else if (node instanceof InlineComponent) {
                                        //m.add(translateInlineAction);
                                        InlineComponent component = (InlineComponent)node;
@@ -356,9 +362,14 @@ public class Plant3DEditor extends ResourceEditorPart {
                                        routePipeAction.setComponent(component);
                                        m.add(addComponentAction);
                                        addComponentAction.setComponent(component);
+                                       m.add(removeAction);
+                                       m.add(removeSplitAction);
+                                       removeSplitAction.setNode(node);
+                               } else {
+                                   m.add(removeAction);
                                }
                                
-                               m.add(removeAction);
+                               
                                translateAction.setNode(node);
                                translateInlineAction.setNode(node);
                                rotateAction.setNode(node);