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 3ac6bd6966f5f69a4b4e130483b65a4dd1daa96c..f0249f524688e83f2e5775f37e4288dd2f3f22ef 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 e0e4a1f363e37369a56631e81bd46f6d7c182b42..840508cb62a464e7d65a30300b921b049b149802 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 fa4696be91bd640a20946cf8c76c5eb7f06cb5b5..59c71e09be9719346dab338a0f726b40a5e54a16 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 9d158d957ba375e75ce480b02500cab7a068f769..3eb14b3f34d3d56816e79f8dfd624fce14176c0a 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 ae94708938c4c38079dac283a8e3c11bc3f2959c..8228a0f20958ec60391c879602582c2ccb612aed 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 be414df2b4593357620117187d0a05710dd5a7e8..c87ac54f978321f3bd1aa087de717ef465805806 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);
         }