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 InfrastructureRequiredRoleEditHelper extends |
26 | PalladioComponentModelBaseEditHelper { |
27 | @Override |
28 | protected ICommand getConfigureCommand(ConfigureRequest request) { |
29 | InfrastructureInterface resource = null; |
30 | |
31 | ArrayList<Object> filterList = new ArrayList<Object>(); |
32 | filterList.add(Repository.class); |
33 | filterList.add(InfrastructureInterface.class); |
34 | |
35 | ArrayList<EReference> additionalReferences = new ArrayList<EReference>(); |
36 | PalladioSelectEObjectDialog dialog = new PalladioSelectEObjectDialog( |
37 | PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), |
38 | filterList, additionalReferences, request |
39 | .getElementToConfigure().eResource().getResourceSet()); |
40 | dialog.setProvidedService(InfrastructureInterface.class); |
41 | dialog.open(); |
42 | if (dialog.getResult() == null) |
43 | return new CanceledCommand(); |
44 | if (!(dialog.getResult() instanceof InfrastructureInterface)) |
45 | return new CanceledCommand(); |
46 | resource = (InfrastructureInterface) dialog.getResult(); |
47 | |
48 | ICommand cmd = new SetValueCommand( |
49 | new SetRequest( |
50 | request.getElementToConfigure(), |
51 | RepositoryPackage.eINSTANCE |
52 | .getInfrastructureRequiredRole_RequiredInterface__InfrastructureRequiredRole(), |
53 | 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 Infrastructure Required Role Context"); |
63 | cc.add(cmd); |
64 | cc.add(cmd2); |
65 | |
66 | return cc; |
67 | } |
68 | } |