Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2016-10-20 12:08:08 -0400
committerAxel Richard2016-10-24 03:16:42 -0400
commit95ea7167697dd565e3ca2e8c4bc7d7078bd348c7 (patch)
tree9a060503e7fe890f5d85cb43a84b7c4dcf9d8aac
parent99e8fb56b9bab8f8f58ba0b766b0b5e7132b9d6f (diff)
downloadorg.eclipse.emf.compare-95ea7167697dd565e3ca2e8c4bc7d7078bd348c7.tar.gz
org.eclipse.emf.compare-95ea7167697dd565e3ca2e8c4bc7d7078bd348c7.tar.xz
org.eclipse.emf.compare-95ea7167697dd565e3ca2e8c4bc7d7078bd348c7.zip
[506299] Match Node displays "Match" after merge
Use new adapter MatchOfContainmentDiffAdapter to retrieve significant label after a merge that leads to delete related object. Bug: 506299 Change-Id: I0c027dc641552877f3758086cfb3c0ef537b0c20 Signed-off-by: Axel Richard <axel.richard@obeo.fr>
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchItemProviderSpec.java34
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/ReferenceChangeItemProviderSpec.java15
2 files changed, 47 insertions, 2 deletions
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 85829049c..c4ec8cc9a 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
@@ -12,8 +12,11 @@ package org.eclipse.emf.compare.provider.spec;
import static com.google.common.base.Strings.isNullOrEmpty;
+import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.compare.Match;
+import org.eclipse.emf.compare.ReferenceChange;
+import org.eclipse.emf.compare.match.MatchOfContainmentReferenceChangeAdapter;
import org.eclipse.emf.compare.match.impl.NotLoadedFragmentMatch;
import org.eclipse.emf.compare.provider.IItemDescriptionProvider;
import org.eclipse.emf.compare.provider.IItemStyledLabelProvider;
@@ -21,6 +24,7 @@ import org.eclipse.emf.compare.provider.ISemanticObjectLabelProvider;
import org.eclipse.emf.compare.provider.MatchItemProvider;
import org.eclipse.emf.compare.provider.utils.ComposedStyledString;
import org.eclipse.emf.compare.provider.utils.IStyledString;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator;
/**
@@ -71,6 +75,18 @@ public class MatchItemProviderSpec extends MatchItemProvider implements IItemSty
}
if (ret == null) {
+ Adapter adapter = EcoreUtil.getAdapter(match.eAdapters(),
+ MatchOfContainmentReferenceChangeAdapter.class);
+ if (adapter instanceof MatchOfContainmentReferenceChangeAdapter) {
+ ReferenceChange referenceChange = ((MatchOfContainmentReferenceChangeAdapter)adapter)
+ .getReferenceChange();
+ if (referenceChange != null) {
+ ret = itemDelegator.getImage(referenceChange.getValue());
+ }
+ }
+ }
+
+ if (ret == null) {
ret = super.getImage(object);
}
@@ -106,7 +122,23 @@ public class MatchItemProviderSpec extends MatchItemProvider implements IItemSty
ret += " (" + name + ")"; //$NON-NLS-1$ //$NON-NLS-2$
}
} else {
- ret = super.getText(object);
+ Adapter matchAdapter = EcoreUtil.getAdapter(match.eAdapters(),
+ MatchOfContainmentReferenceChangeAdapter.class);
+ if (matchAdapter instanceof MatchOfContainmentReferenceChangeAdapter) {
+ ReferenceChange referenceChange = ((MatchOfContainmentReferenceChangeAdapter)matchAdapter)
+ .getReferenceChange();
+ Adapter rcAdapter = null;
+ if (referenceChange != null) {
+ rcAdapter = EcoreUtil.getAdapter(referenceChange.eAdapters(),
+ ReferenceChangeItemProviderSpec.class);
+ }
+ if (rcAdapter instanceof ReferenceChangeItemProviderSpec) {
+ ret = ((ReferenceChangeItemProviderSpec)rcAdapter).getValueText(referenceChange);
+ }
+ }
+ if (isNullOrEmpty(ret)) {
+ ret = super.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 2fc853c5f..ac849b6fb 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2015 Obeo.
+ * Copyright (c) 2012, 2016 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
@@ -69,6 +69,19 @@ public class ReferenceChangeItemProviderSpec extends ReferenceChangeItemProvider
/**
* {@inheritDoc}
*
+ * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#isAdapterForType(Object)
+ */
+ @Override
+ public boolean isAdapterForType(Object type) {
+ if (type == ReferenceChangeItemProviderSpec.class) {
+ return true;
+ }
+ return super.isAdapterForType(type);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.eclipse.emf.compare.provider.ReferenceChangeItemProvider#getText(java.lang.Object)
*/
@Override

Back to the top