| 1 | /** |
| 2 | * |
| 3 | */ |
| 4 | package de.uka.ipd.sdq.pcm.gmf.usage.helper; |
| 5 | |
| 6 | import org.eclipse.core.commands.ExecutionException; |
| 7 | import org.eclipse.core.runtime.IAdaptable; |
| 8 | import org.eclipse.core.runtime.IProgressMonitor; |
| 9 | import org.eclipse.gmf.runtime.common.core.command.CommandResult; |
| 10 | import org.eclipse.gmf.runtime.common.core.command.ICommand; |
| 11 | import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand; |
| 12 | import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand; |
| 13 | import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; |
| 14 | import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; |
| 15 | |
| 16 | import de.uka.ipd.sdq.pcm.repository.ProvidedRole; |
| 17 | import de.uka.ipd.sdq.pcm.repository.Signature; |
| 18 | import de.uka.ipd.sdq.pcm.usagemodel.UsagemodelPackage; |
| 19 | |
| 20 | /** |
| 21 | * @author admin |
| 22 | * |
| 23 | */ |
| 24 | public class EntryLevelSystemCallConfigureCommand extends ConfigureElementCommand { |
| 25 | |
| 26 | private ConfigureRequest request = null; |
| 27 | private Signature signature = null; |
| 28 | private ProvidedRole providedRole = null; |
| 29 | |
| 30 | public EntryLevelSystemCallConfigureCommand(ConfigureRequest request, |
| 31 | Signature signature, ProvidedRole providedRole) { |
| 32 | super(request); |
| 33 | this.request = request; |
| 34 | this.signature = signature; |
| 35 | this.providedRole = providedRole; |
| 36 | } |
| 37 | |
| 38 | /* (non-Javadoc) |
| 39 | * @see org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
| 40 | */ |
| 41 | @Override |
| 42 | protected CommandResult doExecuteWithResult(IProgressMonitor monitor, |
| 43 | IAdaptable info) throws ExecutionException { |
| 44 | |
| 45 | CommandResult commandResult = setSignatureEntryLevelSystemCall(monitor, |
| 46 | info); |
| 47 | if (!isOK(commandResult)) { |
| 48 | return CommandResult |
| 49 | .newErrorCommandResult("Set Signature for the EntryLevelSystemCall failed!"); |
| 50 | } |
| 51 | commandResult = setProvidedRoleEntryLevelSystemCall(monitor, info); |
| 52 | if (!isOK(commandResult)) { |
| 53 | return CommandResult |
| 54 | .newErrorCommandResult("Set ProvidedRole for the EntryLevelSystemCall failed!"); |
| 55 | } |
| 56 | return CommandResult.newOKCommandResult(); |
| 57 | } |
| 58 | |
| 59 | private CommandResult setSignatureEntryLevelSystemCall( |
| 60 | IProgressMonitor monitor, IAdaptable info) |
| 61 | throws ExecutionException { |
| 62 | |
| 63 | ICommand cmd = new SetValueCommand(new SetRequest(request |
| 64 | .getElementToConfigure(), UsagemodelPackage.eINSTANCE |
| 65 | .getEntryLevelSystemCall_OperationSignature__EntryLevelSystemCall(), |
| 66 | signature)); |
| 67 | |
| 68 | cmd.execute(monitor, info); |
| 69 | |
| 70 | return cmd.getCommandResult(); |
| 71 | } |
| 72 | |
| 73 | private CommandResult setProvidedRoleEntryLevelSystemCall( |
| 74 | IProgressMonitor monitor, IAdaptable info) |
| 75 | throws ExecutionException { |
| 76 | |
| 77 | ICommand cmd = new SetValueCommand(new SetRequest(request |
| 78 | .getElementToConfigure(), UsagemodelPackage.eINSTANCE |
| 79 | .getEntryLevelSystemCall_ProvidedRole_EntryLevelSystemCall(), |
| 80 | providedRole)); |
| 81 | |
| 82 | cmd.execute(monitor, info); |
| 83 | |
| 84 | return cmd.getCommandResult(); |
| 85 | } |
| 86 | |
| 87 | |
| 88 | } |