Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » equalityHelperExtensionProvider extension point ignored
equalityHelperExtensionProvider extension point ignored [message #1834473] Tue, 10 November 2020 23:50 Go to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 402
Registered: March 2011
Senior Member
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 [message #1834695 is a reply to message #1834473] Mon, 16 November 2020 10:02 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1893
Registered: July 2009
Senior Member
Hello,

The equalityHelperExtensionProvider is not meant for use to replace the equality helper, but to add new kind of mapping rules to it. There are currently no extension point to completely replace the equality helper, but you could go the long way and replace the match engine by your own (org.eclipse.emf.compare.rcp.matchEngine extension point). You can simply provide your own MatchEngine.Factory with a higher ranking than the default and change the equality helper we're using to create it. Overriding org.eclipse.emf.compare.match.impl.MatchEngineFactoryImpl and changing the org.eclipse.emf.compare.match.impl.MatchEngineFactoryImpl.getMatchEngine() implementation should get you the expected result.

Regards,

Laurent Goubet
Obeo
Re: equalityHelperExtensionProvider extension point ignored [SOLVED] [message #1834707 is a reply to message #1834695] Mon, 16 November 2020 16:05 Go to previous message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 402
Registered: March 2011
Senior Member
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.
Previous Topic:Maven for EMF Compare
Next Topic:Crossover operation by EMF Compare
Goto Forum:
  


Current Time: Tue Aug 03 11:58:24 GMT 2021

Powered by FUDForum. Page generated in 0.02143 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top