1 package net.systemeD.halcyon.connection.actions {
3 import net.systemeD.halcyon.connection.*;
5 public class DeleteNodeAction extends UndoableEntityAction {
6 private var setDeleted:Function;
7 private var effects:CompositeUndoableAction;
9 public function DeleteNodeAction(node:Node, setDeleted:Function) {
10 super(node, "Delete");
11 this.setDeleted = setDeleted;
14 public override function doAction():uint {
15 var node:Node = entity as Node;
16 if ( node.isDeleted() )
19 effects = new CompositeUndoableAction("Delete refs");
20 node.removeFromParents(effects.push);
24 // The Delete[entity]Action is unusual, since it can be called both to delete an entity, and is also used to undo its creation
25 // (hence preserving the negative id, if the creation is subsequently redone). Normally a deletion would mark the entity dirty, but
26 // if a newly created entity is being deleted, the entity is now clean.
27 // When the creation is "redone", it's actually an undo on the deletion of the new entity (see below),
28 // and so the connection will need to be considered dirty again. Usually it's an existing object that's deleted and restored,
29 // which would make things clean.
30 // See also CreateEntityAction
37 node.dispatchEvent(new EntityEvent(Connection.NODE_DELETED, node)); // delete NodeUI
42 public override function undoAction():uint {
43 var node:Node = entity as Node;
52 Connection.getConnection().dispatchEvent(new EntityEvent(Connection.NEW_NODE, entity));
53 if ( effects != null )