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.composition.CompositionPackage; |
17 | import de.uka.ipd.sdq.pcm.core.entity.EntityPackage; |
18 | import de.uka.ipd.sdq.pcm.dialogs.selection.PalladioSelectEObjectDialog; |
19 | import de.uka.ipd.sdq.pcm.repository.Repository; |
20 | import de.uka.ipd.sdq.pcm.repository.RepositoryComponent; |
21 | |
22 | /** |
23 | * @generated not |
24 | */ |
25 | public class AssemblyContextEditHelper extends |
26 | PalladioComponentModelBaseEditHelper { |
27 | |
28 | @Override |
29 | protected ICommand getConfigureCommand(ConfigureRequest request) { |
30 | RepositoryComponent resource = null; |
31 | |
32 | ArrayList<Object> filterList = new ArrayList<Object>(); |
33 | filterList.add(Repository.class); |
34 | //filterList.add(ProvidesComponentType.class); // <- what is/was it for? |
35 | filterList.add(RepositoryComponent.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(RepositoryComponent.class); |
43 | dialog.open(); |
44 | if (dialog.getResult() == null) |
45 | return new CanceledCommand(); |
46 | if (!(dialog.getResult() instanceof RepositoryComponent)) |
47 | return new CanceledCommand(); |
48 | resource = (RepositoryComponent) dialog.getResult(); |
49 | |
50 | ICommand cmd = new SetValueCommand(new SetRequest(request |
51 | .getElementToConfigure(), CompositionPackage.eINSTANCE |
52 | .getAssemblyContext_EncapsulatedComponent__AssemblyContext(), |
53 | resource)); |
54 | |
55 | String allocationName = "Assembly_" + resource.getEntityName(); |
56 | allocationName += " <" + resource.getEntityName() + ">"; |
57 | |
58 | ICommand cmd2 = new SetValueCommand(new SetRequest(request |
59 | .getElementToConfigure(), EntityPackage.eINSTANCE |
60 | .getNamedElement_EntityName(), allocationName)); |
61 | |
62 | CompositeCommand cc = new CompositeCommand("Configure Assembly Context"); |
63 | cc.add(cmd); |
64 | cc.add(cmd2); |
65 | |
66 | return cc; |
67 | } |
68 | |
69 | } |