1 | package de.uka.ipd.sdq.pcm.gmf.resource.helper; |
2 | |
3 | import org.eclipse.emf.ecore.EObject; |
4 | import org.eclipse.gmf.runtime.common.core.command.ICommand; |
5 | import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand; |
6 | import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; |
7 | import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice; |
8 | import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; |
9 | import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; |
10 | import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; |
11 | import org.eclipse.jface.dialogs.Dialog; |
12 | import org.eclipse.ui.PlatformUI; |
13 | |
14 | import de.uka.ipd.sdq.pcm.core.CoreFactory; |
15 | import de.uka.ipd.sdq.pcm.core.PCMRandomVariable; |
16 | import de.uka.ipd.sdq.pcm.dialogs.stoex.StochasticExpressionEditDialog; |
17 | import de.uka.ipd.sdq.pcm.parameter.ParameterPackage; |
18 | import de.uka.ipd.sdq.pcm.resourceenvironment.CommunicationLinkResourceSpecification; |
19 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceenvironmentPackage; |
20 | import de.uka.ipd.sdq.stoex.analyser.visitors.TypeEnum; |
21 | |
22 | public class LatencyEditHelperAdvice extends AbstractEditHelperAdvice implements |
23 | IEditHelperAdvice { |
24 | |
25 | // @Override |
26 | // protected ICommand getBeforeConfigureCommand(ConfigureRequest request) { |
27 | // PCMRandomVariable rv = CoreFactory.eINSTANCE.createPCMRandomVariable(); |
28 | // rv.setSpecification(""); |
29 | // |
30 | // StochasticExpressionEditDialog dialog = new StochasticExpressionEditDialog( |
31 | // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), |
32 | // TypeEnum.ANY, rv); |
33 | // dialog.open(); |
34 | // |
35 | // if (dialog.getReturnCode() == Dialog.CANCEL) |
36 | // return new CanceledCommand(); |
37 | // |
38 | // rv.setSpecification(dialog.getResultText()); |
39 | // |
40 | // ICommand cmd = new SetValueCommand(new SetRequest(request |
41 | // .getElementToConfigure(), |
42 | // ResourceenvironmentPackage.eINSTANCE.getCommunicationLinkResourceSpecification_Latency_CommunicationLinkResourceSpecification(), |
43 | // rv)); |
44 | // |
45 | // return cmd; |
46 | // } |
47 | |
48 | protected ICommand getCommand( |
49 | CommunicationLinkResourceSpecification communicationLinkResourceSpecification) { |
50 | PCMRandomVariable rv = CoreFactory.eINSTANCE.createPCMRandomVariable(); |
51 | rv.setSpecification(""); |
52 | |
53 | StochasticExpressionEditDialog dialog = new StochasticExpressionEditDialog( |
54 | PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), |
55 | TypeEnum.ANY, rv); |
56 | dialog.open(); |
57 | |
58 | if (dialog.getReturnCode() == Dialog.CANCEL) |
59 | return new CanceledCommand(); |
60 | |
61 | rv.setSpecification(dialog.getResultText()); |
62 | |
63 | ICommand cmd = new SetValueCommand( |
64 | new SetRequest( |
65 | communicationLinkResourceSpecification, |
66 | ResourceenvironmentPackage.eINSTANCE |
67 | .getCommunicationLinkResourceSpecification_Latency_CommunicationLinkResourceSpecification(), |
68 | rv)); |
69 | |
70 | return cmd; |
71 | } |
72 | } |