01: package newprocess.diagram.edit.policies;
02:
03: import newprocess.Actor;
04: import newprocess.AsyncActivity;
05: import newprocess.diagram.cust.operation.AsyncActivityDeleteOperation;
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 AsyncActivityItemSemanticEditPolicy 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: protected EObject getElementToDestroy() {
30: View view = (View) getHost().getModel();
31: EAnnotation annotation = view
32: .getEAnnotation("Shortcut"); //$NON-NLS-1$
33: if (annotation != null) {
34: return view;
35: }
36:
37: // if the activity should be deleted, also delete all linked terms
38: AsyncActivityDeleteOperation deleteOperation = new AsyncActivityDeleteOperation();
39: deleteOperation.doExecute(getHost());
40:
41: return super .getElementToDestroy();
42: }
43:
44: });
45: }
46:
47: /**
48: * @generated
49: */
50: protected Command getCreateRelationshipCommand(
51: CreateRelationshipRequest req) {
52: if (New_processElementTypes.AsyncActivityActor_4001 == req
53: .getElementType()) {
54: return req.getTarget() == null ? getCreateStartOutgoingAsyncActivity_Actor4001Command(req)
55: : null;
56: }
57: return super .getCreateRelationshipCommand(req);
58: }
59:
60: /**
61: * @generated
62: */
63: protected Command getCreateStartOutgoingAsyncActivity_Actor4001Command(
64: CreateRelationshipRequest req) {
65: EObject sourceEObject = req.getSource();
66: EObject targetEObject = req.getTarget();
67: if (false == sourceEObject instanceof AsyncActivity
68: || (targetEObject != null && false == targetEObject instanceof Actor)) {
69: return UnexecutableCommand.INSTANCE;
70: }
71: AsyncActivity source = (AsyncActivity) sourceEObject;
72: Actor target = (Actor) targetEObject;
73: if (!New_processBaseItemSemanticEditPolicy.LinkConstraints
74: .canCreateAsyncActivityActor_4001(source, target)) {
75: return UnexecutableCommand.INSTANCE;
76: }
77: return new Command() {
78: };
79: }
80: }
|