Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/PartCompartmentSemanticEditPolicy.java')
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/PartCompartmentSemanticEditPolicy.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/PartCompartmentSemanticEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/PartCompartmentSemanticEditPolicy.java
index 622dd608d3b..d9e20429fa0 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/PartCompartmentSemanticEditPolicy.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/PartCompartmentSemanticEditPolicy.java
@@ -13,10 +13,16 @@
*****************************************************************************/
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.blocks.Block;
import org.eclipse.papyrus.sysml.diagram.common.commands.CreateConstraintPropertyWithTypeConfigureCommandFactory;
import org.eclipse.papyrus.sysml.diagram.common.commands.CreatePartWithTypeConfigureCommandFactory;
import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
@@ -32,11 +38,24 @@ public class PartCompartmentSemanticEditPolicy extends CompartmentSemanticEditPo
@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.CONSTRAINT_PROPERTY)) {
+ baseType = SysMLElementTypes.CONSTRAINT_PROPERTY;
+ }
+ }
+
+
+ if(SysMLElementTypes.PART_PROPERTY == baseType) {
req.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new CreatePartWithTypeConfigureCommandFactory());
}
- if(SysMLElementTypes.CONSTRAINT_PROPERTY == req.getElementType()) {
+ if(SysMLElementTypes.CONSTRAINT_PROPERTY == baseType) {
req.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new CreateConstraintPropertyWithTypeConfigureCommandFactory());
}

Back to the top