Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikaël Barbero2013-01-31 08:12:57 -0500
committerMikaël Barbero2013-02-01 09:16:17 -0500
commitd51787da4fee8e8014cbcd78c1615ed34c1135b8 (patch)
tree4970d4967c9287a3dfc700dffd3ee95607146a53
parent01c0f09b07c9b54f71fb0bd1c5005a532e2034cd (diff)
downloadorg.eclipse.emf.compare-d51787da4fee8e8014cbcd78c1615ed34c1135b8.tar.gz
org.eclipse.emf.compare-d51787da4fee8e8014cbcd78c1615ed34c1135b8.tar.xz
org.eclipse.emf.compare-d51787da4fee8e8014cbcd78c1615ed34c1135b8.zip
add image for MatchedResource objects that use the provider of the first
non null resource between left, right and origin. fix the too eager common suffix computation on resourceURI. add the origin uri in the label now that we strip the suffix.
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchResourceItemProviderSpec.java53
1 files changed, 46 insertions, 7 deletions
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 2027633a7..828c03484 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
@@ -11,11 +11,14 @@
package org.eclipse.emf.compare.provider.spec;
import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.MatchResource;
import org.eclipse.emf.compare.provider.IItemStyledLabelProvider;
import org.eclipse.emf.compare.provider.MatchResourceItemProvider;
import org.eclipse.emf.compare.provider.utils.ComposedStyledString;
import org.eclipse.emf.compare.provider.utils.IStyledString;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
/**
* Specialized {@link MatchResourceItemProvider} returning nice output for {@link #getText(Object)} and
@@ -56,16 +59,46 @@ public class MatchResourceItemProviderSpec extends MatchResourceItemProvider imp
if (rightURI != null) {
text += rightURI.substring(commonBase.length());
}
- // TODO is that really useful info?
- // if (matchResource.eContainer() instanceof Comparison
- // && ((Comparison)matchResource.eContainer()).isThreeWay()) {
- // final String originURI = matchResource.getOriginURI();
- // text += " (" + originURI + ")";
- // }
+ if (matchResource.eContainer() instanceof Comparison
+ && ((Comparison)matchResource.eContainer()).isThreeWay()) {
+ final String originURI = matchResource.getOriginURI();
+ text += " (" + originURI.substring(commonBase.length()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
return text;
}
/**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.provider.MatchResourceItemProvider#getImage(java.lang.Object)
+ */
+ @Override
+ public Object getImage(Object object) {
+ final MatchResource matchResource = (MatchResource)object;
+ Resource resource = matchResource.getLeft();
+ if (resource == null) {
+ resource = matchResource.getRight();
+ if (resource == null) {
+ resource = matchResource.getOrigin();
+ }
+ }
+
+ if (resource != null) {
+ IItemLabelProvider itemLabelProvider = (IItemLabelProvider)getRootAdapterFactory().adapt(
+ resource, IItemLabelProvider.class);
+
+ Object image = itemLabelProvider.getImage(resource);
+ if (image != null) {
+ return image;
+ } else {
+ return super.getImage(object);
+ }
+ } else {
+ return super.getImage(object);
+ }
+ }
+
+ /**
* Returns the longest common starting substring of the two given strings.
*
* @param left
@@ -83,9 +116,15 @@ public class MatchResourceItemProviderSpec extends MatchResourceItemProvider imp
final char[] rightChars = right.toCharArray();
final StringBuilder buffer = new StringBuilder();
+ StringBuilder fragmentBuffer = new StringBuilder();
for (int i = 0; i < Math.min(leftChars.length, rightChars.length); i++) {
if (leftChars[i] == rightChars[i]) {
- buffer.append(leftChars[i]);
+ fragmentBuffer.append(leftChars[i]);
+
+ if (leftChars[i] == '\\' || leftChars[i] == '/') {
+ buffer.append(fragmentBuffer);
+ fragmentBuffer = new StringBuilder();
+ }
} else {
break;
}

Back to the top