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