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 | /** |
25 | * @generated not |
26 | */ |
27 | public class RequiredRoleEditHelper extends |
28 | PalladioComponentModelBaseEditHelper { |
29 | |
30 | @Override |
31 | protected ICommand getConfigureCommand(ConfigureRequest request) { |
32 | Interface resource = null; |
33 | |
34 | ArrayList<Object> filterList = new ArrayList<Object>(); |
35 | filterList.add(Repository.class); |
36 | filterList.add(Interface.class); |
37 | |
38 | ArrayList<EReference> additionalReferences = new ArrayList<EReference>(); |
39 | PalladioSelectEObjectDialog dialog = new PalladioSelectEObjectDialog( |
40 | PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), |
41 | filterList, additionalReferences, request |
42 | .getElementToConfigure().eResource().getResourceSet()); |
43 | dialog.setProvidedService(Interface.class); |
44 | dialog.open(); |
45 | if (dialog.getResult() == null) |
46 | return new CanceledCommand(); |
47 | if (!(dialog.getResult() instanceof Interface)) |
48 | return new CanceledCommand(); |
49 | resource = (Interface) dialog.getResult(); |
50 | |
51 | ICommand cmd = new SetValueCommand(new SetRequest(request |
52 | .getElementToConfigure(), RepositoryPackage.eINSTANCE |
53 | .getRequiredRole_RequiringEntity_RequiredRole(), resource)); |
54 | |
55 | String name = "Required_" + resource.getEntityName(); |
56 | |
57 | ICommand cmd2 = new SetValueCommand(new SetRequest(request |
58 | .getElementToConfigure(), EntityPackage.eINSTANCE |
59 | .getNamedElement_EntityName(), name)); |
60 | |
61 | CompositeCommand cc = new CompositeCommand( |
62 | "Configure Required Role Context"); |
63 | cc.add(cmd); |
64 | cc.add(cmd2); |
65 | |
66 | return cc; |
67 | } |
68 | |
69 | } |