01: /*******************************************************************************
02: * Copyright (c) 2000, 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.policies;
11:
12: import java.util.List;
13:
14: import org.eclipse.gef.EditPart;
15: import org.eclipse.gef.commands.Command;
16: import org.eclipse.gef.commands.CompoundCommand;
17: import org.eclipse.gef.editpolicies.ContainerEditPolicy;
18: import org.eclipse.gef.requests.CreateRequest;
19: import org.eclipse.gef.requests.GroupRequest;
20:
21: import org.openwfe.gpe.model.CompositeOrOneChild;
22: import org.openwfe.gpe.model.FlowElement;
23: import org.openwfe.gpe.model.commands.OrphanChildCommand;
24:
25: /**
26: * ActivityContainerEditPolicy
27: * @author Daniel Lee
28: */
29: public class ActivityContainerEditPolicy extends ContainerEditPolicy {
30:
31: /**
32: * @see ContainerEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
33: */
34: protected Command getCreateCommand(CreateRequest request) {
35: return null;
36: }
37:
38: /**
39: * @see org.eclipse.gef.editpolicies.ContainerEditPolicy#getOrphanChildrenCommand(org.eclipse.gef.requests.GroupRequest)
40: */
41: protected Command getOrphanChildrenCommand(GroupRequest request) {
42: List parts = request.getEditParts();
43: CompoundCommand result = new CompoundCommand();
44: for (int i = 0; i < parts.size(); i++) {
45: OrphanChildCommand orphan = new OrphanChildCommand();
46: orphan.setChild((FlowElement) ((EditPart) parts.get(i))
47: .getModel());
48: orphan
49: .setParent((CompositeOrOneChild) getHost()
50: .getModel());
51: result.add(orphan);
52: }
53: return result.unwrap();
54: }
55:
56: }
|