001: package newprocess.diagram.edit.policies;
002:
003: import newprocess.ConditionProxy;
004: import newprocess.ConditionTerm;
005: import newprocess.NewprocessPackage;
006: import newprocess.OperatorTerm;
007: import newprocess.Root;
008: import newprocess.Term;
009: import newprocess.diagram.providers.New_processElementTypes;
010:
011: import org.eclipse.emf.ecore.EAnnotation;
012: import org.eclipse.emf.ecore.EObject;
013: import org.eclipse.gef.commands.Command;
014: import org.eclipse.gef.commands.UnexecutableCommand;
015: import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
016: import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
017: import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
018: import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
019: import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
020: import org.eclipse.gmf.runtime.notation.View;
021:
022: /**
023: * @generated
024: */
025: public class ConditionTermItemSemanticEditPolicy extends
026: New_processBaseItemSemanticEditPolicy {
027:
028: /**
029: * @generated
030: */
031: protected Command getDestroyElementCommand(DestroyElementRequest req) {
032: return getMSLWrapper(new DestroyElementCommand(req) {
033:
034: protected EObject getElementToDestroy() {
035: View view = (View) getHost().getModel();
036: EAnnotation annotation = view
037: .getEAnnotation("Shortcut"); //$NON-NLS-1$
038: if (annotation != null) {
039: return view;
040: }
041: return super .getElementToDestroy();
042: }
043:
044: });
045: }
046:
047: /**
048: * @generated
049: */
050: protected Command getCreateRelationshipCommand(
051: CreateRelationshipRequest req) {
052: if (New_processElementTypes.RootTerm_4002 == req
053: .getElementType()) {
054: return req.getTarget() == null ? null
055: : getCreateCompleteIncomingRoot_Term4002Command(req);
056: }
057: if (New_processElementTypes.OperatorTermSubTerm_4003 == req
058: .getElementType()) {
059: return req.getTarget() == null ? null
060: : getCreateCompleteIncomingOperatorTerm_SubTerm4003Command(req);
061: }
062: if (New_processElementTypes.ConditionTermConditionProxy_4004 == req
063: .getElementType()) {
064: return req.getTarget() == null ? getCreateStartOutgoingConditionTerm_ConditionProxy4004Command(req)
065: : null;
066: }
067: return super .getCreateRelationshipCommand(req);
068: }
069:
070: /**
071: * @generated
072: */
073: protected Command getCreateCompleteIncomingRoot_Term4002Command(
074: CreateRelationshipRequest req) {
075: EObject sourceEObject = req.getSource();
076: EObject targetEObject = req.getTarget();
077: if (false == sourceEObject instanceof Root
078: || false == targetEObject instanceof Term) {
079: return UnexecutableCommand.INSTANCE;
080: }
081: Root source = (Root) sourceEObject;
082: Term target = (Term) targetEObject;
083: if (!New_processBaseItemSemanticEditPolicy.LinkConstraints
084: .canCreateRootTerm_4002(source, target)) {
085: return UnexecutableCommand.INSTANCE;
086: }
087: SetRequest setReq = new SetRequest(req.getSource(),
088: NewprocessPackage.eINSTANCE.getRoot_Term(), req
089: .getTarget());
090: return getMSLWrapper(new SetValueCommand(setReq));
091: }
092:
093: /**
094: * @generated
095: */
096: protected Command getCreateCompleteIncomingOperatorTerm_SubTerm4003Command(
097: CreateRelationshipRequest req) {
098: EObject sourceEObject = req.getSource();
099: EObject targetEObject = req.getTarget();
100: if (false == sourceEObject instanceof OperatorTerm
101: || false == targetEObject instanceof Term) {
102: return UnexecutableCommand.INSTANCE;
103: }
104: OperatorTerm source = (OperatorTerm) sourceEObject;
105: Term target = (Term) targetEObject;
106: if (!New_processBaseItemSemanticEditPolicy.LinkConstraints
107: .canCreateOperatorTermSubTerm_4003(source, target)) {
108: return UnexecutableCommand.INSTANCE;
109: }
110: SetRequest setReq = new SetRequest(req.getSource(),
111: NewprocessPackage.eINSTANCE.getOperatorTerm_SubTerm(),
112: req.getTarget());
113: return getMSLWrapper(new SetValueCommand(setReq));
114: }
115:
116: /**
117: * @generated
118: */
119: protected Command getCreateStartOutgoingConditionTerm_ConditionProxy4004Command(
120: CreateRelationshipRequest req) {
121: EObject sourceEObject = req.getSource();
122: EObject targetEObject = req.getTarget();
123: if (false == sourceEObject instanceof ConditionTerm
124: || (targetEObject != null && false == targetEObject instanceof ConditionProxy)) {
125: return UnexecutableCommand.INSTANCE;
126: }
127: ConditionTerm source = (ConditionTerm) sourceEObject;
128: ConditionProxy target = (ConditionProxy) targetEObject;
129: if (!New_processBaseItemSemanticEditPolicy.LinkConstraints
130: .canCreateConditionTermConditionProxy_4004(source,
131: target)) {
132: return UnexecutableCommand.INSTANCE;
133: }
134: return new Command() {
135: };
136: }
137: }
|