| 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 ThroughputEditHelperAdvice extends AbstractEditHelperAdvice |
| 23 | implements 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(), ResourceenvironmentPackage.eINSTANCE.getCommunicationLinkResourceSpecification_Throughput_CommunicationLinkResourceSpecification(), |
| 42 | // rv)); |
| 43 | // |
| 44 | // return cmd; |
| 45 | // } |
| 46 | |
| 47 | protected ICommand getCommand(CommunicationLinkResourceSpecification communicationLinkResourceSpecification) { |
| 48 | PCMRandomVariable rv = CoreFactory.eINSTANCE.createPCMRandomVariable(); |
| 49 | rv.setSpecification(""); |
| 50 | |
| 51 | StochasticExpressionEditDialog dialog = new StochasticExpressionEditDialog( |
| 52 | PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), |
| 53 | TypeEnum.ANY, rv); |
| 54 | dialog.open(); |
| 55 | |
| 56 | if (dialog.getReturnCode() == Dialog.CANCEL) |
| 57 | return new CanceledCommand(); |
| 58 | |
| 59 | rv.setSpecification(dialog.getResultText()); |
| 60 | |
| 61 | ICommand cmd = new MySetValueCommand(new SetRequest(communicationLinkResourceSpecification, |
| 62 | ResourceenvironmentPackage.eINSTANCE.getCommunicationLinkResourceSpecification_Throughput_CommunicationLinkResourceSpecification(), |
| 63 | rv)); |
| 64 | cmd.setLabel("Throughput"); |
| 65 | return cmd; |
| 66 | } |
| 67 | } |