01: /*******************************************************************************
02: * Copyright (c) 2003, 2004 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Common Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/cpl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.openwfe.gpe.model.commands;
11:
12: import java.util.List;
13:
14: import org.eclipse.gef.commands.Command;
15:
16: import org.openwfe.gpe.model.CompositeOrOneChild;
17: import org.openwfe.gpe.model.FlowElement;
18:
19: /**
20: * OrphanChildCommand
21: * @author Daniel Lee
22: */
23: public class OrphanChildCommand extends Command {
24:
25: private CompositeOrOneChild parent;
26: private FlowElement child;
27: private int index;
28:
29: /**
30: * @see org.eclipse.gef.commands.Command#execute()
31: */
32: public void execute() {
33: List children = parent.getChildren();
34: index = children.indexOf(child);
35: parent.removeChild(child);
36: }
37:
38: /**
39: * Sets the child to the passed FlowElement
40: * @param child the child
41: */
42: public void setChild(FlowElement child) {
43: this .child = child;
44: }
45:
46: /**
47: * Sets the parent to the passed CompositeOrOneChild
48: * @param parent the parent
49: */
50: public void setParent(CompositeOrOneChild parent) {
51: this .parent = parent;
52: }
53:
54: /**
55: * @see org.eclipse.gef.commands.Command#undo()
56: */
57: public void undo() {
58: parent.addChild(child, index);
59: }
60:
61: }
|