diff options
author | Remi Schnekenburger | 2015-04-29 20:30:22 +0000 |
---|---|---|
committer | Remi Schnekenburger | 2015-04-29 20:30:22 +0000 |
commit | ab31757185b4ee0df3413fd0ae72d350cfa3c7f8 (patch) | |
tree | 20003556417ebf635542f3fb5bfac102dda8af60 /extraplugins/umlrt | |
parent | 88fbb18540b01994d12230f8b4eea5eeaee7eed7 (diff) | |
download | org.eclipse.papyrus-ab31757185b4ee0df3413fd0ae72d350cfa3c7f8.tar.gz org.eclipse.papyrus-ab31757185b4ee0df3413fd0ae72d350cfa3c7f8.tar.xz org.eclipse.papyrus-ab31757185b4ee0df3413fd0ae72d350cfa3c7f8.zip |
411009: [UML RT] Provide tooling support for the UML-RT Profile
https://bugs.eclipse.org/bugs/show_bug.cgi?id=411009
Add a in/inout label before Protocol messages
Reuse existing behavior for UML label provider
Diffstat (limited to 'extraplugins/umlrt')
11 files changed, 243 insertions, 201 deletions
diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.properties/propertyView/UML-RT/ui/SingleProtocol.xwt b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.properties/propertyView/UML-RT/ui/SingleProtocol.xwt index 1f8cf8f332e..5ba870b9450 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.properties/propertyView/UML-RT/ui/SingleProtocol.xwt +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.properties/propertyView/UML-RT/ui/SingleProtocol.xwt @@ -18,10 +18,10 @@ <ppel:PropertiesLayout numColumns="3"></ppel:PropertiesLayout> </Composite.layout> <ppe:MultiReference input="{Binding}" - property="UMLRealTimeExt:Protocol:Incoming" customLabel="Incoming"></ppe:MultiReference> - <ppe:MultiReference input="{Binding}" property="UMLRealTimeExt:Protocol:Outgoing" customLabel="Outgoing"></ppe:MultiReference> <ppe:MultiReference input="{Binding}" + property="UMLRealTimeExt:Protocol:Incoming" customLabel="Incoming"></ppe:MultiReference> + <ppe:MultiReference input="{Binding}" property="UMLRealTimeExt:Protocol:InOut" customLabel="In-Out"></ppe:MultiReference> </Composite> </Composite>
\ No newline at end of file diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/configuration/UMLRT.configuration b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/configuration/UMLRT.configuration index 5fa2c7981ae..14ea28b433c 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/configuration/UMLRT.configuration +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/configuration/UMLRT.configuration @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <configuration:PapyrusConfiguration xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:configuration="http://www.eclipse.org/papyrus/infra/viewpoints/configuration" xmi:id="_oa8yUBP7EeSS0oyATXohNA" defaultStakeholder="_stSKMBP7EeSS0oyATXohNA"> - <stakeholders xmi:id="_stSKMBP7EeSS0oyATXohNA" name="MetaModeler" viewpoints="_3T-cEBP7EeSS0oyATXohNA"/> + <stakeholders xmi:id="_stSKMBP7EeSS0oyATXohNA" name="UML-RT Modeler" viewpoints="_3T-cEBP7EeSS0oyATXohNA"/> <viewpoints xsi:type="configuration:PapyrusViewpoint" xmi:id="_3T-cEBP7EeSS0oyATXohNA" name="UMLRT Viewpoint"> <modelKinds xsi:type="configuration:PapyrusDiagram" xmi:id="_Z79eQHcZEeSnWeKqQOfW2A" name="UML-RT Capsule Diagram" icon="platform:/plugin/org.eclipse.papyrus.uml.diagram.clazz/icons/obj16/Diagram_Class.gif" implementationID="CompositeStructure" categories="_vUL7ABP7EeSS0oyATXohNA" customPalette="" customStyle=""> <modelRules xmi:id="_I9zbAHk9EeSk0Zv84QxXew"> @@ -43,5 +43,5 @@ </modelKinds> </viewpoints> <metamodel href="http://www.eclipse.org/uml2/5.0.0/UML#/"/> - <categories xmi:id="_vUL7ABP7EeSS0oyATXohNA" name="uml"/> + <categories xmi:id="_vUL7ABP7EeSS0oyATXohNA" name="UML-RT"/> </configuration:PapyrusConfiguration> diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/facet/Protocol.custom b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/facet/Protocol.custom index 7123e770b42..42f60b86b58 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/facet/Protocol.custom +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/facet/Protocol.custom @@ -11,7 +11,7 @@ name="UML-RT Protocols" documentation="Simplification of the display of UML-RT protocols" mustBeLoadedByDefault="true" - rank="-1"> + rank="-100"> <eClassifiers xsi:type="efacet:Facet" name="ProtocolContainerFacet" @@ -207,5 +207,23 @@ xsi:type="efacet:FacetOperation" href="../../../plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject/isVisible"/> </facetOperations> + <facetOperations + name="HideCollapseLinks"> + <eType + xsi:type="ecore:EDataType" + href="http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/> + <eParameters + name="eStructuralFeature"> + <eType + xsi:type="ecore:EClass" + href="http://www.eclipse.org/emf/2002/Ecore#//EStructuralFeature"/> + </eParameters> + <query + xsi:type="javaQuery:JavaQuery" + implementationClassName="org.eclipse.papyrus.umlrt.ui.queries.collaboration.HideCollapseLinksExceptDirectionQuery"/> + <override + xsi:type="efacet:FacetOperation" + href="../../../plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject/collapseLink"/> + </facetOperations> </eClassifiers> </custom:Customization> diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/facet/SimpleUMLRT.custom b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/facet/SimpleUMLRT.custom index 580e11af48c..727e609a5f4 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/facet/SimpleUMLRT.custom +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/facet/SimpleUMLRT.custom @@ -9,12 +9,12 @@ xmlns:javaQuery="http://www.eclipse.org/papyrus/emf/facet/query/java/0.2.incubation/javaquery" name="simpleUMLRT" documentation="Display structure of a UML-RT model" - rank="1500"> + rank="-50"> <eClassifiers xsi:type="custom:EClassCustomization" - name="Element"> + name="NamedElement"> <extendedMetaclass - href="http://www.eclipse.org/uml2/5.0.0/UML#//Element"/> + href="http://www.eclipse.org/uml2/5.0.0/UML#//NamedElement"/> <facetOperations name="GetLabel"> <eType diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/newchildmenu/newChildMenu.xmi b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/newchildmenu/newChildMenu.xmi index f3a8b54a9e1..a9ea68846e9 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/newchildmenu/newChildMenu.xmi +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/newchildmenu/newChildMenu.xmi @@ -30,10 +30,6 @@ label="RTMessageSet" elementTypeIdRef="org.eclipse.papyrus.umlrt.RTMessageSet"/> <menu xsi:type="ElementCreationMenuModel:CreationMenu" - label="RTMessage IN" - icon="platform:/plugin/org.eclipse.papyrus.umlrt.ui/icons/rt_message_in.gif" - elementTypeIdRef="org.eclipse.papyrus.umlrt.RTMessageIn"/> - <menu xsi:type="ElementCreationMenuModel:CreationMenu" label="RTMessage OUT" icon="platform:/plugin/org.eclipse.papyrus.umlrt.ui/icons/rt_message_out.gif" elementTypeIdRef="org.eclipse.papyrus.umlrt.RTMessageOut"/> @@ -41,4 +37,8 @@ label="RTMessage INOUT" icon="platform:/plugin/org.eclipse.papyrus.umlrt.ui/icons/rt_message_inout.gif" elementTypeIdRef="org.eclipse.papyrus.umlrt.RTMessageInOut"/> + <menu xsi:type="ElementCreationMenuModel:CreationMenu" + label="RTMessage IN" + icon="platform:/plugin/org.eclipse.papyrus.umlrt.ui/icons/rt_message_in.gif" + elementTypeIdRef="org.eclipse.papyrus.umlrt.RTMessageIn"/> </ElementCreationMenuModel:Folder> diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/provider/UMLRTFilteredLabelProvider.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/provider/UMLRTFilteredLabelProvider.java index 98ec32dccec..fa3a70c2ccc 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/provider/UMLRTFilteredLabelProvider.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/provider/UMLRTFilteredLabelProvider.java @@ -13,56 +13,20 @@ package org.eclipse.papyrus.umlrt.ui.provider; -import java.util.HashMap; -import java.util.Map; - import org.eclipse.emf.ecore.EObject; import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher; import org.eclipse.gmf.runtime.emf.type.core.IElementType; import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; -import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.infra.services.labelprovider.service.IFilteredLabelProvider; -import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider; -import org.eclipse.papyrus.umlrt.custom.IUMLRTElementTypes; import org.eclipse.papyrus.umlrt.custom.UMLRTElementTypesEnumerator; import org.eclipse.papyrus.umlrt.ui.Activator; -import org.eclipse.swt.graphics.Image; import org.eclipse.uml2.uml.Element; /** * Label provider used by the label provider service */ -public class UMLRTFilteredLabelProvider implements IFilteredLabelProvider { - - public final Map<String, String> typeIdtoIconPath; - - /** path to the icons in the plugin */ - protected static String ICON_PATH = "/icons/"; - - protected static String RT_MESSAGE_IN_ICON = ICON_PATH + "rt_message_in.gif";//$NON-NLS-1$ - protected static String RT_MESSAGE_IN_OUT_ICON = ICON_PATH + "rt_message_inout.gif";//$NON-NLS-1$ - protected static String RT_MESSAGE_OUT_ICON = ICON_PATH + "rt_message_out.gif";//$NON-NLS-1$ - protected static String RT_MESSAGE_UNDEFINED_ICON = ICON_PATH + "rt_message_undefined.gif";//$NON-NLS-1$ - - /** - * Default constructor - */ - public UMLRTFilteredLabelProvider() { - typeIdtoIconPath = new HashMap<String, String>(); - typeIdtoIconPath.put(IUMLRTElementTypes.CAPSULE_ID, ICON_PATH + "capsule.png"); //$NON-NLS-1$ - typeIdtoIconPath.put(IUMLRTElementTypes.CAPSULE_PART_ID, ICON_PATH + "capsule_part.png");//$NON-NLS-1$ - typeIdtoIconPath.put(IUMLRTElementTypes.PROTOCOL_CONTAINER_ID, ICON_PATH + "protocol_container.png");//$NON-NLS-1$ - typeIdtoIconPath.put(IUMLRTElementTypes.PROTOCOL_ID, ICON_PATH + "protocol.png");//$NON-NLS-1$ - typeIdtoIconPath.put(IUMLRTElementTypes.RT_CONNECTOR_ID, ICON_PATH + "rt_connector.png");//$NON-NLS-1$ - typeIdtoIconPath.put(IUMLRTElementTypes.RT_EXCLUDED_ELEMENT_ID, ICON_PATH + "rt_excludedElement.gif");//$NON-NLS-1$ - typeIdtoIconPath.put(IUMLRTElementTypes.RT_MESSAGE_SET_ID, ICON_PATH + "rt_messageset.png");//$NON-NLS-1$ - typeIdtoIconPath.put(IUMLRTElementTypes.RT_PORT_ID, ICON_PATH + "rt_port.png");//$NON-NLS-1$ - typeIdtoIconPath.put(IUMLRTElementTypes.RT_MESSAGE_IN_ID, RT_MESSAGE_IN_ICON); - typeIdtoIconPath.put(IUMLRTElementTypes.RT_MESSAGE_INOUT_ID, RT_MESSAGE_IN_OUT_ICON); - typeIdtoIconPath.put(IUMLRTElementTypes.RT_MESSAGE_OUT_ID, RT_MESSAGE_OUT_ICON); - typeIdtoIconPath.put(IUMLRTElementTypes.RT_MESSAGE_ID, RT_MESSAGE_UNDEFINED_ICON); - } +public class UMLRTFilteredLabelProvider extends UMLRTLabelProvider implements IFilteredLabelProvider { /** * {@inheritDoc} @@ -97,157 +61,30 @@ public class UMLRTFilteredLabelProvider implements IFilteredLabelProvider { * {@inheritDoc} */ @Override - public Image getImage(Object element) { + public String getText(Object element) { EObject semanticObject = EMFHelper.getEObject(element); - - if (!(semanticObject instanceof Element)) { - Activator.log.debug("Trying to display an UMLRT image for a non UML-RT element"); - return null; + if (semanticObject == null) { + return super.getText(element); } - // depending on the element type that matches, return a different icon - String matchingTypeMatcher = getMatchingType(semanticObject); - - if( matchingTypeMatcher ==null) { - return null; - } - - Image image = null; - // a match was done. give a different icon given the value - switch (matchingTypeMatcher) { -// case IUMLRTElementTypes.RT_MESSAGE_SET_ID: -// // for RT message, direction can give different icons -// -// // the element has the RT messageset stereotype applied. It should be possible to retrieve it and even better the direction -// RTMessageKind kind = MessageSetUtils.getMessageKind(semanticObject); -// if (kind != null) { -// switch (kind) { -// case IN: -// image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_SET_IN_ICON); -// break; -// case OUT: -// image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_SET_OUT_ICON); -// break; -// case IN_OUT: -// image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_SET_IN_OUT_ICON); -// break; -// default: -// image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_SET_UNDEFINED_ICON); -// break; -// } -// break; -// } -// image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_SET_UNDEFINED_ICON); -// break; - case IUMLRTElementTypes.RT_MESSAGE_IN_ID: - image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_IN_ICON); - break; - case IUMLRTElementTypes.RT_MESSAGE_OUT_ID: - image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_OUT_ICON); - break; - case IUMLRTElementTypes.RT_MESSAGE_INOUT_ID: - image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_IN_OUT_ICON); - break; + // specific for RT Message label + ISpecializationType inMessageType = (ISpecializationType) UMLRTElementTypesEnumerator.RT_MESSAGE_IN; + ISpecializationType outMessageType = (ISpecializationType) UMLRTElementTypesEnumerator.RT_MESSAGE_OUT; + ISpecializationType inOutMessageType = (ISpecializationType) UMLRTElementTypesEnumerator.RT_MESSAGE_INOUT; - // - // // for RT message, direction can give different icons - // - // RTMessageKind kind = RTMessageUtils.getMessageKind(semanticObject); - // if (kind != null) { - // switch (kind) { - // case IN: - // image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_IN_ICON); - // break; - // case OUT: - // image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_OUT_ICON); - // break; - // case IN_OUT: - // image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_IN_OUT_ICON); - // break; - // default: - // image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_UNDEFINED_ICON); - // break; - // } - // break; - // } - default: - image = getElementImage(matchingTypeMatcher, semanticObject); - break; + if (inMessageType != null && inMessageType.getMatcher() != null && inMessageType.getMatcher().matches((EObject) semanticObject)) { + return "in " + super.getText(element); } - return image; - } - - /** - * Return the element type identifier for the given semantic EObject, given the predefined UML-RT list - * - * @param semanticObject - * the element to display - * @return the unique UML-RT element type identifier or <code>null</code> - */ - protected String getMatchingType(EObject semanticObject) { - for (IElementType type : UMLRTElementTypesEnumerator.getAllRTTypes()) { - if (type instanceof ISpecializationType) { - if (((ISpecializationType) type).getMatcher().matches(semanticObject)) { - return type.getId(); - } - } + if (outMessageType != null && outMessageType.getMatcher() != null && outMessageType.getMatcher().matches((EObject) semanticObject)) { + return "out " + super.getText(element); } - return null; - } - /** - * @param type - * @param element - * @return - */ - protected Image getElementImage(String id, EObject semanticObject) { - String iconPath = typeIdtoIconPath.get(id); - if (iconPath != null) { - return org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, iconPath); + if (inOutMessageType != null && inOutMessageType.getMatcher() != null && inOutMessageType.getMatcher().matches((EObject) semanticObject)) { + return "inout " + super.getText(element); } - return null; - - } - - /** - * {@inheritDoc} - */ - @Override - public String getText(Object element) { - return new UMLLabelProvider().getText(element); - } - - /** - * {@inheritDoc} - */ - @Override - public void addListener(ILabelProviderListener listener) { - - } - - /** - * {@inheritDoc} - */ - @Override - public void dispose() { - - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isLabelProperty(Object element, String property) { - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public void removeListener(ILabelProviderListener listener) { + return super.getText(element); } } diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/provider/UMLRTLabelProvider.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/provider/UMLRTLabelProvider.java index 80dcd232baf..0de3594cd45 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/provider/UMLRTLabelProvider.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/provider/UMLRTLabelProvider.java @@ -13,14 +13,57 @@ package org.eclipse.papyrus.umlrt.ui.provider; +import java.util.HashMap; +import java.util.Map; + import org.eclipse.emf.ecore.EObject; -import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.uml.tools.providers.DelegatingItemLabelProvider; +import org.eclipse.papyrus.uml.tools.providers.UMLFilteredLabelProvider; +import org.eclipse.papyrus.umlrt.custom.IUMLRTElementTypes; +import org.eclipse.papyrus.umlrt.custom.UMLRTElementTypesEnumerator; +import org.eclipse.papyrus.umlrt.ui.Activator; import org.eclipse.swt.graphics.Image; +import org.eclipse.uml2.uml.Element; /** * UML-RT specific label provider. */ -public class UMLRTLabelProvider extends UMLLabelProvider { +public class UMLRTLabelProvider extends UMLFilteredLabelProvider { + + public final Map<String, String> typeIdtoIconPath; + + /** path to the icons in the plugin */ + protected static String ICON_PATH = "/icons/"; + + protected static String RT_MESSAGE_IN_ICON = ICON_PATH + "rt_message_in.gif";//$NON-NLS-1$ + protected static String RT_MESSAGE_IN_OUT_ICON = ICON_PATH + "rt_message_inout.gif";//$NON-NLS-1$ + protected static String RT_MESSAGE_OUT_ICON = ICON_PATH + "rt_message_out.gif";//$NON-NLS-1$ + protected static String RT_MESSAGE_UNDEFINED_ICON = ICON_PATH + "rt_message_undefined.gif";//$NON-NLS-1$ + + private static final IItemLabelProvider labelProvider = new DelegatingItemLabelProvider(); + + /** + * Default constructor + */ + public UMLRTLabelProvider() { + typeIdtoIconPath = new HashMap<String, String>(); + typeIdtoIconPath.put(IUMLRTElementTypes.CAPSULE_ID, ICON_PATH + "capsule.png"); //$NON-NLS-1$ + typeIdtoIconPath.put(IUMLRTElementTypes.CAPSULE_PART_ID, ICON_PATH + "capsule_part.png");//$NON-NLS-1$ + typeIdtoIconPath.put(IUMLRTElementTypes.PROTOCOL_CONTAINER_ID, ICON_PATH + "protocol_container.png");//$NON-NLS-1$ + typeIdtoIconPath.put(IUMLRTElementTypes.PROTOCOL_ID, ICON_PATH + "protocol.png");//$NON-NLS-1$ + typeIdtoIconPath.put(IUMLRTElementTypes.RT_CONNECTOR_ID, ICON_PATH + "rt_connector.png");//$NON-NLS-1$ + typeIdtoIconPath.put(IUMLRTElementTypes.RT_EXCLUDED_ELEMENT_ID, ICON_PATH + "rt_excludedElement.gif");//$NON-NLS-1$ + typeIdtoIconPath.put(IUMLRTElementTypes.RT_MESSAGE_SET_ID, ICON_PATH + "rt_messageset.png");//$NON-NLS-1$ + typeIdtoIconPath.put(IUMLRTElementTypes.RT_PORT_ID, ICON_PATH + "rt_port.png");//$NON-NLS-1$ + typeIdtoIconPath.put(IUMLRTElementTypes.RT_MESSAGE_IN_ID, RT_MESSAGE_IN_ICON); + typeIdtoIconPath.put(IUMLRTElementTypes.RT_MESSAGE_INOUT_ID, RT_MESSAGE_IN_OUT_ICON); + typeIdtoIconPath.put(IUMLRTElementTypes.RT_MESSAGE_OUT_ID, RT_MESSAGE_OUT_ICON); + typeIdtoIconPath.put(IUMLRTElementTypes.RT_MESSAGE_ID, RT_MESSAGE_UNDEFINED_ICON); + } /** * @see org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider#getImage(org.eclipse.emf.ecore.EObject) @@ -29,8 +72,83 @@ public class UMLRTLabelProvider extends UMLLabelProvider { * @return */ @Override - protected Image getImage(EObject element) { - return super.getImage(element); + public Image getImage(Object element) { + EObject semanticObject = EMFHelper.getEObject(element); + + if (!(semanticObject instanceof Element)) { + Activator.log.debug("Trying to display an UMLRT image for a non UML-RT element"); + return null; + } + + // depending on the element type that matches, return a different icon + String matchingTypeMatcher = getMatchingType(semanticObject); + + if (matchingTypeMatcher == null) { + return null; + } + + Image image = null; + // a match was done. give a different icon given the value + switch (matchingTypeMatcher) { + case IUMLRTElementTypes.RT_MESSAGE_IN_ID: + image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_IN_ICON); + break; + case IUMLRTElementTypes.RT_MESSAGE_OUT_ID: + image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_OUT_ICON); + break; + case IUMLRTElementTypes.RT_MESSAGE_INOUT_ID: + image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_IN_OUT_ICON); + break; + default: + image = getElementImage(matchingTypeMatcher, semanticObject); + break; + } + + return image; + } + + + /** + * @see org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider#getText(java.lang.Object) + * + * @param element + * @return + */ + @Override + public String getText(Object element) { + return labelProvider.getText(element); + } + + /** + * Return the element type identifier for the given semantic EObject, given the predefined UML-RT list + * + * @param semanticObject + * the element to display + * @return the unique UML-RT element type identifier or <code>null</code> + */ + protected String getMatchingType(EObject semanticObject) { + for (IElementType type : UMLRTElementTypesEnumerator.getAllRTTypes()) { + if (type instanceof ISpecializationType) { + if (((ISpecializationType) type).getMatcher().matches(semanticObject)) { + return type.getId(); + } + } + } + return null; + } + + /** + * @param type + * @param element + * @return + */ + protected Image getElementImage(String id, EObject semanticObject) { + String iconPath = typeIdtoIconPath.get(id); + if (iconPath != null) { + return org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, iconPath); + } + return null; + } } diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/DisplayMessageSetsOnlyQuery.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/DisplayMessageSetsOnlyQuery.java index ba55df2049d..bb81ffd9d5d 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/DisplayMessageSetsOnlyQuery.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/DisplayMessageSetsOnlyQuery.java @@ -1,3 +1,15 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * CEA LIST - Initial API and implementation + * + *****************************************************************************/ package org.eclipse.papyrus.umlrt.ui.queries; import org.eclipse.emf.ecore.EStructuralFeature; diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/DisplayMessagesOnlyQuery.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/DisplayMessagesOnlyQuery.java index c0531887cb9..26bc3e22908 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/DisplayMessagesOnlyQuery.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/DisplayMessagesOnlyQuery.java @@ -1,3 +1,15 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * CEA LIST - Initial API and implementation + * + *****************************************************************************/ package org.eclipse.papyrus.umlrt.ui.queries; import org.eclipse.emf.ecore.EStructuralFeature; diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/GetLabelQuery.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/GetLabelQuery.java index 6b48abf5346..ac634be0195 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/GetLabelQuery.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/GetLabelQuery.java @@ -14,23 +14,26 @@ package org.eclipse.papyrus.umlrt.ui.queries; import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; -import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; -import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider; -import org.eclipse.uml2.uml.Element; +import org.eclipse.papyrus.uml.modelexplorer.queries.GetComplexName; +import org.eclipse.papyrus.umlrt.ui.provider.UMLRTFilteredLabelProvider; +import org.eclipse.uml2.uml.NamedElement; -public class GetLabelQuery implements IJavaQuery2<Element, String> { +public class GetLabelQuery extends GetComplexName { - private static final UMLLabelProvider UML_LABEL_PROVIDER= new UMLLabelProvider(); + private static final UMLRTFilteredLabelProvider UML_LABEL_PROVIDER = new UMLRTFilteredLabelProvider(); /** * {@inheritDoc} */ - public String evaluate(final Element context, + public String evaluate(final NamedElement context, final IParameterValueList2 parameterValues, final IFacetManager facetManager) throws DerivedTypedElementException { + if (UML_LABEL_PROVIDER.accept(context)) { + return UML_LABEL_PROVIDER.getText(context); + } + return super.evaluate(context, parameterValues, facetManager); - return "RT_"+UML_LABEL_PROVIDER.getText(context); } } diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/collaboration/HideCollapseLinksExceptDirectionQuery.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/collaboration/HideCollapseLinksExceptDirectionQuery.java new file mode 100644 index 00000000000..2b2e4abfe67 --- /dev/null +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/collaboration/HideCollapseLinksExceptDirectionQuery.java @@ -0,0 +1,42 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * CEA LIST - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.umlrt.ui.queries.collaboration; + +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; +import org.eclipse.uml2.uml.Collaboration; + +public class HideCollapseLinksExceptDirectionQuery implements IJavaQuery2<Collaboration, Boolean> { + public Boolean evaluate(final Collaboration context, + final IParameterValueList2 parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + // display only in / out and inout features. They should not be collapsed also + ParameterValue parameterValue = parameterValues.getParameterValueByName("eStructuralFeature"); + EStructuralFeature eStructuralFeature = (EStructuralFeature) parameterValue.getValue(); + // the eStructure is a containmentReference or Facet Reference? + if (eStructuralFeature instanceof FacetReference) { + // check this is in / out or inout + String name = ((FacetReference) eStructuralFeature).getName(); + if ("in".equals(name) || "out".equals(name) || "inout".equals(name)) { + return true; + } + } + return false; + } +} |