Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » Customized EMF Comare UI(Creating our own EMF Compare UI)
Customized EMF Comare UI [message #1053697] Tue, 07 May 2013 09:36 Go to next message
Anuj Mehta is currently offline Anuj Mehta
Messages: 10
Registered: July 2009
Junior Member
Hi,

EMF Compare gives us standard UI where we can compare the structural differences of two EMF models.

In our use case we can't use this functionality because we are showing EMF model in the form based editor UI so if we need to compare two EMF models then we need to compare the two form based editors.

So couple of doubts ....

1. Is there any support available by which we can enhance the standard EMF compare UI?

2. Is it possible to feed the comparisons (after calling compare method from EMFCompare class of two EMF models) to this customized UI If not then how can we extract the useful data form comparisons and create our own UI out of it.



[Updated on: Tue, 07 May 2013 10:48]

Report message to a moderator

Re: Customized EMF Comare UI [message #1053724 is a reply to message #1053697] Tue, 07 May 2013 11:49 Go to previous messageGo to next message
Cedric Brun is currently offline Cedric Brun
Messages: 367
Registered: July 2009
Senior Member
1. Is there any support available by which we can enhance the standard EMF compare UI?

Depends on what you want to do, but the standard UI is using the Eclipse Compare standards, we are pretty much tied to the viewer. I don't think integrating form based editors would be easy

2. Is it possible to feed the comparisons (after calling compare method from EMFCompare class of two EMF models) to this customized UI If not then how can we extract the useful data form comparisons and create our own UI out of it.

Yes, the EMF Compare class will bring you back an EMF model representing the differences. (org.eclipse.emf.compare.Comparison) your editor can browse this data and use it to show the differences, for example org.eclipse.emf.compare.Comparison.getDifferences(EObject) will return the differences that are referencing the given EObject.
As a sidenote the Comparison model itself can be displayed using the classical ItemProvider/AdapterFactory pattern of EMF.


Re: Customized EMF Comare UI [message #1053880 is a reply to message #1053724] Wed, 08 May 2013 05:47 Go to previous messageGo to next message
Anuj Mehta is currently offline Anuj Mehta
Messages: 10
Registered: July 2009
Junior Member
Hi Cedric,
Thanks for sharing the valuable information on this topic.

Regarding to the first Question

Currently I have used following APIs

Factory fatory1 = FactoryImpl.init();
Action action1 = fatory1.createAction();
action1.setName("Action1");

EMFController emfModel1 = fatory1.createEMFController();
emfModel1.getActions().add(action1);

Method method1 = fatory1.createMethod();
method1.setName("Method1");
emfModel1.getMethods().add(method1);


Factory fatory2 = FactoryImpl.init();
Action action2 = fatory2.createAction();
action2.setName("Action2");

EMFController emfModel2 = fatory2.createEMFController();
emfModel2.getActions().add(action2);

Event event2 = fatory2.createEvent();
event2.setName("event2");
emfModel2.getEvents().add(event2);



IMatchEngine.Factory factory = new MatchEngineFactoryImpl(UseIdentifiers.NEVER);
IMatchEngine.Factory.Registry matchEngineRegistry = new MatchEngineFactoryRegistryImpl();
matchEngineRegistry .add(factory);
EMFCompare comparator = EMFCompare.builder().setMatchEngineFactoryRegistry(matchEngineRegistry).build();
Comparison comparison = comparator.compare(EMFCompare.createDefaultScope(emfModel1, emfModel2));


ICompareEditingDomain editingDomain = EMFCompareEditingDomain.create(emfModel1, emfModel2,emfModel1);
AdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
CompareEditorInput input = new ComparisonEditorInput(new CompareConfiguration(), comparison, editingDomain, adapterFactory);
CompareUI.openCompareEditor(input,true);

And the output is

Structure Compare

* EMFController
*[^] Action Action1
Action1[name changed]
*[-] Event event2[events delete]
*[+] Method Method1[methods add]

(Since cannot paste the image so showing by typing....)

This above structure compare suiting well in our use case but can be little enhanced...So couple of Doubts :

1. Currently Text Compare is empty what should be done extra in order to use this.

2. If we select any of the object in the Structure Compare nothing is shown in the properties view ...so how can we integrate properties view with this compare editor.

3. How can we change the icons of the different objects...Actually In our use case we have different icons for these objects.



[Updated on: Wed, 08 May 2013 05:50]

Report message to a moderator

Re: Customized EMF Comare UI [message #1057856 is a reply to message #1053880] Thu, 09 May 2013 10:57 Go to previous messageGo to next message
Anuj Mehta is currently offline Anuj Mehta
Messages: 10
Registered: July 2009
Junior Member
Regarding Doubts 1 and 2 I got the answer...after doing some exploration...

Doubt 3 is still there...Is it possible if we some how can extend the labelProvider??
Re: Customized EMF Comare UI [message #1058322 is a reply to message #1057856] Mon, 13 May 2013 14:48 Go to previous messageGo to next message
Mikael Barbero is currently offline Mikael Barbero
Messages: 53
Registered: July 2009
Member
Hi Anuj,

By default, the label provider is using standard EMF ItemProvider. These providers can be overridden through the org.eclipse.emf.compare.rcp.adapterFactory extension. Basically, it is the same extension point as the EMF one but takes a additional rank to let you override default and lower ranked item provider.

You have an example of how to use it in the org.eclipse.emf.compare.diagram.edit plugin.


Best regards,

Mikael Barbero
Obeo
Re: Customized EMF Comare UI [message #1059071 is a reply to message #1057856] Thu, 16 May 2013 14:03 Go to previous messageGo to next message
Anuj Mehta is currently offline Anuj Mehta
Messages: 10
Registered: July 2009
Junior Member
Hi Mikael,


I am able update the tree for Structure Compare section with our icons and I have used following extension point

<extension point="org.eclipse.emf.edit.itemProviderAdapterFactories">
<factory
uri="http://www.eclipse.org/emf/compare"
class="test.MyCompareItemProviderAdapterFactorySpec"
supportedTypes=
"org.eclipse.emf.edit.provider.IEditingDomainItemProvider
org.eclipse.emf.edit.provider.IStructuredItemContentProvider
org.eclipse.emf.edit.provider.ITreeItemContentProvider
org.eclipse.emf.edit.provider.IItemLabelProvider
org.eclipse.emf.edit.provider.IItemPropertySource
org.eclipse.emf.compare.provider.IItemStyledLabelProvider
org.eclipse.emf.compare.provider.IItemDescriptionProvider"/>
</extension>
here MyCompareItemProviderAdapterFactorySpec extends CompareItemProviderAdapterFactorySpec
and we are overriding MatchItemProviderSpec, ReferenceChangeItemProviderSpec, AttributeChangeItemProviderSpec and doing the initialisation under MyCompareItemProviderAdapterFactorySpec class

Is this correct and how do we set proper ranking here?

After doing this, we are able to change the icons for structure Compare Section but EMF model Compare Section (where actual comparison happen) still shows the default icons so what is the extension to update these icons too ?

Thanks for sharing the valuable information!

Best Regards,
Anuj





Re: Customized EMF Comare UI [message #1065135 is a reply to message #1057856] Mon, 24 June 2013 13:21 Go to previous message
Axel RICHARD is currently offline Axel RICHARD
Messages: 18
Registered: September 2010
Location: France
Junior Member
Hi Anuj,

You say in your previous message that you have an answer for this problem: "If we select any of the object in the Structure Compare nothing is shown in the properties view ...so how can we integrate properties view with this compare editor."

Could you tell me more about how solution did you use to solve the problem ?

Thanks,

Axel.


Axel Richard
Obeo

[Updated on: Mon, 24 June 2013 13:22]

Report message to a moderator

Previous Topic:UnmatchElement List vs total
Next Topic:CompareEditorInput
Goto Forum:
  


Current Time: Tue Sep 23 16:21:40 GMT 2014

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

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