Merge branch 'master' of github.com:systemed/potlatch2
[potlatch2.git] / net / systemeD / halcyon / connection / actions / CreatePOIAction.as
1 package net.systemeD.halcyon.connection.actions {
2
3     import net.systemeD.halcyon.connection.*;
4     import net.systemeD.halcyon.Map;
5     import flash.events.*;
6     
7     public class CreatePOIAction extends CompositeUndoableAction {
8     
9         private var newNode:Node;
10                 private var tags:Object;
11                 private var lat:Number;
12                 private var lon:Number;
13                 private var connection:Connection;
14         
15         public function CreatePOIAction(connection:Connection, tags:Object, lat:Number, lon:Number) {
16           super("Create POI");
17           this.connection = connection;
18           this.tags = tags;
19           this.lat = lat;
20           this.lon = lon;
21         }
22         
23         public override function doAction():uint {
24           if (newNode == null) {
25             newNode = connection.createNode(tags,lat,lon,push);
26           }
27           super.doAction();
28           connection.registerPOI(newNode);
29           
30           return SUCCESS;
31         }
32         
33         public override function undoAction():uint {
34           super.undoAction();
35           connection.unregisterPOI(newNode);
36           
37           return SUCCESS;
38         }
39         
40         public function getNode():Node {
41           return newNode;
42         }
43     }
44 }