Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2013-11-04 07:45:38 -0500
committervlorenzo2013-11-04 07:49:43 -0500
commit8ab21fdeb770b6add5b9360b264694ebe9f863fc (patch)
tree9c6440d6203fff3e28be7eaa2ddd4750313d9b71 /plugins
parent85a38f064689273472b9b52abbc8683a8b536df6 (diff)
downloadorg.eclipse.papyrus-8ab21fdeb770b6add5b9360b264694ebe9f863fc.tar.gz
org.eclipse.papyrus-8ab21fdeb770b6add5b9360b264694ebe9f863fc.tar.xz
org.eclipse.papyrus-8ab21fdeb770b6add5b9360b264694ebe9f863fc.zip
420506: [IBD] Restore Connector Link ignore the nestedPath and
partWithPort https://bugs.eclipse.org/bugs/show_bug.cgi?id=420506
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLCreateOrShowExistingElementHelper.java56
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomBlockPropertyCompositeSemanticEditPolicy.java5
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomDefaultSemanticEditPolicy.java6
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/utils/ConnectorUtils.java47
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/CreateOrShowExistingElementHelper.java22
5 files changed, 116 insertions, 20 deletions
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLCreateOrShowExistingElementHelper.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLCreateOrShowExistingElementHelper.java
index b7bc1510c4f..4486341296e 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLCreateOrShowExistingElementHelper.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLCreateOrShowExistingElementHelper.java
@@ -13,14 +13,26 @@
*****************************************************************************/
package org.eclipse.papyrus.sysml.diagram.common.utils;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.services.edit.utils.RequestParameterConstants;
import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.common.helper.ILinkMappingHelper;
+import org.eclipse.papyrus.sysml.service.types.utils.ConnectorUtils;
import org.eclipse.papyrus.uml.diagram.common.helper.CreateOrShowExistingElementHelper;
+import org.eclipse.papyrus.uml.diagram.common.helper.ILinkMappingHelper;
+import org.eclipse.papyrus.uml.diagram.common.util.EdgeEndsMapper;
import org.eclipse.uml2.uml.AggregationKind;
import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.Connector;
+import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.UMLPackage;
/**
* Show Existing Link Helper for SysML. This class provides specific management for SysML Association.
@@ -31,6 +43,11 @@ import org.eclipse.uml2.uml.Property;
public class SysMLCreateOrShowExistingElementHelper extends CreateOrShowExistingElementHelper {
/**
+ * the sysml connector util
+ */
+ private ConnectorUtils sysmlConnectorUtils = new ConnectorUtils();
+
+ /**
*
* Constructor.
*
@@ -58,11 +75,11 @@ public class SysMLCreateOrShowExistingElementHelper extends CreateOrShowExisting
*/
@Override
protected String getIElementTypeNameToDisplay(final IElementType elementType) {
- if(SysMLElementTypes.ASSOCIATION_NONE.equals(elementType) || SysMLElementTypes.ASSOCIATION_NONE_DIRECTED.equals(elementType)){
+ if(SysMLElementTypes.ASSOCIATION_NONE.equals(elementType) || SysMLElementTypes.ASSOCIATION_NONE_DIRECTED.equals(elementType)) {
return "Association/DirectAssociation"; //$NON-NLS-1$
- }else if(SysMLElementTypes.ASSOCIATION_COMPOSITE.equals(elementType) || SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED.equals(elementType)){
+ } else if(SysMLElementTypes.ASSOCIATION_COMPOSITE.equals(elementType) || SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED.equals(elementType)) {
return "Composition/DirectComposition"; //$NON-NLS-1$
- }else if(SysMLElementTypes.ASSOCIATION_SHARED.equals(elementType) || SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED.equals(elementType)){
+ } else if(SysMLElementTypes.ASSOCIATION_SHARED.equals(elementType) || SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED.equals(elementType)) {
return "Aggregation/DirectAggregation"; //$NON-NLS-1$
}
return super.getIElementTypeNameToDisplay(elementType);
@@ -127,4 +144,35 @@ public class SysMLCreateOrShowExistingElementHelper extends CreateOrShowExisting
}
}
+
+ /**
+ * @param request
+ * the request for the creation
+ * @param wantedEClass
+ * @return
+ * a list of {@link EdgeEndsMapper} referencing the existing links between the source and the target
+ */
+ protected List<EdgeEndsMapper> getExistingLinksBetweenSourceAndTarget(final CreateRelationshipRequest request, final IElementType wantedElementType) {
+ if(wantedElementType.getEClass() == UMLPackage.eINSTANCE.getConnector()) {
+ final List<EdgeEndsMapper> existingElement = new ArrayList<EdgeEndsMapper>();
+ for(final Element current : ((Element)request.getContainer()).getOwnedElements()) {
+ if(hasWantedType(current, wantedElementType)) {
+ final Collection<?> sources = this.linkMappingHelper.getSource(current);
+ final Collection<?> targets = this.linkMappingHelper.getTarget(current);
+
+ if(sources.contains(request.getSource()) && targets.contains(request.getTarget())) {
+ //we verify the nestedPath before to propose to restore a connector
+ View sourceView = (View)request.getParameter(RequestParameterConstants.EDGE_CREATE_REQUEST_SOURCE_VIEW);
+ View targetView = (View)request.getParameter(RequestParameterConstants.EDGE_CREATE_REQUEST_TARGET_VIEW);
+ boolean canBeDisplayed = this.sysmlConnectorUtils.canDisplayExistingConnectorBetweenViewsAccordingToNestedPaths((Connector)current, sourceView, targetView);
+ if(canBeDisplayed) {
+ existingElement.add(new EdgeEndsMapper(current, sources, null, null));
+ }
+ }
+ }
+ }
+ return existingElement;
+ }
+ return super.getExistingLinksBetweenSourceAndTarget(request, wantedElementType);
+ }
}
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomBlockPropertyCompositeSemanticEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomBlockPropertyCompositeSemanticEditPolicy.java
index adff7be704f..9a45070753c 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomBlockPropertyCompositeSemanticEditPolicy.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomBlockPropertyCompositeSemanticEditPolicy.java
@@ -21,6 +21,7 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelations
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.gmf.diagram.common.provider.IGraphicalTypeRegistry;
import org.eclipse.papyrus.sysml.diagram.common.edit.policy.BlockPropertyCompositeSemanticEditPolicy;
+import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLCreateOrShowExistingElementHelper;
import org.eclipse.papyrus.sysml.diagram.internalblock.provider.CustomGraphicalTypeRegistry;
import org.eclipse.papyrus.sysml.diagram.internalblock.provider.ElementTypes;
import org.eclipse.papyrus.sysml.diagram.internalblock.provider.GraphicalTypeRegistry;
@@ -49,6 +50,8 @@ public class CustomBlockPropertyCompositeSemanticEditPolicy extends BlockPropert
private CreateOrShowExistingElementHelper linkHelper = new CreateOrShowExistingElementHelper();
+ /** the sysml link helper to use for specific case */
+ private CreateOrShowExistingElementHelper sysmlLinkHelper = new SysMLCreateOrShowExistingElementHelper();
/**
* {@inheritDoc}
*/
@@ -77,7 +80,7 @@ public class CustomBlockPropertyCompositeSemanticEditPolicy extends BlockPropert
if(defaultCommand.canExecute()) {
final IElementType elementType = req.getElementType();
if(UMLElementTypes.CONNECTOR.equals(req.getElementType())) {
- return this.linkHelper.getCreateOrRestoreElementCommand(req, defaultCommand, elementType);
+ return this.sysmlLinkHelper.getCreateOrRestoreElementCommand(req, defaultCommand, elementType);
}
if(UMLElementTypes.DEPENDENCY.equals(req.getElementType())) {
return this.linkHelper.getCreateOrRestoreElementCommand(req, defaultCommand, elementType);
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomDefaultSemanticEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomDefaultSemanticEditPolicy.java
index 515d6b1cc72..c6737301de0 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomDefaultSemanticEditPolicy.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomDefaultSemanticEditPolicy.java
@@ -21,6 +21,7 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelations
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultSemanticEditPolicy;
import org.eclipse.papyrus.gmf.diagram.common.provider.IGraphicalTypeRegistry;
+import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLCreateOrShowExistingElementHelper;
import org.eclipse.papyrus.sysml.diagram.internalblock.provider.CustomGraphicalTypeRegistry;
import org.eclipse.papyrus.sysml.diagram.internalblock.provider.ElementTypes;
import org.eclipse.papyrus.sysml.diagram.internalblock.provider.GraphicalTypeRegistry;
@@ -50,6 +51,9 @@ public class CustomDefaultSemanticEditPolicy extends DefaultSemanticEditPolicy {
/** the link helper to use */
private CreateOrShowExistingElementHelper linkHelper = new CreateOrShowExistingElementHelper();
+ /** the sysml link helper to use for specific case */
+ private CreateOrShowExistingElementHelper sysmlLinkHelper = new SysMLCreateOrShowExistingElementHelper();
+
/**
* {@inheritDoc}
*/
@@ -78,7 +82,7 @@ public class CustomDefaultSemanticEditPolicy extends DefaultSemanticEditPolicy {
if(defaultCommand.canExecute()) {
final IElementType elementType = req.getElementType();
if(UMLElementTypes.CONNECTOR.equals(req.getElementType())) {
- return this.linkHelper.getCreateOrRestoreElementCommand(req, defaultCommand, elementType);
+ return this.sysmlLinkHelper.getCreateOrRestoreElementCommand(req, defaultCommand, elementType);
}
if(UMLElementTypes.DEPENDENCY.equals(req.getElementType())) {
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/utils/ConnectorUtils.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/utils/ConnectorUtils.java
index d6a0fb89f46..d57be0e7c32 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/utils/ConnectorUtils.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/utils/ConnectorUtils.java
@@ -21,9 +21,11 @@ import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.sysml.blocks.Block;
import org.eclipse.papyrus.sysml.blocks.NestedConnectorEnd;
import org.eclipse.uml2.uml.ConnectableElement;
+import org.eclipse.uml2.uml.Connector;
import org.eclipse.uml2.uml.ConnectorEnd;
import org.eclipse.uml2.uml.Port;
import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.StructuredClassifier;
import org.eclipse.uml2.uml.Type;
import org.eclipse.uml2.uml.util.UMLUtil;
@@ -247,4 +249,49 @@ public class ConnectorUtils extends org.eclipse.papyrus.uml.service.types.utils.
}
return false;
}
+
+ /**
+ *
+ * @param connector
+ * a connector existing in the model
+ * @param sourceView
+ * a potential source for this connector
+ * @param targetView
+ * a potential target for this connector
+ * @return
+ * <code>true</code> if displaying the existing connector between this source and this target view is correct
+ */
+ public final boolean canDisplayExistingConnectorBetweenViewsAccordingToNestedPaths(final Connector connector, final View sourceView, final View targetView) {
+ ConnectorUtils utils = new ConnectorUtils();
+ final List<Property> sourcePath = utils.getNestedPropertyPath(sourceView, targetView);
+ final List<Property> targetPath = utils.getNestedPropertyPath(targetView, sourceView);
+ boolean hasWantedPath = true;
+ for(final ConnectorEnd end : connector.getEnds()) {
+ if(sourceView != null && end.getRole() == sourceView.getElement()) {
+ hasWantedPath = hasWantedPath && haveSamePath(sourcePath, end);
+ } else if(targetView != null && end.getRole() == targetView.getElement()) {
+ hasWantedPath = hasWantedPath && haveSamePath(targetPath, end);
+ }
+ }
+ return hasWantedPath;
+ }
+
+ /**
+ *
+ * @param wantedPath
+ * the wanted nested path for the end
+ * @param end
+ * an end
+ * @return
+ * true if the end has as nested path THE wanted path
+ */
+ protected boolean haveSamePath(final List<Property> wantedPath, final ConnectorEnd end) {
+ Stereotype ste = end.getAppliedStereotype("SysML::Blocks::NestedConnectorEnd");//$NON-NLS-1$
+ if(ste != null) {
+ final NestedConnectorEnd nestedConnectorEnd = (NestedConnectorEnd)end.getStereotypeApplication(ste);
+ return nestedConnectorEnd.getPropertyPath().equals(wantedPath);
+ } else {
+ return wantedPath.isEmpty();
+ }
+ }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/CreateOrShowExistingElementHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/CreateOrShowExistingElementHelper.java
index 8dc3740b269..8c5c36871af 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/CreateOrShowExistingElementHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/CreateOrShowExistingElementHelper.java
@@ -53,7 +53,7 @@ public class CreateOrShowExistingElementHelper {
/**
* the link helper to use. Will be used in the future
*/
- private ILinkMappingHelper linkMappingHelper;
+ protected final ILinkMappingHelper linkMappingHelper;
/**
* preferences used to know if the dialog must be displayed or not
@@ -103,7 +103,7 @@ public class CreateOrShowExistingElementHelper {
if(showDialogAccordingPreferences() && defaultCommand.canExecute()) {
final EObject container = req.getContainer();
if(container instanceof Element) {
- final List<EdgeEndsMapper> existingElements = getExistingLinksBetweenSourceAndTarget((Element)req.getContainer(), req.getSource(), req.getTarget(), linkElementType);
+ final List<EdgeEndsMapper> existingElements = getExistingLinksBetweenSourceAndTarget(req, linkElementType);
if(existingElements.size() > 0) {
final String className = getIElementTypeNameToDisplay(linkElementType);
final String dialogTitle = NLS.bind(Messages.CreateOrShowExistingElementHelper_CreateOrRestoreX, className);
@@ -158,25 +158,19 @@ public class CreateOrShowExistingElementHelper {
/**
*
- * @param container
- * the container
- * @param source
- * @param target
+ * @param request
+ * the request to create the element
* @param wantedEClass
* @return
- * a list of {@link EdgeEndsMapper} referencing the exising links between the source and the target
+ * a list of {@link EdgeEndsMapper} referencing the existing links between the source and the target
*/
- protected List<EdgeEndsMapper> getExistingLinksBetweenSourceAndTarget(final Element container, final EObject source, final EObject target, final IElementType wantedElementType) {
+ protected List<EdgeEndsMapper> getExistingLinksBetweenSourceAndTarget(final CreateRelationshipRequest request, final IElementType wantedElementType) {
final List<EdgeEndsMapper> existingElement = new ArrayList<EdgeEndsMapper>();
- for(final Element current : container.getOwnedElements()) {
+ for(final Element current : ((Element)request.getContainer()).getOwnedElements()) {
if(hasWantedType(current, wantedElementType)) {
- if(target != null) {
- int i = 0;
- i++;
- }
final Collection<?> sources = this.linkMappingHelper.getSource(current);
final Collection<?> targets = this.linkMappingHelper.getTarget(current);
- if(sources.contains(source) && targets.contains(target)) {
+ if(sources.contains(request.getSource()) && targets.contains(request.getTarget())) {
final EClass wantedEClass = wantedElementType.getEClass();
if((wantedEClass == UMLPackage.eINSTANCE.getConnector()) || (wantedEClass == UMLPackage.eINSTANCE.getAssociation())) {
existingElement.add(new EdgeEndsMapper(current, sources, null, null));

Back to the top