dcbdf85c317e2aeb3dd4d87365ae31ac85408da5
[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         import net.systemeD.halcyon.Globals;
10
11         public class NoSelection extends ControllerState {
12
13                 public function NoSelection() {
14                 }
15
16                 override public function isSelectionState():Boolean {
17                         return false;
18                 }
19                 
20                 override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
21                         var focus:Entity = getTopLevelFocusEntity(entity);
22
23                         if (event.type==MouseEvent.MOUSE_UP && focus==null && map.dragstate!=map.DRAGGING) {
24                                 map.dragstate=map.NOT_DRAGGING;
25                                 var undo:CompositeUndoableAction = new BeginWayAction();
26                                 var startNode:Node = controller.connection.createNode(
27                                         {}, 
28                                         controller.map.coord2lat(event.localY),
29                                         controller.map.coord2lon(event.localX), undo.push);
30                                 var way:Way = controller.connection.createWay({}, [startNode], undo.push);
31                                 MainUndoStack.getGlobalStack().addAction(undo);
32                                 return new DrawWay(way, true, false);
33                         }
34                         var cs:ControllerState = sharedMouseEvents(event, entity);
35                         return cs ? cs : this;
36                 }
37                 
38                 override public function processKeyboardEvent(event:KeyboardEvent):ControllerState {
39                         var cs:ControllerState = sharedKeyboardEvents(event);
40                         return cs ? cs : this;
41                 }
42                 
43         override public function enterState():void {
44                         controller.map.mouseUpHandler();
45                         Globals.vars.root.addDebug("**** -> "+this);
46         }
47         override public function exitState(newState:ControllerState):void {
48                         Globals.vars.root.addDebug("**** <- "+this);
49         }
50                 override public function toString():String {
51                         return "NoSelection";
52                 }
53
54         }
55 }