1 | /* |
2 | *Copyright 2007, SDQ, IPD, Uni Karlsruhe (TH) |
3 | */ |
4 | package de.uka.ipd.sdq.pcm.gmf.composite.edit.helpers; |
5 | |
6 | import java.util.ArrayList; |
7 | |
8 | import org.eclipse.emf.ecore.EReference; |
9 | import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; |
10 | import org.eclipse.gmf.runtime.common.core.command.ICommand; |
11 | import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand; |
12 | import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; |
13 | import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; |
14 | import org.eclipse.ui.PlatformUI; |
15 | |
16 | import de.uka.ipd.sdq.pcm.core.entity.EntityPackage; |
17 | import de.uka.ipd.sdq.pcm.dialogs.selection.PalladioSelectEObjectDialog; |
18 | import de.uka.ipd.sdq.pcm.repository.Interface; |
19 | import de.uka.ipd.sdq.pcm.repository.Repository; |
20 | import de.uka.ipd.sdq.pcm.repository.RepositoryPackage; |
21 | |
22 | // TODO: decide whether this file is obsolete |
23 | /** |
24 | * @generated not |
25 | */ |
26 | public class ProvidedRoleEditHelper extends |
27 | PalladioComponentModelBaseEditHelper { |
28 | |
29 | @Override |
30 | protected ICommand getConfigureCommand(ConfigureRequest request) { |
31 | Interface resource = null; |
32 | |
33 | ArrayList<Object> filterList = new ArrayList<Object>(); |
34 | filterList.add(Repository.class); |
35 | filterList.add(Interface.class); |
36 | |
37 | ArrayList<EReference> additionalReferences = new ArrayList<EReference>(); |
38 | PalladioSelectEObjectDialog dialog = new PalladioSelectEObjectDialog( |
39 | PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), |
40 | filterList, additionalReferences, request |
41 | .getElementToConfigure().eResource().getResourceSet()); |
42 | dialog.setProvidedService(Interface.class); |
43 | dialog.open(); |
44 | if (dialog.getResult() == null) |
45 | return new CanceledCommand(); |
46 | if (!(dialog.getResult() instanceof Interface)) |
47 | return new CanceledCommand(); |
48 | resource = (Interface) dialog.getResult(); |
49 | |
50 | ICommand cmd = new SetValueCommand(new SetRequest(request |
51 | .getElementToConfigure(), RepositoryPackage.eINSTANCE |
52 | .getProvidedRole_ProvidingEntity_ProvidedRole(), resource)); |
53 | |
54 | String name = "Provided_" + resource.getEntityName(); |
55 | |
56 | ICommand cmd2 = new SetValueCommand(new SetRequest(request |
57 | .getElementToConfigure(), EntityPackage.eINSTANCE |
58 | .getNamedElement_EntityName(), name)); |
59 | |
60 | CompositeCommand cc = new CompositeCommand( |
61 | "Configure Provided Role Context"); |
62 | cc.add(cmd); |
63 | cc.add(cmd2); |
64 | |
65 | return cc; |
66 | } |
67 | |
68 | } |