Convert Relation.setMember to use the undo system. Fixes 3586. This stuff could do...
authorAndy Allan <andy@gravitystorm.co.uk>
Tue, 29 Mar 2011 19:47:16 +0000 (20:47 +0100)
committerAndy Allan <andy@gravitystorm.co.uk>
Tue, 29 Mar 2011 19:47:16 +0000 (20:47 +0100)
net/systemeD/halcyon/connection/Relation.as
net/systemeD/potlatch2/TagViewer.mxml

index e6bdbd1..795dd78 100644 (file)
@@ -60,13 +60,11 @@ package net.systemeD.halcyon.connection {
             return members[index];
         }
 
-        public function setMember(index:uint, member:RelationMember):void {
-            var oldMember:RelationMember = getMember(index);
-            
-                       members.splice(index, 1, member);
-            oldMember.entity.removeParent(this);
-                       member.entity.addParent(this);
-                       markDirty();
+        public function setMember(index:uint, member:RelationMember, performAction:Function):void {
+            var composite:CompositeUndoableAction = new CompositeUndoableAction("Set Member at index "+index);
+            composite.push(new RemoveMemberByIndexAction(this, members, index));
+            composite.push(new AddMemberToRelationAction(this, index, member, members));
+            performAction(composite);
         }
 
                public function findMembersByRole(role:String, entityType:Class=null):Array {
index bc79c8d..4de166e 100644 (file)
                        for each (var entity:Entity in EntityCollection(selectedEntity).entities) {
                                var indexes:Array=relation.findEntityMemberIndexes(entity);
                                for each (var index:int in indexes) {
-                                       relation.setMember(index, new RelationMember(entity,newRole));
+                                       relation.setMember(index, new RelationMember(entity,newRole), MainUndoStack.getGlobalStack().addAction);
                                }
                        }
                } else {
-                       relation.setMember(props['index'], new RelationMember(selectedEntity,newRole));
+                       relation.setMember(props['index'], new RelationMember(selectedEntity,newRole), MainUndoStack.getGlobalStack().addAction);
                }
       }