01: package newprocess.diagram.edit.policies;
02:
03: import org.eclipse.gef.commands.Command;
04: import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
05: import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
06: import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
07: import org.eclipse.emf.ecore.EObject;
08: import org.eclipse.emf.ecore.EAnnotation;
09: import org.eclipse.gmf.runtime.notation.View;
10: import newprocess.Actor;
11: import newprocess.AsyncActivity;
12:
13: import newprocess.diagram.providers.New_processElementTypes;
14:
15: import org.eclipse.gef.commands.UnexecutableCommand;
16:
17: /**
18: * @generated
19: */
20: public class AsyncActivity2ItemSemanticEditPolicy extends
21: New_processBaseItemSemanticEditPolicy {
22:
23: /**
24: * @generated
25: */
26: protected Command getDestroyElementCommand(DestroyElementRequest req) {
27: return getMSLWrapper(new DestroyElementCommand(req) {
28:
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: return super .getElementToDestroy();
37: }
38:
39: });
40: }
41:
42: /**
43: * @generated
44: */
45: protected Command getCreateRelationshipCommand(
46: CreateRelationshipRequest req) {
47: if (New_processElementTypes.AsyncActivityActor_4001 == req
48: .getElementType()) {
49: return req.getTarget() == null ? getCreateStartOutgoingAsyncActivity_Actor4001Command(req)
50: : null;
51: }
52: return super .getCreateRelationshipCommand(req);
53: }
54:
55: /**
56: * @generated
57: */
58: protected Command getCreateStartOutgoingAsyncActivity_Actor4001Command(
59: CreateRelationshipRequest req) {
60: EObject sourceEObject = req.getSource();
61: EObject targetEObject = req.getTarget();
62: if (false == sourceEObject instanceof AsyncActivity
63: || (targetEObject != null && false == targetEObject instanceof Actor)) {
64: return UnexecutableCommand.INSTANCE;
65: }
66: AsyncActivity source = (AsyncActivity) sourceEObject;
67: Actor target = (Actor) targetEObject;
68: if (!New_processBaseItemSemanticEditPolicy.LinkConstraints
69: .canCreateAsyncActivityActor_4001(source, target)) {
70: return UnexecutableCommand.INSTANCE;
71: }
72: return new Command() {
73: };
74: }
75: }
|