fix horrid merge bug (yay!). Implement suspend/resume events for redrawing, to speed...
[potlatch2.git] / net / systemeD / halcyon / connection / Connection.as
index f7d48d5..14d48a1 100755 (executable)
@@ -59,10 +59,19 @@ package net.systemeD.halcyon.connection {
         public static var NEW_WAY:String = "new_way";
         public static var NEW_RELATION:String = "new_relation";
         public static var NEW_POI:String = "new_poi";
-        public static var TAG_CHANGE:String = "tag_change";
+        public static var TAG_CHANGED:String = "tag_change";
         public static var NODE_MOVED:String = "node_moved";
         public static var WAY_NODE_ADDED:String = "way_node_added";
         public static var WAY_NODE_REMOVED:String = "way_node_removed";
+               public static var NODE_DELETED:String = "node_deleted";
+               public static var WAY_DELETED:String = "way_deleted";
+               public static var RELATION_DELETED:String = "relation_deleted";
+               public static var RELATION_MEMBER_ADDED:String = "relation_member_added";
+               public static var RELATION_MEMBER_REMOVED:String = "relation_member_deleted";
+               public static var ADDED_TO_RELATION:String = "added_to_relation";
+               public static var REMOVED_FROM_RELATION:String = "removed_from_relation";
+               public static var SUSPEND_REDRAW:String = "suspend_redraw";
+               public static var RESUME_REDRAW:String = "resume_redraw";
 
         // store the data we download
         private var negativeID:Number = -1;
@@ -76,19 +85,19 @@ package net.systemeD.halcyon.connection {
             return negativeID--;
         }
 
-        protected function setNode(node:Node):void {
+        protected function setNode(node:Node,queue:Boolean):void {
             nodes[node.id] = node;
-            if (node.loaded) { sendEvent(new EntityEvent(NEW_NODE, node)); }
+            if (node.loaded) { sendEvent(new EntityEvent(NEW_NODE, node),queue); }
         }
 
-        protected function setWay(way:Way):void {
+        protected function setWay(way:Way,queue:Boolean):void {
             ways[way.id] = way;
-            if (way.loaded) { sendEvent(new EntityEvent(NEW_WAY, way)); }
+            if (way.loaded) { sendEvent(new EntityEvent(NEW_WAY, way),queue); }
         }
 
-        protected function setRelation(relation:Relation):void {
+        protected function setRelation(relation:Relation,queue:Boolean):void {
             relations[relation.id] = relation;
-            if (relation.loaded) { sendEvent(new EntityEvent(NEW_RELATION, relation)); }
+            if (relation.loaded) { sendEvent(new EntityEvent(NEW_RELATION, relation),queue); }
         }
 
         protected function renumberNode(oldID:Number, node:Node):void {
@@ -106,14 +115,16 @@ package net.systemeD.halcyon.connection {
             delete relations[oldID];
         }
 
-               public function sendEvent(e:*):void {
+
+               public function sendEvent(e:*,queue:Boolean):void {
+                       // queue is only used for AMFConnection
                        dispatchEvent(e);
                }
 
-        protected function registerPOI(node:Node):void {
+        public function registerPOI(node:Node):void {
             if ( pois.indexOf(node) < 0 ) {
                 pois.push(node);
-                sendEvent(new EntityEvent(NEW_POI, node));
+                sendEvent(new EntityEvent(NEW_POI, node),false);
             }
         }
 
@@ -126,7 +137,7 @@ package net.systemeD.halcyon.connection {
 
         protected function setActiveChangeset(changeset:Changeset):void {
             this.changeset = changeset;
-            sendEvent(new EntityEvent(NEW_CHANGESET, changeset));
+            sendEvent(new EntityEvent(NEW_CHANGESET, changeset),false);
         }
         
         public function getNode(id:Number):Node {
@@ -143,19 +154,19 @@ package net.systemeD.halcyon.connection {
 
         public function createNode(tags:Object, lat:Number, lon:Number):Node {
             var node:Node = new Node(nextNegative, 0, tags, true, lat, lon);
-            setNode(node);
+            setNode(node,false);
             return node;
         }
 
         public function createWay(tags:Object, nodes:Array):Way {
             var way:Way = new Way(nextNegative, 0, tags, true, nodes.concat());
-            setWay(way);
+            setWay(way,false);
             return way;
         }
 
         public function createRelation(tags:Object, members:Array):Relation {
             var relation:Relation = new Relation(nextNegative, 0, tags, true, members.concat());
-            setRelation(relation);
+            setRelation(relation,false);
             return relation;
         }