diff options
Diffstat (limited to 'plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/StructureCompartmentSemanticEditPolicy.java')
-rw-r--r-- | plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/StructureCompartmentSemanticEditPolicy.java | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/StructureCompartmentSemanticEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/StructureCompartmentSemanticEditPolicy.java index f045b8976ee..2aa9a51e4c2 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/StructureCompartmentSemanticEditPolicy.java +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/StructureCompartmentSemanticEditPolicy.java @@ -13,9 +13,14 @@ *****************************************************************************/ package org.eclipse.papyrus.sysml.diagram.common.edit.policy; +import java.util.Arrays; +import java.util.List; + 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.gmf.diagram.common.edit.policy.CompartmentSemanticEditPolicy; +import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType; import org.eclipse.papyrus.infra.services.edit.commands.IConfigureCommandFactory; import org.eclipse.papyrus.sysml.diagram.common.commands.CreateActorPartWithTypeConfigureCommandFactory; import org.eclipse.papyrus.sysml.diagram.common.commands.CreateConstraintPropertyWithTypeConfigureCommandFactory; @@ -35,23 +40,41 @@ public class StructureCompartmentSemanticEditPolicy extends CompartmentSemanticE @Override protected Command getCreateCommand(CreateElementRequest req) { - if(SysMLElementTypes.PART_PROPERTY == req.getElementType()) { + IElementType elementTypeToCreate = req.getElementType(); + IElementType baseType = elementTypeToCreate; + //if extended type, retrieve the sysml closest element element type + if(elementTypeToCreate instanceof IExtendedHintedElementType) { + List<IElementType> superTypes = Arrays.asList(elementTypeToCreate.getAllSuperTypes()); + if(superTypes.contains(SysMLElementTypes.PART_PROPERTY)) { + baseType = SysMLElementTypes.PART_PROPERTY; + } else if(superTypes.contains(SysMLElementTypes.REFERENCE_PROPERTY)) { + baseType = SysMLElementTypes.REFERENCE_PROPERTY; + } else if(superTypes.contains(SysMLElementTypes.ACTOR_PART_PROPERTY)) { + baseType = SysMLElementTypes.ACTOR_PART_PROPERTY; + } else if(superTypes.contains(SysMLElementTypes.VALUE_PROPERTY)) { + baseType = SysMLElementTypes.VALUE_PROPERTY; + } else if(superTypes.contains(SysMLElementTypes.CONSTRAINT_PROPERTY)) { + baseType = SysMLElementTypes.CONSTRAINT_PROPERTY; + } + } + + if(SysMLElementTypes.PART_PROPERTY == baseType) { req.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new CreatePartWithTypeConfigureCommandFactory()); } - if(SysMLElementTypes.REFERENCE_PROPERTY == req.getElementType()) { + if(SysMLElementTypes.REFERENCE_PROPERTY == baseType) { req.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new CreateReferenceWithTypeConfigureCommandFactory()); } - if(SysMLElementTypes.ACTOR_PART_PROPERTY == req.getElementType()) { + if(SysMLElementTypes.ACTOR_PART_PROPERTY == baseType) { req.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new CreateActorPartWithTypeConfigureCommandFactory()); } - if(SysMLElementTypes.VALUE_PROPERTY == req.getElementType()) { + if(SysMLElementTypes.VALUE_PROPERTY == baseType) { req.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new CreateValueWithTypeConfigureCommandFactory()); } - if(SysMLElementTypes.CONSTRAINT_PROPERTY == req.getElementType()) { + if(SysMLElementTypes.CONSTRAINT_PROPERTY == baseType) { req.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new CreateConstraintPropertyWithTypeConfigureCommandFactory()); } |