1 | package de.uka.ipd.sdq.pcm.gmf.usage.helper; |
2 | |
3 | import org.eclipse.core.commands.ExecutionException; |
4 | import org.eclipse.core.runtime.IAdaptable; |
5 | import org.eclipse.core.runtime.IProgressMonitor; |
6 | import org.eclipse.gmf.runtime.common.core.command.CommandResult; |
7 | import org.eclipse.gmf.runtime.common.core.command.ICommand; |
8 | import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry; |
9 | import org.eclipse.gmf.runtime.emf.type.core.IElementType; |
10 | import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand; |
11 | import org.eclipse.gmf.runtime.emf.type.core.commands.CreateElementCommand; |
12 | import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand; |
13 | import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; |
14 | import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice; |
15 | import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; |
16 | import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; |
17 | import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; |
18 | |
19 | import de.uka.ipd.sdq.pcm.usagemodel.UsagemodelPackage; |
20 | import de.uka.ipd.sdq.stoex.StoexPackage; |
21 | |
22 | public class CreateLoopIterationsEditHelperAdvice extends |
23 | AbstractEditHelperAdvice implements IEditHelperAdvice { |
24 | |
25 | /* |
26 | * (non-Javadoc) |
27 | * |
28 | * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest) |
29 | */ |
30 | @Override |
31 | protected ICommand getAfterConfigureCommand(final ConfigureRequest request) { |
32 | ConfigureElementCommand confElementReq = new ConfigureElementCommand(request) { |
33 | |
34 | @Override |
35 | protected CommandResult doExecuteWithResult( |
36 | IProgressMonitor monitor, IAdaptable info) |
37 | throws ExecutionException { |
38 | |
39 | IElementType elementType = ElementTypeRegistry.getInstance(). |
40 | getType("de.uka.ipd.sdq.pcm.gmf.seff.PCMRandomVariable_9000"); |
41 | CreateElementRequest createRequest = new CreateElementRequest(request.getElementToConfigure(),elementType); |
42 | CreateElementCommand createCommand = new CreateElementCommand(createRequest); |
43 | createCommand.execute(monitor, info); |
44 | |
45 | SetRequest setSpecReq = new SetRequest(createCommand.getNewElement(), |
46 | StoexPackage.eINSTANCE.getRandomVariable_Specification(), |
47 | "1"); |
48 | SetValueCommand setRndVarCmd = new SetValueCommand(setSpecReq); |
49 | setRndVarCmd.execute(monitor, info); |
50 | |
51 | SetRequest setRequest = new SetRequest(request.getElementToConfigure(), |
52 | UsagemodelPackage.eINSTANCE.getLoop_LoopIteration_Loop(), |
53 | createCommand.getNewElement()); |
54 | SetValueCommand cmd = new SetValueCommand(setRequest); |
55 | cmd.execute(monitor, info); |
56 | |
57 | return CommandResult.newOKCommandResult(); |
58 | } |
59 | |
60 | }; |
61 | return confElementReq; |
62 | } |
63 | } |