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/ValueCompartmentSemanticEditPolicy.java')
-rw-r--r-- | plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/ValueCompartmentSemanticEditPolicy.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/ValueCompartmentSemanticEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/ValueCompartmentSemanticEditPolicy.java index 23d354a9d40..bd61d2b09be 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/ValueCompartmentSemanticEditPolicy.java +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/ValueCompartmentSemanticEditPolicy.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.CreateValueWithTypeConfigureCommandFactory; import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes; @@ -31,7 +36,17 @@ public class ValueCompartmentSemanticEditPolicy extends CompartmentSemanticEditP @Override protected Command getCreateCommand(CreateElementRequest req) { - if(SysMLElementTypes.VALUE_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.VALUE_PROPERTY)) { + baseType = SysMLElementTypes.VALUE_PROPERTY; + } + } + + if(SysMLElementTypes.VALUE_PROPERTY == baseType) { req.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new CreateValueWithTypeConfigureCommandFactory()); } |