summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2013-01-29 09:24:50 (EST)
committer Axel Richard2013-01-30 09:16:25 (EST)
commiteac77a2364f2ce1aa2eae66bf6e5f432031df229 (patch)
tree408c534378c1daa35e0e2a230881c28c729c5bc1
parent1ec1442bda02cacf1332fc94def28214856e25cb (diff)
downloadorg.eclipse.emf.compare-eac77a2364f2ce1aa2eae66bf6e5f432031df229.zip
org.eclipse.emf.compare-eac77a2364f2ce1aa2eae66bf6e5f432031df229.tar.gz
org.eclipse.emf.compare-eac77a2364f2ce1aa2eae66bf6e5f432031df229.tar.bz2
[399456] Managed enhance readability of Resource Attachment Change forrefs/changes/37/10037/2
the structural differences. Change-Id: Idfd6a115f4be608febe66f19639273c6e23e179c
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/CompareItemProviderAdapterFactorySpec.java240
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ComparisonItemProviderSpec.java219
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ResourceAttachmentChangeItemProviderSpec.java178
3 files changed, 423 insertions, 214 deletions
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 28834d7..eb272fc 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
@@ -1,113 +1,127 @@
-/*******************************************************************************
- * 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.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;
-
-/**
- * Specialized {@link CompareItemProviderAdapterFactory} returning ItemProviderAdapter with nice
- * {@link IItemLabelProvider#getText(Object)} and {@link IItemLabelProvider#getImage(Object)}.
- *
- * @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
- */
-public class CompareItemProviderAdapterFactorySpec extends CompareItemProviderAdapterFactory {
-
- public CompareItemProviderAdapterFactorySpec() {
- super();
- supportedTypes.add(IItemStyledLabelProvider.class);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.compare.provider.CompareItemProviderAdapterFactory#createMatchAdapter()
- */
- @Override
- public Adapter createMatchAdapter() {
- if (matchItemProvider == null) {
- matchItemProvider = new MatchItemProviderSpec(this);
- }
-
- return matchItemProvider;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.compare.provider.CompareItemProviderAdapterFactory#createReferenceChangeAdapter()
- */
- @Override
- public Adapter createReferenceChangeAdapter() {
- if (referenceChangeItemProvider == null) {
- referenceChangeItemProvider = new ReferenceChangeItemProviderSpec(this);
- }
-
- return referenceChangeItemProvider;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.compare.provider.CompareItemProviderAdapterFactory#createAttributeChangeAdapter()
- */
- @Override
- public Adapter createAttributeChangeAdapter() {
- if (attributeChangeItemProvider == null) {
- attributeChangeItemProvider = new AttributeChangeItemProviderSpec(this);
- }
-
- return attributeChangeItemProvider;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.compare.provider.CompareItemProviderAdapterFactory#createMatchResourceAdapter()
- */
- @Override
- public Adapter createMatchResourceAdapter() {
- if (matchResourceItemProvider == null) {
- matchResourceItemProvider = new MatchResourceItemProviderSpec(this);
- }
- return matchResourceItemProvider;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.compare.provider.CompareItemProviderAdapterFactory#createComparisonAdapter()
- */
- @Override
- public Adapter createComparisonAdapter() {
- if (comparisonItemProvider == null) {
- comparisonItemProvider = new ComparisonItemProviderSpec(this);
- }
-
- return comparisonItemProvider;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.compare.provider.CompareItemProviderAdapterFactory#createConflictAdapter()
- */
- @Override
- public Adapter createConflictAdapter() {
- if (conflictItemProvider == null) {
- conflictItemProvider = new ConflictItemProviderSpec(this);
- }
-
- return conflictItemProvider;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 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.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;
+
+/**
+ * Specialized {@link CompareItemProviderAdapterFactory} returning ItemProviderAdapter with nice
+ * {@link IItemLabelProvider#getText(Object)} and {@link IItemLabelProvider#getImage(Object)}.
+ *
+ * @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
+ */
+public class CompareItemProviderAdapterFactorySpec extends CompareItemProviderAdapterFactory {
+
+ public CompareItemProviderAdapterFactorySpec() {
+ super();
+ supportedTypes.add(IItemStyledLabelProvider.class);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.CompareItemProviderAdapterFactory#createMatchAdapter()
+ */
+ @Override
+ public Adapter createMatchAdapter() {
+ if (matchItemProvider == null) {
+ matchItemProvider = new MatchItemProviderSpec(this);
+ }
+
+ return matchItemProvider;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.CompareItemProviderAdapterFactory#createReferenceChangeAdapter()
+ */
+ @Override
+ public Adapter createReferenceChangeAdapter() {
+ if (referenceChangeItemProvider == null) {
+ referenceChangeItemProvider = new ReferenceChangeItemProviderSpec(this);
+ }
+
+ return referenceChangeItemProvider;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.CompareItemProviderAdapterFactory#createAttributeChangeAdapter()
+ */
+ @Override
+ public Adapter createAttributeChangeAdapter() {
+ if (attributeChangeItemProvider == null) {
+ attributeChangeItemProvider = new AttributeChangeItemProviderSpec(this);
+ }
+
+ return attributeChangeItemProvider;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.CompareItemProviderAdapterFactory#createMatchResourceAdapter()
+ */
+ @Override
+ public Adapter createMatchResourceAdapter() {
+ if (matchResourceItemProvider == null) {
+ matchResourceItemProvider = new MatchResourceItemProviderSpec(this);
+ }
+ return matchResourceItemProvider;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.CompareItemProviderAdapterFactory#createComparisonAdapter()
+ */
+ @Override
+ public Adapter createComparisonAdapter() {
+ if (comparisonItemProvider == null) {
+ comparisonItemProvider = new ComparisonItemProviderSpec(this);
+ }
+
+ return comparisonItemProvider;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.CompareItemProviderAdapterFactory#createConflictAdapter()
+ */
+ @Override
+ public Adapter createConflictAdapter() {
+ if (conflictItemProvider == null) {
+ conflictItemProvider = new ConflictItemProviderSpec(this);
+ }
+
+ return conflictItemProvider;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.CompareItemProviderAdapterFactory#createResourceAttachmentChangeAdapter()
+ */
+ @Override
+ public Adapter createResourceAttachmentChangeAdapter() {
+ if (resourceAttachmentChangeItemProvider == null) {
+ resourceAttachmentChangeItemProvider = new ResourceAttachmentChangeItemProviderSpec(this);
+ }
+
+ return resourceAttachmentChangeItemProvider;
+ }
+}
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 e2f9e35..9caf4a0 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
@@ -1,101 +1,118 @@
-/*******************************************************************************
- * 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.spec;
-
-import static com.google.common.collect.Iterables.concat;
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.collect.Iterables.isEmpty;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-
-import java.util.Collection;
-
-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.compare.provider.utils.ComposedStyledString;
-import org.eclipse.emf.compare.provider.utils.IStyledString;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
-
-/**
- * @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
- */
-public class ComparisonItemProviderSpec extends ComparisonItemProvider implements IItemStyledLabelProvider {
-
- /**
- * @param adapterFactory
- */
- public ComparisonItemProviderSpec(AdapterFactory adapterFactory) {
- super(adapterFactory);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getChildren(java.lang.Object)
- */
- @Override
- public Collection<?> getChildren(Object object) {
- Comparison comparison = (Comparison)object;
- return ImmutableList.copyOf(getChildrenIterable(comparison));
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#hasChildren(java.lang.Object)
- */
- @Override
- public boolean hasChildren(Object object) {
- Comparison comparison = (Comparison)object;
- return !isEmpty(getChildrenIterable(comparison));
- }
-
- private Iterable<EObject> getChildrenIterable(Comparison comparison) {
- Iterable<Match> match = getNonEmptyMatches(comparison);
- return concat(match, comparison.getMatchedResources());
- }
-
- private Iterable<Match> getNonEmptyMatches(Comparison comparison) {
- Iterable<Match> match = filter(comparison.getMatches(), new Predicate<Match>() {
- public boolean apply(Match input) {
- final boolean ret;
- IEditingDomainItemProvider editingDomainItemProvider = (IEditingDomainItemProvider)adapterFactory
- .adapt(input, IEditingDomainItemProvider.class);
-
- if (editingDomainItemProvider instanceof MatchItemProviderSpec) {
- ret = !isEmpty(((MatchItemProviderSpec)editingDomainItemProvider)
- .getChildrenIterable(input));
- } else if (editingDomainItemProvider != null) {
- ret = !editingDomainItemProvider.getChildren(input).isEmpty();
- } else {
- ret = false;
- }
-
- return ret;
- }
- });
- return match;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.compare.provider.IItemStyledLabelProvider#getStyledText(java.lang.Object)
- */
- public IStyledString.IComposedStyledString getStyledText(Object object) {
- return new ComposedStyledString(getText(object));
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 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.spec;
+
+import static com.google.common.collect.Iterables.concat;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.isEmpty;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.Match;
+import org.eclipse.emf.compare.ResourceAttachmentChange;
+import org.eclipse.emf.compare.provider.ComparisonItemProvider;
+import org.eclipse.emf.compare.provider.IItemStyledLabelProvider;
+import org.eclipse.emf.compare.provider.utils.ComposedStyledString;
+import org.eclipse.emf.compare.provider.utils.IStyledString;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+
+/**
+ * @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
+ */
+public class ComparisonItemProviderSpec extends ComparisonItemProvider implements IItemStyledLabelProvider {
+
+ /**
+ * @param adapterFactory
+ */
+ public ComparisonItemProviderSpec(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getChildren(java.lang.Object)
+ */
+ @Override
+ public Collection<?> getChildren(Object object) {
+ Comparison comparison = (Comparison)object;
+ return ImmutableList.copyOf(getChildrenIterable(comparison));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#hasChildren(java.lang.Object)
+ */
+ @Override
+ public boolean hasChildren(Object object) {
+ Comparison comparison = (Comparison)object;
+ return !isEmpty(getChildrenIterable(comparison));
+ }
+
+ private Iterable<EObject> getChildrenIterable(Comparison comparison) {
+ Iterable<? extends EObject> matches = getNonEmptyMatches(comparison);
+ List<EObject> children = Lists.newArrayList(matches);
+ for (EObject match : matches) {
+ EList<Diff> differences = ((Match)match).getDifferences();
+ Iterable<ResourceAttachmentChange> resourcesAttachmentChanges = filter(differences,
+ ResourceAttachmentChange.class);
+ if (!isEmpty(resourcesAttachmentChanges)) {
+ children.remove(match);
+ Iterables.addAll(children, resourcesAttachmentChanges);
+ }
+ }
+
+ return concat(children, comparison.getMatchedResources());
+ }
+
+ private Iterable<Match> getNonEmptyMatches(Comparison comparison) {
+ Iterable<Match> match = filter(comparison.getMatches(), new Predicate<Match>() {
+ public boolean apply(Match input) {
+ final boolean ret;
+ IEditingDomainItemProvider editingDomainItemProvider = (IEditingDomainItemProvider)adapterFactory
+ .adapt(input, IEditingDomainItemProvider.class);
+
+ if (editingDomainItemProvider instanceof MatchItemProviderSpec) {
+ ret = !isEmpty(((MatchItemProviderSpec)editingDomainItemProvider)
+ .getChildrenIterable(input));
+ } else if (editingDomainItemProvider != null) {
+ ret = !editingDomainItemProvider.getChildren(input).isEmpty();
+ } else {
+ ret = false;
+ }
+
+ return ret;
+ }
+ });
+ return match;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.IItemStyledLabelProvider#getStyledText(java.lang.Object)
+ */
+ public IStyledString.IComposedStyledString getStyledText(Object object) {
+ return new ComposedStyledString(getText(object));
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ResourceAttachmentChangeItemProviderSpec.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ResourceAttachmentChangeItemProviderSpec.java
new file mode 100644
index 0000000..adc955c
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ResourceAttachmentChangeItemProviderSpec.java
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.spec;
+
+import static com.google.common.base.Predicates.not;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Lists.newArrayList;
+
+import com.google.common.collect.ImmutableCollection;
+import com.google.common.collect.ImmutableList;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.compare.DifferenceKind;
+import org.eclipse.emf.compare.Match;
+import org.eclipse.emf.compare.ResourceAttachmentChange;
+import org.eclipse.emf.compare.provider.AdapterFactoryUtil;
+import org.eclipse.emf.compare.provider.IItemStyledLabelProvider;
+import org.eclipse.emf.compare.provider.ResourceAttachmentChangeItemProvider;
+import org.eclipse.emf.compare.provider.utils.ComposedStyledString;
+import org.eclipse.emf.compare.provider.utils.IStyledString.IComposedStyledString;
+import org.eclipse.emf.compare.provider.utils.IStyledString.Style;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+
+/**
+ * Specialized {@link ResourceAttachmentChangeItemProvider} returning nice output for {@link #getText(Object)}
+ * and {@link #getImage(Object)}.
+ *
+ * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
+ * @since 3.0
+ */
+public class ResourceAttachmentChangeItemProviderSpec extends ResourceAttachmentChangeItemProvider implements IItemStyledLabelProvider {
+
+ private final OverlayImageProvider overlayProvider;
+
+ /**
+ * Constructor calling super {@link #ResourceAttachmentChangeItemProvider(AdapterFactory)}.
+ *
+ * @param adapterFactory
+ * The adapter factory.
+ */
+ public ResourceAttachmentChangeItemProviderSpec(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ overlayProvider = new OverlayImageProvider(getResourceLocator(), true);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.ResourceAttachmentChangeItemProvider#getChildren(java.lang.Object)
+ */
+ @Override
+ public Collection<?> getChildren(Object object) {
+ Collection<?> superChildren = super.getChildren(object);
+ List<? super Object> ret = newArrayList(superChildren);
+
+ ResourceAttachmentChange resourceAttachmentChange = (ResourceAttachmentChange)object;
+ final EObject value;
+ switch (resourceAttachmentChange.getSource()) {
+ case LEFT:
+ value = resourceAttachmentChange.getMatch().getLeft();
+ break;
+ case RIGHT:
+ value = resourceAttachmentChange.getMatch().getRight();
+ break;
+ default:
+ value = null;
+ new IllegalStateException();
+ break;
+ }
+
+ Match matchOfValue = resourceAttachmentChange.getMatch().getComparison().getMatch(value);
+ if (matchOfValue != null) {
+ Collection<?> children = getChildren(matchOfValue);
+ children.remove(resourceAttachmentChange);
+ ret.addAll(children);
+ }
+
+ return ImmutableList.copyOf(filter(ret, not(MatchItemProviderSpec.REFINED_DIFF)));
+ }
+
+ private Collection<?> getChildren(Match matchOfValue) {
+ final Collection<?> children;
+ ITreeItemContentProvider matchItemContentProvider = (ITreeItemContentProvider)adapterFactory.adapt(
+ matchOfValue, ITreeItemContentProvider.class);
+ if (matchItemContentProvider != null) {
+ Collection<?> itemProviderChildren = matchItemContentProvider.getChildren(matchOfValue);
+ if (itemProviderChildren instanceof ImmutableCollection<?>) {
+ children = newArrayList(itemProviderChildren);
+ } else {
+ children = itemProviderChildren;
+ }
+
+ Iterator<?> childrenIterator = children.iterator();
+ while (childrenIterator.hasNext()) {
+ Object child = childrenIterator.next();
+ if (child instanceof Match) {
+ if (!matchItemContentProvider.hasChildren(child)) {
+ childrenIterator.remove();
+ }
+ }
+
+ }
+ } else {
+ children = ImmutableList.of();
+ }
+ return children;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.MatchItemProvider#getImage(java.lang.Object)
+ */
+ @Override
+ public Object getImage(Object object) {
+ final Match match = ((ResourceAttachmentChange)object).getMatch();
+ Object ret = AdapterFactoryUtil.getImage(getRootAdapterFactory(), match.getLeft());
+ if (ret == null) {
+ ret = AdapterFactoryUtil.getImage(getRootAdapterFactory(), match.getRight());
+ }
+ if (ret == null) {
+ ret = AdapterFactoryUtil.getImage(getRootAdapterFactory(), match.getOrigin());
+ }
+ if (ret == null) {
+ ret = super.getImage(object);
+ }
+
+ Object matchImage = overlayProvider.getComposedImage(match, ret);
+ ret = overlayImage(object, matchImage);
+
+ return ret;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.ResourceAttachmentChangeItemProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText(Object object) {
+ return getStyledText(object).getString();
+ }
+
+ public IComposedStyledString getStyledText(Object object) {
+ final Match match = ((ResourceAttachmentChange)object).getMatch();
+ String value = AdapterFactoryUtil.getText(getRootAdapterFactory(), match.getLeft());
+ if (value == null) {
+ value = AdapterFactoryUtil.getText(getRootAdapterFactory(), match.getRight());
+ }
+ if (value == null) {
+ value = AdapterFactoryUtil.getText(getRootAdapterFactory(), match.getOrigin());
+ }
+ if (value == null) {
+ value = super.getText(object);
+ }
+
+ ComposedStyledString ret = new ComposedStyledString(value);
+
+ DifferenceKind labelValue = ((ResourceAttachmentChange)object).getKind();
+ String label = labelValue == null ? "" : labelValue.toString().toLowerCase(); //$NON-NLS-1$
+
+ return ret.append(" [resource contents " + label + "]", Style.DECORATIONS_STYLER); //$NON-NLS-1$ //$NON-NLS-2$
+
+ }
+}