01: package org.openwfe.gpe.model.commands;
02:
03: import java.util.ArrayList;
04: import java.util.List;
05:
06: import org.eclipse.gef.commands.Command;
07:
08: import org.openwfe.gpe.model.CompositeOrOneChild;
09: import org.openwfe.gpe.model.FlowElement;
10:
11: /**
12: * Handles the deletion of Activities.
13: * @author Daniel Lee
14: */
15: public class DeleteCommand extends Command {
16:
17: private FlowElement child;
18: private CompositeOrOneChild parent;
19: private int index = -1;
20:
21: /**
22: * @see org.eclipse.gef.commands.Command#execute()
23: */
24: public void execute() {
25: primExecute();
26: }
27:
28: /**
29: * Invokes the execution of this command.
30: */
31: protected void primExecute() {
32: index = parent.getChildren().indexOf(child);
33: parent.removeChild(child);
34: }
35:
36: /**
37: * @see org.eclipse.gef.commands.Command#redo()
38: */
39: public void redo() {
40: primExecute();
41: }
42:
43: /**
44: * Sets the child to the passed FlowElement
45: * @param a the child
46: */
47: public void setChild(FlowElement a) {
48: child = a;
49: }
50:
51: /**
52: * Sets the parent to the passed CompositeOrOneChild
53: * @param sa the parent
54: */
55: public void setParent(CompositeOrOneChild sa) {
56: parent = sa;
57: }
58:
59: /**
60: * @see org.eclipse.gef.commands.Command#undo()
61: */
62: public void undo() {
63: parent.addChild(child, index);
64: }
65:
66: }
|