Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » How to attach itemproviders to EMF Compare UI?
How to attach itemproviders to EMF Compare UI? [message #1281175] Mon, 31 March 2014 13:20 Go to next message
Anja Hansen is currently offline Anja HansenFriend
Messages: 10
Registered: March 2014
Junior Member

I am comparing two files containing values in a setup described by a EMF model.
The values are loaded into the EMF model and the "runtime model" is given to EMF Compare. It works fine.

My question is how do I define an item provider (to provide customized icons, text labels and background colour) to the EMF Compare UI?

In our model an ItemProvider has been generated for each type in the model, but I would like to keep the item provider for the compare-view separate from the rest of the application's UI. This means that I want EMF Compare to stop looking at the standard item providers for the object type, and in stead use a compare-item-provider shared by most/all compared types.

I have not been able to find any user-examples of this in the documentation or unit tests, but I have found several references to various solutions, but none of them in enough detail that I have been able to reproduce them...

1. Should I use CompareConfiguration.setLabelProvider(ICompareInput, ICompareInputLabelProvider)? If so how do I get a compareInput? Can I get it from my Comparison or ??

2. Should I extend AdapterFactoryLabelProvider? If so, how do I connect this label provider or its adapter factory to the UI?

3. Should I extend CompareItemProviderAdapterFactorySpec and MatchItemProviderSpec as described in this old guide:
But then again how do I connect the resulting itemprovider with the UI?

I'm working based on the sample code from the EMF Compare Developer Guide and How To Open Compare Dialog.

Re: How to attach itemproviders to EMF Compare UI? [message #1281199 is a reply to message #1281175] Mon, 31 March 2014 14:07 Go to previous messageGo to next message
Mikael Barbero is currently offline Mikael BarberoFriend
Messages: 55
Registered: July 2009
Hi Anja,

You should subclass the item provider adapter factory (IPAF) generated by EMF and create specializations of the item providers of the elements you want to customize. This new IPAF should then be registered to the extension point "org.eclipse.emf.edit.itemProviderAdapterFactories"

I suggest you have a look at the class DiagramCompareItemProviderAdapterFactorySpec in the bundle We overrode the item providers of the GMF notation model to customize the way they are displayed in EMF Compare. This item provider adapter factory is registered through the extension point "org.eclipse.emf.edit.itemProviderAdapterFactories". This extension point will make the connection to UI by itself. You don't need to do anything else.


You should be able to customize the way your model elements are displayed in EMF Compare by doing something similar.

To be complete, here are answers to your questions:
1) No, this label provider is for the Compare Editor and various labels that displayed around the tree viewers (name of the resources etc.).
2) No, you don't have access to the location where it is bound to the viewer anyway.
3) The solution I propose above is similar to the one you found on the wiki except that in my solution you don't have to customize how the changes are displayed, only how your elements are displayed.

Feel free to ask more questions if it is still not clear.

Re: How to attach itemproviders to EMF Compare UI? [message #1281804 is a reply to message #1281199] Tue, 01 April 2014 11:34 Go to previous message
Anja Hansen is currently offline Anja HansenFriend
Messages: 10
Registered: March 2014
Junior Member
Hi Mikael

Thank you for your quick reply.
After having looked some more on the code of the project that I have just started on, I can see that I need some more knowledge om EMF in general before I can hope to zigzag my way between the existing project code and EMF Compare.
The existing code already uses the extension point that you mention for other views in the application.

What I really looked for is something like the AttributeChangeItemProviderSpec does (combining model & Diff item provider functionality). Exept that I would like to use a model-item provider different from the standard one to keep things isolated. I'll probably get back to you when I'm more clear on what is possible and what is not Wink
Previous Topic:Export Comparison
Next Topic:Best way to combine two attribute changes into a high-level atomic one
Goto Forum:

Current Time: Sat Oct 23 09:24:53 GMT 2021

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

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

Back to the top