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