01: package newprocess.diagram.edit.helpers;
02:
03: import newprocess.AsyncActivity;
04: import newprocess.Expression;
05: import newprocess.NewprocessFactory;
06: import newprocess.NewprocessPackage;
07: import newprocess.Root;
08:
09: import org.eclipse.core.commands.ExecutionException;
10: import org.eclipse.core.runtime.IAdaptable;
11: import org.eclipse.core.runtime.IProgressMonitor;
12: import org.eclipse.emf.ecore.EClass;
13: import org.eclipse.emf.ecore.EObject;
14: import org.eclipse.emf.ecore.EReference;
15: import org.eclipse.gmf.runtime.common.core.command.CommandResult;
16: import org.eclipse.gmf.runtime.common.core.command.ICommand;
17: import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
18: import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand;
19: import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
20:
21: /**
22: * @generated
23: */
24: public class AsyncActivityEditHelper extends New_processBaseEditHelper {
25: /**
26: * This method generates the Pre-and Postconditions
27: * and the Roots
28: */
29: @Override
30: protected ICommand getConfigureCommand(final ConfigureRequest req) {
31: return new ConfigureElementCommand(req) {
32: protected CommandResult doExecuteWithResult(
33: IProgressMonitor monitor, IAdaptable info)
34: throws ExecutionException {
35: EObject element = req.getElementToConfigure();
36:
37: // add the pre and postcondition and essential roots
38: doConfiguration(element, monitor);
39: return CommandResult.newOKCommandResult(element);
40: }
41: };
42: }
43:
44: /**
45: * By creating an SyncActivity the Pre-and Postconditions should also
46: * be generated
47: *
48: * @param element
49: * @param monitor
50: */
51: protected void doConfiguration(EObject element,
52: IProgressMonitor monitor) {
53: AsyncActivity activity = (AsyncActivity) element;
54:
55: // create the Precondition
56: EReference preconditionContainer = NewprocessPackage.eINSTANCE
57: .getAsyncActivity_HasPrecondition();
58: Expression expressionPre = NewprocessFactory.eINSTANCE
59: .createExpression();
60: EClass expressionClassPre = expressionPre.eClass();
61: EObject preCond = EMFCoreUtil.create(activity,
62: preconditionContainer, expressionClassPre);
63:
64: // Create Root
65: EReference rootContainer = NewprocessPackage.eINSTANCE
66: .getExpression_HasRoot();
67: Root root = NewprocessFactory.eINSTANCE.createRoot();
68: EClass rootClass = root.eClass();
69: EMFCoreUtil.create(preCond, rootContainer, rootClass);
70:
71: // create the Postcondition
72: EReference postconditionContainer = NewprocessPackage.eINSTANCE
73: .getAsyncActivity_HasPostcondition();
74: Expression expressionPost = NewprocessFactory.eINSTANCE
75: .createExpression();
76: EClass expressionClassPost = expressionPost.eClass();
77:
78: EObject postCond = EMFCoreUtil.create(activity,
79: postconditionContainer, expressionClassPost);
80:
81: // create Root
82: rootContainer = NewprocessPackage.eINSTANCE
83: .getExpression_HasRoot();
84: root = NewprocessFactory.eINSTANCE.createRoot();
85: rootClass = root.eClass();
86: EMFCoreUtil.create(postCond, rootContainer, rootClass);
87:
88: // set the default value of the timeout property to "86400"
89: activity.setTimeout(86400);
90: }
91: }
|