Retain preferences even when .swf filename has changed
[potlatch2.git] / net / systemeD / potlatch2 / Toolbox.mxml
index 5ed66ea..1826e26 100644 (file)
@@ -14,7 +14,7 @@
                <!-- Top row -->
 
                <s:Button icon="@Embed('../../../embedded/delete.svg')"
-                       click='doDelete();' 
+                       click='doDelete(event.ctrlKey,event.shiftKey);' 
                        enabled="{canDo('delete')}" 
                        alpha="{getAlpha('delete')}" 
                        toolTip="{deleteToolTipText()}" 
                public function init(controller:EditController):void {
                        this.controller=controller;
                        /* check if the toolbox was explictly turned off in a previous session */
-                       if( SharedObject.getLocal("user_state").data['toolbox_visible'] == false) {
+                       if( SharedObject.getLocal("user_state","/").data['toolbox_visible'] == false) {
                          this.visible = false;
                        }
                }
                
                public function toggle():void {
                        this.visible=!this.visible;
-                       var obj:SharedObject = SharedObject.getLocal("user_state");
+                       var obj:SharedObject = SharedObject.getLocal("user_state","/");
                        obj.setProperty("toolbox_visible",this.visible);
                        obj.flush();
                }
                // --------------------------------------------------------------------------------
                // Individual toolbox actions
 
-               public function doDelete():void {
+               public function doDelete(controlKey:Boolean,shiftKey:Boolean):void {
                        var undo:CompositeUndoableAction = new CompositeUndoableAction("Delete objects");
-                       for each (var entity:Entity in controller.state.selection) {
-                               if (entity is Node) { entity.connection.unregisterPOI(Node(entity)); }
-                               entity.remove(undo.push);
-                       }
-                       MainUndoStack.getGlobalStack().addAction(undo);
-
-                       if (controller.state is SelectedWayNode) {
-                               controller.setState(new SelectedWay(SelectedWayNode(controller.state).selectedWay));
-                       } else {
+                       if (controlKey) {
+                               // Temporary function to delete everything with non-accepting status
+                               var conn:Connection=controller.state.selection[0].connection;
+                               var o:Object=conn.getObjectsByBbox(controller.map.edge_l, controller.map.edge_r, controller.map.edge_t, controller.map.edge_b);
+                               for each (var way:Way in o.waysInside) {
+                                       if (way.status=='no' || (shiftKey && way.status=='partial')) { way.remove(undo.push); }
+                               }
+                               for each (var poi:Node in o.poisInside) {
+                                       if (poi.status=='no' || (shiftKey && way.status=='partial')) { poi.connection.unregisterPOI(poi); poi.remove(undo.push); }
+                               }
+                               MainUndoStack.getGlobalStack().addAction(undo);
                                controller.setState(new NoSelection());
+                               
+                       } else {
+                               // Standard delete function
+                               for each (var entity:Entity in controller.state.selection) {
+                                       if (entity is Node) { entity.connection.unregisterPOI(Node(entity)); }
+                                       entity.remove(undo.push);
+                               }
+                               MainUndoStack.getGlobalStack().addAction(undo);
+
+                               if (controller.state is SelectedWayNode) {
+                                       controller.setState(new SelectedWay(SelectedWayNode(controller.state).selectedWay));
+                               } else {
+                                       controller.setState(new NoSelection());
+                               }
                        }
                }