remove a huge load of pseudo-traces
[potlatch2.git] / net / systemeD / potlatch2 / controller / NoSelection.as
1 package net.systemeD.potlatch2.controller {
2         import flash.events.*;
3         import flash.display.*;
4         import net.systemeD.potlatch2.EditController;
5         import net.systemeD.halcyon.connection.*;
6     import net.systemeD.halcyon.connection.actions.*;
7         import net.systemeD.halcyon.Map;
8         import net.systemeD.halcyon.MapPaint;
9
10         public class NoSelection extends ControllerState {
11
12                 public function NoSelection() {
13                 }
14
15                 override public function isSelectionState():Boolean {
16                         return false;
17                 }
18                 
19                 override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
20                         var cs:ControllerState = sharedMouseEvents(event, entity);
21                         if (cs) return cs;
22
23                         var paint:MapPaint = getMapPaint(DisplayObject(event.target));
24                         var focus:Entity = getTopLevelFocusEntity(entity);
25
26                         if (event.type==MouseEvent.MOUSE_UP && (focus==null || (paint && paint.isBackground)) && map.dragstate!=map.DRAGGING) {
27                                 map.dragstate=map.NOT_DRAGGING;
28                                 var undo:CompositeUndoableAction = new BeginWayAction();
29                                 var startNode:Node = controller.connection.createNode(
30                                         {}, 
31                                         controller.map.coord2lat(event.localY),
32                                         controller.map.coord2lon(event.localX), undo.push);
33                                 var way:Way = controller.connection.createWay({}, [startNode], undo.push);
34                                 MainUndoStack.getGlobalStack().addAction(undo);
35                                 return new DrawWay(way, true, false);
36                         }
37                         return this;
38                 }
39                 
40                 override public function processKeyboardEvent(event:KeyboardEvent):ControllerState {
41                         var cs:ControllerState = sharedKeyboardEvents(event);
42                         return cs ? cs : this;
43                 }
44                 
45         override public function enterState():void {
46                         controller.map.mouseUpHandler();
47         }
48         override public function exitState(newState:ControllerState):void {
49         }
50                 override public function toString():String {
51                         return "NoSelection";
52                 }
53
54         }
55 }