Modify the add junction code to run all the necessary changes into one Composite...
authorAndy Allan <gravitystorm@gmail.com>
Thu, 2 Sep 2010 18:54:05 +0000 (18:54 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Thu, 2 Sep 2010 18:54:05 +0000 (18:54 +0000)
TODO.txt
net/systemeD/halcyon/connection/Way.as
net/systemeD/potlatch2/controller/DrawWay.as

index 5f59a2c..3a3e3c0 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -30,7 +30,6 @@ Potlatch 2: main outstanding issues
 * Options should be remembered via SharedObjects
 * small node hitzone when creating areas - hitzone and mouseover UI don't match up
 * backspaceNode leaves junctions on other ways highlighted
-* Unexpected number of undo actions (3) when undoing drawway after adding a junction
 * GPS loading should have a loading... label
 * Pressing undo/redo sometimes doesn't change controllerstate. (e.g. create POI + undo leaves the tag panel still referring to POI)
 * Resizing window doesn't update Yahoo, until map is panned.
index cf6f96c..7341b74 100644 (file)
@@ -150,8 +150,7 @@ package net.systemeD.halcyon.connection {
             
             // splice in new node
             if ( isSnap ) {
-                newNode.latp = snapped.y;
-                newNode.lon = snapped.x;
+                newNode.setLonLatp(snapped.x, snapped.y, performAction);
             }
             insertNode(newIndex, newNode, performAction);
             return newIndex;
index c02c339..5d4ad08 100644 (file)
@@ -44,7 +44,9 @@ package net.systemeD.potlatch2.controller {
 
                        if ( event.type == MouseEvent.MOUSE_UP ) {
                                if ( entity == null || isBackground ) {
-                                       node = createAndAddNode(event);
+                                       node = createAndAddNode(event, MainUndoStack.getGlobalStack().addAction);
+                    controller.map.setHighlight(node, { selectedway: true });
+                    controller.map.setPurgable(node, false);
                                        resetElastic(node);
                                        lastClick=node;
                                } else if ( entity is Node ) {
@@ -84,10 +86,13 @@ package net.systemeD.potlatch2.controller {
                                                appendNode(node,undo.push);
                                    MainUndoStack.getGlobalStack().addAction(undo);
                                        } else {
-                                               // add junction node - another way
-                                               node = createAndAddNode(event);
-                                               Way(entity).insertNodeAtClosestPosition(node, true,
-                                                   MainUndoStack.getGlobalStack().addAction);
+                        // add junction node - another way
+                        var jnct:CompositeUndoableAction = new CompositeUndoableAction("Junction Node");
+                        node = createAndAddNode(event, jnct.push);
+                        Way(entity).insertNodeAtClosestPosition(node, true, jnct.push);
+                        MainUndoStack.getGlobalStack().addAction(jnct);
+                        controller.map.setHighlight(node, { selectedway: true });
+                        controller.map.setPurgable(node, false);
                                        }
                                        resetElastic(node);
                                        lastClick=node;
@@ -177,7 +182,7 @@ package net.systemeD.potlatch2.controller {
                        return this;
                }
 
-               public function createAndAddNode(event:MouseEvent):Node {
+               public function createAndAddNode(event:MouseEvent, performAction:Function):Node {
                    var undo:CompositeUndoableAction = new CompositeUndoableAction("Add node");
                    
                        var lat:Number = controller.map.coord2lat(event.localY);
@@ -185,9 +190,7 @@ package net.systemeD.potlatch2.controller {
                        var node:Node = controller.connection.createNode({}, lat, lon, undo.push);
                        appendNode(node, undo.push);
                        
-                       MainUndoStack.getGlobalStack().addAction(undo);
-                       controller.map.setHighlight(node, { selectedway: true });
-                       controller.map.setPurgable(node, false);
+                       performAction(undo);
                        return node;
                }