Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael ADAM2016-08-25 09:58:59 +0000
committerGerrit Code Review @ Eclipse.org2016-09-27 08:02:02 +0000
commitad65ff8c3f11fd8651c42be6eff13abbb1d3b279 (patch)
tree96920ac8874dce44d109342dda08af4e1e09814f
parent21f7c5441e48e341c79ccd90cc78227b39c6e6d7 (diff)
downloadorg.eclipse.papyrus-ad65ff8c3f11fd8651c42be6eff13abbb1d3b279.tar.gz
org.eclipse.papyrus-ad65ff8c3f11fd8651c42be6eff13abbb1d3b279.tar.xz
org.eclipse.papyrus-ad65ff8c3f11fd8651c42be6eff13abbb1d3b279.zip
Bug 500219 - [Model Explorer] Papyrus Should provide an other way to
customize uml label Change-Id: Ic3213ed9aefb636f4e581df7996378dfd96d8937 Signed-off-by: Mickael ADAM <mickael.adam@ALL4TEC.net>
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/META-INF/MANIFEST.MF2
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/exported/CustomizationUtils.java8
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel.edit/META-INF/MANIFEST.MF2
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/.settings/org.eclipse.core.resources.prefs1
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/META-INF/MANIFEST.MF7
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/model/custom_primitive_types-0.2.0.ecore7
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/model/custom_primitive_types-0.2.0.genmodel1
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/pom.xml2
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/Alignment.java49
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/CustomptFactory.java5
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/CustomptPackage.java50
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/Shadow.java49
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/impl/CustomptFactoryImpl.java103
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/impl/CustomptPackageImpl.java75
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedLabelProvider.java26
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedLabelProvider.java94
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/DecoratingCustomizedLabelProvider.java22
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/ResolvingCustomizedLabelProvider.java30
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.query.java.sdk.ui/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.labelprovider/src/org/eclipse/papyrus/infra/services/labelprovider/service/ExtensibleLabelProvider.java24
-rw-r--r--plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/META-INF/MANIFEST.MF1
-rw-r--r--plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/icons/labelCustom.gifbin0 -> 299 bytes
-rw-r--r--plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/plugin.xml48
-rw-r--r--plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/resource/CustomizableUMLLabel.custom15
-rw-r--r--plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/dialogs/CustomizeUMLLabelDialog.java613
-rw-r--r--plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/CustomizeUMLLabelHandler.java73
-rw-r--r--plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/UMLLabelCustomizableTester.java57
-rw-r--r--plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/messages/Messages.java39
-rw-r--r--plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/messages/messages.properties9
-rw-r--r--plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/preferences/CustomizableLabelPreferenceInitializer.java45
-rw-r--r--plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/preferences/CustomizableLabelPreferences.java25
-rw-r--r--plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetComplexStyledName.java77
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/profile/definition/LabelStylersEnum.java144
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/profile/definition/LabelTypesEnum.java88
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/CustomizableDelegatingItemLabelProvider.java439
36 files changed, 2013 insertions, 221 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/META-INF/MANIFEST.MF b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/META-INF/MANIFEST.MF
index 00a1c80b084..8faa15d3def 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/META-INF/MANIFEST.MF
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/META-INF/MANIFEST.MF
@@ -7,7 +7,7 @@ Export-Package: org.eclipse.papyrus.emf.facet.custom.core,
org.eclipse.papyrus.emf.facet.custom.core.internal.query
Require-Bundle: org.eclipse.ui;bundle-version="[3.107.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.12.0,4.0.0)",
- org.eclipse.papyrus.emf.facet.custom.metamodel;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.emf.facet.custom.metamodel;bundle-version="[1.3.0,2.0.0)";visibility:=reexport,
org.eclipse.papyrus.emf.facet.efacet.core;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.papyrus.emf.facet.util.core;bundle-version="[1.2.0,2.0.0)",
org.eclipse.emf.validation;bundle-version="[1.8.0,2.0.0)"
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/exported/CustomizationUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/exported/CustomizationUtils.java
index 36a961abc48..d17f8fcc391 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/exported/CustomizationUtils.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/exported/CustomizationUtils.java
@@ -10,6 +10,7 @@
* Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
* Gregoire Dupe (Mia-Software) - Bug 376576 - [EFacet] Change the multiplicity of Facet::extendedFacet
* David Couvrand (Soft-Maint) - Bug 418418 - [Customization] Overlay icons not implemented
+ * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - implementation of IStyledLabelProvider
*/
package org.eclipse.papyrus.emf.facet.custom.core.internal.exported;
@@ -22,6 +23,7 @@ import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
import org.eclipse.papyrus.emf.facet.custom.core.exception.CustomizationException;
import org.eclipse.papyrus.emf.facet.custom.core.internal.Activator;
@@ -127,6 +129,12 @@ public final class CustomizationUtils {
Activator.getDefault());
}
}
+
+ // Patch to convert StyledString to String in case of customManager provide StyleString and String is expected.
+ if (result instanceof StyledString && !classs.isInstance(result)) {
+ result = (T) result.toString();
+ }
+
return result;
}
}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel.edit/META-INF/MANIFEST.MF b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel.edit/META-INF/MANIFEST.MF
index b267c1b7ae4..3d20d83dedc 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel.edit/META-INF/MANIFEST.MF
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel.edit/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Export-Package: org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.provider;x-internal:=true
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.12.0,4.0.0)",
- org.eclipse.papyrus.emf.facet.custom.metamodel;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.emf.facet.custom.metamodel;bundle-version="[1.3.0,2.0.0)";visibility:=reexport,
org.eclipse.papyrus.emf.facet.efacet.metamodel;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
org.eclipse.papyrus.emf.facet.efacet.metamodel.edit;bundle-version="[1.2.0,2.0.0)";visibility:=reexport
Bundle-Vendor: %providerName
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/.settings/org.eclipse.core.resources.prefs b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/.settings/org.eclipse.core.resources.prefs
index e1105b315f5..6b2762e2f36 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/.settings/org.eclipse.core.resources.prefs
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/.settings/org.eclipse.core.resources.prefs
@@ -1,4 +1,3 @@
-#Thu Oct 20 20:43:55 CEST 2011
eclipse.preferences.version=1
encoding//model/custom_main.ecorediag=UTF-8
encoding//model/custom_property_declaration.ecorediag=UTF-8
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/META-INF/MANIFEST.MF b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/META-INF/MANIFEST.MF
index 1e7b5b27d6f..0849e5a3dbc 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/META-INF/MANIFEST.MF
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/META-INF/MANIFEST.MF
@@ -1,6 +1,9 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.12.0,4.0.0)",
- org.eclipse.papyrus.emf.facet.efacet.metamodel;bundle-version="[1.2.0,2.0.0)";visibility:=reexport
+ org.eclipse.emf.ecore;bundle-version="[2.12.0,3.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.emf.facet.efacet.metamodel;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
+ org.eclipse.emf.edit;bundle-version="[2.12.0,3.0.0)",
+ org.eclipse.jface;bundle-version="[3.12.0,4.0.0)"
Export-Package: org.eclipse.papyrus.emf.facet.custom.metamodel.custompt,
org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom,
org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.impl,
@@ -14,7 +17,7 @@ Export-Package: org.eclipse.papyrus.emf.facet.custom.metamodel.custompt,
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 1.3.0.qualifier
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-ManifestVersion: 2
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/model/custom_primitive_types-0.2.0.ecore b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/model/custom_primitive_types-0.2.0.ecore
index 16c772e2b38..bc6d75d7e35 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/model/custom_primitive_types-0.2.0.ecore
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/model/custom_primitive_types-0.2.0.ecore
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<ecore:EPackage xmi:version="2.0"
- xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="custompt"
- nsURI="http://www.eclipse.org/papyrus/emf/facet/custom/0.2.incubation/custom_primitive_types"
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="custompt" nsURI="http://www.eclipse.org/papyrus/emf/facet/custom/0.2.incubation/custom_primitive_types"
nsPrefix="custompt">
<eClassifiers xsi:type="ecore:EDataType" name="Image" instanceClassName="org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage"/>
<eClassifiers xsi:type="ecore:EDataType" name="Color" instanceClassName="org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IColor"/>
@@ -16,4 +14,5 @@
<eLiterals name="CENTER" value="1"/>
<eLiterals name="RIGHT" value="2"/>
</eClassifiers>
+ <eClassifiers xsi:type="ecore:EDataType" name="StyledLabel" instanceClassName="org.eclipse.jface.viewers.StyledString"/>
</ecore:EPackage>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/model/custom_primitive_types-0.2.0.genmodel b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/model/custom_primitive_types-0.2.0.genmodel
index 66acb7a10b0..b64920b7d48 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/model/custom_primitive_types-0.2.0.genmodel
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/model/custom_primitive_types-0.2.0.genmodel
@@ -19,5 +19,6 @@
</genEnums>
<genDataTypes ecoreDataType="custom_primitive_types-0.2.0.ecore#//Image"/>
<genDataTypes ecoreDataType="custom_primitive_types-0.2.0.ecore#//Color"/>
+ <genDataTypes ecoreDataType="custom_primitive_types-0.2.0.ecore#//StyledLabel"/>
</genPackages>
</genmodel:GenModel>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/pom.xml b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/pom.xml
index b54d39edc35..8170cd8c3c6 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/pom.xml
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/pom.xml
@@ -7,6 +7,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.emf.facet.custom.metamodel</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.3.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/Alignment.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/Alignment.java
index b462da95e88..23a87022531 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/Alignment.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/Alignment.java
@@ -24,7 +24,6 @@ import org.eclipse.emf.common.util.Enumerator;
* A representation of the literals of the enumeration '<em><b>Alignment</b></em>',
* and utility methods for working with them.
* <!-- end-user-doc -->
- *
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.CustomptPackage#getAlignment()
* @model
* @generated
@@ -34,7 +33,6 @@ public enum Alignment implements Enumerator {
* The '<em><b>LEFT</b></em>' literal object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @see #LEFT_VALUE
* @generated
* @ordered
@@ -45,7 +43,6 @@ public enum Alignment implements Enumerator {
* The '<em><b>CENTER</b></em>' literal object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @see #CENTER_VALUE
* @generated
* @ordered
@@ -56,7 +53,6 @@ public enum Alignment implements Enumerator {
* The '<em><b>RIGHT</b></em>' literal object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @see #RIGHT_VALUE
* @generated
* @ordered
@@ -70,7 +66,6 @@ public enum Alignment implements Enumerator {
* If the meaning of '<em><b>LEFT</b></em>' literal object isn't clear, there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
- *
* @see #LEFT
* @model
* @generated
@@ -85,7 +80,6 @@ public enum Alignment implements Enumerator {
* If the meaning of '<em><b>CENTER</b></em>' literal object isn't clear, there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
- *
* @see #CENTER
* @model
* @generated
@@ -100,7 +94,6 @@ public enum Alignment implements Enumerator {
* If the meaning of '<em><b>RIGHT</b></em>' literal object isn't clear, there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
- *
* @see #RIGHT
* @model
* @generated
@@ -112,21 +105,19 @@ public enum Alignment implements Enumerator {
* An array of all the '<em><b>Alignment</b></em>' enumerators.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
private static final Alignment[] VALUES_ARRAY =
new Alignment[] {
- LEFT,
- CENTER,
- RIGHT,
- };
+ LEFT,
+ CENTER,
+ RIGHT,
+ };
/**
* A public read-only list of all the '<em><b>Alignment</b></em>' enumerators.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public static final List<Alignment> VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY));
@@ -135,7 +126,8 @@ public enum Alignment implements Enumerator {
* Returns the '<em><b>Alignment</b></em>' literal with the specified literal value.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
+ * @param literal the literal.
+ * @return the matching enumerator or <code>null</code>.
* @generated
*/
public static Alignment get(String literal) {
@@ -152,7 +144,8 @@ public enum Alignment implements Enumerator {
* Returns the '<em><b>Alignment</b></em>' literal with the specified name.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
+ * @param name the name.
+ * @return the matching enumerator or <code>null</code>.
* @generated
*/
public static Alignment getByName(String name) {
@@ -169,17 +162,15 @@ public enum Alignment implements Enumerator {
* Returns the '<em><b>Alignment</b></em>' literal with the specified integer value.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
+ * @param value the integer value.
+ * @return the matching enumerator or <code>null</code>.
* @generated
*/
public static Alignment get(int value) {
switch (value) {
- case LEFT_VALUE:
- return LEFT;
- case CENTER_VALUE:
- return CENTER;
- case RIGHT_VALUE:
- return RIGHT;
+ case LEFT_VALUE: return LEFT;
+ case CENTER_VALUE: return CENTER;
+ case RIGHT_VALUE: return RIGHT;
}
return null;
}
@@ -187,7 +178,6 @@ public enum Alignment implements Enumerator {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
private final int value;
@@ -195,7 +185,6 @@ public enum Alignment implements Enumerator {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
private final String name;
@@ -203,7 +192,6 @@ public enum Alignment implements Enumerator {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
private final String literal;
@@ -212,7 +200,6 @@ public enum Alignment implements Enumerator {
* Only this class can construct instances.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
private Alignment(int value, String name, String literal) {
@@ -224,38 +211,34 @@ public enum Alignment implements Enumerator {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public int getValue() {
- return value;
+ return value;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public String getName() {
- return name;
+ return name;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public String getLiteral() {
- return literal;
+ return literal;
}
/**
* Returns the literal value of the enumerator, which is its string representation.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
@Override
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/CustomptFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/CustomptFactory.java
index 372fbee5c3a..8578c782939 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/CustomptFactory.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/CustomptFactory.java
@@ -18,18 +18,14 @@ import org.eclipse.emf.ecore.EFactory;
/**
* <!-- begin-user-doc --> The <b>Factory</b> for the model. It provides a
* create method for each non-abstract class of the model. <!-- end-user-doc -->
- *
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.CustomptPackage
* @generated
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
*/
public interface CustomptFactory extends EFactory {
/**
* The singleton instance of the factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
CustomptFactory eINSTANCE = org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.impl.CustomptFactoryImpl.init();
@@ -38,7 +34,6 @@ public interface CustomptFactory extends EFactory {
* Returns the package supported by this factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @return the package supported by this factory.
* @generated
*/
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/CustomptPackage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/CustomptPackage.java
index efb373a956d..eec647d5eba 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/CustomptPackage.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/CustomptPackage.java
@@ -28,7 +28,6 @@ import org.eclipse.emf.ecore.EPackage;
* <li>and each data type</li>
* </ul>
* <!-- end-user-doc -->
- *
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.CustomptFactory
* @model kind="package"
* @generated
@@ -38,7 +37,6 @@ public interface CustomptPackage extends EPackage {
* The package name.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
String eNAME = "custompt";
@@ -47,7 +45,6 @@ public interface CustomptPackage extends EPackage {
* The package namespace URI.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
String eNS_URI = "http://www.eclipse.org/papyrus/emf/facet/custom/0.2.incubation/custom_primitive_types";
@@ -56,7 +53,6 @@ public interface CustomptPackage extends EPackage {
* The package namespace name.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
String eNS_PREFIX = "custompt";
@@ -65,7 +61,6 @@ public interface CustomptPackage extends EPackage {
* The singleton instance of the package.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
CustomptPackage eINSTANCE = org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.impl.CustomptPackageImpl.init();
@@ -74,7 +69,6 @@ public interface CustomptPackage extends EPackage {
* The meta object id for the '{@link org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Shadow <em>Shadow</em>}' enum.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Shadow
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.impl.CustomptPackageImpl#getShadow()
* @generated
@@ -85,7 +79,6 @@ public interface CustomptPackage extends EPackage {
* The meta object id for the '{@link org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Alignment <em>Alignment</em>}' enum.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Alignment
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.impl.CustomptPackageImpl#getAlignment()
* @generated
@@ -96,7 +89,6 @@ public interface CustomptPackage extends EPackage {
* The meta object id for the '<em>Image</em>' data type.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.impl.CustomptPackageImpl#getImage()
* @generated
@@ -107,7 +99,6 @@ public interface CustomptPackage extends EPackage {
* The meta object id for the '<em>Color</em>' data type.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IColor
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.impl.CustomptPackageImpl#getColor()
* @generated
@@ -115,10 +106,19 @@ public interface CustomptPackage extends EPackage {
int COLOR = 3;
/**
+ * The meta object id for the '<em>Styled Label</em>' data type.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.jface.viewers.StyledString
+ * @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.impl.CustomptPackageImpl#getStyledLabel()
+ * @generated
+ */
+ int STYLED_LABEL = 4;
+
+ /**
* Returns the meta object for enum '{@link org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Shadow <em>Shadow</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @return the meta object for enum '<em>Shadow</em>'.
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Shadow
* @generated
@@ -129,7 +129,6 @@ public interface CustomptPackage extends EPackage {
* Returns the meta object for enum '{@link org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Alignment <em>Alignment</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @return the meta object for enum '<em>Alignment</em>'.
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Alignment
* @generated
@@ -140,7 +139,6 @@ public interface CustomptPackage extends EPackage {
* Returns the meta object for data type '{@link org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage <em>Image</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @return the meta object for data type '<em>Image</em>'.
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage
* @model instanceClass="org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage"
@@ -152,7 +150,6 @@ public interface CustomptPackage extends EPackage {
* Returns the meta object for data type '{@link org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IColor <em>Color</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @return the meta object for data type '<em>Color</em>'.
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IColor
* @model instanceClass="org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IColor"
@@ -161,10 +158,20 @@ public interface CustomptPackage extends EPackage {
EDataType getColor();
/**
+ * Returns the meta object for data type '{@link org.eclipse.jface.viewers.StyledString <em>Styled Label</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for data type '<em>Styled Label</em>'.
+ * @see org.eclipse.jface.viewers.StyledString
+ * @model instanceClass="org.eclipse.jface.viewers.StyledString"
+ * @generated
+ */
+ EDataType getStyledLabel();
+
+ /**
* Returns the factory that creates the instances of the model.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @return the factory that creates the instances of the model.
* @generated
*/
@@ -180,7 +187,6 @@ public interface CustomptPackage extends EPackage {
* <li>and each data type</li>
* </ul>
* <!-- end-user-doc -->
- *
* @generated
*/
interface Literals {
@@ -188,7 +194,6 @@ public interface CustomptPackage extends EPackage {
* The meta object literal for the '{@link org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Shadow <em>Shadow</em>}' enum.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Shadow
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.impl.CustomptPackageImpl#getShadow()
* @generated
@@ -199,7 +204,6 @@ public interface CustomptPackage extends EPackage {
* The meta object literal for the '{@link org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Alignment <em>Alignment</em>}' enum.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Alignment
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.impl.CustomptPackageImpl#getAlignment()
* @generated
@@ -210,7 +214,6 @@ public interface CustomptPackage extends EPackage {
* The meta object literal for the '<em>Image</em>' data type.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.impl.CustomptPackageImpl#getImage()
* @generated
@@ -221,13 +224,22 @@ public interface CustomptPackage extends EPackage {
* The meta object literal for the '<em>Color</em>' data type.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IColor
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.impl.CustomptPackageImpl#getColor()
* @generated
*/
EDataType COLOR = eINSTANCE.getColor();
+ /**
+ * The meta object literal for the '<em>Styled Label</em>' data type.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.jface.viewers.StyledString
+ * @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.impl.CustomptPackageImpl#getStyledLabel()
+ * @generated
+ */
+ EDataType STYLED_LABEL = eINSTANCE.getStyledLabel();
+
}
} // CustomptPackage
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/Shadow.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/Shadow.java
index 7aec54783e6..35b1d6ae4ba 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/Shadow.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/Shadow.java
@@ -24,7 +24,6 @@ import org.eclipse.emf.common.util.Enumerator;
* A representation of the literals of the enumeration '<em><b>Shadow</b></em>',
* and utility methods for working with them.
* <!-- end-user-doc -->
- *
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.CustomptPackage#getShadow()
* @model
* @generated
@@ -34,7 +33,6 @@ public enum Shadow implements Enumerator {
* The '<em><b>NONE</b></em>' literal object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @see #NONE_VALUE
* @generated
* @ordered
@@ -45,7 +43,6 @@ public enum Shadow implements Enumerator {
* The '<em><b>IN</b></em>' literal object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @see #IN_VALUE
* @generated
* @ordered
@@ -56,7 +53,6 @@ public enum Shadow implements Enumerator {
* The '<em><b>OUT</b></em>' literal object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @see #OUT_VALUE
* @generated
* @ordered
@@ -70,7 +66,6 @@ public enum Shadow implements Enumerator {
* If the meaning of '<em><b>NONE</b></em>' literal object isn't clear, there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
- *
* @see #NONE
* @model
* @generated
@@ -85,7 +80,6 @@ public enum Shadow implements Enumerator {
* If the meaning of '<em><b>IN</b></em>' literal object isn't clear, there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
- *
* @see #IN
* @model
* @generated
@@ -100,7 +94,6 @@ public enum Shadow implements Enumerator {
* If the meaning of '<em><b>OUT</b></em>' literal object isn't clear, there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
- *
* @see #OUT
* @model
* @generated
@@ -112,21 +105,19 @@ public enum Shadow implements Enumerator {
* An array of all the '<em><b>Shadow</b></em>' enumerators.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
private static final Shadow[] VALUES_ARRAY =
new Shadow[] {
- NONE,
- IN,
- OUT,
- };
+ NONE,
+ IN,
+ OUT,
+ };
/**
* A public read-only list of all the '<em><b>Shadow</b></em>' enumerators.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public static final List<Shadow> VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY));
@@ -135,7 +126,8 @@ public enum Shadow implements Enumerator {
* Returns the '<em><b>Shadow</b></em>' literal with the specified literal value.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
+ * @param literal the literal.
+ * @return the matching enumerator or <code>null</code>.
* @generated
*/
public static Shadow get(String literal) {
@@ -152,7 +144,8 @@ public enum Shadow implements Enumerator {
* Returns the '<em><b>Shadow</b></em>' literal with the specified name.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
+ * @param name the name.
+ * @return the matching enumerator or <code>null</code>.
* @generated
*/
public static Shadow getByName(String name) {
@@ -169,17 +162,15 @@ public enum Shadow implements Enumerator {
* Returns the '<em><b>Shadow</b></em>' literal with the specified integer value.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
+ * @param value the integer value.
+ * @return the matching enumerator or <code>null</code>.
* @generated
*/
public static Shadow get(int value) {
switch (value) {
- case NONE_VALUE:
- return NONE;
- case IN_VALUE:
- return IN;
- case OUT_VALUE:
- return OUT;
+ case NONE_VALUE: return NONE;
+ case IN_VALUE: return IN;
+ case OUT_VALUE: return OUT;
}
return null;
}
@@ -187,7 +178,6 @@ public enum Shadow implements Enumerator {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
private final int value;
@@ -195,7 +185,6 @@ public enum Shadow implements Enumerator {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
private final String name;
@@ -203,7 +192,6 @@ public enum Shadow implements Enumerator {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
private final String literal;
@@ -212,7 +200,6 @@ public enum Shadow implements Enumerator {
* Only this class can construct instances.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
private Shadow(int value, String name, String literal) {
@@ -224,38 +211,34 @@ public enum Shadow implements Enumerator {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public int getValue() {
- return value;
+ return value;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public String getName() {
- return name;
+ return name;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public String getLiteral() {
- return literal;
+ return literal;
}
/**
* Returns the literal value of the enumerator, which is its string representation.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
@Override
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/impl/CustomptFactoryImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/impl/CustomptFactoryImpl.java
index 550a0a25e0e..15693273348 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/impl/CustomptFactoryImpl.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/impl/CustomptFactoryImpl.java
@@ -19,8 +19,10 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.impl.EFactoryImpl;
import org.eclipse.emf.ecore.plugin.EcorePlugin;
+import org.eclipse.emf.edit.provider.StyledString;
import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IColor;
import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage;
+import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.*;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Alignment;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.CustomptFactory;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.CustomptPackage;
@@ -30,7 +32,6 @@ import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Shadow;
* <!-- begin-user-doc -->
* An implementation of the model <b>Factory</b>.
* <!-- end-user-doc -->
- *
* @generated
*/
public class CustomptFactoryImpl extends EFactoryImpl implements CustomptFactory {
@@ -38,16 +39,16 @@ public class CustomptFactoryImpl extends EFactoryImpl implements CustomptFactory
* Creates the default factory implementation.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public static CustomptFactory init() {
try {
- CustomptFactory theCustomptFactory = (CustomptFactory) EPackage.Registry.INSTANCE.getEFactory("http://www.eclipse.org/papyrus/emf/facet/custom/0.2.incubation/custom_primitive_types");
+ CustomptFactory theCustomptFactory = (CustomptFactory)EPackage.Registry.INSTANCE.getEFactory(CustomptPackage.eNS_URI);
if (theCustomptFactory != null) {
return theCustomptFactory;
}
- } catch (Exception exception) {
+ }
+ catch (Exception exception) {
EcorePlugin.INSTANCE.log(exception);
}
return new CustomptFactoryImpl();
@@ -57,7 +58,6 @@ public class CustomptFactoryImpl extends EFactoryImpl implements CustomptFactory
* Creates an instance of the factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public CustomptFactoryImpl() {
@@ -67,79 +67,76 @@ public class CustomptFactoryImpl extends EFactoryImpl implements CustomptFactory
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
@Override
public EObject create(EClass eClass) {
switch (eClass.getClassifierID()) {
- default:
- throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
+ default:
+ throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
@Override
public Object createFromString(EDataType eDataType, String initialValue) {
switch (eDataType.getClassifierID()) {
- case CustomptPackage.SHADOW:
- return createShadowFromString(eDataType, initialValue);
- case CustomptPackage.ALIGNMENT:
- return createAlignmentFromString(eDataType, initialValue);
- case CustomptPackage.IMAGE:
- return createImageFromString(eDataType, initialValue);
- case CustomptPackage.COLOR:
- return createColorFromString(eDataType, initialValue);
- default:
- throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
+ case CustomptPackage.SHADOW:
+ return createShadowFromString(eDataType, initialValue);
+ case CustomptPackage.ALIGNMENT:
+ return createAlignmentFromString(eDataType, initialValue);
+ case CustomptPackage.IMAGE:
+ return createImageFromString(eDataType, initialValue);
+ case CustomptPackage.COLOR:
+ return createColorFromString(eDataType, initialValue);
+ case CustomptPackage.STYLED_LABEL:
+ return createStyledLabelFromString(eDataType, initialValue);
+ default:
+ throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
@Override
public String convertToString(EDataType eDataType, Object instanceValue) {
switch (eDataType.getClassifierID()) {
- case CustomptPackage.SHADOW:
- return convertShadowToString(eDataType, instanceValue);
- case CustomptPackage.ALIGNMENT:
- return convertAlignmentToString(eDataType, instanceValue);
- case CustomptPackage.IMAGE:
- return convertImageToString(eDataType, instanceValue);
- case CustomptPackage.COLOR:
- return convertColorToString(eDataType, instanceValue);
- default:
- throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
+ case CustomptPackage.SHADOW:
+ return convertShadowToString(eDataType, instanceValue);
+ case CustomptPackage.ALIGNMENT:
+ return convertAlignmentToString(eDataType, instanceValue);
+ case CustomptPackage.IMAGE:
+ return convertImageToString(eDataType, instanceValue);
+ case CustomptPackage.COLOR:
+ return convertColorToString(eDataType, instanceValue);
+ case CustomptPackage.STYLED_LABEL:
+ return convertStyledLabelToString(eDataType, instanceValue);
+ default:
+ throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public Shadow createShadowFromString(EDataType eDataType, String initialValue) {
Shadow result = Shadow.get(initialValue);
- if (result == null) {
- throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
- }
+ if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
return result;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public String convertShadowToString(EDataType eDataType, Object instanceValue) {
@@ -149,21 +146,17 @@ public class CustomptFactoryImpl extends EFactoryImpl implements CustomptFactory
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public Alignment createAlignmentFromString(EDataType eDataType, String initialValue) {
Alignment result = Alignment.get(initialValue);
- if (result == null) {
- throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
- }
+ if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
return result;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public String convertAlignmentToString(EDataType eDataType, Object instanceValue) {
@@ -173,17 +166,15 @@ public class CustomptFactoryImpl extends EFactoryImpl implements CustomptFactory
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public IImage createImageFromString(EDataType eDataType, String initialValue) {
- return (IImage) super.createFromString(eDataType, initialValue);
+ return (IImage)super.createFromString(eDataType, initialValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public String convertImageToString(EDataType eDataType, Object instanceValue) {
@@ -193,17 +184,15 @@ public class CustomptFactoryImpl extends EFactoryImpl implements CustomptFactory
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public IColor createColorFromString(EDataType eDataType, String initialValue) {
- return (IColor) super.createFromString(eDataType, initialValue);
+ return (IColor)super.createFromString(eDataType, initialValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public String convertColorToString(EDataType eDataType, Object instanceValue) {
@@ -213,17 +202,33 @@ public class CustomptFactoryImpl extends EFactoryImpl implements CustomptFactory
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
+ * @generated
+ */
+ public org.eclipse.jface.viewers.StyledString createStyledLabelFromString(EDataType eDataType, String initialValue) {
+ return (org.eclipse.jface.viewers.StyledString)super.createFromString(eDataType, initialValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String convertStyledLabelToString(EDataType eDataType, Object instanceValue) {
+ return super.convertToString(eDataType, instanceValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
* @generated
*/
public CustomptPackage getCustomptPackage() {
- return (CustomptPackage) getEPackage();
+ return (CustomptPackage)getEPackage();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @deprecated
* @generated
*/
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/impl/CustomptPackageImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/impl/CustomptPackageImpl.java
index 907647fd4dc..00e2865743a 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/impl/CustomptPackageImpl.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/custompt/impl/CustomptPackageImpl.java
@@ -17,6 +17,7 @@ import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.impl.EPackageImpl;
+import org.eclipse.emf.edit.provider.StyledString;
import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IColor;
import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Alignment;
@@ -28,14 +29,12 @@ import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Shadow;
* <!-- begin-user-doc -->
* An implementation of the model <b>Package</b>.
* <!-- end-user-doc -->
- *
* @generated
*/
public class CustomptPackageImpl extends EPackageImpl implements CustomptPackage {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
private EEnum shadowEEnum = null;
@@ -43,7 +42,6 @@ public class CustomptPackageImpl extends EPackageImpl implements CustomptPackage
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
private EEnum alignmentEEnum = null;
@@ -51,7 +49,6 @@ public class CustomptPackageImpl extends EPackageImpl implements CustomptPackage
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
private EDataType imageEDataType = null;
@@ -59,17 +56,26 @@ public class CustomptPackageImpl extends EPackageImpl implements CustomptPackage
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
private EDataType colorEDataType = null;
/**
- * Creates an instance of the model <b>Package</b>, registered with {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EDataType styledLabelEDataType = null;
+
+ /**
+ * Creates an instance of the model <b>Package</b>, registered with
+ * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
* package URI value.
- * <p>
- * Note: the correct way to create the package is via the static factory method {@link #init init()}, which also performs initialization of the package, or returns the registered package, if one already exists. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ * <p>Note: the correct way to create the package is via the static
+ * factory method {@link #init init()}, which also performs
+ * initialization of the package, or returns the registered package,
+ * if one already exists.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @see org.eclipse.emf.ecore.EPackage.Registry
* @see org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.CustomptPackage#eNS_URI
* @see #init()
@@ -82,29 +88,26 @@ public class CustomptPackageImpl extends EPackageImpl implements CustomptPackage
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
private static boolean isInited = false;
/**
* Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
- *
- * <p>
- * This method is used to initialize {@link CustomptPackage#eINSTANCE} when that field is accessed. Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
+ *
+ * <p>This method is used to initialize {@link CustomptPackage#eINSTANCE} when that field is accessed.
+ * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #eNS_URI
* @see #createPackageContents()
* @see #initializePackageContents()
* @generated
*/
public static CustomptPackage init() {
- if (isInited) {
- return (CustomptPackage) EPackage.Registry.INSTANCE.getEPackage(CustomptPackage.eNS_URI);
- }
+ if (isInited) return (CustomptPackage)EPackage.Registry.INSTANCE.getEPackage(CustomptPackage.eNS_URI);
// Obtain or create and register package
- CustomptPackageImpl theCustomptPackage = (CustomptPackageImpl) (EPackage.Registry.INSTANCE.get(eNS_URI) instanceof CustomptPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new CustomptPackageImpl());
+ CustomptPackageImpl theCustomptPackage = (CustomptPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof CustomptPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new CustomptPackageImpl());
isInited = true;
@@ -117,7 +120,7 @@ public class CustomptPackageImpl extends EPackageImpl implements CustomptPackage
// Mark meta-data to indicate it can't be changed
theCustomptPackage.freeze();
-
+
// Update the registry and return the package
EPackage.Registry.INSTANCE.put(CustomptPackage.eNS_URI, theCustomptPackage);
return theCustomptPackage;
@@ -126,7 +129,6 @@ public class CustomptPackageImpl extends EPackageImpl implements CustomptPackage
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public EEnum getShadow() {
@@ -136,7 +138,6 @@ public class CustomptPackageImpl extends EPackageImpl implements CustomptPackage
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public EEnum getAlignment() {
@@ -146,7 +147,6 @@ public class CustomptPackageImpl extends EPackageImpl implements CustomptPackage
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public EDataType getImage() {
@@ -156,7 +156,6 @@ public class CustomptPackageImpl extends EPackageImpl implements CustomptPackage
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public EDataType getColor() {
@@ -166,33 +165,37 @@ public class CustomptPackageImpl extends EPackageImpl implements CustomptPackage
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
+ * @generated
+ */
+ public EDataType getStyledLabel() {
+ return styledLabelEDataType;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
* @generated
*/
public CustomptFactory getCustomptFactory() {
- return (CustomptFactory) getEFactoryInstance();
+ return (CustomptFactory)getEFactoryInstance();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
private boolean isCreated = false;
/**
- * Creates the meta-model objects for the package. This method is
+ * Creates the meta-model objects for the package. This method is
* guarded to have no affect on any invocation but its first.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public void createPackageContents() {
- if (isCreated) {
- return;
- }
+ if (isCreated) return;
isCreated = true;
// Create enums
@@ -202,28 +205,25 @@ public class CustomptPackageImpl extends EPackageImpl implements CustomptPackage
// Create data types
imageEDataType = createEDataType(IMAGE);
colorEDataType = createEDataType(COLOR);
+ styledLabelEDataType = createEDataType(STYLED_LABEL);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
private boolean isInitialized = false;
/**
- * Complete the initialization of the package and its meta-model. This
+ * Complete the initialization of the package and its meta-model. This
* method is guarded to have no affect on any invocation but its first.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- *
* @generated
*/
public void initializePackageContents() {
- if (isInitialized) {
- return;
- }
+ if (isInitialized) return;
isInitialized = true;
// Initialize package
@@ -245,6 +245,7 @@ public class CustomptPackageImpl extends EPackageImpl implements CustomptPackage
// Initialize data types
initEDataType(imageEDataType, IImage.class, "Image", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
initEDataType(colorEDataType, IColor.class, "Color", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
+ initEDataType(styledLabelEDataType, org.eclipse.jface.viewers.StyledString.class, "StyledLabel", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
// Create resource
createResource(eNS_URI);
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedLabelProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedLabelProvider.java
index dc309d9c2f8..e2ce6216ce7 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedLabelProvider.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedLabelProvider.java
@@ -11,13 +11,16 @@
* Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
* Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
* Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - implementation of IStyledLabelProvider
*/
package org.eclipse.papyrus.emf.facet.custom.ui;
import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
import org.eclipse.swt.graphics.Image;
@@ -30,7 +33,7 @@ import org.eclipse.swt.graphics.Image;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICustomizedLabelProvider extends ILabelProvider,
- IColorProvider, IFontProvider, ICustomizedToolTipLabelProvider {
+ IColorProvider, IFontProvider, ICustomizedToolTipLabelProvider, IStyledLabelProvider {
/**
* This method returns the customization manager used by the label provider. The
* customization stack updates have to be done using this {@link ICustomizationManager}.
@@ -64,4 +67,25 @@ public interface ICustomizedLabelProvider extends ILabelProvider,
*/
ICustomizedLabelProvider cloneLabelProvider();
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
+ *
+ * @since 1.3
+ */
+ @Override
+ default StyledString getStyledText(final Object element) {
+ return new StyledString(getText(element));
+ }
+
+ /**
+ * Returns the styled text label for the given element.
+ *
+ * @since 1.3
+ */
+ default StyledString getStyledText(final Object element, final ETypedElement eTypedElement) {
+ return new StyledString(getText(element, eTypedElement));
+ }
+
}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedLabelProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedLabelProvider.java
index dbd3499764f..aa319689a6c 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedLabelProvider.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedLabelProvider.java
@@ -16,13 +16,14 @@
* Gregoire Dupe (Mia-Software) - Bug 374941 - To be able to customize overlay icons on EClass
* Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
* Vincent Lorenzo (CEA-LIST) - Bug 352603 - [Table] A tooltip which displays the full label of a String cell editor
- * Grégoire Dupé(Mia-Software) - Bug 352603 - [Table] A tooltip which displays the full label of a String cell editor
+ * Gr�goire Dup�(Mia-Software) - Bug 352603 - [Table] A tooltip which displays the full label of a String cell editor
* David Couvrand (Soft-Maint) - Bug 402725 - Need a query to get an image from an URI
* Nicolas Rault (Soft-Maint) - Bug 402725 - Need a query to get an image from an URI
* David Couvrand (Soft-Maint) - Bug 418418 - [Customization] Overlay icons not implemented
* David Couvrand (Soft-Maint) - Bug 422058 - Implementation of strikethrough and underline in the CustomizedLabelProvider
- * Grégoire Dupé (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table
+ * Gr�goire Dup� (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table
* Thomas Cicognani (Soft-Maint) - Bug 424414 - ImageManager doesn't cache images
+ * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - implementation of IStyledLabelProvider
*/
package org.eclipse.papyrus.emf.facet.custom.ui.internal;
@@ -105,8 +106,8 @@ public class CustomizedLabelProvider extends CellLabelProvider implements
public String getText(final Object element) {
String result;
if (element instanceof EObject) {
- result = getPropertyValue(element,
- this.propertiesHandler.getLabelProperty(), null, String.class);
+ result = getPropertyValue(element, this.propertiesHandler.getLabelProperty(), null, String.class);
+
} else if (element == null) {
result = Messages.CustomizedLabelProvider_null;
} else if (element instanceof List<?>) {
@@ -139,6 +140,27 @@ public class CustomizedLabelProvider extends CellLabelProvider implements
return result;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider#getStyledText(java.lang.Object)
+ */
+ @Override
+ public StyledString getStyledText(final Object element) {
+ Object result = null;
+ if (element instanceof EObject) {
+ result = getPropertyValue(element,
+ this.propertiesHandler.getLabelProperty(), null, StyledString.class);
+ if (result instanceof String) {
+ result = new StyledString((String) result);
+ }
+ } else {
+ result = new StyledString(getText(element));
+ }
+
+ return (StyledString) result;
+ }
+
private static ICustomOverride getICustomOverride() {
final Bundle bundle = Activator.getDefault().getBundle();
final BundleContext bundleContext = bundle.getBundleContext();
@@ -150,17 +172,22 @@ public class CustomizedLabelProvider extends CellLabelProvider implements
}
public String getText(final Object object, final ETypedElement eTypedElement) {
- String result;
+ String result = null;
if (object == null) {
result = Messages.CustomizedLabelProvider_null;
} else {
if (object instanceof EObject) {
final EObject eObject = (EObject) object;
try {
- result = this.customManager.getCustomValueOf(eObject,
+ Object objectResult = this.customManager.getCustomValueOf(eObject,
eTypedElement,
this.propertiesHandler.getLabelProperty(),
- String.class);
+ Object.class);
+ if (objectResult instanceof StyledString) {
+ result = objectResult.toString();
+ } else if (objectResult instanceof String) {
+ result = (String) objectResult;
+ }
} catch (CustomizationException e) {
Logger.logError(e, Activator.getDefault());
result = "!!! Error, cf log !!!";
@@ -171,27 +198,36 @@ public class CustomizedLabelProvider extends CellLabelProvider implements
}
return result;
+ }
- // TODO Remove before to commit
- // if (structuralFeature.getUpperBound() == 1) {
- // final Object object = this.customManager.getFacetManager().get(eObject,
- // structuralFeature, Object.class);
- // result = getText(object);
- // } else {
- // final StringBuffer stringBuffer = new StringBuffer();
- // final List<Object> objects = this.customManager.getFacetManager()
- // .getMultiValued(eObject, structuralFeature, Object.class);
- // final Iterator<Object> objectsIter = objects.iterator();
- // while (objectsIter.hasNext()) {
- // final Object object = objectsIter.next();
- // stringBuffer.append(this.getText(object));
- // if (objectsIter.hasNext()) {
- // stringBuffer.append(", ");
- // }
- // }
- // result = stringBuffer.toString();
- // }
- // TODO (end)
+ @Override
+ public StyledString getStyledText(final Object object, final ETypedElement eTypedElement) {
+ StyledString result = null;
+ if (object == null) {
+ result = new StyledString(Messages.CustomizedLabelProvider_null);
+ } else {
+ if (object instanceof EObject) {
+ final EObject eObject = (EObject) object;
+ try {
+ Object objectResult = this.customManager.getCustomValueOf(eObject,
+ eTypedElement,
+ this.propertiesHandler.getLabelProperty(),
+ Object.class);
+ if (objectResult instanceof StyledString) {
+ result = (StyledString) objectResult;
+ } else if (objectResult instanceof String) {
+ result = new StyledString((String) objectResult);
+ }
+ } catch (CustomizationException e) {
+ Logger.logError(e, Activator.getDefault());
+ result = new StyledString("!!! Error, cf log !!!");
+ }
+ } else {
+ result = new StyledString(object.toString());
+ }
+
+ }
+ return result;
}
@Override
@@ -587,8 +623,4 @@ public class CustomizedLabelProvider extends CellLabelProvider implements
return new CustomizedLabelProvider(this.customManager);
}
- public StyledString getStyledText(final Object element) {
- return new StyledString(getText(element));
- }
-
}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/DecoratingCustomizedLabelProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/DecoratingCustomizedLabelProvider.java
index c339a77c462..b16b59b9798 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/DecoratingCustomizedLabelProvider.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/DecoratingCustomizedLabelProvider.java
@@ -7,6 +7,7 @@
*
* Contributors:
* David Couvrand (Soft-Maint) - Bug 418418 - [Customization] Overlay icons not implemented
+ * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - implementation of getStyledText
*******************************************************************************/
package org.eclipse.papyrus.emf.facet.custom.ui.internal;
@@ -14,6 +15,7 @@ import org.eclipse.emf.ecore.ETypedElement;
import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider;
import org.eclipse.jface.viewers.IDecorationContext;
import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider;
import org.eclipse.swt.graphics.Color;
@@ -32,6 +34,26 @@ public class DecoratingCustomizedLabelProvider extends
super(labelProvider, decorator, decorationContext);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider#getStyledText(java.lang.Object)
+ */
+ @Override
+ public StyledString getStyledText(final Object element) {
+ return this.lblProvider.getStyledText(element);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider#getStyledText(java.lang.Object, org.eclipse.emf.ecore.ETypedElement)
+ */
+ @Override
+ public StyledString getStyledText(final Object element, final ETypedElement eTypedElement) {
+ return this.lblProvider.getStyledText(element, eTypedElement);
+ }
+
public DecoratingCustomizedLabelProvider(
final ICustomizationManager customizationMgr) {
this(new CustomizedLabelProvider(customizationMgr),
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/ResolvingCustomizedLabelProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/ResolvingCustomizedLabelProvider.java
index a4ad09bdbd9..759b7670c68 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/ResolvingCustomizedLabelProvider.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/ResolvingCustomizedLabelProvider.java
@@ -7,11 +7,14 @@
*
* Contributors:
* Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider
+ * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - implementation of getStyledText
+ *
*******************************************************************************/
package org.eclipse.papyrus.emf.facet.custom.ui.internal;
import org.eclipse.emf.ecore.ETypedElement;
import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EAttributeTreeElement;
@@ -66,6 +69,32 @@ public class ResolvingCustomizedLabelProvider implements ICustomizedLabelProvide
return result;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider#getStyledText(java.lang.Object)
+ */
+ @Override
+ public StyledString getStyledText(final Object element) {
+ StyledString result;
+ if (delegate instanceof ICustomizedLabelProvider) {
+ if (element instanceof EReferenceTreeElement) {
+ final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
+ final EObjectTreeElement parent = treeElement.getParent();
+ result = this.delegate.getStyledText(parent.getEObject(), treeElement.getEReference());
+ } else if (element instanceof EAttributeTreeElement) {
+ final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
+ final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
+ result = this.delegate.getStyledText(parent.getEObject(), treeElement.getEAttribute());
+ } else {
+ result = this.delegate.getStyledText(CustomizedContentProviderUtils.resolve(element));
+ }
+ } else {
+ result = new StyledString(getText(element));
+ }
+ return result;
+ }
+
public void addListener(final ILabelProviderListener listener) {
this.delegate.addListener(listener);
}
@@ -489,4 +518,5 @@ public class ResolvingCustomizedLabelProvider implements ICustomizedLabelProvide
public ICustomizedLabelProvider cloneLabelProvider() {
return new ResolvingCustomizedLabelProvider(this.delegate.cloneLabelProvider());
}
+
}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.query.java.sdk.ui/META-INF/MANIFEST.MF b/plugins/facet/org.eclipse.papyrus.emf.facet.query.java.sdk.ui/META-INF/MANIFEST.MF
index feac1c9e029..71f84730317 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.query.java.sdk.ui/META-INF/MANIFEST.MF
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.query.java.sdk.ui/META-INF/MANIFEST.MF
@@ -7,7 +7,7 @@ Require-Bundle: org.eclipse.papyrus.emf.facet.efacet.sdk.ui;bundle-version="[1.2
org.eclipse.jdt.core;bundle-version="[3.12.0,4.0.0)",
org.eclipse.emf.codegen.ecore;bundle-version="[2.12.0,3.0.0)",
org.eclipse.jdt.ui;bundle-version="[3.12.0,4.0.0)",
- org.eclipse.papyrus.emf.facet.custom.metamodel;bundle-version="[1.2.0,2.0.0)",
+ org.eclipse.papyrus.emf.facet.custom.metamodel;bundle-version="[1.3.0,2.0.0)",
org.eclipse.papyrus.emf.facet.util.pde.core;bundle-version="[1.2.0,2.0.0)"
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF
index 157431fc326..829b9e13a9a 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF
@@ -12,7 +12,7 @@ Require-Bundle: org.eclipse.papyrus.infra.nattable.model;bundle-version="[2.0.0,
org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)",
org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="[1.2.0,2.0.0)",
org.eclipse.papyrus.emf.facet.query.java.core;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
- org.eclipse.papyrus.emf.facet.custom.metamodel;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.emf.facet.custom.metamodel;bundle-version="[1.3.0,2.0.0)";visibility:=reexport,
org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="[2.0.0,3.0.0)",
org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)",
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.labelprovider/src/org/eclipse/papyrus/infra/services/labelprovider/service/ExtensibleLabelProvider.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.labelprovider/src/org/eclipse/papyrus/infra/services/labelprovider/service/ExtensibleLabelProvider.java
index 561402e95ee..673412d45d0 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.labelprovider/src/org/eclipse/papyrus/infra/services/labelprovider/service/ExtensibleLabelProvider.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.labelprovider/src/org/eclipse/papyrus/infra/services/labelprovider/service/ExtensibleLabelProvider.java
@@ -9,6 +9,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - Workspace-independent model validation view (CDO)
+ * Mickael ADAM (ALL4TEC) - Bug 500219 - implementation of IStyledLabelProvider
*****************************************************************************/
package org.eclipse.papyrus.infra.services.labelprovider.service;
@@ -19,12 +20,14 @@ import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
@@ -38,7 +41,7 @@ import org.eclipse.swt.graphics.Image;
* @author Camille Letavernier
*
*/
-public class ExtensibleLabelProvider implements ILabelProvider, IQualifierLabelProvider, ILabelProviderListener, IColorProvider, IFontProvider {
+public class ExtensibleLabelProvider implements ILabelProvider, IQualifierLabelProvider, ILabelProviderListener, IColorProvider, IFontProvider, IStyledLabelProvider {
private final Set<ILabelProviderListener> listeners;
@@ -188,4 +191,23 @@ public class ExtensibleLabelProvider implements ILabelProvider, IQualifierLabelP
listener.labelProviderChanged(event);
}
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
+ */
+ @Override
+ public StyledString getStyledText(final Object element) {
+ StyledString text = null;
+
+ ILabelProvider provider = getProvider(element);
+ if (provider instanceof IStyledLabelProvider) {
+ text = ((IStyledLabelProvider) provider).getStyledText(element);
+ } else {
+ text = new StyledString(provider.getText(element));
+ }
+
+ return text;
+ }
}
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/META-INF/MANIFEST.MF b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/META-INF/MANIFEST.MF
index 4362a5b50ac..560da3aefa8 100644
--- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/META-INF/MANIFEST.MF
+++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/META-INF/MANIFEST.MF
@@ -2,6 +2,7 @@ Manifest-Version: 1.0
Export-Package: org.eclipse.papyrus.uml.modelexplorer,
org.eclipse.papyrus.uml.modelexplorer.factory,
org.eclipse.papyrus.uml.modelexplorer.handler,
+ org.eclipse.papyrus.uml.modelexplorer.preferences,
org.eclipse.papyrus.uml.modelexplorer.queries,
org.eclipse.papyrus.uml.modelexplorer.util
Require-Bundle: org.eclipse.papyrus.views.modelexplorer;bundle-version="[3.0.0,4.0.0)",
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/icons/labelCustom.gif b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/icons/labelCustom.gif
new file mode 100644
index 00000000000..e582c628993
--- /dev/null
+++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/icons/labelCustom.gif
Binary files differ
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/plugin.xml b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/plugin.xml
index c2cbad6bc60..bbbcaa7f0b3 100644
--- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/plugin.xml
+++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/plugin.xml
@@ -92,6 +92,23 @@
style="toggle">
</command>
</menuContribution>
+ <menuContribution
+ allPopups="false"
+ locationURI="menu:org.eclipse.papyrus.views.modelexplorer.modelexplorer">
+ <command
+ commandId="org.eclipse.papyrus.uml.modelexplorer.customization.customizeUMLLabel"
+ icon="icons/labelCustom.gif"
+ label="Customize UML Label..."
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <test
+ property="org.eclipse.papyrus.uml.modelexplorer.testUMLLabelCustomized.isUMLLabelCustomizable"
+ value="true">
+ </test>
+ </visibleWhen>
+ </command>
+ </menuContribution>
</extension>
<!-- This declaration is added in order command (DeleteCommandHandler) status to be
@@ -2339,6 +2356,11 @@
id="org.eclipse.ui.commands.toggleState">
</state>
</command>
+ <command
+ description="Customize the UML Label in Model Explorer"
+ id="org.eclipse.papyrus.uml.modelexplorer.customization.customizeUMLLabel"
+ name="Customize UML Label">
+ </command>
</extension>
<extension
point="org.eclipse.papyrus.emf.facet.util.emf.core.modeldeclaration">
@@ -2438,6 +2460,13 @@
</activeWhen>
</handler>
</extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.papyrus.uml.modelexplorer.handler.CustomizeUMLLabelHandler"
+ commandId="org.eclipse.papyrus.uml.modelexplorer.customization.customizeUMLLabel">
+ </handler>
+ </extension>
<extension
point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
@@ -2447,6 +2476,13 @@
properties="isNameChangeable"
type="org.eclipse.jface.viewers.IStructuredSelection">
</propertyTester>
+ <propertyTester
+ class="org.eclipse.papyrus.uml.modelexplorer.handler.UMLLabelCustomizableTester"
+ id="org.eclipse.papyrus.uml.modelexplorer.testUMLLabelCustomized"
+ namespace="org.eclipse.papyrus.uml.modelexplorer.testUMLLabelCustomized"
+ properties="isUMLLabelCustomizable"
+ type="java.lang.Object">
+ </propertyTester>
</extension>
<extension
point="org.eclipse.papyrus.extensionpoints.editors.DirectEditor">
@@ -2463,4 +2499,16 @@
</Priority>
</DirectEditor>
</extension>
+ <extension
+ point="org.eclipse.papyrus.emf.facet.util.emf.core.modeldeclaration">
+ <modeldeclaration
+ file="resource/CustomizableUMLLabel.custom">
+ </modeldeclaration>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.papyrus.uml.modelexplorer.preferences.CustomizableLabelPreferenceInitializer">
+ </initializer>
+ </extension>
</plugin>
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
new file mode 100644
index 00000000000..8684524ff3f
--- /dev/null
+++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/resource/CustomizableUMLLabel.custom
@@ -0,0 +1,15 @@
+<?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">
+ <eClassifiers xsi:type="custom:EClassCustomization" name="Element">
+ <extendedMetaclass href="http://www.eclipse.org/uml2/5.0.0/UML#//NamedElement"/>
+ <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">
+ <eType xsi:type="ecore:EClass" href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ </eParameters>
+ <query xsi:type="javaQuery:JavaQuery" implementationClassName="org.eclipse.papyrus.uml.modelexplorer.queries.GetComplexStyledName"/>
+ <override xsi:type="efacet:FacetOperation" href="../../../plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject/label"/>
+ </facetOperations>
+ <extendedFacets href="../../../plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject"/>
+ </eClassifiers>
+</custom:Customization>
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/dialogs/CustomizeUMLLabelDialog.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/dialogs/CustomizeUMLLabelDialog.java
new file mode 100644
index 00000000000..19d56dbaf16
--- /dev/null
+++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/dialogs/CustomizeUMLLabelDialog.java
@@ -0,0 +1,613 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST.
+ *
+ * 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:
+ * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.modelexplorer.dialogs;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.ComboBoxViewerCellEditor;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.papyrus.uml.modelexplorer.Activator;
+import org.eclipse.papyrus.uml.modelexplorer.messages.Messages;
+import org.eclipse.papyrus.uml.modelexplorer.preferences.CustomizableLabelPreferences;
+import org.eclipse.papyrus.uml.tools.profile.definition.LabelStylersEnum;
+import org.eclipse.papyrus.uml.tools.profile.definition.LabelTypesEnum;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.dialogs.SelectionDialog;
+
+/**
+ * A dialog to customize UML Label of model explorer.
+ *
+ */
+public final class CustomizeUMLLabelDialog extends SelectionDialog implements SelectionListener {
+
+ /** The Predefined customization "Name and Stereotype". */
+ private static final String CUSTO_NAME_STEREOTYPE = "Name and Stereotype";//$NON-NLS-1$
+
+ /** The Predefined customization "Stereotype, Metaclass and Name". */
+ private static final String CUSTO_STEREOTYPE_METACLASS_NAME = "Stereotype, Metaclass and Name";//$NON-NLS-1$
+
+ /** The Predefined customization "Name". */
+ protected static final String CUSTO_NAME = "Name";//$NON-NLS-1$
+
+ /** The Predefined customization "Customized". */
+ protected static final String CUSTO_CUSTOM = "Customized";//$NON-NLS-1$
+
+ /** The table viewer for entries. */
+ protected TableViewer tableViewer;
+
+ /** The Add control. */
+ protected Button add;
+
+ /** The Remove control. */
+ protected Button remove;
+
+ /** The Up control. */
+ protected Button up;
+
+ /** The Down control. */
+ protected Button down;
+
+ /** A Composite containing the different control buttons (Add, remove, ...). */
+ protected Composite controlsSection;
+
+ protected List<String> predefinedCustoList = new ArrayList<String>() {
+ {
+ add(CUSTO_CUSTOM);
+ add(CUSTO_NAME);
+ add(CUSTO_STEREOTYPE_METACLASS_NAME);
+ add(CUSTO_NAME_STEREOTYPE);
+ }
+ };
+
+ protected ComboViewer predefinedCustoViewer;
+
+ /**
+ * Constructor.
+ */
+ public CustomizeUMLLabelDialog(final Shell parentShell) {
+ super(parentShell);
+ setTitle(Messages.CustomizeUMLLabelDialog_Title);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(final Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+
+ // Create the label
+ Label label = new Label(composite, SWT.NONE);
+ label.setText(Messages.CustomizeUMLLabelDialog_dialogLabel);
+
+ // Create the control section containing buttons
+ createStylesTablePart(composite);
+
+ // Create buttons
+ createListControls();
+
+ // Create Predefined customization composite
+ createLoadPredefinedCustoPart(composite);
+
+
+ // Update buttons
+ updateControls();
+
+ return composite;
+ }
+
+ /**
+ * Create the control section containing buttons.
+ */
+ protected void createStylesTablePart(final Composite composite) {
+ // Create the control section containing buttons
+ controlsSection = new Composite(composite, SWT.NONE);
+ controlsSection.setLayout(new FillLayout());
+ controlsSection.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
+
+ // Create the table viewer
+ tableViewer = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL
+ | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+ tableViewer.setContentProvider(ArrayContentProvider.getInstance());
+
+ // Setthe table
+ Table table = tableViewer.getTable();
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ // Create columns
+ createColumns(tableViewer);
+
+ // Set the input
+ tableViewer.setInput(getEntriesFromPreferences());
+
+ // define layout for the viewer
+ GridData gridData = new GridData();
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.horizontalSpan = 2;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.heightHint = 150;
+ tableViewer.getControl().setLayoutData(gridData);
+
+ // Add listener on table viewer
+ tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ updateControls();
+ }
+ });
+ }
+
+ /**
+ * Create Predefined customization composite.
+ */
+ protected void createLoadPredefinedCustoPart(final Composite composite) {
+ Composite predifineComposite = new Composite(composite, SWT.NONE);
+ predifineComposite.setLayout(new FillLayout());
+ predifineComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1));
+
+ Label labelSelectStyle = new Label(predifineComposite, SWT.NONE);
+ labelSelectStyle.setText(Messages.CustomizeUMLLabelDialog_ComboCustomizationLabel);
+
+ predefinedCustoViewer = new ComboViewer(predifineComposite, SWT.NONE);
+ predefinedCustoViewer.setContentProvider(ArrayContentProvider.getInstance());
+ predefinedCustoViewer.setLabelProvider(new LabelProvider());
+ predefinedCustoViewer.setInput(predefinedCustoList);
+ predefinedCustoViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ updateTable(event);
+ }
+ });
+ predefinedCustoViewer.setSelection(new StructuredSelection(CUSTO_CUSTOM), true);
+ }
+
+ /**
+ * update the Table when select a new predefined customization.
+ */
+ protected void updateTable(final SelectionChangedEvent event) {
+ if (null != event) {
+ String selection = (String) ((StructuredSelection) event.getSelection()).getFirstElement();
+ List<String[]> newInput = new ArrayList<String[]>();
+ switch (selection) {
+ case CUSTO_NAME:
+ newInput.add(new String[] { LabelTypesEnum.LABEL.getLiteral(), LabelStylersEnum.DEFAULT.getLiteral() });
+ break;
+ case CUSTO_STEREOTYPE_METACLASS_NAME:
+ newInput.add(new String[] { LabelTypesEnum.STEREOTYPE.getLiteral(), LabelStylersEnum.DEFAULT.getLiteral() });
+ newInput.add(new String[] { LabelTypesEnum.METACLASS.getLiteral(), LabelStylersEnum.DEFAULT.getLiteral() });
+ newInput.add(new String[] { LabelTypesEnum.LABEL.getLiteral(), LabelStylersEnum.DEFAULT.getLiteral() });
+ break;
+ case CUSTO_NAME_STEREOTYPE:
+ newInput.add(new String[] { LabelTypesEnum.LABEL.getLiteral(), LabelStylersEnum.DEFAULT.getLiteral() });
+ newInput.add(new String[] { LabelTypesEnum.DASH_SEPARATOR.getLiteral(), LabelStylersEnum.GREY.getLiteral() });
+ newInput.add(new String[] { LabelTypesEnum.STEREOTYPE.getLiteral(), LabelStylersEnum.GREY.getLiteral() });
+ break;
+ case CUSTO_CUSTOM:
+ break;
+ default:
+ break;
+ }
+ if (!newInput.isEmpty()) {
+ tableViewer.setInput(newInput);
+ tableViewer.refresh();
+ }
+ }
+
+ }
+
+ /**
+ * Creates the Add/Remove controls,
+ * and the Up/Down controls
+ */
+ protected void createListControls() {
+ up = createButton(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("/icons/Up_12x12.gif"), Messages.CustomizeUMLLabelDialog_upButtonTooltip); //$NON-NLS-1$
+ down = createButton(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("/icons/Down_12x12.gif"), Messages.CustomizeUMLLabelDialog_downButtonTooltip); //$NON-NLS-1$
+ add = createButton(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("/icons/Add_12x12.gif"), Messages.CustomizeUMLLabelDialog_createButtonTooltip); //$NON-NLS-1$
+ remove = createButton(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("/icons/Delete_12x12.gif"), Messages.CustomizeUMLLabelDialog_deleteButtonTooltip); //$NON-NLS-1$
+ }
+
+ /**
+ * Create the button on the control setction.
+ *
+ * @param image
+ * The image of the button.
+ * @param toolTipText
+ * The tooltipText.
+ * @return the created button.
+ */
+ protected Button createButton(Image image, String toolTipText) {
+ Button button = new Button(controlsSection, SWT.PUSH);
+ button.setImage(image);
+ button.addSelectionListener(this);
+ button.setToolTipText(toolTipText);
+ return button;
+ }
+
+ /**
+ * @return the List of type/style entries from preference as a List<String[2]> where each string[2] contains {type,style}.
+ */
+ protected List<String[]> getEntriesFromPreferences() {
+
+ String[] types = Activator.getDefault().getPreferenceStore().getString(CustomizableLabelPreferences.CUSTOMIZED_TYPES).split(" ");//$NON-NLS-1$
+ String[] styles = Activator.getDefault().getPreferenceStore().getString(CustomizableLabelPreferences.CUSTOMIZED_STYLES).split(" ");//$NON-NLS-1$
+
+ List<String[]> entries = new ArrayList<String[]>();
+
+ for (int i = 0; i < types.length; i++) {
+ String type = types[i];
+ String style;
+ if (i < styles.length) {
+ style = styles[i];
+ } else {
+ style = LabelStylersEnum.BLACK.getLiteral();
+ }
+ String[] entry = new String[] { type, style };
+
+ entries.add(entry);
+ }
+
+ return entries;
+ }
+
+ /**
+ * create columns types and styles for the viewer.
+ */
+ protected void createColumns(final TableViewer viewer) {
+
+ // Create the types column
+ TableViewerColumn colTypes = new TableViewerColumn(viewer, SWT.NONE);
+ colTypes.getColumn().setWidth(200);
+ colTypes.getColumn().setText(Messages.CustomizeUMLLabelDialog_typesColumnTitle);
+
+ colTypes.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ String text;
+ if (element instanceof String[]) {
+ String[] entry = (String[]) element;
+ text = entry[0];
+ } else {
+ text = element.toString();
+ }
+ return text;
+ }
+ });
+ colTypes.setEditingSupport(new ArrayStringWithComboEditingSupport(tableViewer, 0, LabelTypesEnum.values()));
+
+ // Create the styles column
+ TableViewerColumn colStyles = new TableViewerColumn(viewer, SWT.NONE);
+ colStyles.getColumn().setWidth(200);
+ colStyles.getColumn().setText(Messages.CustomizeUMLLabelDialog_stylesColumnTitle);
+
+ colStyles.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ String text;
+ if (element instanceof String[]) {
+ String[] entry = (String[]) element;
+ text = entry[1];
+ } else {
+ text = element.toString();
+ }
+ return text;
+ }
+ });
+ colStyles.setEditingSupport(new ArrayStringWithComboEditingSupport(tableViewer, 1, LabelStylersEnum.values()));
+ }
+
+ /**
+ * The Class The support edit with with combo and with inputs elements as String[].
+ */
+ private class ArrayStringWithComboEditingSupport extends EditingSupport {
+
+ /** The index on the String[]. */
+ private int index;
+
+ /** the input for the comboBox. */
+ private Object comboInput;
+
+ /**
+ * Constructor.
+ *
+ * @param viewer
+ * The viewer.
+ * @param index
+ * The index on the String[].
+ * @param comboInput
+ * the input for the comboBox.
+ */
+ public ArrayStringWithComboEditingSupport(final ColumnViewer viewer, final int index, final Object comboInput) {
+ super(viewer);
+ this.index = index;
+ this.comboInput = comboInput;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.EditingSupport#getCellEditor(java.lang.Object)
+ */
+ @Override
+ protected CellEditor getCellEditor(final Object element) {
+ ComboBoxViewerCellEditor cellEditor = new ComboBoxViewerCellEditor(tableViewer.getTable());
+ cellEditor.setContentProvider(new ArrayContentProvider());
+ cellEditor.setLabelProvider(new LabelProvider());
+ cellEditor.setInput(comboInput);
+
+ return cellEditor;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.EditingSupport#canEdit(java.lang.Object)
+ */
+ @Override
+ protected boolean canEdit(final Object element) {
+ boolean canEdit = false;
+ if (element instanceof String[] && index < ((String[]) element).length) {
+ canEdit = true;
+
+ }
+ return canEdit;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.EditingSupport#getValue(java.lang.Object)
+ */
+ @Override
+ protected Object getValue(final Object element) {
+ String text;
+ if (element instanceof String[] && index < ((String[]) element).length) {
+ String[] entry = (String[]) element;
+ text = entry[index];
+ } else {
+ text = element.toString();
+ }
+ return text;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.EditingSupport#setValue(java.lang.Object, java.lang.Object)
+ */
+ @Override
+ protected void setValue(final Object element, final Object value) {
+ if (null != value && element instanceof String[] && index < ((String[]) element).length) {
+ String[] entry = (String[]) element;
+ entry[index] = value.toString();
+ tableViewer.update(element, null);
+ }
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+
+ Map<String, String> map = getLabelStylesMap();
+ setResult(Collections.singletonList(map));
+
+ super.okPressed();
+ }
+
+ /**
+ * @return the map to be return to be set in preferences.
+ */
+ protected Map<String, String> getLabelStylesMap() {
+ // Construct the map to be return to be set in preferences.
+ StringBuilder types = new StringBuilder();
+ StringBuilder styles = new StringBuilder();
+
+ if (tableViewer.getInput() instanceof List) {
+ @SuppressWarnings("unchecked")
+ List<String[]> entries = (List<String[]>) tableViewer.getInput();
+
+ for (int i = 0; i < entries.size(); i++) {
+ String[] entry = entries.get(i);
+ types.append(entry[0]);
+ styles.append(entry[1]);
+ if (i < entries.size() - 1) {
+ types.append(" ");//$NON-NLS-1$
+ styles.append(" ");//$NON-NLS-1$
+ }
+ }
+ }
+
+ Map<String, String> map = new HashMap<String, String>();
+ map.put(CustomizableLabelPreferences.CUSTOMIZED_TYPES, types.toString());
+ map.put(CustomizableLabelPreferences.CUSTOMIZED_STYLES, styles.toString());
+ return map;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected(final SelectionEvent event) {
+ if (event.widget != null) {
+ if (event.widget == add) {
+ addAction();
+ } else if (event.widget == remove) {
+ removeAction();
+ } else if (event.widget == up) {
+ upAction();
+ } else if (event.widget == down) {
+ downAction();
+ }
+ updateControls();
+ tableViewer.refresh();
+ predefinedCustoViewer.setSelection(new StructuredSelection(CUSTO_CUSTOM), true);
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetDefaultSelected(final SelectionEvent e) {
+ // Do nothing
+ }
+
+ /**
+ * @return the first selected element of the table viewer.
+ */
+ protected Object getSelection() {
+ return ((IStructuredSelection) tableViewer.getStructuredSelection()).getFirstElement();
+ }
+
+ /**
+ * update controls(buttons...)
+ */
+ protected void updateControls() {
+ Object selection = getSelection();
+ remove.setEnabled(null != selection);
+ down.setEnabled(null != selection && !isSelectionLast());
+ up.setEnabled(null != selection && !isSelectionFirst());
+ }
+
+ /**
+ * Down the selected element.
+ */
+ protected void downAction() {
+ Object selection = getSelection();
+ if (null != selection && !isSelectionLast()) {
+ Object input = tableViewer.getInput();
+ if (input instanceof List) {
+ int index = ((List) input).indexOf(selection);
+ ((List) input).remove(selection);
+ ((List) input).add(index + 1, selection);
+ }
+ }
+ }
+
+ /**
+ * Up the selected Element.
+ */
+ protected void upAction() {
+ Object selection = getSelection();
+ if (null != selection && !isSelectionFirst()) {
+ Object input = tableViewer.getInput();
+ if (input instanceof List) {
+ int index = ((List) input).indexOf(selection);
+ ((List) input).remove(selection);
+ ((List) input).add(index - 1, selection);
+ }
+ }
+ }
+
+ /**
+ * Remove the selected Element
+ */
+ protected void removeAction() {
+ List<?> selections = tableViewer.getStructuredSelection().toList();
+
+ for (Object selection : selections) {
+ Object input = tableViewer.getInput();
+ if (input instanceof List) {
+ ((List) input).remove(selection);
+ }
+ }
+ }
+
+ /**
+ * Add a new entry at the end of the list.
+ */
+ protected void addAction() {
+ Object input = tableViewer.getInput();
+ if (input instanceof List) {
+ String[] newEntry = new String[2];
+
+ newEntry[0] = LabelTypesEnum.LABEL.getLiteral();
+ newEntry[1] = LabelStylersEnum.BLACK.getLiteral();
+
+ ((List<String[]>) input).add(newEntry);
+ tableViewer.refresh();
+ tableViewer.setSelection(new StructuredSelection(newEntry));
+ tableViewer.refresh();
+ }
+ }
+
+ /**
+ * @return true if the selection is the last element of the list.
+ */
+ protected boolean isSelectionLast() {
+ boolean isLast = false;
+ Object selection = getSelection();
+ Object input = tableViewer.getInput();
+ if (input instanceof List) {
+ isLast = ((List<?>) input).indexOf(selection) == ((List<?>) input).size() - 1;
+ }
+ return isLast;
+ }
+
+ /**
+ * @return true if the selection is the first element of the list.
+ */
+ protected boolean isSelectionFirst() {
+ boolean isLast = false;
+ Object selection = getSelection();
+ Object input = tableViewer.getInput();
+ if (input instanceof List) {
+ isLast = ((List<?>) input).indexOf(selection) == 0;
+ }
+ return isLast;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/CustomizeUMLLabelHandler.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/CustomizeUMLLabelHandler.java
new file mode 100644
index 00000000000..9b1a63d1fec
--- /dev/null
+++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/CustomizeUMLLabelHandler.java
@@ -0,0 +1,73 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST.
+ *
+ * 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:
+ * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.modelexplorer.handler;
+
+import java.util.Map;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.uml.modelexplorer.Activator;
+import org.eclipse.papyrus.uml.modelexplorer.dialogs.CustomizeUMLLabelDialog;
+import org.eclipse.papyrus.uml.modelexplorer.preferences.CustomizableLabelPreferences;
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.navigator.CommonNavigator;
+
+
+/**
+ * Than handler to display dialog to customize UML Label.
+ */
+public class CustomizeUMLLabelHandler extends AbstractHandler {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(final ExecutionEvent event) throws ExecutionException {
+
+ // Create the dialog
+ CustomizeUMLLabelDialog dialog = new CustomizeUMLLabelDialog(Display.getDefault().getActiveShell());
+
+ // open it
+ int code = dialog.open();
+ if (Window.OK == code) {
+ Object[] result = dialog.getResult();
+ if (0 < result.length && result[0] instanceof Map) {
+ Map map = (Map<String, String>) result[0];
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ store.setValue(CustomizableLabelPreferences.CUSTOMIZED_TYPES, map.get(CustomizableLabelPreferences.CUSTOMIZED_TYPES).toString());
+ store.setValue(CustomizableLabelPreferences.CUSTOMIZED_STYLES, map.get(CustomizableLabelPreferences.CUSTOMIZED_STYLES).toString());
+ }
+
+ // Refresh model explorer view
+ IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
+ if (activePart instanceof ModelExplorerPageBookView) {
+ IViewPart page = ((ModelExplorerPageBookView) activePart).getActiveView();
+ if (page instanceof CommonNavigator) {
+ ((CommonNavigator) page).getCommonViewer().refresh();
+ }
+ }
+
+ }
+ return null;
+ }
+
+
+}
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/UMLLabelCustomizableTester.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/UMLLabelCustomizableTester.java
new file mode 100644
index 00000000000..656d27514f6
--- /dev/null
+++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/UMLLabelCustomizableTester.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST.
+ *
+ * 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:
+ * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.modelexplorer.handler;
+
+import java.util.Iterator;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
+import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
+import org.eclipse.papyrus.views.modelexplorer.Activator;
+
+/**
+ * A tester use to test if the CustomizableUMLLabel facet model is loaded.
+ */
+public class UMLLabelCustomizableTester extends PropertyTester {
+
+ /** The name of the facet model used to customize uml label */
+ private static final String CUSTOMIZABLE_UML_LABEL = "CustomizableUMLLabel";
+
+ /** the property key */
+ private static final String IS_UML_LABEL_CUSTOMIZABLE = "isUMLLabelCustomizable";//$NON-NLS-1$
+
+ public UMLLabelCustomizableTester() {
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+ */
+ @Override
+ public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) {
+ boolean result = false;
+ if (IS_UML_LABEL_CUSTOMIZABLE.equals(property)) {
+ ICustomizationManager customizationManager = Activator.getDefault().getCustomizationManager();
+
+ for (Iterator<Customization> iterator = customizationManager.getManagedCustomizations().iterator(); !result && iterator.hasNext();) {
+ Customization customization = iterator.next();
+
+ if (CUSTOMIZABLE_UML_LABEL.equals(customization.getName())) {
+ result = true;
+ }
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/messages/Messages.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/messages/Messages.java
new file mode 100644
index 00000000000..fbbb2a8f83a
--- /dev/null
+++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/messages/Messages.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2016 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.uml.modelexplorer.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * The Message Class.
+ */
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.uml.modelexplorer.messages.messages"; //$NON-NLS-1$
+ public static String CustomizeUMLLabelDialog_ComboCustomizationLabel;
+ public static String CustomizeUMLLabelDialog_createButtonTooltip;
+ public static String CustomizeUMLLabelDialog_deleteButtonTooltip;
+ public static String CustomizeUMLLabelDialog_dialogLabel;
+ public static String CustomizeUMLLabelDialog_downButtonTooltip;
+ public static String CustomizeUMLLabelDialog_stylesColumnTitle;
+ public static String CustomizeUMLLabelDialog_Title;
+ public static String CustomizeUMLLabelDialog_typesColumnTitle;
+ public static String CustomizeUMLLabelDialog_upButtonTooltip;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/messages/messages.properties b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/messages/messages.properties
new file mode 100644
index 00000000000..81bc12228f4
--- /dev/null
+++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/messages/messages.properties
@@ -0,0 +1,9 @@
+CustomizeUMLLabelDialog_ComboCustomizationLabel=Load a Predefined Customization:
+CustomizeUMLLabelDialog_createButtonTooltip=Create a new element
+CustomizeUMLLabelDialog_deleteButtonTooltip=Delete the selected element
+CustomizeUMLLabelDialog_dialogLabel=Customize UML Labels of Model Explorer:
+CustomizeUMLLabelDialog_downButtonTooltip=Down the selected element
+CustomizeUMLLabelDialog_stylesColumnTitle=Styles
+CustomizeUMLLabelDialog_Title=Customize UML Label
+CustomizeUMLLabelDialog_typesColumnTitle=Types
+CustomizeUMLLabelDialog_upButtonTooltip=Up the selected element
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/preferences/CustomizableLabelPreferenceInitializer.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/preferences/CustomizableLabelPreferenceInitializer.java
new file mode 100644
index 00000000000..8577768af79
--- /dev/null
+++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/preferences/CustomizableLabelPreferenceInitializer.java
@@ -0,0 +1,45 @@
+/*****************************************************************************
+ * Copyright (c) 2016 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:
+ * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - Initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.modelexplorer.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.uml.modelexplorer.Activator;
+import org.eclipse.papyrus.uml.tools.profile.definition.LabelStylersEnum;
+import org.eclipse.papyrus.uml.tools.profile.definition.LabelTypesEnum;
+
+/**
+ * Initializer for UML label customization preferences in Model Explorer.
+ */
+public class CustomizableLabelPreferenceInitializer extends AbstractPreferenceInitializer {
+
+ /**
+ * Constructor.
+ */
+ public CustomizableLabelPreferenceInitializer() {
+ super();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ */
+ @Override
+ public void initializeDefaultPreferences() {
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ store.setDefault(CustomizableLabelPreferences.CUSTOMIZED_TYPES, LabelTypesEnum.STEREOTYPE.getLiteral() + " " + LabelTypesEnum.LABEL.getLiteral());//$NON-NLS-1$
+ store.setDefault(CustomizableLabelPreferences.CUSTOMIZED_STYLES, LabelStylersEnum.DEFAULT.getLiteral() + " " + LabelStylersEnum.DEFAULT.getLiteral());//$NON-NLS-1$
+ }
+
+}
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/preferences/CustomizableLabelPreferences.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/preferences/CustomizableLabelPreferences.java
new file mode 100644
index 00000000000..113c69f3fdd
--- /dev/null
+++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/preferences/CustomizableLabelPreferences.java
@@ -0,0 +1,25 @@
+/*****************************************************************************
+ * Copyright (c) 2016 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:
+ * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - Initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.modelexplorer.preferences;
+
+/**
+ * The CustomizableLabel Preferences keys.
+ */
+public interface CustomizableLabelPreferences {
+
+ /** The preference key for the types list. */
+ public static final String CUSTOMIZED_TYPES = "CustomizedTypes"; //$NON-NLS-1$
+
+ /** The preference key for the styles list. */
+ public static final String CUSTOMIZED_STYLES = "CustomizedStyles"; //$NON-NLS-1$
+}
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
new file mode 100644
index 00000000000..7f241593de5
--- /dev/null
+++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetComplexStyledName.java
@@ -0,0 +1,77 @@
+/*****************************************************************************
+ * Copyright (c) 2016 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:
+ * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.modelexplorer.queries;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.StyledString.Styler;
+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.ParameterValue;
+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.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;
+
+/**
+ * A query to get the Name as StyledString. The label is styled with preferences.
+ */
+public class GetComplexStyledName implements IJavaQuery2<NamedElement, StyledString> {
+
+ /** the label provider */
+ private static final CustomizableDelegatingItemLabelProvider labelProvider = new CustomizableDelegatingItemLabelProvider();
+
+ /**
+ * {@inheritDoc}
+ *
+ * @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 {
+ ParameterValue parameterValue = parameterValues.getParameterValueByName("eObject"); //$NON-NLS-1$
+ if (parameterValue.getValue() instanceof EStructuralFeature) {
+ return new StyledString(((EStructuralFeature) parameterValue.getValue()).getName());
+ }
+
+ labelProvider.setStylesList(getTypes(), getStylers());
+
+ return labelProvider.getStyledText(source);
+ }
+
+ /**
+ * @return the types list to display from the preference store.
+ */
+ protected List<String> getTypes() {
+ String[] types = Activator.getDefault().getPreferenceStore().getString(CustomizableLabelPreferences.CUSTOMIZED_TYPES).split(" ");//$NON-NLS-1$
+ List<String> typesList = Arrays.asList(types);
+ return typesList;
+ }
+
+ /**
+ * @return the stylers list to display from the preference store.
+ */
+ protected List<Styler> getStylers() {
+ String[] styles = Activator.getDefault().getPreferenceStore().getString(CustomizableLabelPreferences.CUSTOMIZED_STYLES).split(" ");//$NON-NLS-1$
+ List<Styler> stylesList = new ArrayList<>();
+ for (int i = 0; i < styles.length; i++) {
+ stylesList.add(LabelStylersEnum.getByLiteral(styles[i]).getStyler());
+ }
+ return stylesList;
+ }
+
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/profile/definition/LabelStylersEnum.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/profile/definition/LabelStylersEnum.java
new file mode 100644
index 00000000000..a80c548624a
--- /dev/null
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/profile/definition/LabelStylersEnum.java
@@ -0,0 +1,144 @@
+/*****************************************************************************
+ * Copyright (c) 2016 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:
+ * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.tools.profile.definition;
+
+import org.eclipse.jface.resource.ColorRegistry;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.StyledString.Styler;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.TextStyle;
+
+
+/**
+ * The Enum of Styler used for UML label customization.
+ */
+public enum LabelStylersEnum {
+
+ /** Default style is apply(from facet customisation) */
+ DEFAULT((Styler) null, "default"), //$NON-NLS-1$
+
+ /** The Black */
+ BLACK(new RGB(0, 0, 0), "black"), //$NON-NLS-1$
+
+ /** The blue Styler enum(the return Styler return is null) */
+ BLUE(StyledString.COUNTER_STYLER, "blue"), //$NON-NLS-1$
+
+ /** The gold Styler enum(the return Styler return is null) */
+ GOLD(StyledString.DECORATIONS_STYLER, "gold"), //$NON-NLS-1$
+
+ /** The grey Styler enum(the return Styler return is null) */
+ GREY(StyledString.QUALIFIER_STYLER, "grey"); //$NON-NLS-1$
+
+ /** The literal. */
+ private String literal;
+
+ /** The styler */
+ private Styler styler;
+
+ /**
+ * Instantiates a new label style enum.
+ *
+ * @param styler
+ * The styler.
+ * @param literal
+ * The literal.
+ */
+ private LabelStylersEnum(final Styler styler, final String literal) {
+ this.styler = styler;
+ this.literal = literal;
+ }
+
+ /**
+ * Instantiates a new label style enum.
+ *
+ * @param color
+ * The rgb color.
+ * @param literal
+ * The literal.
+ */
+ private LabelStylersEnum(final RGB color, final String literal) {
+ JFaceResources.getColorRegistry().put(literal, color);
+ this.styler = new DefaultStyler(literal, null);
+ this.literal = literal;
+ }
+
+ /**
+ * Gets the line style.
+ *
+ * @return the line style
+ */
+ public Styler getStyler() {
+ return styler;
+ }
+
+ /**
+ * Gets the literal.
+ *
+ * @return the literal
+ */
+ public String getLiteral() {
+ return literal;
+ }
+
+ /** The Constant LINE_STYLE_ARRAY. */
+ private static final LabelStylersEnum[] STYLER_ARRAY = new LabelStylersEnum[] { DEFAULT, BLACK, BLUE, GOLD, GREY };
+
+ /**
+ * Gets the by literal.
+ *
+ * @param literal
+ * the literal
+ * @return the Enum by literal
+ */
+ public static LabelStylersEnum getByLiteral(final String literal) {
+ for (int i = 0; i < STYLER_ARRAY.length; ++i) {
+ LabelStylersEnum result = STYLER_ARRAY[i];
+ if (result.getLiteral().equals(literal)) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the literal value of the enumerator, which is its string representation.
+ *
+ * @return the string
+ */
+ @Override
+ public String toString() {
+ return literal;
+ }
+
+ private static class DefaultStyler extends Styler {
+ private final String fForegroundColorName;
+ private final String fBackgroundColorName;
+
+ public DefaultStyler(String foregroundColorName,
+ String backgroundColorName) {
+ fForegroundColorName = foregroundColorName;
+ fBackgroundColorName = backgroundColorName;
+ }
+
+ @Override
+ public void applyStyles(TextStyle textStyle) {
+ ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
+ if (fForegroundColorName != null) {
+ textStyle.foreground = colorRegistry.get(fForegroundColorName);
+ }
+ if (fBackgroundColorName != null) {
+ textStyle.background = colorRegistry.get(fBackgroundColorName);
+ }
+ }
+ }
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/profile/definition/LabelTypesEnum.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/profile/definition/LabelTypesEnum.java
new file mode 100644
index 00000000000..f494ebedebf
--- /dev/null
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/profile/definition/LabelTypesEnum.java
@@ -0,0 +1,88 @@
+/*****************************************************************************
+ * Copyright (c) 2016 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:
+ * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.tools.profile.definition;
+
+/**
+ * the differents type of label that can compose an UML Label.
+ */
+public enum LabelTypesEnum {
+
+ /** The default core label. */
+ LABEL("label"), //$NON-NLS-1$
+
+ /** The qualify name. */
+ QUALIFY_NAME("qualifyName"), //$NON-NLS-1$
+
+ /** The stereotype. */
+ STEREOTYPE("stereotype"), //$NON-NLS-1$
+
+ /** The metaclass. */
+ METACLASS("metaclass"), //$NON-NLS-1$
+
+ /** The dash Separator. */
+ DASH_SEPARATOR("dashSeparator"), //$NON-NLS-1$
+
+ /** The colon Separator. */
+ COLON_SEPARATOR("colonSeparator"); //$NON-NLS-1$
+
+ /** The literal. */
+ private String literal;
+
+ /**
+ * Instantiates a new label style enum.
+ *
+ * @param literal
+ * the literal
+ */
+ private LabelTypesEnum(final String literal) {
+ this.literal = literal;
+ }
+
+ /**
+ * Gets the literal.
+ *
+ * @return the literal
+ */
+ public String getLiteral() {
+ return literal;
+ }
+
+ /** The Constant LINE_STYLE_ARRAY. */
+ private static final LabelTypesEnum[] TYPES_ARRAY = new LabelTypesEnum[] { LABEL, STEREOTYPE, QUALIFY_NAME, COLON_SEPARATOR, DASH_SEPARATOR, METACLASS };
+
+ /**
+ * Gets the by literal.
+ *
+ * @param literal
+ * the literal
+ * @return the by literal
+ */
+ public static LabelTypesEnum getByLiteral(final String literal) {
+ for (int i = 0; i < TYPES_ARRAY.length; ++i) {
+ LabelTypesEnum result = TYPES_ARRAY[i];
+ if (result.getLiteral().equals(literal)) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the literal value of the enumerator, which is its string representation.
+ *
+ * @return the string
+ */
+ @Override
+ public String toString() {
+ return literal;
+ }
+}
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
new file mode 100644
index 00000000000..26283933ac6
--- /dev/null
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/CustomizableDelegatingItemLabelProvider.java
@@ -0,0 +1,439 @@
+/*****************************************************************************
+ * Copyright (c) 2016 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:
+ * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - Initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.tools.providers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.StyledString.Styler;
+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.NamedElement;
+
+
+/**
+ * An item label provider that delegates to an adapter factory and rewrites the result for UML element labels.
+ * If the adapter factory needs to be disposed (which is usually the case for item-provider factories), then
+ * this is the responsibility of the client that creates the delegating label provider.
+ */
+public class CustomizableDelegatingItemLabelProvider implements IItemLabelProvider {
+
+ /** left Stereotype delimiters ('Guillemets francais'). */
+ private static String ST_LEFT = "\u00AB"; //$NON-NLS-1$
+
+ /** Right Stereotype delimiters ('Guillemets francais'). */
+ private static String ST_RIGHT = "\u00BB"; //$NON-NLS-1$
+
+ /**
+ * The pattern of UML2 Edit labels:
+ * <ol>
+ * <li>keywords (ad hoc and stereotypes), if any, followed by</li>
+ * <li>an optional metaclass specifier, followed by</li>
+ * <li>metaclass-specific decorations (such as derived mark {@code "/"} for properties)</li>
+ * <li>the element name, possibly localized or inferred if omitted by the modeler</li>
+ * <li>metaclass-specific decorations (such as type and multiplicity {@code ": String [1..*]"} for properties)</li>
+ * </ol>
+ */
+ private static final Pattern UML2_LABEL_PATTERN = Pattern.compile("(?:<<(.+?)>>)?\\s*(<[^<>]+>)?\\s*(.*)");//$NON-NLS-1$
+
+ /** The separator dash label. */
+ private static final String SEPARATOR_DASH = "-";//$NON-NLS-1$
+
+ /** The separator colon label. */
+ private static final String SEPARATOR_COLON = ":";//$NON-NLS-1$
+
+ /** The adapter factory. */
+ private final AdapterFactory itemAdapterFactory;
+
+ /** The styles list. */
+ List<Entry<String, Styler>> stylesList = new ArrayList<Entry<String, Styler>>();
+
+ /**
+ * Initializes me with my delegate factory and a bit-mask of which label components to allow.
+ *
+ * @param itemAdapterFactory
+ * my delegate factory
+ * @param stylesList
+ * The list of entry of styles
+ */
+ public CustomizableDelegatingItemLabelProvider(final AdapterFactory itemAdapterFactory, final List<Entry<String, Styler>> stylesList) {
+ super();
+ this.itemAdapterFactory = itemAdapterFactory;
+ this.stylesList = stylesList;
+ }
+
+ /**
+ * Initializes me with my delegate factory. I do not suppress any components of the label.
+ *
+ * @param itemAdapterFactory
+ * my delegate factory
+ */
+ public CustomizableDelegatingItemLabelProvider(final AdapterFactory itemAdapterFactory) {
+ this(itemAdapterFactory, getDefaultStyles());
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param labelTypes
+ * The label types list.
+ * @param labelStyles
+ * The label type list.
+ */
+ public CustomizableDelegatingItemLabelProvider(final List<String> labelTypes, final List<Styler> labelStyles) {
+ this(Activator.getDefault().getItemProviderAdapterFactory(), toStylesList(labelTypes, labelStyles));
+ }
+
+ /**
+ * Set the styles list.
+ *
+ * @param stylesList
+ * the stylesList to set
+ */
+ public void setStylesList(List<Entry<String, Styler>> stylesList) {
+ this.stylesList = stylesList;
+ }
+
+ /**
+ * Set the styles list with labelTypes list and labelStyles list.
+ *
+ * @param labelTypes
+ * the types List to set
+ * @param labelStyles
+ * the styles List to set
+ */
+ public void setStylesList(final List<String> labelTypes, final List<Styler> labelStyles) {
+ this.stylesList = toStylesList(labelTypes, labelStyles);
+ }
+
+ /**
+ * get the list of {@link Entry}.
+ *
+ * @param labelTypes
+ * the types List to set
+ * @param labelStyles
+ * the styles List to set
+ * @return the list of {@link Entry}.
+ */
+ protected static List<Entry<String, Styler>> toStylesList(final List<String> labelTypes, final List<Styler> labelStyles) {
+ List<Entry<String, Styler>> list = new ArrayList<Entry<String, Styler>>();
+
+ Iterator<Styler> stylerIterator = labelStyles.iterator();
+ for (@SuppressWarnings("rawtypes")
+ Iterator iterator = labelTypes.iterator(); iterator.hasNext();) {
+ String type = (String) iterator.next();
+ Styler styler = null;
+ if (stylerIterator.hasNext()) {
+ styler = stylerIterator.next();
+ }
+ list.add(new StyleEntry(type, styler));
+ }
+
+ return list;
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param styleslist
+ * the list of {@link Entry}.
+ */
+ public CustomizableDelegatingItemLabelProvider(final List<Entry<String, Styler>> styleslist) {
+ this(Activator.getDefault().getItemProviderAdapterFactory(), styleslist);
+ }
+
+ /**
+ * @return the default styled list.
+ */
+ protected static List<Entry<String, Styler>> getDefaultStyles() {
+ List<Entry<String, Styler>> styles = new ArrayList<Entry<String, Styler>>();
+ styles.add(new StyleEntry(LabelTypesEnum.STEREOTYPE.getLiteral(), null));
+ styles.add(new StyleEntry(LabelTypesEnum.STEREOTYPE.getLiteral(), null));
+ return styles;
+
+ }
+
+ /**
+ * Initializes me with my plug-in's {@linkplain Activator#getItemProviderAdapterFactory() shared adapter factory} as my delegate factory. I do not
+ * suppress any components of the label. <em>Note</em> that the shared adapter factory does not need to be disposed.
+ */
+ public CustomizableDelegatingItemLabelProvider() {
+ this(Activator.getDefault().getItemProviderAdapterFactory());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.edit.provider.IItemLabelProvider#getText(java.lang.Object)
+ */
+ public String getText(final Object object) {
+ return getStyledText(object).toString();
+ }
+
+ /**
+ * Gets the styles text from the object.
+ */
+ public StyledString getStyledText(final Object object) {
+ EObject element = EMFHelper.getEObject(object);
+ StyledString result = new StyledString();
+
+ if (null != element) {
+
+ LinkedList<Entry<String, Styler>> styles = new LinkedList<Entry<String, Styler>>(stylesList);
+
+ while (!styles.isEmpty()) {
+ Entry<String, Styler> stypeEntry = styles.pop();
+ String type = stypeEntry.getKey();
+ LabelTypesEnum typeEnum = LabelTypesEnum.getByLiteral(type);
+ Styler style = stypeEntry.getValue();
+
+ Boolean stringAdded = false;
+
+ switch (typeEnum) {
+ case LABEL:
+ result.append(getLabel(element, LabelTypesEnum.LABEL.getLiteral()), style);
+ stringAdded = true;
+ break;
+ case STEREOTYPE:
+ String stereotypes = getLabel(element, LabelTypesEnum.STEREOTYPE.getLiteral());
+ if (null != stereotypes && !stereotypes.isEmpty()) {
+ result.append(ST_LEFT, style).append(stereotypes, style).append(ST_RIGHT, style);
+ stringAdded = true;
+ }
+ break;
+ case METACLASS:
+ result.append(getLabel(element, LabelTypesEnum.METACLASS.getLiteral()), style);
+ stringAdded = true;
+ break;
+ case DASH_SEPARATOR:
+ if (0 < result.length() && !isStylesListEmpty(element, styles)) {
+ result.append(SEPARATOR_DASH, style);
+ stringAdded = true;
+ }
+ break;
+ case COLON_SEPARATOR:
+ if (0 < result.length() && !isStylesListEmpty(element, styles)) {
+ result.append(SEPARATOR_COLON, style);
+ stringAdded = true;
+ }
+ break;
+ case QUALIFY_NAME:
+ if (element instanceof NamedElement && null != ((NamedElement) element).getQualifiedName()) {
+ result.append(((NamedElement) element).getQualifiedName(), style);
+ stringAdded = true;
+ }
+ break;
+
+
+ default:
+ break;
+ }
+
+ // Add space between each if necessary
+ if (stringAdded && !isStylesListEmpty(element, styles)) {
+ result.append(' ');// $NON-NLS-1$
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * @return true if if the return the value of the corresponding styles is empty.
+ */
+ private boolean isStylesListEmpty(final EObject element, final LinkedList<Entry<String, Styler>> styles) {
+ StringBuilder text = new StringBuilder();
+ for (@SuppressWarnings("rawtypes")
+ Iterator iterator = styles.iterator(); iterator.hasNext();) {
+ @SuppressWarnings("unchecked")
+ Entry<String, Styler> entry = (Entry<String, Styler>) iterator.next();
+ if (!(LabelTypesEnum.DASH_SEPARATOR.getLiteral()).equals(entry.getKey())
+ && !(LabelTypesEnum.COLON_SEPARATOR.getLiteral()).equals(entry.getKey())) {
+ text.append(getLabel(element, entry.getKey()));
+ }
+ }
+ return text.toString().isEmpty();
+ }
+
+ /**
+ * Get the label of the type of the element.
+ */
+ protected String getLabel(final EObject element, final String type) {
+
+ String result = null;
+
+ // Delegate to UML2 Edit providers to get localized and inferred names where applicable
+ IItemLabelProvider provider = getDelegate(element);
+ String umlResult = (provider == null) ? ModelUtils.getDefaultName(element) : provider.getText(element);
+
+ if (null != umlResult) {
+ // Rewrite the stereotype list and strip the metaclass qualifier, unless there is no label, in which
+ // case we leave the metaclass qualifier
+ Matcher m = UML2_LABEL_PATTERN.matcher(umlResult);
+ if (m.matches()) {
+ LabelTypesEnum typeEnum = LabelTypesEnum.getByLiteral(type);
+ switch (typeEnum) {
+ case LABEL:
+ result = m.group(3);
+ break;
+ case STEREOTYPE:
+ result = m.group(1);
+ break;
+ case METACLASS:
+ result = m.group(2);
+ break;
+ case DASH_SEPARATOR:
+ result = SEPARATOR_DASH;
+ break;
+ case COLON_SEPARATOR:
+ result = SEPARATOR_COLON;
+ break;
+ case QUALIFY_NAME:
+ result = ((NamedElement) element).getQualifiedName();
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ return null != result ? result : "";//$NON-NLS-1$
+
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.edit.provider.IItemLabelProvider#getImage(java.lang.Object)
+ */
+ public Object getImage(final Object object) {
+ EObject element = EMFHelper.getEObject(object);
+ if (null == element) {
+ return null;
+ }
+
+ // Delegate to UML2 Edit providers to get localized and inferred names where applicable
+ IItemLabelProvider provider = getDelegate(element);
+ return (provider == null) ? null : provider.getImage(element);
+ }
+
+ /**
+ * Gets the delegate for the object.
+ */
+ protected IItemLabelProvider getDelegate(EObject object) {
+ return (IItemLabelProvider) itemAdapterFactory.adapt(object, IItemLabelProvider.class);
+ }
+
+
+ /**
+ * The Style Entry class. An Entry of a type associated with a styler.
+ */
+ public static class StyleEntry implements Entry<String, Styler> {
+
+ /** The type. */
+ private String type;
+
+ /** The Styler */
+ private Styler styler;
+
+ /**
+ * Constructor.
+ */
+ public StyleEntry() {
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param type
+ * The type.
+ * @param styler
+ * The Styler
+ */
+ public StyleEntry(final String type, final Styler styler) {
+ this.type = type;
+ this.styler = styler;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.util.Map.Entry#getKey()
+ */
+ @Override
+ public String getKey() {
+ return type;
+ }
+
+ /**
+ * Gets the type.
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.util.Map.Entry#getValue()
+ */
+ @Override
+ public Styler getValue() {
+ return styler;
+ }
+
+ /**
+ * Gets the style.
+ */
+ public Styler getStyle() {
+ return getValue();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.util.Map.Entry#setValue(java.lang.Object)
+ */
+ @Override
+ public Styler setValue(final Styler value) {
+ Styler oldValue = styler;
+ styler = value;
+ return oldValue;
+ }
+
+ /**
+ * Set the styler.
+ */
+ public Styler setStyler(final Styler value) {
+ return setValue(value);
+ }
+
+ }
+
+
+}

Back to the top