change relation.appendMember to use the undo system, and update various places as...
authorAndy Allan <gravitystorm@gmail.com>
Tue, 7 Dec 2010 16:46:30 +0000 (16:46 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Tue, 7 Dec 2010 16:46:30 +0000 (16:46 +0000)
net/systemeD/halcyon/connection/Relation.as
net/systemeD/halcyon/connection/actions/AddMemberToRelationAction.as
net/systemeD/halcyon/connection/actions/MergeWaysAction.as
net/systemeD/potlatch2/RelationSelectPanel.mxml
net/systemeD/potlatch2/TagViewer.mxml
net/systemeD/potlatch2/mapfeatures/editors/RelationMemberEditor.as
net/systemeD/potlatch2/mapfeatures/editors/TurnRestrictionIcon.mxml

index 46688b0c39a9fc58178d3a64dd70280011eea1f0..4d0d6cbc2b3aaa490edfe09043ac2f08f3634e36 100644 (file)
@@ -79,13 +79,9 @@ package net.systemeD.halcyon.connection {
             performAction(new AddMemberToRelationAction(this, index, member, members));
         }
 
-        public function appendMember(member:RelationMember):uint {
-            members.push(member);
-                       member.entity.addParent(this);
-                       markDirty();
-
-                       dispatchEvent(new RelationMemberEvent(Connection.RELATION_MEMBER_ADDED, member.entity, this, members.length-1));
-            return members.length;
+        public function appendMember(member:RelationMember, performAction:Function):uint {
+            performAction(new AddMemberToRelationAction(this, -1, member, members));
+            return members.length + 1;
         }
 
                public function removeMember(entity:Entity, performAction:Function):void {
index 7312038a50decdff6fdb4c7cd1e100f7a66a37f6..b41cfde8409e15f199c489c5c681371aa4f31399 100644 (file)
@@ -8,7 +8,7 @@ package net.systemeD.halcyon.connection.actions {
         private var member:RelationMember;
         private var memberList:Array;
         
-        public function AddMemberToRelationAction(rel:Relation, index:uint, member:RelationMember, memberList:Array) {
+        public function AddMemberToRelationAction(rel:Relation, index:int, member:RelationMember, memberList:Array) {
             super(rel, "Add " + member.entity.getType() + " " + member.entity.id + " at position " + index + " to ");
             this.rel = rel;
             this.index = index;
index da2117db47557cfce74bbe5ef0c19f63cc2b6cca..104362fc14f2ce0f705a8dd869dff31720213114 100644 (file)
@@ -46,7 +46,7 @@ package net.systemeD.halcyon.connection.actions {
                        for each (var r:Relation in way2.parentRelations) {
                                // ** needs to copy roles as well
                                if (r.findEntityMemberIndex(way1)==-1) {
-                                       r.appendMember(new RelationMember(way1, ''));
+                                       r.appendMember(new RelationMember(way1, ''), push);
                                }
                        }
         }
index ea3712a87e542a13129adbcf3675125a207d7a33..574ba41acc096dcb8b05ac25ea5193b3384d7240 100644 (file)
@@ -41,7 +41,7 @@
         
         public function updateEntityAndClose():void {
           var relation:Relation = conn.getRelation(relationSelector.selectedItem.relId);
-          relation.appendMember(new RelationMember(entity, ''));
+          relation.appendMember(new RelationMember(entity, ''), MainUndoStack.getGlobalStack().addAction);
           PopUpManager.removePopUp(this);
         }
         
index 2b9b29359bbbc66c3f16c0b76854b2f152beb1cc..d40a1d59a1fd3232e762c178cc6400b579476cac 100644 (file)
           
           var conn:Connection = Connection.getConnectionInstance();
           var rel:Relation = selectedEntity as Relation
+          var action:CompositeUndoableAction = new CompositeUndoableAction("Rearrange relation members for "+rel);
           
           // drop members
           for (var i:int=rel.length-1 ; i>=0; i--) {
             } else if (memberObject.type == 'relation') {
               e = conn.getRelation(id);
             }
-            rel.appendMember(new RelationMember(e, memberObject.role));
+            rel.appendMember(new RelationMember(e, memberObject.role), action.push);
           }
+          MainUndoStack.getGlobalStack().addAction(action);
       }
       
       private function editRelation(id:Number):void {
index 92ce619a84695db9f56f54c98397482ef6579a6a..9b350528a4ba8ad4ff7df8a71ab21fe490b1ba73 100644 (file)
@@ -53,7 +53,7 @@ package net.systemeD.potlatch2.mapfeatures.editors {
       
       public function addMember(relation:Relation, role:String):void {
           if (_entity != null && !_entity.hasParent(relation))
-              relation.appendMember(new RelationMember(_entity, role));
+              relation.appendMember(new RelationMember(_entity, role), MainUndoStack.getGlobalStack().addAction);
       }
 
       public function set factory(factory:RelationMemberEditorFactory):void {
index 378d89b7cdec22e76a5030e09c607b015af5e2d9..943a41c9c6080738697a9f9bf2e44e4c586c5ad1 100644 (file)
                for each (var memberEntity:Entity in old) {
                        rel.removeMember(memberEntity, undo.push);
                }
-               undo.doAction();
 
                // now add new entity
-               // ** FIXME - appendMember should be undoable
-               rel.appendMember(new RelationMember(entity,role))
+               rel.appendMember(new RelationMember(entity,role), undo.push);
+
+        undo.doAction();
 
                if (show.label=='Hide') { setHighlights(true); }
        }