diff options
Diffstat (limited to 'extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/utils/ProtocolUtils.java')
-rw-r--r-- | extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/utils/ProtocolUtils.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/utils/ProtocolUtils.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/utils/ProtocolUtils.java index 9607a9f60d8..155038e0d35 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/utils/ProtocolUtils.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/utils/ProtocolUtils.java @@ -13,7 +13,18 @@ package org.eclipse.papyrus.umlrt.custom.utils; +import java.util.Collections; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; +import org.eclipse.papyrus.umlrt.UMLRealTime.RTMessageKind; +import org.eclipse.papyrus.umlrt.custom.IUMLRTElementTypes; +import org.eclipse.papyrus.umlrt.internals.Activator; import org.eclipse.uml2.uml.Collaboration; +import org.eclipse.uml2.uml.Operation; import org.eclipse.uml2.uml.Package; /** @@ -32,4 +43,36 @@ public class ProtocolUtils { return protocol.getNearestPackage(); } + /** + * Returns <code>true</code> if the context element is a Protocol (Collaboration stereotyped by "protocol") + * + * @param context + * the eobject to test + * @return <code>true</code> if the context element is a Protocol (Collaboration stereotyped by "protocol") + */ + public static Boolean isProtocol(EObject context) { + IElementType type = ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.PROTOCOL_ID); + if (!(type instanceof ISpecializationType)) { // check at the same time UMLRT element types are correctly loaded + return false; + } + if (((ISpecializationType) type).getMatcher().matches(context)) { + return true; + } + return false; + } + + /** + * @param in + * @return + */ + public static List<Operation> getRTMessages(Collaboration protocol, RTMessageKind direction, boolean showInherited) { + Package protocolContainer = getPackageContainer(protocol); + if(protocolContainer ==null) { + Activator.log.error("Impossible to get the root protocol container", null); + return Collections.emptyList(); + } + + return ProtocolContainerUtils.getRTMessages(protocolContainer, direction, showInherited); + } + } |