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 46688b0..4d0d6cb 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 7312038..b41cfde 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 da2117d..104362f 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 ea3712a..574ba41 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 2b9b293..d40a1d5 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 92ce619..9b35052 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 378d89b..943a41c 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); }
        }