equalityHelperExtensionProvider extension point ignored [message #1834473] |
Tue, 10 November 2020 18:50  |
Eclipse User |
|
|
|
Hi. I'm trying to override the Default EqualityHelper, so I attempted to use the equalityHelperExtensionProvider extension point in org.eclipse.emf.compare.rcp but the class I defined associated with this extension point never gets used. in spiute of the fact that I gave it a very high ranking. I'm using the DefaultMatchEngine. Is this a bug or is there another way to override the EqualityHelper?
I looked at the solution described in https://www.eclipse.org/emf/compare/documentation/latest/FAQ.html which creates a new MatchEngine with a new ComparisonFactory, but the problem is that the last line is
Comparison comparison = EMFCompare.builder().setMatchEngine(new DefaultMatchEngine(DefaultMatchEngine
.createDefaultEObjectMatcher(UseIdentifiers.WHEN_AVAILABLE), comparisonFactory)).build().compare(scope);
which means that you have to call the compare method yourself, but I need a solution which uses the existing UI actions already integrated with EGit, which call the compare method.
In short, is there a way to override the EqualityHelper that doesn't require me to create my own new UI actions or EGit integration?
Thanks
PS: I'm using EMF Compare 3.3.7 on Papyrus 4.4 2019-06.
|
|
|
|
Re: equalityHelperExtensionProvider extension point ignored [SOLVED] [message #1834707 is a reply to message #1834695] |
Mon, 16 November 2020 11:05  |
Eclipse User |
|
|
|
Thanks Laurent.
Indeed, overriding the MatchEngineFactory does work.
My solution is as follows:
public class MyMatchEngineFactory extends MatchEngineFactoryImpl {
public MyMatchEngineFactory() {
super(DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.WHEN_AVAILABLE),
makeComparisonFactory());
}
private static IComparisonFactory makeComparisonFactory() {
return new DefaultComparisonFactory(makeEqualityHelper());
}
private static IEqualityHelperFactory makeEqualityHelper() {
return new DefaultEqualityHelperFactory() {
@Override
public IEqualityHelper createEqualityHelper() {
final LoadingCache<EObject, URI> cache = EqualityHelper.createDefaultCache(getCacheBuilder());
return new EqualityHelper(cache) {
@Override
public boolean matchingValues(Object object1, Object object2) {
// My custom code
return match;
}
};
}
};
}
}
and in the corresponding plugin.xml:
<extension
point="org.eclipse.emf.compare.rcp.matchEngine">
<engineFactory
class="my.plugin.MyMatchEngineFactory"
label="My Match Engine"
ranking="20">
</engineFactory>
PS: It would be nice to have a simpler way to override the EqualityHelper.
|
|
|
Powered by
FUDForum. Page generated in 0.05929 seconds