| 1 | package de.uka.ipd.sdq.pcm.gmf.repository.helper; |
| 2 | |
| 3 | import org.eclipse.gmf.runtime.common.core.command.ICommand; |
| 4 | import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand; |
| 5 | import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; |
| 6 | import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice; |
| 7 | import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; |
| 8 | import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; |
| 9 | import org.eclipse.ui.PlatformUI; |
| 10 | |
| 11 | import de.uka.ipd.sdq.pcm.dialogs.variablenames.SetOutputVariableNameDialog; |
| 12 | import de.uka.ipd.sdq.pcm.parameter.ParameterPackage; |
| 13 | import de.uka.ipd.sdq.stoex.AbstractNamedReference; |
| 14 | |
| 15 | public class ComponentParameterEditHelperAdvice extends |
| 16 | AbstractEditHelperAdvice implements IEditHelperAdvice { |
| 17 | |
| 18 | @Override |
| 19 | protected ICommand getAfterConfigureCommand(ConfigureRequest request) { |
| 20 | SetOutputVariableNameDialog dialog = new SetOutputVariableNameDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); |
| 21 | dialog.open(); |
| 22 | |
| 23 | String enteredName = dialog.getResult(); |
| 24 | if (enteredName == null){ |
| 25 | return new CanceledCommand(); |
| 26 | } |
| 27 | |
| 28 | AbstractNamedReference namedReference = |
| 29 | dialog.getOutputVariableReference(); |
| 30 | |
| 31 | ICommand cmd = new SetValueCommand(new SetRequest(request |
| 32 | .getElementToConfigure(), ParameterPackage.eINSTANCE |
| 33 | .getVariableUsage_NamedReference__VariableUsage(), |
| 34 | namedReference)); |
| 35 | return cmd; |
| 36 | } |
| 37 | |
| 38 | } |