01: package newprocess.diagram.edit.policies;
02:
03: import newprocess.ConditionProxy;
04: import newprocess.Expansion;
05: import newprocess.diagram.cust.operation.ExpansionDeleteOperation;
06: import newprocess.diagram.providers.New_processElementTypes;
07:
08: import org.eclipse.emf.ecore.EAnnotation;
09: import org.eclipse.emf.ecore.EObject;
10: import org.eclipse.gef.commands.Command;
11: import org.eclipse.gef.commands.UnexecutableCommand;
12: import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
13: import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
14: import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
15: import org.eclipse.gmf.runtime.notation.View;
16:
17: /**
18: * @generated
19: */
20: public class ExpansionItemSemanticEditPolicy extends
21: New_processBaseItemSemanticEditPolicy {
22:
23: /**
24: * @generated NOT
25: * @author sh
26: */
27: protected Command getDestroyElementCommand(DestroyElementRequest req) {
28: return getMSLWrapper(new DestroyElementCommand(req) {
29:
30: protected EObject getElementToDestroy() {
31: View view = (View) getHost().getModel();
32: EAnnotation annotation = view
33: .getEAnnotation("Shortcut"); //$NON-NLS-1$
34: if (annotation != null) {
35: return view;
36: }
37:
38: // if the activity should be deleted, also delete all linked terms
39: ExpansionDeleteOperation deleteOperation = new ExpansionDeleteOperation();
40: deleteOperation.doExecute(getHost());
41:
42: return super .getElementToDestroy();
43: }
44:
45: });
46: }
47:
48: /**
49: * @generated
50: */
51: protected Command getCreateRelationshipCommand(
52: CreateRelationshipRequest req) {
53: if (New_processElementTypes.ExpansionExpansionProxy_4006 == req
54: .getElementType()) {
55: return req.getTarget() == null ? getCreateStartOutgoingExpansion_ExpansionProxy4006Command(req)
56: : null;
57: }
58: return super .getCreateRelationshipCommand(req);
59: }
60:
61: /**
62: * @generated
63: */
64: protected Command getCreateStartOutgoingExpansion_ExpansionProxy4006Command(
65: CreateRelationshipRequest req) {
66: EObject sourceEObject = req.getSource();
67: EObject targetEObject = req.getTarget();
68: if (false == sourceEObject instanceof Expansion
69: || (targetEObject != null && false == targetEObject instanceof ConditionProxy)) {
70: return UnexecutableCommand.INSTANCE;
71: }
72: Expansion source = (Expansion) sourceEObject;
73: ConditionProxy target = (ConditionProxy) targetEObject;
74: if (!New_processBaseItemSemanticEditPolicy.LinkConstraints
75: .canCreateExpansionExpansionProxy_4006(source, target)) {
76: return UnexecutableCommand.INSTANCE;
77: }
78: return new Command() {
79: };
80: }
81: }
|