Working 'replace node' functionality.
[potlatch2.git] / net / systemeD / potlatch2 / controller / DrawWay.as
index d269b0b607132b547c7065813b5f9f932fa0cd98..08b11d0b6382033d9a049d311bf5fc1e75b9f7c4 100644 (file)
@@ -177,7 +177,7 @@ package net.systemeD.potlatch2.controller {
                                case Keyboard.DELETE:           
                                case Keyboard.BACKSPACE:        
                                case 189: /* minus */       return backspaceNode(MainUndoStack.getGlobalStack().addAction);
                                case Keyboard.DELETE:           
                                case Keyboard.BACKSPACE:        
                                case 189: /* minus */       return backspaceNode(MainUndoStack.getGlobalStack().addAction);
-                               case 79: /* O */                        return new SelectedWayNode(firstSelected as Way, editEnd ? Way(firstSelected).length-1 : 0); //, event);
+                               case 79: /* O */                        return replaceNode();
                                case 82: /* R */            repeatTags(firstSelected); return this;
                                case 70: /* F */            followWay(); return this;
                        }
                                case 82: /* R */            repeatTags(firstSelected); return this;
                                case 70: /* F */            followWay(); return this;
                        }
@@ -185,6 +185,18 @@ package net.systemeD.potlatch2.controller {
                        return cs ? cs : this;
                        
                }
                        return cs ? cs : this;
                        
                }
+
+               public function replaceNode():ControllerState {
+                       var way:Way=Way(firstSelected);
+                       var oldNode:Node=editEnd ? way.getLastNode() : way.getNode(0);
+                       var newNode:Node=oldNode.replaceWithNew(layer.connection,
+                                                               controller.map.coord2lat(layer.mouseY), 
+                                                               controller.map.coord2lon(layer.mouseX), {},
+                                                               MainUndoStack.getGlobalStack().addAction);
+                       var d:DragWayNode=new DragWayNode(way, way.indexOfNode(newNode), new MouseEvent(MouseEvent.CLICK, true, false, layer.mouseX, layer.mouseY), true);
+                       d.forceDragStart();
+                       return d;
+               }
                
                protected function keyExitDrawing():ControllerState {
                        var cs:ControllerState=stopDrawing();
                
                protected function keyExitDrawing():ControllerState {
                        var cs:ControllerState=stopDrawing();