diff options
| author | ysroh | 2016-12-19 17:14:10 +0000 |
|---|---|---|
| committer | Gerrit Code Review @ Eclipse.org | 2016-12-22 16:21:56 +0000 |
| commit | efd202200e9fb0486674f75d3cdcbe19e2420e80 (patch) | |
| tree | 2df41114927a6bd31d24c0ae8cec8519088cb72f | |
| parent | 4090a0f422cca0565e9e773f483396f365cd1d74 (diff) | |
| download | org.eclipse.papyrus-rt-efd202200e9fb0486674f75d3cdcbe19e2420e80.tar.gz org.eclipse.papyrus-rt-efd202200e9fb0486674f75d3cdcbe19e2420e80.tar.xz org.eclipse.papyrus-rt-efd202200e9fb0486674f75d3cdcbe19e2420e80.zip | |
Bug 502424 - [Tooling] Allow creation of connectors between two relay
ports and relay port to internal behaviour port
Pass through connector port ends should have different conjugation
Change-Id: Ic86ae096bec910ed72cb7cc701cf627b98ba8496
Signed-off-by: ysroh <ysroh@zeligsoft.com>
| -rw-r--r-- | plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/internal/advice/ConnectorEndPortsCompatibilityAdvice.java | 80 |
1 files changed, 56 insertions, 24 deletions
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/internal/advice/ConnectorEndPortsCompatibilityAdvice.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/internal/advice/ConnectorEndPortsCompatibilityAdvice.java index d282effa9..a9f2bb0be 100644 --- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/internal/advice/ConnectorEndPortsCompatibilityAdvice.java +++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/internal/advice/ConnectorEndPortsCompatibilityAdvice.java @@ -8,6 +8,7 @@ * * Contributors: * Young-Soo Roh - Initial API and implementation + * Young-Soo Roh - Bug#502424 * *****************************************************************************/ @@ -28,6 +29,8 @@ import org.eclipse.gmf.runtime.notation.View; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.papyrusrt.umlrt.core.types.ElementTypeUtils; import org.eclipse.papyrusrt.umlrt.core.types.IUMLRTElementTypes; +import org.eclipse.papyrusrt.umlrt.core.utils.RTPortKindEnum; +import org.eclipse.papyrusrt.umlrt.core.utils.RTPortUtils; import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.RTConnector; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; @@ -42,6 +45,13 @@ import org.eclipse.uml2.uml.UMLPackage; public class ConnectorEndPortsCompatibilityAdvice extends AbstractEditHelperAdvice { /** + * Constructor. + * + */ + public ConnectorEndPortsCompatibilityAdvice() { + } + + /** * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeCreateRelationshipCommand(org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest) * * @param request @@ -74,30 +84,7 @@ public class ConnectorEndPortsCompatibilityAdvice extends AbstractEditHelperAdvi } if (canConnect) { - View port1View = (View) request.getParameter(org.eclipse.papyrus.infra.services.edit.utils.RequestParameterConstants.EDGE_CREATE_REQUEST_TARGET_VIEW); - View port2View = (View) request.getParameter(org.eclipse.papyrus.infra.services.edit.utils.RequestParameterConstants.EDGE_CREATE_REQUEST_SOURCE_VIEW); - if (port2View != null && port2View.eContainer() != null - && port1View != null && port1View.eContainer() != null) { - EObject port1Container = ((View) port2View.eContainer()).getElement(); - EObject port2Container = ((View) port1View.eContainer()).getElement(); - - - // Connection from or to port of the class should be delegation unless the port is internal behaviour port - boolean isDelegation = (ElementTypeUtils.matches(port1Container, IUMLRTElementTypes.CAPSULE_ID) && port1.isService()) - || (ElementTypeUtils.matches(port2Container, IUMLRTElementTypes.CAPSULE_ID) && port2.isService()); - - if (!isDelegation) { - if (port1.isConjugated() == port2.isConjugated()) { - // assembly connector must have different conjugation - canConnect = false; - } - } else { - if (port1.isConjugated() != port2.isConjugated()) { - // delegation connector must have same conjugation - canConnect = false; - } - } - } + canConnect = checkConjugationCompatibility(request); } if (!canConnect) { @@ -115,4 +102,49 @@ public class ConnectorEndPortsCompatibilityAdvice extends AbstractEditHelperAdvi } }; } + + /** + * Check two ports have compatible conjugation. + * + * @param request + * request + * @return true if compatible + */ + private boolean checkConjugationCompatibility(final CreateRelationshipRequest request) { + boolean result = true; + Port port1 = (Port) request.getSource(); + Port port2 = (Port) request.getTarget(); + View port1View = (View) request.getParameter(org.eclipse.papyrus.infra.services.edit.utils.RequestParameterConstants.EDGE_CREATE_REQUEST_TARGET_VIEW); + View port2View = (View) request.getParameter(org.eclipse.papyrus.infra.services.edit.utils.RequestParameterConstants.EDGE_CREATE_REQUEST_SOURCE_VIEW); + if (port2View != null && port2View.eContainer() != null + && port1View != null && port1View.eContainer() != null) { + EObject port1Container = ((View) port2View.eContainer()).getElement(); + EObject port2Container = ((View) port1View.eContainer()).getElement(); + + RTPortKindEnum port1Kind = RTPortUtils.getKind(port1); + RTPortKindEnum port2Kind = RTPortUtils.getKind(port2); + + // Connection from or to port of the class should be delegation unless the port is internal behaviour port + boolean isDelegation = (ElementTypeUtils.matches(port1Container, IUMLRTElementTypes.CAPSULE_ID) && port1.isService()) + || (ElementTypeUtils.matches(port2Container, IUMLRTElementTypes.CAPSULE_ID) && port2.isService()); + + if (!isDelegation) { + if (port1.isConjugated() == port2.isConjugated()) { + // assembly connector must have different conjugation + result = false; + } + } else { + if (port1Container == port2Container && port1Kind == RTPortKindEnum.RELAY && port2Kind == RTPortKindEnum.RELAY) { + // pass-through connector should have different conjugation. + if (port1.isConjugated() == port2.isConjugated()) { + result = false; + } + } else if (port1.isConjugated() != port2.isConjugated()) { + // all delegation connector except pass-through connector must have same conjugation + result = false; + } + } + } + return result; + } } |
