R to repeat tags
authorRichard Fairhurst <richard@systemed.net>
Tue, 1 Jun 2010 17:57:49 +0000 (17:57 +0000)
committerRichard Fairhurst <richard@systemed.net>
Tue, 1 Jun 2010 17:57:49 +0000 (17:57 +0000)
net/systemeD/potlatch2/EditController.as
net/systemeD/potlatch2/controller/ControllerState.as
net/systemeD/potlatch2/controller/DrawWay.as
net/systemeD/potlatch2/controller/SelectedPOINode.as
net/systemeD/potlatch2/controller/SelectedWay.as
net/systemeD/potlatch2/controller/SelectedWayNode.as

index 3ac6bd6..f0249f5 100644 (file)
@@ -16,6 +16,7 @@ package net.systemeD.potlatch2 {
         private var _connection:Connection;
         
                private var keys:Object={};
+               public var clipboards:Object={};
 
         public function EditController(map:Map, tagViewer:TagViewer, toolbox:Toolbox) {
             this._map = map;
index e0e4a1f..840508c 100644 (file)
@@ -115,6 +115,17 @@ package net.systemeD.potlatch2.controller {
                        return null;
                }
                
+               protected function repeatTags(object:Entity):void {
+                       if (!controller.clipboards[object.getType()]) { return; }
+                       object.suspend();
 
+                   var undo:CompositeUndoableAction = new CompositeUndoableAction("Repeat tags");
+                       for (var k:String in controller.clipboards[object.getType()]) {
+                               object.setTag(k, controller.clipboards[object.getType()][k], undo.push)
+                       }
+                       MainUndoStack.getGlobalStack().addAction(undo);
+
+                       object.resume();
+               }
     }
 }
index fa4696b..59c71e0 100644 (file)
@@ -96,8 +96,12 @@ package net.systemeD.potlatch2.controller {
                }
 
                override public function processKeyboardEvent(event:KeyboardEvent):ControllerState {
-                       if ( event.keyCode == 13 || event.keyCode == 27 ) { return stopDrawing(); }
-                       else if (event.keyCode == Keyboard.BACKSPACE) { return backspaceNode(MainUndoStack.getGlobalStack().addAction); }
+                       switch (event.keyCode) {
+                               case 13:                                        return stopDrawing();
+                               case 27:                                        return stopDrawing();
+                               case Keyboard.BACKSPACE:        return backspaceNode(MainUndoStack.getGlobalStack().addAction);
+                               case 82:                                        repeatTags(selectedWay); return this;
+                       }
                        var cs:ControllerState = sharedKeyboardEvents(event);
                        return cs ? cs : this;
                }
index 9d158d9..3eb14b3 100644 (file)
@@ -41,6 +41,7 @@ package net.systemeD.potlatch2.controller {
                        switch (event.keyCode) {
                                case Keyboard.BACKSPACE:        return deletePOI();
                                case Keyboard.DELETE:           return deletePOI();
+                               case 82:                                        repeatTags(selectedNode); return this;  // 'R'
                        }
                        var cs:ControllerState = sharedKeyboardEvents(event);
                        return cs ? cs : this;
@@ -51,12 +52,13 @@ package net.systemeD.potlatch2.controller {
                        selectedNode.remove(MainUndoStack.getGlobalStack().addAction);
                        return new NoSelection();
                }
-               
+
         override public function enterState():void {
             selectNode(initNode);
                        Globals.vars.root.addDebug("**** -> "+this);
         }
         override public function exitState():void {
+                       controller.clipboards['node']=selectedNode.getTagsCopy();
             clearSelection();
                        Globals.vars.root.addDebug("**** <- "+this);
         }
index ae94708..8228a0f 100644 (file)
@@ -62,7 +62,8 @@ package net.systemeD.potlatch2.controller {
                        switch (event.keyCode) {
                                case 80:                                        return new SelectedParallelWay(selectedWay);
                                case 81:                                        Quadrilateralise.quadrilateralise(selectedWay); return this;
-                case 82:                    selectedWay.reverseNodes(MainUndoStack.getGlobalStack().addAction); return this;         
+                               case 82:                                        repeatTags(selectedWay); return this;
+                case 86:                    selectedWay.reverseNodes(MainUndoStack.getGlobalStack().addAction); return this;
                 case 89:                    Simplify.simplify(selectedWay, controller.map, true); return this;         
                                case Keyboard.BACKSPACE:        if (event.shiftKey) { return deleteWay(); } break;
                                case Keyboard.DELETE:           if (event.shiftKey) { return deleteWay(); } break;
@@ -121,6 +122,7 @@ package net.systemeD.potlatch2.controller {
                        Globals.vars.root.addDebug("**** -> "+this+" "+selectedWay.id);
         }
         override public function exitState():void {
+                       controller.clipboards['way']=selectedWay.getTagsCopy();
             clearSelection();
                        Globals.vars.root.addDebug("**** <- "+this);
         }
index be414df..c87ac54 100644 (file)
@@ -61,8 +61,9 @@ package net.systemeD.potlatch2.controller {
 
                override public function processKeyboardEvent(event:KeyboardEvent):ControllerState {
                        switch (event.keyCode) {
-                               case 189:                                       return removeNode();    // '-'
-                               case 88:                                        return splitWay();              // 'X'
+                               case 189:                                       return removeNode();                                    // '-'
+                               case 88:                                        return splitWay();                                              // 'X'
+                               case 82:                                        repeatTags(selectedNode); return this;  // 'R'
                                case Keyboard.BACKSPACE:        return deleteNode();
                                case Keyboard.DELETE:           return deleteNode();
                        }
@@ -75,6 +76,7 @@ package net.systemeD.potlatch2.controller {
                        Globals.vars.root.addDebug("**** -> "+this);
         }
                override public function exitState():void {
+                       controller.clipboards['node']=selectedNode.getTagsCopy();
             clearSelection();
                        Globals.vars.root.addDebug("**** <- "+this);
         }