001: package newprocess.diagram.edit.policies;
002:
003: import newprocess.ConditionProxy;
004: import newprocess.NewprocessPackage;
005: import newprocess.OperatorTerm;
006: import newprocess.Root;
007: import newprocess.Term;
008: import newprocess.diagram.cust.operation.OperatorTermChainDeleteOperation;
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 OrOperatorItemSemanticEditPolicy extends
026: New_processBaseItemSemanticEditPolicy {
027:
028: /**
029: * @generated NOT
030: * @author sh
031: */
032: protected Command getDestroyElementCommand(DestroyElementRequest req) {
033: return getMSLWrapper(new DestroyElementCommand(req) {
034:
035: protected EObject getElementToDestroy() {
036: View view = (View) getHost().getModel();
037: EAnnotation annotation = view
038: .getEAnnotation("Shortcut"); //$NON-NLS-1$
039: if (annotation != null) {
040: return view;
041: }
042:
043: // if the operator should be deleted, also delete all linked ports
044: OperatorTermChainDeleteOperation deleteOperation = new OperatorTermChainDeleteOperation();
045: deleteOperation.doExecute(getHost());
046:
047: return super .getElementToDestroy();
048: }
049:
050: });
051: }
052:
053: /**
054: * @generated
055: */
056: protected Command getCreateRelationshipCommand(
057: CreateRelationshipRequest req) {
058: if (New_processElementTypes.RootTerm_4002 == req
059: .getElementType()) {
060: return req.getTarget() == null ? null
061: : getCreateCompleteIncomingRoot_Term4002Command(req);
062: }
063: if (New_processElementTypes.OperatorTermSubTerm_4003 == req
064: .getElementType()) {
065: return req.getTarget() == null ? getCreateStartOutgoingOperatorTerm_SubTerm4003Command(req)
066: : getCreateCompleteIncomingOperatorTerm_SubTerm4003Command(req);
067: }
068: return super .getCreateRelationshipCommand(req);
069: }
070:
071: /**
072: * @generated
073: */
074: protected Command getCreateCompleteIncomingRoot_Term4002Command(
075: CreateRelationshipRequest req) {
076: EObject sourceEObject = req.getSource();
077: EObject targetEObject = req.getTarget();
078: if (false == sourceEObject instanceof Root
079: || false == targetEObject instanceof Term) {
080: return UnexecutableCommand.INSTANCE;
081: }
082: Root source = (Root) sourceEObject;
083: Term target = (Term) targetEObject;
084: if (!New_processBaseItemSemanticEditPolicy.LinkConstraints
085: .canCreateRootTerm_4002(source, target)) {
086: return UnexecutableCommand.INSTANCE;
087: }
088: SetRequest setReq = new SetRequest(req.getSource(),
089: NewprocessPackage.eINSTANCE.getRoot_Term(), req
090: .getTarget());
091: return getMSLWrapper(new SetValueCommand(setReq));
092: }
093:
094: /**
095: * @generated NOT
096: * @author sh
097: */
098: protected Command getCreateStartOutgoingOperatorTerm_SubTerm4003Command(
099: CreateRelationshipRequest req) {
100: /*
101: EObject sourceEObject = req.getSource();
102: EObject targetEObject = req.getTarget();
103: if (false == sourceEObject instanceof OperatorTerm
104: || (targetEObject != null && false == targetEObject instanceof Term)) {
105: return UnexecutableCommand.INSTANCE;
106: }
107: OperatorTerm source = (OperatorTerm) sourceEObject;
108: Term target = (Term) targetEObject;
109: if (!New_processBaseItemSemanticEditPolicy.LinkConstraints
110: .canCreateOperatorTermSubTerm_4003(source, target)) {
111: return UnexecutableCommand.INSTANCE;
112: }
113: return new Command() {
114: };
115: */
116:
117: EObject sourceEObject = req.getSource();
118: EObject targetEObject = req.getTarget();
119: if (false == sourceEObject instanceof OperatorTerm
120: || (targetEObject != null && false == targetEObject instanceof ConditionProxy)) {
121: return UnexecutableCommand.INSTANCE;
122: }
123: OperatorTerm source = (OperatorTerm) sourceEObject;
124: Term target = (Term) targetEObject;
125: if (!New_processBaseItemSemanticEditPolicy.LinkConstraints
126: .canCreateOperatorTermSubTerm_4003(source, target)) {
127: return UnexecutableCommand.INSTANCE;
128: }
129: return new Command() {
130: };
131: }
132:
133: /**
134: * @generated
135: */
136: protected Command getCreateCompleteIncomingOperatorTerm_SubTerm4003Command(
137: CreateRelationshipRequest req) {
138: EObject sourceEObject = req.getSource();
139: EObject targetEObject = req.getTarget();
140: if (false == sourceEObject instanceof OperatorTerm
141: || false == targetEObject instanceof Term) {
142: return UnexecutableCommand.INSTANCE;
143: }
144: OperatorTerm source = (OperatorTerm) sourceEObject;
145: Term target = (Term) targetEObject;
146: if (!New_processBaseItemSemanticEditPolicy.LinkConstraints
147: .canCreateOperatorTermSubTerm_4003(source, target)) {
148: return UnexecutableCommand.INSTANCE;
149: }
150: SetRequest setReq = new SetRequest(req.getSource(),
151: NewprocessPackage.eINSTANCE.getOperatorTerm_SubTerm(),
152: req.getTarget());
153: return getMSLWrapper(new SetValueCommand(setReq));
154: }
155: }
|