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.jface.dialogs.Dialog; |
10 | import org.eclipse.ui.PlatformUI; |
11 | |
12 | import de.uka.ipd.sdq.pcm.core.CoreFactory; |
13 | import de.uka.ipd.sdq.pcm.core.PCMRandomVariable; |
14 | import de.uka.ipd.sdq.pcm.dialogs.stoex.StochasticExpressionEditDialog; |
15 | import de.uka.ipd.sdq.pcm.parameter.ParameterPackage; |
16 | import de.uka.ipd.sdq.stoex.analyser.visitors.TypeEnum; |
17 | |
18 | public class VariableCharacterisationEditHelperAdvice extends |
19 | AbstractEditHelperAdvice implements IEditHelperAdvice { |
20 | |
21 | @Override |
22 | protected ICommand getAfterConfigureCommand(ConfigureRequest request) { |
23 | PCMRandomVariable rv = CoreFactory.eINSTANCE.createPCMRandomVariable(); |
24 | rv.setSpecification(""); |
25 | |
26 | StochasticExpressionEditDialog dialog = new StochasticExpressionEditDialog( |
27 | PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), |
28 | TypeEnum.ANY, rv); |
29 | dialog.open(); |
30 | |
31 | if (dialog.getReturnCode() == Dialog.CANCEL) |
32 | return new CanceledCommand(); |
33 | |
34 | rv.setSpecification(dialog.getResultText()); |
35 | |
36 | ICommand cmd = new SetValueCommand( |
37 | new SetRequest(request.getElementToConfigure(), |
38 | ParameterPackage.eINSTANCE.getVariableCharacterisation_Specification_VariableCharacterisation(), |
39 | rv)); |
40 | |
41 | return cmd; |
42 | } |
43 | } |