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