1 | /* |
2 | * Copyright 2009, SDQ, IPD, Uni Karlsruhe (TH) |
3 | */ |
4 | package de.uka.ipd.sdq.pcm.gmf.resource.edit.policies; |
5 | |
6 | import org.eclipse.emf.transaction.TransactionalEditingDomain; |
7 | import org.eclipse.gef.commands.Command; |
8 | import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; |
9 | import org.eclipse.gmf.runtime.emf.commands.core.commands.DuplicateEObjectsCommand; |
10 | import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; |
11 | import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest; |
12 | |
13 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.commands.LinkingResource2CreateCommand; |
14 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.commands.ResourceContainerCreateCommand; |
15 | import de.uka.ipd.sdq.pcm.gmf.resource.providers.PalladioComponentModelElementTypes; |
16 | |
17 | /** |
18 | * @generated |
19 | */ |
20 | public class ResourceEnvironmentItemSemanticEditPolicy extends |
21 | PalladioComponentModelBaseItemSemanticEditPolicy { |
22 | |
23 | /** |
24 | * @generated |
25 | */ |
26 | public ResourceEnvironmentItemSemanticEditPolicy() { |
27 | super(PalladioComponentModelElementTypes.ResourceEnvironment_1000); |
28 | } |
29 | |
30 | /** |
31 | * @generated |
32 | */ |
33 | protected Command getCreateCommand(CreateElementRequest req) { |
34 | if (PalladioComponentModelElementTypes.ResourceContainer_2001 == req |
35 | .getElementType()) { |
36 | return getGEFWrapper(new ResourceContainerCreateCommand(req)); |
37 | } |
38 | if (PalladioComponentModelElementTypes.LinkingResource_2003 == req |
39 | .getElementType()) { |
40 | return getGEFWrapper(new LinkingResource2CreateCommand(req)); |
41 | } |
42 | return super.getCreateCommand(req); |
43 | } |
44 | |
45 | /** |
46 | * @generated |
47 | */ |
48 | protected Command getDuplicateCommand(DuplicateElementsRequest req) { |
49 | TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()) |
50 | .getEditingDomain(); |
51 | return getGEFWrapper(new DuplicateAnythingCommand(editingDomain, req)); |
52 | } |
53 | |
54 | /** |
55 | * @generated |
56 | */ |
57 | private static class DuplicateAnythingCommand extends |
58 | DuplicateEObjectsCommand { |
59 | |
60 | /** |
61 | * @generated |
62 | */ |
63 | public DuplicateAnythingCommand( |
64 | TransactionalEditingDomain editingDomain, |
65 | DuplicateElementsRequest req) { |
66 | super(editingDomain, req.getLabel(), req |
67 | .getElementsToBeDuplicated(), req |
68 | .getAllDuplicatedElementsMap()); |
69 | } |
70 | |
71 | } |
72 | |
73 | } |