1 | /* |
2 | *Copyright 2007, SDQ, IPD, U KA |
3 | */ |
4 | package de.uka.ipd.sdq.pcm.gmf.allocation.edit.commands; |
5 | |
6 | import de.uka.ipd.sdq.pcm.allocation.Allocation; |
7 | import de.uka.ipd.sdq.pcm.allocation.AllocationContext; |
8 | import de.uka.ipd.sdq.pcm.allocation.AllocationPackage; |
9 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceContainer; |
10 | |
11 | import org.eclipse.emf.ecore.EClass; |
12 | import org.eclipse.emf.ecore.EObject; |
13 | |
14 | import org.eclipse.gmf.runtime.emf.type.core.commands.CreateElementCommand; |
15 | |
16 | import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; |
17 | |
18 | import org.eclipse.gmf.runtime.notation.View; |
19 | |
20 | /** |
21 | * @generated |
22 | */ |
23 | public class AllocationContextCreateCommand extends CreateElementCommand { |
24 | |
25 | /** |
26 | * @generated |
27 | */ |
28 | public AllocationContextCreateCommand(CreateElementRequest req) { |
29 | super(req); |
30 | } |
31 | |
32 | private Allocation allocation; |
33 | |
34 | /** |
35 | * @generated not |
36 | */ |
37 | public AllocationContextCreateCommand(CreateElementRequest req, Allocation a) { |
38 | super(req); |
39 | this.allocation = a; |
40 | } |
41 | |
42 | /** |
43 | * @generated |
44 | */ |
45 | protected EClass getEClassToEdit() { |
46 | return AllocationPackage.eINSTANCE.getAllocation(); |
47 | } |
48 | |
49 | /** |
50 | * @generated not |
51 | */ |
52 | protected EObject getElementToEdit() { |
53 | EObject container = allocation; |
54 | if (container instanceof View) { |
55 | container = ((View) container).getElement(); |
56 | } |
57 | return container; |
58 | } |
59 | |
60 | @Override |
61 | protected EObject doDefaultElementCreation() { |
62 | AllocationContext ctx = (AllocationContext) super |
63 | .doDefaultElementCreation(); |
64 | ctx |
65 | .setResourceContainer_AllocationContext((ResourceContainer) ((CreateElementRequest) this |
66 | .getRequest()).getContainer()); |
67 | return ctx; |
68 | } |
69 | |
70 | } |