Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » Customize EMF compare - Match phase.
Customize EMF compare - Match phase. [message #1411102] Fri, 22 August 2014 11:47
Bhushan Patil is currently offline Bhushan PatilFriend
Messages: 10
Registered: February 2014
Junior Member
Hi,

I want to customize EMF Compare mechanism.
My requirement is - Objects should be matched through their name only and should not use default logic (which is provided by EMF compare to match resources).

As per developer guide we can do this by following code:

Function<EObject, String> idFunction === new Function<EObject, String>() {
public String apply(EObject input) {
if (input instanceof MyEObject) {
return ((MyEObject)input).getName();
}
// a null return here tells the match engine to fall back to the other matchers
return null;
}
};
// Using this matcher as fall back, EMF Compare will still search for XMI IDs on EObjects
// for which we had no custom id function.
IEObjectMatcher fallBackMatcher === DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.WHEN_AVAILABLE);
IEObjectMatcher customIDMatcher === new IdentifierEObjectMatcher(fallBackMatcher, idFunction);

IComparisonFactory comparisonFactory === new DefaultComparisonFactory(new DefaultEqualityHelperFactory());

IMatchEngine matchEngine === new DefaultMatchEngine(customIDMatcher, comparisonFactory);
IMatchEngine.Factory.Registry registry === MatchEngineFactoryRegistryImpl.createStandaloneInstance();
// for OSGi (IDE, RCP) usage
// IMatchEngine.Factory.Registry registry === EMFCompareRCPPlugin.getMatchEngineFactoryRegistry();
engineFactory.setRanking(20); // default engine ranking is 10, must be higher to override.
registry.add(engineFactory);
EMFCompare.builder().setMatchEngineFactoryRegistry(registry).build().compare(scope);

My questions are -

1) How can I plug this code in existing EMF compare mechanism?
2) Do I need to create separate menu same as (Compare with -> Each Other) and invoke this code using the menu?
3) Is it possible to plug this code using extension points?
4) If possible then what are those extension points?

Please suggest.

[Updated on: Fri, 22 August 2014 11:47]

Report message to a moderator

Previous Topic:How to compare more than two Eobjects using EMF compare
Next Topic:Refactoring idea for org.eclipse.compare.CompareEditorInput?
Goto Forum:
  


Current Time: Wed Jan 17 01:50:40 GMT 2018

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

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