| 1 | package de.uka.ipd.sdq.pcm.dialogs.resource; |
| 2 | |
| 3 | import org.eclipse.gef.Request; |
| 4 | import org.eclipse.gef.commands.Command; |
| 5 | import org.eclipse.gmf.runtime.common.core.command.ICommand; |
| 6 | import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; |
| 7 | import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; |
| 8 | import org.eclipse.gmf.runtime.diagram.ui.editpolicies.OpenEditPolicy; |
| 9 | import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand; |
| 10 | import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; |
| 11 | import org.eclipse.gmf.runtime.notation.View; |
| 12 | import org.eclipse.ui.PlatformUI; |
| 13 | |
| 14 | import de.uka.ipd.sdq.pcm.resourceenvironment.ProcessingResourceSpecification; |
| 15 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceenvironmentPackage; |
| 16 | import de.uka.ipd.sdq.pcm.resourceenvironment.SchedulingPolicy; |
| 17 | |
| 18 | public class OpenSchedulingPolicyDialog extends OpenEditPolicy { |
| 19 | |
| 20 | @Override |
| 21 | protected Command getOpenCommand(Request request) { |
| 22 | SchedulingPolicy policy; |
| 23 | |
| 24 | SelectSchedulingPolicyElementDialog dialog = new SelectSchedulingPolicyElementDialog( |
| 25 | PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); |
| 26 | dialog.open(); |
| 27 | if (dialog.getResult() == null) { |
| 28 | return null; |
| 29 | } |
| 30 | |
| 31 | if (!(dialog.getResult() instanceof SchedulingPolicy)){ |
| 32 | return null; |
| 33 | } |
| 34 | policy = dialog.getResult(); |
| 35 | |
| 36 | ProcessingResourceSpecification specification = (ProcessingResourceSpecification)(((View) ((IGraphicalEditPart) getHost()).getModel()).getElement()); |
| 37 | ICommand icmd = new SetValueCommand( |
| 38 | new SetRequest( |
| 39 | specification, |
| 40 | ResourceenvironmentPackage.eINSTANCE.getProcessingResourceSpecification_SchedulingPolicy(), |
| 41 | policy)); |
| 42 | return new ICommandProxy(icmd); |
| 43 | } |
| 44 | |
| 45 | } |