Skip to main content
summaryrefslogtreecommitdiffstats
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/NestedBlockPropertyCompositeSemanticEditPolicy.java')
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/NestedBlockPropertyCompositeSemanticEditPolicy.java40
1 files changed, 33 insertions, 7 deletions
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/NestedBlockPropertyCompositeSemanticEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/NestedBlockPropertyCompositeSemanticEditPolicy.java
index 87879341944..6d7d2500c9d 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/NestedBlockPropertyCompositeSemanticEditPolicy.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/NestedBlockPropertyCompositeSemanticEditPolicy.java
@@ -13,11 +13,16 @@
*****************************************************************************/
package org.eclipse.papyrus.sysml.diagram.common.edit.policy;
+import java.util.Arrays;
+import java.util.List;
+
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultSemanticEditPolicy;
+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.CreateFlowPortWithFlowSpecificationConfigureCommandFactory;
import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
@@ -44,17 +49,38 @@ public class NestedBlockPropertyCompositeSemanticEditPolicy extends DefaultSeman
Type type = ((Property) eObject).getType();
if ((type != null) && (((ISpecializationType)SysMLElementTypes.BLOCK).getMatcher().matches(type))) {
- if((SysMLElementTypes.FLOW_PORT == req.getElementType())
- || (SysMLElementTypes.FLOW_PORT_IN == req.getElementType())
- || (SysMLElementTypes.FLOW_PORT_OUT == req.getElementType())
- || (SysMLElementTypes.FLOW_PORT_IN_OUT == req.getElementType())
- || (SysMLElementTypes.FLOW_PORT_NA == req.getElementType())
- || (UMLElementTypes.PORT == 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.FLOW_PORT)) {
+ baseType = SysMLElementTypes.FLOW_PORT;
+ } else if(superTypes.contains(SysMLElementTypes.FLOW_PORT_IN)) {
+ baseType = SysMLElementTypes.FLOW_PORT_IN;
+ } else if(superTypes.contains(SysMLElementTypes.FLOW_PORT_OUT)) {
+ baseType = SysMLElementTypes.FLOW_PORT_OUT;
+ } else if(superTypes.contains(SysMLElementTypes.FLOW_PORT_IN_OUT)) {
+ baseType = SysMLElementTypes.FLOW_PORT_IN_OUT;
+ } else if(superTypes.contains(SysMLElementTypes.FLOW_PORT_NA)) {
+ baseType = SysMLElementTypes.FLOW_PORT_NA;
+ } else if(superTypes.contains(UMLElementTypes.PORT )) {
+ baseType = UMLElementTypes.PORT ;
+ }
+ }
+
+ if((SysMLElementTypes.FLOW_PORT == baseType)
+ || (SysMLElementTypes.FLOW_PORT_IN == baseType)
+ || (SysMLElementTypes.FLOW_PORT_OUT == baseType)
+ || (SysMLElementTypes.FLOW_PORT_IN_OUT == baseType)
+ || (SysMLElementTypes.FLOW_PORT_NA == baseType)
+ || (UMLElementTypes.PORT == baseType)) {
req.setContainer(type);
}
- if(SysMLElementTypes.FLOW_PORT_NA == req.getElementType()) {
+ if(SysMLElementTypes.FLOW_PORT_NA == baseType) {
req.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new CreateFlowPortWithFlowSpecificationConfigureCommandFactory());
}
}

Back to the top