summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2013-01-17 05:15:42 (EST)
committer Mikaƫl Barbero2013-01-25 08:53:25 (EST)
commitdb993319d95f1b04fd5139af9e7d4e8f3017fa41 (patch)
tree4e2a093a1071e96d5a6cd8f26024fbe1c0ed054c
parentcd6a8b71aed364a82c97be232c46d5bb410701b5 (diff)
downloadorg.eclipse.emf.compare-db993319d95f1b04fd5139af9e7d4e8f3017fa41.zip
org.eclipse.emf.compare-db993319d95f1b04fd5139af9e7d4e8f3017fa41.tar.gz
org.eclipse.emf.compare-db993319d95f1b04fd5139af9e7d4e8f3017fa41.tar.bz2
[398099] enhanced labels in structural viewerrefs/changes/27/9927/1
Initiate enhanced labels system based on jface StyledStrings to improve readability of the structural differences. * Add new StyledStringUtil utility class to easily use StyledStrings. * ItemProviders now implements newly created interface IItemStyledLabelProvider. * Add jface dependency on projects org.eclipse.emf.compare.edit and org.eclipse.emf.compare.ide.ui. * Manage enhanced styled labels for EMF Compare UML2 extension. * Add jface dependency on projects org.eclipse.emf.compare.uml2.edit.
-rw-r--r--plugins/org.eclipse.emf.compare.edit/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.emf.compare.edit/plugin.xml3
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src-gen/org/eclipse/emf/compare/provider/EMFCompareEditPlugin.java1
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/IItemStyledLabelProvider.java18
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/AttributeChangeItemProviderSpec.java77
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/CompareItemProviderAdapterFactorySpec.java6
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ComparisonItemProviderSpec.java13
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ConflictItemProviderSpec.java21
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchItemProviderSpec.java13
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchResourceItemProviderSpec.java13
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ReferenceChangeItemProviderSpec.java73
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/utils/StyledStringUtil.java112
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java4
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewerLabelProvider.java39
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.edit/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.edit/plugin.xml3
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/provider/spec/ForwardingUMLDiffItemProvider.java97
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/provider/spec/StereotypeApplicationChangeItemProviderSpec.java114
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/provider/spec/UMLCompareAdapterFactorySpec.java6
19 files changed, 440 insertions, 179 deletions
diff --git a/plugins/org.eclipse.emf.compare.edit/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare.edit/META-INF/MANIFEST.MF
index 5ddf566..1fd34a8 100644
--- a/plugins/org.eclipse.emf.compare.edit/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.compare.edit/META-INF/MANIFEST.MF
@@ -19,7 +19,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.edit;visibility:=reexport,
org.eclipse.emf.ecore;visibility:=reexport,
org.eclipse.emf.ecore.edit;visibility:=reexport,
- org.eclipse.emf.transaction;bundle-version="1.3.0"
+ org.eclipse.emf.transaction;bundle-version="1.3.0",
+ org.eclipse.jface
Bundle-ActivationPolicy: lazy
Import-Package: com.google.common.base;version="[10.0.0,11.0.0)",
com.google.common.collect;version="[10.0.0,11.0.0)"
diff --git a/plugins/org.eclipse.emf.compare.edit/plugin.xml b/plugins/org.eclipse.emf.compare.edit/plugin.xml
index c16737a..e7a9d46 100644
--- a/plugins/org.eclipse.emf.compare.edit/plugin.xml
+++ b/plugins/org.eclipse.emf.compare.edit/plugin.xml
@@ -23,7 +23,8 @@
org.eclipse.emf.edit.provider.IStructuredItemContentProvider
org.eclipse.emf.edit.provider.ITreeItemContentProvider
org.eclipse.emf.edit.provider.IItemLabelProvider
- org.eclipse.emf.edit.provider.IItemPropertySource"/>
+ org.eclipse.emf.edit.provider.IItemPropertySource
+ org.eclipse.emf.compare.provider.IItemStyledLabelProvider"/>
</extension>
</plugin>
diff --git a/plugins/org.eclipse.emf.compare.edit/src-gen/org/eclipse/emf/compare/provider/EMFCompareEditPlugin.java b/plugins/org.eclipse.emf.compare.edit/src-gen/org/eclipse/emf/compare/provider/EMFCompareEditPlugin.java
index 80a0c3d..4054e25 100644
--- a/plugins/org.eclipse.emf.compare.edit/src-gen/org/eclipse/emf/compare/provider/EMFCompareEditPlugin.java
+++ b/plugins/org.eclipse.emf.compare.edit/src-gen/org/eclipse/emf/compare/provider/EMFCompareEditPlugin.java
@@ -29,7 +29,6 @@ public final class EMFCompareEditPlugin extends EMFPlugin {
public static final String PLUGIN_ID = "org.eclipse.emf.compare.edit"; //$NON-NLS-1$
/**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/IItemStyledLabelProvider.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/IItemStyledLabelProvider.java
new file mode 100644
index 0000000..1092b02
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/IItemStyledLabelProvider.java
@@ -0,0 +1,18 @@
+package org.eclipse.emf.compare.provider;
+
+import org.eclipse.jface.viewers.StyledString;
+
+/**
+ * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
+ */
+public interface IItemStyledLabelProvider {
+
+ /**
+ * Returns the styled text label for the given object.
+ *
+ * @param object
+ * the object to evaluate the styled string for.
+ * @return the styled string.
+ */
+ public StyledString getStyledText(Object object);
+}
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/AttributeChangeItemProviderSpec.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/AttributeChangeItemProviderSpec.java
index d9626c9..40d2620 100644
--- a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/AttributeChangeItemProviderSpec.java
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/AttributeChangeItemProviderSpec.java
@@ -20,15 +20,16 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.compare.AttributeChange;
import org.eclipse.emf.compare.Conflict;
import org.eclipse.emf.compare.DifferenceKind;
-import org.eclipse.emf.compare.DifferenceSource;
import org.eclipse.emf.compare.provider.AdapterFactoryUtil;
import org.eclipse.emf.compare.provider.AttributeChangeItemProvider;
+import org.eclipse.emf.compare.provider.IItemStyledLabelProvider;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.jface.viewers.StyledString;
/**
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
-public class AttributeChangeItemProviderSpec extends AttributeChangeItemProvider {
+public class AttributeChangeItemProviderSpec extends AttributeChangeItemProvider implements IItemStyledLabelProvider {
/**
* @param adapterFactory
@@ -61,38 +62,7 @@ public class AttributeChangeItemProviderSpec extends AttributeChangeItemProvider
*/
@Override
public String getText(Object object) {
- final AttributeChange attChange = (AttributeChange)object;
-
- final String valueText = getValueText(attChange);
- final String attributeText = getAttributeText(attChange);
-
- String remotely = ""; //$NON-NLS-1$
- if (attChange.getSource() == DifferenceSource.RIGHT) {
- remotely = "remotely "; //$NON-NLS-1$
- }
-
- String ret = ""; //$NON-NLS-1$
- switch (attChange.getKind()) {
- case ADD:
- ret = valueText + " has been " + remotely + "added to " + attributeText; //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case DELETE:
- ret = valueText + " has been " + remotely + "deleted from " + attributeText; //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case CHANGE:
- String changeText = ReferenceChangeItemProviderSpec.changeText(attChange, attChange
- .getAttribute());
- ret = attributeText + " " + valueText + " has been " + remotely + changeText; //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case MOVE:
- ret = valueText + " has been " + remotely + "moved in '" + attributeText; //$NON-NLS-1$ //$NON-NLS-2$
- break;
- default:
- throw new IllegalStateException("Unsupported " + DifferenceKind.class.getSimpleName() //$NON-NLS-1$
- + " value: " + attChange.getKind()); //$NON-NLS-1$
- }
-
- return ret;
+ return getStyledText(object).getString();
}
protected String getAttributeText(final AttributeChange attChange) {
@@ -144,4 +114,43 @@ public class AttributeChangeItemProviderSpec extends AttributeChangeItemProvider
return super.getForeground(object);
}
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.IItemStyledLabelProvider#getStyledText(java.lang.Object)
+ */
+ public StyledString getStyledText(Object object) {
+ final AttributeChange attChange = (AttributeChange)object;
+
+ final String valueText = getValueText(attChange);
+
+ final String attributeText = getAttributeText(attChange);
+
+ StyledString ret = new StyledString(valueText);
+ ret.append(" [" + attributeText, StyledString.DECORATIONS_STYLER); //$NON-NLS-1$
+
+ switch (attChange.getKind()) {
+ case ADD:
+ ret.append(" add", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$
+ break;
+ case DELETE:
+ ret.append(" delete", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$
+ break;
+ case CHANGE:
+ ret.append(
+ " " + ReferenceChangeItemProviderSpec.changeText(attChange, attChange.getAttribute()), //$NON-NLS-1$
+ StyledString.DECORATIONS_STYLER);
+ break;
+ case MOVE:
+ ret.append(" move", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$
+ break;
+ default:
+ throw new IllegalStateException("Unsupported " + DifferenceKind.class.getSimpleName() //$NON-NLS-1$
+ + " value: " + attChange.getKind()); //$NON-NLS-1$
+ }
+ ret.append("]", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$
+
+ return ret;
+ }
}
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/CompareItemProviderAdapterFactorySpec.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/CompareItemProviderAdapterFactorySpec.java
index b3e708a..28834d7 100644
--- a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/CompareItemProviderAdapterFactorySpec.java
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/CompareItemProviderAdapterFactorySpec.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.compare.provider.spec;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.compare.provider.CompareItemProviderAdapterFactory;
+import org.eclipse.emf.compare.provider.IItemStyledLabelProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
/**
@@ -22,6 +23,11 @@ import org.eclipse.emf.edit.provider.IItemLabelProvider;
*/
public class CompareItemProviderAdapterFactorySpec extends CompareItemProviderAdapterFactory {
+ public CompareItemProviderAdapterFactorySpec() {
+ super();
+ supportedTypes.add(IItemStyledLabelProvider.class);
+ }
+
/**
* {@inheritDoc}
*
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ComparisonItemProviderSpec.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ComparisonItemProviderSpec.java
index b75ca7f..975fb97 100644
--- a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ComparisonItemProviderSpec.java
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ComparisonItemProviderSpec.java
@@ -23,13 +23,15 @@ import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.Match;
import org.eclipse.emf.compare.provider.ComparisonItemProvider;
+import org.eclipse.emf.compare.provider.IItemStyledLabelProvider;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.jface.viewers.StyledString;
/**
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
-public class ComparisonItemProviderSpec extends ComparisonItemProvider {
+public class ComparisonItemProviderSpec extends ComparisonItemProvider implements IItemStyledLabelProvider {
/**
* @param adapterFactory
@@ -86,4 +88,13 @@ public class ComparisonItemProviderSpec extends ComparisonItemProvider {
});
return match;
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.IItemStyledLabelProvider#getStyledText(java.lang.Object)
+ */
+ public StyledString getStyledText(Object object) {
+ return new StyledString(getText(object));
+ }
}
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ConflictItemProviderSpec.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ConflictItemProviderSpec.java
index 53e4535..1f7963a 100644
--- a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ConflictItemProviderSpec.java
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ConflictItemProviderSpec.java
@@ -17,11 +17,13 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.compare.Conflict;
import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.compare.provider.ConflictItemProvider;
+import org.eclipse.emf.compare.provider.IItemStyledLabelProvider;
+import org.eclipse.jface.viewers.StyledString;
/**
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
-public class ConflictItemProviderSpec extends ConflictItemProvider {
+public class ConflictItemProviderSpec extends ConflictItemProvider implements IItemStyledLabelProvider {
/**
* @param adapterFactory
@@ -37,10 +39,7 @@ public class ConflictItemProviderSpec extends ConflictItemProvider {
*/
@Override
public String getText(Object object) {
- Conflict conflict = (Conflict)object;
- int size = conflict.getDifferences().size() - 1;
- return conflict.getKind().getName() + " conflict with " + size + " other difference"
- + (size > 1 ? "s" : "");
+ return getStyledText(object).getString();
}
/**
@@ -54,4 +53,16 @@ public class ConflictItemProviderSpec extends ConflictItemProvider {
EList<Diff> differences = conflict.getDifferences();
return differences;
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.IItemStyledLabelProvider#getStyledText(java.lang.Object)
+ */
+ public StyledString getStyledText(Object object) {
+ Conflict conflict = (Conflict)object;
+ int size = conflict.getDifferences().size() - 1;
+ return new StyledString(conflict.getKind().getName() + " conflict with " + size + " other difference" //$NON-NLS-1$ //$NON-NLS-2$
+ + (size > 1 ? "s" : "")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchItemProviderSpec.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchItemProviderSpec.java
index 75bb7f5..a31c88e 100644
--- a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchItemProviderSpec.java
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchItemProviderSpec.java
@@ -32,9 +32,11 @@ import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.compare.Match;
import org.eclipse.emf.compare.ReferenceChange;
import org.eclipse.emf.compare.provider.AdapterFactoryUtil;
+import org.eclipse.emf.compare.provider.IItemStyledLabelProvider;
import org.eclipse.emf.compare.provider.MatchItemProvider;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
+import org.eclipse.jface.viewers.StyledString;
/**
* Specialized {@link MatchItemProvider} returning nice output for {@link #getText(Object)} and
@@ -42,7 +44,7 @@ import org.eclipse.emf.ecore.EReference;
*
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
-public class MatchItemProviderSpec extends MatchItemProvider {
+public class MatchItemProviderSpec extends MatchItemProvider implements IItemStyledLabelProvider {
private static final Predicate<ReferenceChange> CONTAINMENT_REFERENCE_CHANGE = new Predicate<ReferenceChange>() {
public boolean apply(ReferenceChange input) {
@@ -251,4 +253,13 @@ public class MatchItemProviderSpec extends MatchItemProvider {
Match match = (Match)object;
return !isEmpty(getChildrenIterable(match));
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.IItemStyledLabelProvider#getStyledText(java.lang.Object)
+ */
+ public StyledString getStyledText(Object object) {
+ return new StyledString(getText(object));
+ }
}
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchResourceItemProviderSpec.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchResourceItemProviderSpec.java
index facbf98..219f75e 100644
--- a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchResourceItemProviderSpec.java
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchResourceItemProviderSpec.java
@@ -12,7 +12,9 @@ package org.eclipse.emf.compare.provider.spec;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.compare.MatchResource;
+import org.eclipse.emf.compare.provider.IItemStyledLabelProvider;
import org.eclipse.emf.compare.provider.MatchResourceItemProvider;
+import org.eclipse.jface.viewers.StyledString;
/**
* Specialized {@link MatchResourceItemProvider} returning nice output for {@link #getText(Object)} and
@@ -20,7 +22,7 @@ import org.eclipse.emf.compare.provider.MatchResourceItemProvider;
*
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
-public class MatchResourceItemProviderSpec extends MatchResourceItemProvider {
+public class MatchResourceItemProviderSpec extends MatchResourceItemProvider implements IItemStyledLabelProvider {
/**
* Constructor calling super {@link #MatchResourceItemProviderSpec(AdapterFactory)}.
@@ -90,4 +92,13 @@ public class MatchResourceItemProviderSpec extends MatchResourceItemProvider {
return buffer.toString();
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.IItemStyledLabelProvider#getStyledText(java.lang.Object)
+ */
+ public StyledString getStyledText(Object object) {
+ return new StyledString(getText(object));
+ }
}
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ReferenceChangeItemProviderSpec.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ReferenceChangeItemProviderSpec.java
index 5c9a6e6..05c174f 100644
--- a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ReferenceChangeItemProviderSpec.java
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ReferenceChangeItemProviderSpec.java
@@ -30,12 +30,14 @@ import org.eclipse.emf.compare.DifferenceSource;
import org.eclipse.emf.compare.Match;
import org.eclipse.emf.compare.ReferenceChange;
import org.eclipse.emf.compare.provider.AdapterFactoryUtil;
+import org.eclipse.emf.compare.provider.IItemStyledLabelProvider;
import org.eclipse.emf.compare.provider.ReferenceChangeItemProvider;
import org.eclipse.emf.compare.utils.ReferenceUtil;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.jface.viewers.StyledString;
/**
* Specialized {@link ReferenceChangeItemProvider} returning nice output for {@link #getText(Object)} and
@@ -43,7 +45,7 @@ import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
*
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
-public class ReferenceChangeItemProviderSpec extends ReferenceChangeItemProvider {
+public class ReferenceChangeItemProviderSpec extends ReferenceChangeItemProvider implements IItemStyledLabelProvider {
/**
* Constructor calling super {@link #ReferenceChangeItemProvider(AdapterFactory)}.
@@ -62,37 +64,7 @@ public class ReferenceChangeItemProviderSpec extends ReferenceChangeItemProvider
*/
@Override
public String getText(Object object) {
- final ReferenceChange refChange = (ReferenceChange)object;
-
- final String valueText = getValueText(refChange);
- final String referenceText = getReferenceText(refChange);
-
- String remotely = ""; //$NON-NLS-1$
- if (refChange.getSource() == DifferenceSource.RIGHT) {
- remotely = "remotely "; //$NON-NLS-1$
- }
-
- String ret = ""; //$NON-NLS-1$
- switch (refChange.getKind()) {
- case ADD:
- ret = valueText + " has been " + remotely + "added to " + referenceText; //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case DELETE:
- ret = valueText + " has been " + remotely + "deleted from " + referenceText; //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case CHANGE:
- String changeText = changeText(refChange, refChange.getReference());
- ret = referenceText + " " + valueText + " has been " + remotely + changeText; //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case MOVE:
- ret = valueText + " has been " + remotely + "moved in " + referenceText; //$NON-NLS-1$ //$NON-NLS-2$
- break;
- default:
- throw new IllegalStateException("Unsupported " + DifferenceKind.class.getSimpleName() //$NON-NLS-1$
- + " value: " + refChange.getKind()); //$NON-NLS-1$
- }
-
- return ret;
+ return getStyledText(object).getString();
}
static String changeText(final Diff diff, EStructuralFeature feature) {
@@ -242,4 +214,41 @@ public class ReferenceChangeItemProviderSpec extends ReferenceChangeItemProvider
}
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.IItemStyledLabelProvider#getStyledText(java.lang.Object)
+ */
+ public StyledString getStyledText(Object object) {
+ final ReferenceChange refChange = (ReferenceChange)object;
+
+ final String valueText = getValueText(refChange);
+
+ final String referenceText = getReferenceText(refChange);
+
+ StyledString ret = new StyledString(valueText);
+ ret.append(" [" + referenceText, StyledString.DECORATIONS_STYLER); //$NON-NLS-1$
+
+ switch (refChange.getKind()) {
+ case ADD:
+ ret.append(" add", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$
+ break;
+ case DELETE:
+ ret.append(" delete", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$
+ break;
+ case CHANGE:
+ ret.append(" " + changeText(refChange, refChange.getReference()), //$NON-NLS-1$
+ StyledString.DECORATIONS_STYLER);
+ break;
+ case MOVE:
+ ret.append(" move", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$
+ break;
+ default:
+ throw new IllegalStateException("Unsupported " + DifferenceKind.class.getSimpleName() //$NON-NLS-1$
+ + " value: " + refChange.getKind()); //$NON-NLS-1$
+ }
+ ret.append("]", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$
+
+ return ret;
+ }
}
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/utils/StyledStringUtil.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/utils/StyledStringUtil.java
new file mode 100644
index 0000000..d1ee043
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/utils/StyledStringUtil.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.provider.utils;
+
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.StyledString.Styler;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.TextStyle;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * This utility class holds methods that will be used by the item providers.
+ *
+ * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
+ */
+public final class StyledStringUtil {
+ /**
+ * Utility classes don't need a default constructor.
+ */
+ private StyledStringUtil() {
+ // Hides default constructor
+ }
+
+ private static FontData FONT_DATA = Display.getCurrent().getSystemFont().getFontData()[0];
+
+ private static String DEFAULT_FONT_NAME = FONT_DATA.getName();
+
+ static {
+ JFaceResources.getColorRegistry().put("BLUE", new RGB(18, 120, 143)); //$NON-NLS-1$
+ JFaceResources.getColorRegistry().put("RED", new RGB(143, 14, 55)); //$NON-NLS-1$
+ JFaceResources.getColorRegistry().put("GRAY_BLUE", new RGB(93, 102, 150)); //$NON-NLS-1$
+ JFaceResources.getColorRegistry().put("PURPLE", new RGB(150, 79, 138)); //$NON-NLS-1$
+ JFaceResources.getColorRegistry().put("DARK_GRAY", new RGB(77, 82, 72)); //$NON-NLS-1$
+ }
+
+ public static enum FontStyle {
+ NONE, BOLD, ITALIC
+ }
+
+ public static enum Color {
+
+ WHITE(SWT.COLOR_WHITE), BLACK(SWT.COLOR_BLACK), GREEN(SWT.COLOR_GREEN), GRAY(SWT.COLOR_GRAY), YELLOW(
+ SWT.COLOR_YELLOW), DARK_YELLOW(SWT.COLOR_DARK_YELLOW), DARK_GRAY(1004), BLUE(1000), RED(1001), GRAY_BLUE(
+ 1002), PURPLE(1003);
+
+ private final int value;
+
+ private Color(int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return this.value;
+ }
+ }
+
+ public static StyledString StyledString(final String text) {
+ return new StyledString(text);
+ }
+
+ public static StyledString StyledString(final String text, final Styler styler) {
+ return new StyledString(text, styler);
+ }
+
+ public static StyledString StyledString(final String text, final Color fgColor) {
+ return StyledString(text, fgColor, FontStyle.NONE);
+ }
+
+ public static StyledString StyledString(final String text, final FontStyle fontStyle) {
+ return StyledString(text, Color.BLACK, fontStyle);
+ }
+
+ public static StyledString StyledString(final String text, final Color fgColor, final FontStyle fontStyle) {
+ final Styler styler = new Styler() {
+
+ @Override
+ public void applyStyles(TextStyle textStyle) {
+ switch (fontStyle) {
+ case BOLD:
+ textStyle.font = JFaceResources.getFontRegistry().getBold(DEFAULT_FONT_NAME);
+ break;
+ case ITALIC:
+ textStyle.font = JFaceResources.getFontRegistry().getItalic(DEFAULT_FONT_NAME);
+ break;
+ default:
+ break;
+ }
+
+ org.eclipse.swt.graphics.Color color = JFaceResources.getColorRegistry().get(fgColor.name());
+ if (color != null) {
+ textStyle.foreground = color;
+ } else {
+ textStyle.foreground = Display.getCurrent().getSystemColor(fgColor.getValue());
+ }
+ }
+ };
+
+ return new StyledString(text, styler);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java
index 1393635..26c9ddb 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java
@@ -59,6 +59,7 @@ import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
import org.eclipse.jface.viewers.IElementComparer;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.custom.BusyIndicator;
@@ -107,7 +108,8 @@ public class EMFCompareStructureMergeViewer extends DiffTreeViewer implements Co
fAdapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
boolean leftIsLocal = CompareConfigurationExtension.getBoolean(configuration, "LEFT_IS_LOCAL", false); //$NON-NLS-1$
- setLabelProvider(new EMFCompareStructureMergeViewerLabelProvider(fAdapterFactory, this, leftIsLocal));
+ setLabelProvider(new DelegatingStyledCellLabelProvider(
+ new EMFCompareStructureMergeViewerLabelProvider(fAdapterFactory, this, leftIsLocal)));
setContentProvider(new EMFCompareStructureMergeViewerContentProvider(fAdapterFactory,
differenceGrouper));
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewerLabelProvider.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewerLabelProvider.java
index ddb2d02..eda4f30 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewerLabelProvider.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewerLabelProvider.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.compare.Match;
@@ -21,14 +22,17 @@ import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.provider.Dif
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.provider.ImageProvider;
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.provider.MatchNode;
import org.eclipse.emf.compare.ide.ui.internal.util.EMFCompareCompositeImageDescriptor;
+import org.eclipse.emf.compare.provider.IItemStyledLabelProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
-class EMFCompareStructureMergeViewerLabelProvider extends AdapterFactoryLabelProvider.FontAndColorProvider {
+class EMFCompareStructureMergeViewerLabelProvider extends AdapterFactoryLabelProvider.FontAndColorProvider implements IStyledLabelProvider {
private final boolean fLeftIsLocal;
@@ -46,15 +50,7 @@ class EMFCompareStructureMergeViewerLabelProvider extends AdapterFactoryLabelPro
@Override
public String getText(Object element) {
- final String ret;
- if (element instanceof IDiffElement) {
- ret = ((IDiffElement)element).getName();
- } else if (element instanceof DifferenceGroup) {
- ret = ((DifferenceGroup)element).getName();
- } else {
- ret = super.getText(element);
- }
- return ret;
+ return getStyledText(element).getString();
}
/**
@@ -128,4 +124,27 @@ class EMFCompareStructureMergeViewerLabelProvider extends AdapterFactoryLabelPro
return ret;
}
+
+ public StyledString getStyledText(Object element) {
+ Object target = null;
+ Object adapter = null;
+ if (element instanceof Adapter) {
+ target = ((Adapter)element).getTarget();
+ adapter = adapterFactory.adapt(target, IItemStyledLabelProvider.class);
+ if (adapter instanceof IItemStyledLabelProvider) {
+ return ((IItemStyledLabelProvider)adapter).getStyledText(target);
+ }
+ }
+
+ final String ret;
+ if (element instanceof IDiffElement) {
+ ret = ((IDiffElement)element).getName();
+ } else if (element instanceof DifferenceGroup) {
+ ret = ((DifferenceGroup)element).getName();
+ } else {
+ ret = super.getText(element);
+ }
+ return new StyledString(ret);
+
+ }
}
diff --git a/plugins/org.eclipse.emf.compare.uml2.edit/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare.uml2.edit/META-INF/MANIFEST.MF
index f30c893..ef49251 100644
--- a/plugins/org.eclipse.emf.compare.uml2.edit/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.compare.uml2.edit/META-INF/MANIFEST.MF
@@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.uml2.uml;bundle-version="4.0.0",
org.eclipse.emf.compare,
org.eclipse.uml2.uml.edit;bundle-version="4.0.0",
- org.eclipse.emf.compare.edit
+ org.eclipse.emf.compare.edit,
+ org.eclipse.jface
Bundle-ActivationPolicy: lazy
Import-Package: com.google.common.base;version="[10.0.0,11.0.0)",
org.eclipse.emf.compare.provider
diff --git a/plugins/org.eclipse.emf.compare.uml2.edit/plugin.xml b/plugins/org.eclipse.emf.compare.uml2.edit/plugin.xml
index f0ef13f..4009632 100644
--- a/plugins/org.eclipse.emf.compare.uml2.edit/plugin.xml
+++ b/plugins/org.eclipse.emf.compare.uml2.edit/plugin.xml
@@ -23,7 +23,8 @@ Contributors:
org.eclipse.emf.edit.provider.IStructuredItemContentProvider
org.eclipse.emf.edit.provider.ITreeItemContentProvider
org.eclipse.emf.edit.provider.IItemLabelProvider
- org.eclipse.emf.edit.provider.IItemPropertySource"/>
+ org.eclipse.emf.edit.provider.IItemPropertySource
+ org.eclipse.emf.compare.provider.IItemStyledLabelProvider"/>
</extension>
diff --git a/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/provider/spec/ForwardingUMLDiffItemProvider.java b/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/provider/spec/ForwardingUMLDiffItemProvider.java
index 53a7743..767fcf5 100644
--- a/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/provider/spec/ForwardingUMLDiffItemProvider.java
+++ b/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/provider/spec/ForwardingUMLDiffItemProvider.java
@@ -14,22 +14,33 @@ import java.util.Collection;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.compare.DifferenceKind;
-import org.eclipse.emf.compare.DifferenceSource;
import org.eclipse.emf.compare.Match;
import org.eclipse.emf.compare.provider.AdapterFactoryUtil;
import org.eclipse.emf.compare.provider.ForwardingItemProvider;
+import org.eclipse.emf.compare.provider.IItemStyledLabelProvider;
import org.eclipse.emf.compare.provider.spec.Strings;
import org.eclipse.emf.compare.uml2.UMLDiff;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
+import org.eclipse.jface.viewers.StyledString;
/**
+ * Specialized ForwardingItemProvider for UML.
+ *
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
-public class ForwardingUMLDiffItemProvider extends ForwardingItemProvider {
+public class ForwardingUMLDiffItemProvider extends ForwardingItemProvider implements IItemStyledLabelProvider {
+
+ /**
+ * The maximum length of displayed text.
+ */
+ private static final int MAX_LENGTH = 50;
/**
+ * This constructs an instance from an adapter.
+ *
* @param delegate
+ * the adapter to delegate to.
*/
public ForwardingUMLDiffItemProvider(ItemProviderAdapter delegate) {
super(delegate);
@@ -69,36 +80,7 @@ public class ForwardingUMLDiffItemProvider extends ForwardingItemProvider {
*/
@Override
public String getText(Object object) {
- final UMLDiff umlDiff = (UMLDiff)object;
-
- String remotely = "";
- if (umlDiff.getSource() == DifferenceSource.RIGHT) {
- remotely = "remotely ";
- }
-
- final String valueText = getValueText(umlDiff);
- final String referenceText = getReferenceText(umlDiff);
-
- String ret = "";
- switch (umlDiff.getKind()) {
- case ADD:
- ret = valueText + " has been " + remotely + "added to " + referenceText;
- break;
- case DELETE:
- ret = valueText + " has been " + remotely + "deleted from " + referenceText;
- break;
- case CHANGE:
- ret = valueText + " has been " + remotely + "changed";
- break;
- case MOVE:
- ret = valueText + " has been " + remotely + "moved in " + referenceText;
- break;
- default:
- throw new IllegalStateException("Unsupported " + DifferenceKind.class.getSimpleName()
- + " value: " + umlDiff.getKind());
- }
-
- return ret;
+ return getStyledText(object).getString();
}
/**
@@ -133,16 +115,30 @@ public class ForwardingUMLDiffItemProvider extends ForwardingItemProvider {
return image;
}
+ /**
+ * Returns the value text for the given umlDiff.
+ *
+ * @param umlDiff
+ * the given {@link UMLDiff}.
+ * @return the value text.
+ */
private String getValueText(final UMLDiff umlDiff) {
String value = AdapterFactoryUtil.getText(getRootAdapterFactory(), umlDiff.getDiscriminant());
if (value == null) {
value = "<null>";
} else {
- value = Strings.elide(value, 50, "...");
+ value = Strings.elide(value, MAX_LENGTH, "...");
}
return value;
}
+ /**
+ * Returns the reference text for the given umlDiff.
+ *
+ * @param umlDiff
+ * the given {@link UMLDiff}.
+ * @return the reference text.
+ */
private String getReferenceText(final UMLDiff umlDiff) {
String ret = "";
switch (umlDiff.getKind()) {
@@ -177,4 +173,39 @@ public class ForwardingUMLDiffItemProvider extends ForwardingItemProvider {
return super.getForeground(object);
}
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.IItemStyledLabelProvider#getStyledText(java.lang.Object)
+ */
+ public StyledString getStyledText(Object object) {
+ final UMLDiff umlDiff = (UMLDiff)object;
+
+ final String valueText = getValueText(umlDiff);
+ final String referenceText = getReferenceText(umlDiff);
+
+ StyledString ret = new StyledString(valueText);
+ ret.append(" [" + referenceText, StyledString.DECORATIONS_STYLER); //$NON-NLS-1$
+ switch (umlDiff.getKind()) {
+ case ADD:
+ ret.append(" add", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$
+ break;
+ case DELETE:
+ ret.append(" delete", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$
+ break;
+ case CHANGE:
+ ret.append(" change", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$
+ break;
+ case MOVE:
+ ret.append(" move", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$
+ break;
+ default:
+ throw new IllegalStateException("Unsupported " + DifferenceKind.class.getSimpleName() //$NON-NLS-1$
+ + " value: " + umlDiff.getKind()); //$NON-NLS-1$
+ }
+ ret.append("]", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$
+
+ return ret;
+ }
}
diff --git a/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/provider/spec/StereotypeApplicationChangeItemProviderSpec.java b/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/provider/spec/StereotypeApplicationChangeItemProviderSpec.java
index 03cbcdb..cc614d3 100644
--- a/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/provider/spec/StereotypeApplicationChangeItemProviderSpec.java
+++ b/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/provider/spec/StereotypeApplicationChangeItemProviderSpec.java
@@ -15,13 +15,14 @@ import java.util.Collection;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.compare.DifferenceKind;
-import org.eclipse.emf.compare.DifferenceSource;
import org.eclipse.emf.compare.Match;
import org.eclipse.emf.compare.provider.AdapterFactoryUtil;
+import org.eclipse.emf.compare.provider.IItemStyledLabelProvider;
import org.eclipse.emf.compare.uml2.StereotypeApplicationChange;
import org.eclipse.emf.compare.uml2.UMLDiff;
import org.eclipse.emf.compare.uml2.provider.StereotypeApplicationChangeItemProvider;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.util.UMLUtil;
@@ -31,7 +32,7 @@ import org.eclipse.uml2.uml.util.UMLUtil;
*
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
-public class StereotypeApplicationChangeItemProviderSpec extends StereotypeApplicationChangeItemProvider {
+public class StereotypeApplicationChangeItemProviderSpec extends StereotypeApplicationChangeItemProvider implements IItemStyledLabelProvider {
/**
* This constructs an instance from a factory and a notifier.
@@ -77,60 +78,7 @@ public class StereotypeApplicationChangeItemProviderSpec extends StereotypeAppli
*/
@Override
public String getText(Object object) {
- final UMLDiff umlDiff = (UMLDiff)object;
-
- String remotely = "";
- if (umlDiff.getSource() == DifferenceSource.RIGHT) {
- remotely = "remotely ";
- }
-
- Stereotype stereotype = ((StereotypeApplicationChange)umlDiff).getStereotype();
- if (stereotype == null) {
- stereotype = UMLUtil.getStereotype(umlDiff.getDiscriminant());
- }
-
- final String stereotypeText;
- if (stereotype != null) {
- stereotypeText = AdapterFactoryUtil.getText(getRootAdapterFactory(), stereotype) + ' ';
- } else if (umlDiff.getDiscriminant() instanceof NamedElement) {
- stereotypeText = "Stereotype " + ((NamedElement)umlDiff.getDiscriminant()).getName() + ' ';
- } else {
- // Can't really do more
- stereotypeText = "Stereotype ";
- }
-
- final Match targetMatch = umlDiff.getMatch();
- final EObject target = findNonNullSide(targetMatch);
- String targetLabel = null;
-
- final String action;
- switch (umlDiff.getKind()) {
- case ADD:
- action = "applied";
- targetLabel = " to ";
- break;
- case DELETE:
- action = "unapplied";
- targetLabel = " from ";
- break;
- case CHANGE:
- action = "changed";
- targetLabel = " on ";
- break;
- case MOVE:
- action = "moved";
- targetLabel = " to ";
- break;
- default:
- throw new IllegalStateException("Unsupported " + DifferenceKind.class.getSimpleName()
- + " value: " + umlDiff.getKind());
- }
-
- if (target != null) {
- targetLabel += AdapterFactoryUtil.getText(getRootAdapterFactory(), target);
- }
-
- return stereotypeText + "has been " + remotely + action + targetLabel;
+ return getStyledText(object).getString();
}
/**
@@ -187,4 +135,58 @@ public class StereotypeApplicationChangeItemProviderSpec extends StereotypeAppli
return super.getForeground(object);
}
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.IItemStyledLabelProvider#getStyledText(java.lang.Object)
+ */
+ public StyledString getStyledText(Object object) {
+ final UMLDiff umlDiff = (UMLDiff)object;
+
+ Stereotype stereotype = ((StereotypeApplicationChange)umlDiff).getStereotype();
+ if (stereotype == null) {
+ stereotype = UMLUtil.getStereotype(umlDiff.getDiscriminant());
+ }
+
+ final StyledString stereotypeText = new StyledString();
+ if (stereotype != null) {
+ stereotypeText.append(AdapterFactoryUtil.getText(getRootAdapterFactory(), stereotype) + ' ');
+ } else if (umlDiff.getDiscriminant() instanceof NamedElement) {
+ stereotypeText.append("Stereotype " + ((NamedElement)umlDiff.getDiscriminant()).getName() + ' '); //$NON-NLS-1$
+ } else {
+ // Can't really do more
+ stereotypeText.append("Stereotype "); //$NON-NLS-1$
+ }
+
+ final Match targetMatch = umlDiff.getMatch();
+ final EObject target = findNonNullSide(targetMatch);
+ String targetLabel = null;
+
+ final String action;
+ switch (umlDiff.getKind()) {
+ case ADD:
+ action = "applied"; //$NON-NLS-1$
+ break;
+ case DELETE:
+ action = "unapplied"; //$NON-NLS-1$
+ break;
+ case CHANGE:
+ action = "changed"; //$NON-NLS-1$
+ break;
+ case MOVE:
+ action = "moved"; //$NON-NLS-1$
+ break;
+ default:
+ throw new IllegalStateException("Unsupported " + DifferenceKind.class.getSimpleName() //$NON-NLS-1$
+ + " value: " + umlDiff.getKind()); //$NON-NLS-1$
+ }
+
+ if (target != null) {
+ targetLabel += AdapterFactoryUtil.getText(getRootAdapterFactory(), target);
+ }
+
+ return stereotypeText
+ .append(" [" + targetLabel + " " + action + "]", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
}
diff --git a/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/provider/spec/UMLCompareAdapterFactorySpec.java b/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/provider/spec/UMLCompareAdapterFactorySpec.java
index 8ee7c9b..8a39717 100644
--- a/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/provider/spec/UMLCompareAdapterFactorySpec.java
+++ b/plugins/org.eclipse.emf.compare.uml2.edit/src/org/eclipse/emf/compare/uml2/provider/spec/UMLCompareAdapterFactorySpec.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.compare.uml2.provider.spec;
import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.compare.provider.IItemStyledLabelProvider;
import org.eclipse.emf.compare.uml2.provider.StereotypeApplicationChangeItemProvider;
import org.eclipse.emf.compare.uml2.provider.UMLCompareItemProviderAdapterFactory;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
@@ -48,6 +49,11 @@ public class UMLCompareAdapterFactorySpec extends UMLCompareItemProviderAdapterF
ForwardingUMLDiffItemProvider fSubstitutionChangeItemProvider;
+ public UMLCompareAdapterFactorySpec() {
+ super();
+ supportedTypes.add(IItemStyledLabelProvider.class);
+ }
+
/**
* {@inheritDoc}
*