Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael ADAM2016-09-30 11:52:04 -0400
committerGerrit Code Review @ Eclipse.org2016-10-12 03:53:40 -0400
commitece1cc550e2ef2517bb46b0705a197ce814486a5 (patch)
tree02f35879c65558df478d957c0494de76460f1478 /plugins
parentff57328e9c2d4acf01c47244eb7cf64fbbec886b (diff)
downloadorg.eclipse.papyrus-ece1cc550e2ef2517bb46b0705a197ce814486a5.tar.gz
org.eclipse.papyrus-ece1cc550e2ef2517bb46b0705a197ce814486a5.tar.xz
org.eclipse.papyrus-ece1cc550e2ef2517bb46b0705a197ce814486a5.zip
Bug 503039 - [Model Explorer] Label Customization doesn't work for all
uml Element https://bugs.eclipse.org/bugs/show_bug.cgi?id=503039 Change-Id: I7c8e6e7a3076c5923bdaf08c2f45d96c85c751f5 Signed-off-by: Mickael ADAM <mickael.adam@ALL4TEC.net>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/resource/CustomizableUMLLabel.custom4
-rw-r--r--plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetComplexStyledName.java6
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/CustomizableDelegatingItemLabelProvider.java13
3 files changed, 17 insertions, 6 deletions
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/resource/CustomizableUMLLabel.custom b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/resource/CustomizableUMLLabel.custom
index 8684524ff3f..a4ea2a74482 100644
--- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/resource/CustomizableUMLLabel.custom
+++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/resource/CustomizableUMLLabel.custom
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<custom:Customization xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:custom="http://www.eclipse.org/papyrus/emf/facet/custom/0.2.incubation/custom" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:efacet="http://www.eclipse.org/papyrus/emf/facet/efacet/0.2.incubation/efacet" xmlns:javaQuery="http://www.eclipse.org/papyrus/emf/facet/query/java/0.2.incubation/javaquery" name="CustomizableUMLLabel" documentation="TODO pref, use StyledString instead of EString" rank="900">
+<custom:Customization xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:custom="http://www.eclipse.org/papyrus/emf/facet/custom/0.2.incubation/custom" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:efacet="http://www.eclipse.org/papyrus/emf/facet/efacet/0.2.incubation/efacet" xmlns:javaQuery="http://www.eclipse.org/papyrus/emf/facet/query/java/0.2.incubation/javaquery" name="CustomizableUMLLabel" documentation="use StyledString instead of EString" rank="900">
<eClassifiers xsi:type="custom:EClassCustomization" name="Element">
- <extendedMetaclass href="http://www.eclipse.org/uml2/5.0.0/UML#//NamedElement"/>
+ <extendedMetaclass href="http://www.eclipse.org/uml2/5.0.0/UML#//Element"/>
<facetOperations name="CustomizableUMLLabel">
<eType xsi:type="ecore:EDataType" href="../../org.eclipse.papyrus.emf.facet.custom.metamodel/model/custom_primitive_types-0.2.0.ecore#//StyledLabel"/>
<eParameters name="eObject">
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetComplexStyledName.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetComplexStyledName.java
index 7f241593de5..f7110320423 100644
--- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetComplexStyledName.java
+++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetComplexStyledName.java
@@ -27,12 +27,12 @@ import org.eclipse.papyrus.uml.modelexplorer.Activator;
import org.eclipse.papyrus.uml.modelexplorer.preferences.CustomizableLabelPreferences;
import org.eclipse.papyrus.uml.tools.profile.definition.LabelStylersEnum;
import org.eclipse.papyrus.uml.tools.providers.CustomizableDelegatingItemLabelProvider;
-import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Element;
/**
* A query to get the Name as StyledString. The label is styled with preferences.
*/
-public class GetComplexStyledName implements IJavaQuery2<NamedElement, StyledString> {
+public class GetComplexStyledName implements IJavaQuery2<Element, StyledString> {
/** the label provider */
private static final CustomizableDelegatingItemLabelProvider labelProvider = new CustomizableDelegatingItemLabelProvider();
@@ -42,7 +42,7 @@ public class GetComplexStyledName implements IJavaQuery2<NamedElement, StyledStr
*
* @see org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2#evaluate(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2, org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager)
*/
- public StyledString evaluate(final NamedElement source, final IParameterValueList2 parameterValues, final IFacetManager facetManager) throws DerivedTypedElementException {
+ public StyledString evaluate(final Element source, final IParameterValueList2 parameterValues, final IFacetManager facetManager) throws DerivedTypedElementException {
ParameterValue parameterValue = parameterValues.getParameterValueByName("eObject"); //$NON-NLS-1$
if (parameterValue.getValue() instanceof EStructuralFeature) {
return new StyledString(((EStructuralFeature) parameterValue.getValue()).getName());
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/CustomizableDelegatingItemLabelProvider.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/CustomizableDelegatingItemLabelProvider.java
index 26283933ac6..8ac70ed3759 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/CustomizableDelegatingItemLabelProvider.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/CustomizableDelegatingItemLabelProvider.java
@@ -29,6 +29,7 @@ import org.eclipse.papyrus.emf.facet.util.emf.core.ModelUtils;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.uml.tools.Activator;
import org.eclipse.papyrus.uml.tools.profile.definition.LabelTypesEnum;
+import org.eclipse.uml2.uml.Comment;
import org.eclipse.uml2.uml.NamedElement;
@@ -259,6 +260,11 @@ public class CustomizableDelegatingItemLabelProvider implements IItemLabelProvid
}
}
+ // If no text to display we call UMLLabelProvider which add some text in this case.
+ if (0 >= result.length()) {
+ result.append(new UMLLabelProvider().getText(element));
+ }
+
return result;
}
@@ -298,7 +304,12 @@ public class CustomizableDelegatingItemLabelProvider implements IItemLabelProvid
LabelTypesEnum typeEnum = LabelTypesEnum.getByLiteral(type);
switch (typeEnum) {
case LABEL:
- result = m.group(3);
+ if (element instanceof Comment) {
+ // Comment case which can return <Empty Comment>
+ result = new UMLLabelProvider().getText((Comment) element);
+ } else {
+ result = m.group(3);
+ }
break;
case STEREOTYPE:
result = m.group(1);

Back to the top