diff options
author | Shuai Li | 2018-01-20 11:26:40 +0000 |
---|---|---|
committer | Shuai Li | 2018-03-09 09:19:38 +0000 |
commit | 0dac77dfab1dd890604fd0d47a26eed191c79d1f (patch) | |
tree | 8b03079dd8f2902a5547fb7c0a0371457e83bb0d | |
parent | 782bd293bad76e08c2efb8d56c326fa6df20f1c7 (diff) | |
download | org.eclipse.papyrus-0dac77dfab1dd890604fd0d47a26eed191c79d1f.tar.gz org.eclipse.papyrus-0dac77dfab1dd890604fd0d47a26eed191c79d1f.tar.xz org.eclipse.papyrus-0dac77dfab1dd890604fd0d47a26eed191c79d1f.zip |
Bug 530073 - [UML - Tools] Method getDelegations() in utils
- Add getDelegations method which returns all delegations of a port
instead of the first one.
- Increment minor version number
Change-Id: I7aaec4f73a80760940f965154c5d0f738383769b
Signed-off-by: Shuai Li <shuai.li@cea.fr>
-rw-r--r-- | plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ConnectorUtil.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ConnectorUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ConnectorUtil.java index 6be73c5e898..8ba9f3849bb 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ConnectorUtil.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ConnectorUtil.java @@ -9,11 +9,16 @@ * * Contributors: * Ansgar Radermacher ansgar.radermacher@cea.fr + * Shuai Li (CEA LIST) <shuai.li@cea.fr> - Bug 530073 - 2018 * *****************************************************************************/ package org.eclipse.papyrus.uml.tools.utils; +import java.util.List; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.UniqueEList; import org.eclipse.uml2.uml.Class; import org.eclipse.uml2.uml.ConnectableElement; import org.eclipse.uml2.uml.Connector; @@ -58,6 +63,30 @@ public class ConnectorUtil { } /** + * Return the connector end of a delegation originating from a given port + * or null, if not such delegation exists + * + * @since 3.3.0 + * @param composite + * the composite component + * @param port + * a port (may be inherited) of that implementation + * @return a connector end to which the port delegates or null + */ + public static List<ConnectorEnd> getDelegations(Class composite, Port port) { + EList<ConnectorEnd> conectorEnds = new UniqueEList<ConnectorEnd>(); + for (Connector connector : composite.getOwnedConnectors()) { + if (connectsPort(connector, port)) { + ConnectorEnd otherEnd = connEndNotPart(connector, null); + if (otherEnd != null) { + conectorEnds.add(otherEnd); + } + } + } + return conectorEnds; + } + + /** * check if a connector connects the port that is passed as parameter */ public static boolean connectsPort(Connector connection, Port port) { |