package org.eclipse.papyrus.uml.diagram.activity.edit.policies; import org.eclipse.gef.commands.Command; import org.eclipse.gmf.runtime.emf.type.core.IElementType; import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType; import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils; import org.eclipse.papyrus.uml.diagram.activity.edit.commands.ConstraintInActivityAsPrecondCreateCommand; import org.eclipse.papyrus.uml.diagram.activity.providers.UMLElementTypes; /** * @generated */ public class ActivityCNPreConditionsCompartmentItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy { /** * @generated */ public ActivityCNPreConditionsCompartmentItemSemanticEditPolicy() { super(UMLElementTypes.Activity_3083); } /** * @generated */ protected Command getCreateCommand(CreateElementRequest req) { IElementType requestElementType = req.getElementType(); if(requestElementType == null) { return super.getCreateCommand(req); } IElementType baseElementType = requestElementType; boolean isExtendedType = false; if(requestElementType instanceof IExtendedHintedElementType) { baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType); if(baseElementType != null) { isExtendedType = true; } else { // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs. baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType)requestElementType); isExtendedType = true; } } if(UMLElementTypes.Constraint_3002 == baseElementType) { if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); } return getGEFWrapper(new ConstraintInActivityAsPrecondCreateCommand(req)); } return super.getCreateCommand(req); } }