blob: 0ee0a414d96a97c3c82829c87f26f656a59ef02a [file] [log] [blame]
package org.eclipse.uml2.diagram.profile.edit.policies;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.commands.Command;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.emf.commands.core.commands.DuplicateEObjectsCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.uml2.diagram.profile.edit.commands.ElementImportCreateCommand;
import org.eclipse.uml2.diagram.profile.edit.commands.EnumerationCreateCommand;
import org.eclipse.uml2.diagram.profile.edit.commands.Profile2CreateCommand;
import org.eclipse.uml2.diagram.profile.edit.commands.ProfileCreateCommand;
import org.eclipse.uml2.diagram.profile.edit.commands.StereotypeCreateCommand;
import org.eclipse.uml2.diagram.profile.providers.UMLElementTypes;
import org.eclipse.uml2.uml.UMLPackage;
/**
* @generated
*/
public class ProfileItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
/**
* @generated
*/
protected Command getCreateCommand(CreateElementRequest req) {
if (UMLElementTypes.Stereotype_2001 == req.getElementType()) {
if (req.getContainmentFeature() == null) {
req.setContainmentFeature(UMLPackage.eINSTANCE.getPackage_PackagedElement());
}
return getGEFWrapper(new StereotypeCreateCommand(req));
}
if (UMLElementTypes.Profile_2002 == req.getElementType()) {
if (req.getContainmentFeature() == null) {
req.setContainmentFeature(UMLPackage.eINSTANCE.getPackage_PackagedElement());
}
return getGEFWrapper(new ProfileCreateCommand(req));
}
if (UMLElementTypes.Enumeration_2003 == req.getElementType()) {
if (req.getContainmentFeature() == null) {
req.setContainmentFeature(UMLPackage.eINSTANCE.getPackage_PackagedElement());
}
return getGEFWrapper(new EnumerationCreateCommand(req));
}
if (UMLElementTypes.ElementImport_2006 == req.getElementType()) {
if (req.getContainmentFeature() == null) {
req.setContainmentFeature(UMLPackage.eINSTANCE.getNamespace_ElementImport());
}
return getGEFWrapper(new ElementImportCreateCommand(req));
}
if (UMLElementTypes.Profile_2007 == req.getElementType()) {
if (req.getContainmentFeature() == null) {
req.setContainmentFeature(UMLPackage.eINSTANCE.getPackage_PackagedElement());
}
return getGEFWrapper(new Profile2CreateCommand(req));
}
return super.getCreateCommand(req);
}
/**
* @generated
*/
protected Command getDuplicateCommand(DuplicateElementsRequest req) {
TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
return getGEFWrapper(new DuplicateAnythingCommand(editingDomain, req));
}
/**
* @generated
*/
private static class DuplicateAnythingCommand extends DuplicateEObjectsCommand {
/**
* @generated
*/
public DuplicateAnythingCommand(TransactionalEditingDomain editingDomain, DuplicateElementsRequest req) {
super(editingDomain, req.getLabel(), req.getElementsToBeDuplicated(), req.getAllDuplicatedElementsMap());
}
}
}