01: package newprocess.diagram.edit.helpers;
02:
03: import newprocess.Conclusion;
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 ConclusionEditHelper extends New_processBaseEditHelper {
25: /**
26: * This method generates the Preconditions
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 precondition and essential roots
38: doConfiguration(element, monitor);
39: return CommandResult.newOKCommandResult(element);
40: }
41: };
42: }
43:
44: /**
45: * By creating an Conclusion the Preconditions should also
46: * be generated
47: *
48: * @param element
49: * @param monitor
50: */
51: protected void doConfiguration(EObject element,
52: IProgressMonitor monitor) {
53: Conclusion conclusion = (Conclusion) element;
54:
55: // create the Precondition
56: EReference preconditionContainer = NewprocessPackage.eINSTANCE
57: .getConclusion_HasPrecondition();
58: Expression expressionPre = NewprocessFactory.eINSTANCE
59: .createExpression();
60: EClass expressionClassPre = expressionPre.eClass();
61: EObject preCond = EMFCoreUtil.create(conclusion,
62: preconditionContainer, expressionClassPre);
63:
64: // create the 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: }
|