| 1 | /* |
| 2 | *Copyright 2007, IPD, SDQ, University of Karlsruhe |
| 3 | */ |
| 4 | package de.uka.ipd.sdq.pcm.gmf.repository.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.repository.edit.commands.BasicComponentCreateCommand; |
| 14 | import de.uka.ipd.sdq.pcm.gmf.repository.edit.commands.CompleteComponentTypeCreateCommand; |
| 15 | import de.uka.ipd.sdq.pcm.gmf.repository.edit.commands.CompositeComponentCreateCommand; |
| 16 | import de.uka.ipd.sdq.pcm.gmf.repository.edit.commands.EventGroupCreateCommand; |
| 17 | import de.uka.ipd.sdq.pcm.gmf.repository.edit.commands.InfrastructureInterfaceCreateCommand; |
| 18 | import de.uka.ipd.sdq.pcm.gmf.repository.edit.commands.OperationInterfaceCreateCommand; |
| 19 | import de.uka.ipd.sdq.pcm.gmf.repository.edit.commands.ProvidesComponentTypeCreateCommand; |
| 20 | import de.uka.ipd.sdq.pcm.gmf.repository.edit.commands.SubSystemCreateCommand; |
| 21 | import de.uka.ipd.sdq.pcm.gmf.repository.providers.PalladioComponentModelElementTypes; |
| 22 | |
| 23 | /** |
| 24 | * @generated |
| 25 | */ |
| 26 | public class RepositoryItemSemanticEditPolicy extends |
| 27 | PalladioComponentModelBaseItemSemanticEditPolicy { |
| 28 | |
| 29 | /** |
| 30 | * @generated |
| 31 | */ |
| 32 | public RepositoryItemSemanticEditPolicy() { |
| 33 | super(PalladioComponentModelElementTypes.Repository_1000); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * @generated |
| 38 | */ |
| 39 | protected Command getCreateCommand(CreateElementRequest req) { |
| 40 | if (PalladioComponentModelElementTypes.OperationInterface_2107 == req |
| 41 | .getElementType()) { |
| 42 | return getGEFWrapper(new OperationInterfaceCreateCommand(req)); |
| 43 | } |
| 44 | if (PalladioComponentModelElementTypes.EventGroup_2108 == req |
| 45 | .getElementType()) { |
| 46 | return getGEFWrapper(new EventGroupCreateCommand(req)); |
| 47 | } |
| 48 | if (PalladioComponentModelElementTypes.BasicComponent_2102 == req |
| 49 | .getElementType()) { |
| 50 | return getGEFWrapper(new BasicComponentCreateCommand(req)); |
| 51 | } |
| 52 | if (PalladioComponentModelElementTypes.CompositeComponent_2103 == req |
| 53 | .getElementType()) { |
| 54 | return getGEFWrapper(new CompositeComponentCreateCommand(req)); |
| 55 | } |
| 56 | if (PalladioComponentModelElementTypes.CompleteComponentType_2104 == req |
| 57 | .getElementType()) { |
| 58 | return getGEFWrapper(new CompleteComponentTypeCreateCommand(req)); |
| 59 | } |
| 60 | if (PalladioComponentModelElementTypes.ProvidesComponentType_2105 == req |
| 61 | .getElementType()) { |
| 62 | return getGEFWrapper(new ProvidesComponentTypeCreateCommand(req)); |
| 63 | } |
| 64 | if (PalladioComponentModelElementTypes.SubSystem_2106 == req |
| 65 | .getElementType()) { |
| 66 | return getGEFWrapper(new SubSystemCreateCommand(req)); |
| 67 | } |
| 68 | if (PalladioComponentModelElementTypes.InfrastructureInterface_2109 == req |
| 69 | .getElementType()) { |
| 70 | return getGEFWrapper(new InfrastructureInterfaceCreateCommand(req)); |
| 71 | } |
| 72 | return super.getCreateCommand(req); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * @generated |
| 77 | */ |
| 78 | protected Command getDuplicateCommand(DuplicateElementsRequest req) { |
| 79 | TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()) |
| 80 | .getEditingDomain(); |
| 81 | return getGEFWrapper(new DuplicateAnythingCommand(editingDomain, req)); |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * @generated |
| 86 | */ |
| 87 | private static class DuplicateAnythingCommand extends |
| 88 | DuplicateEObjectsCommand { |
| 89 | |
| 90 | /** |
| 91 | * @generated |
| 92 | */ |
| 93 | public DuplicateAnythingCommand( |
| 94 | TransactionalEditingDomain editingDomain, |
| 95 | DuplicateElementsRequest req) { |
| 96 | super(editingDomain, req.getLabel(), req |
| 97 | .getElementsToBeDuplicated(), req |
| 98 | .getAllDuplicatedElementsMap()); |
| 99 | } |
| 100 | } |
| 101 | } |