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: import newprocess.NewprocessPackage;
13:
14: import newprocess.diagram.providers.New_processElementTypes;
15:
16: import org.eclipse.gef.commands.UnexecutableCommand;
17:
18: import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
19:
20: import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
21:
22: /**
23: * @generated
24: */
25: public class ActorItemSemanticEditPolicy extends
26: New_processBaseItemSemanticEditPolicy {
27:
28: /**
29: * @generated
30: */
31: protected Command getDestroyElementCommand(DestroyElementRequest req) {
32: return getMSLWrapper(new DestroyElementCommand(req) {
33:
34: protected EObject getElementToDestroy() {
35: View view = (View) getHost().getModel();
36: EAnnotation annotation = view
37: .getEAnnotation("Shortcut"); //$NON-NLS-1$
38: if (annotation != null) {
39: return view;
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 ? null
55: : getCreateCompleteIncomingAsyncActivity_Actor4001Command(req);
56: }
57: return super .getCreateRelationshipCommand(req);
58: }
59:
60: /**
61: * @generated
62: */
63: protected Command getCreateCompleteIncomingAsyncActivity_Actor4001Command(
64: CreateRelationshipRequest req) {
65: EObject sourceEObject = req.getSource();
66: EObject targetEObject = req.getTarget();
67: if (false == sourceEObject instanceof AsyncActivity
68: || 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: SetRequest setReq = new SetRequest(req.getSource(),
78: NewprocessPackage.eINSTANCE.getAsyncActivity_Actor(),
79: req.getTarget());
80: return getMSLWrapper(new SetValueCommand(setReq));
81: }
82: }
|