Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF Compare] Migration from version 1.3 to 2.1(R4E Using EMF Compare 2.1)
[EMF Compare] Migration from version 1.3 to 2.1 [message #1008230] Mon, 11 February 2013 16:16 Go to next message
Jacques Bouthillier is currently offline Jacques BouthillierFriend
Messages: 5
Registered: May 2011
Junior Member
Hi,
You wrote 2 classes in R4E ( R4EUIModelPosition.java and UIEMFCompareUtils.java).
R4E was using EMF compare version 1.3.1. We are in the process to migrate and use EMF compare 2.1.
When upgrading the dependencies to use EMF compare 2.1, I discovered the following packages does not exist anymore.

Those 2 classes were using:

org.eclipse.emf.compare.ui_1.3.1 for
org.eclipse.emf.compare.ui.internal.ModelComparator ()
org.eclipse.emf.compare.ui.ModelCompareInput ()
org.eclipse.emf.compare.ui.services.CompareServices ()


org.eclipse.emf.compare.diff_1.3.1 for
org.eclipse.emf.compare.diff.metamodel.ComparisonSnapshot ()
org.eclipse.emf.compare.diff.metamodel.ComparisonResourceSnapshot()

org.eclipse.emf.compare.diagram_1.3.1 for
org.eclipse.emf.compare.diagram.diff.util.DiffUtil.getElement()

org.eclipse.emf.compare_1.3.1 for
org.eclipse.emf.compare.util.AdapterUtils.getItemProviderText()


Could you give me a hint on how those packages evolved, where can I find the methods to replace the preceding packages

Some examples could also be appreciated.


Thanks for your help

Jacques Bouthillier
Re: [EMF Compare] Migration from version 1.3 to 2.1 [message #1008591 is a reply to message #1008230] Wed, 13 February 2013 08:51 Go to previous messageGo to next message
Mikael Barbero is currently offline Mikael BarberoFriend
Messages: 54
Registered: July 2009
Member
Hi Jacques,

EMF Compare 2.x is a full overhaul of EMF Compare, as such all the APIs have changed and there may be no equivalence between old and newest APIs. Here are rough equivalence:

Quote:
org.eclipse.emf.compare.diff_1.3.1 for
org.eclipse.emf.compare.diff.metamodel.ComparisonSnapshot ()
org.eclipse.emf.compare.diff.metamodel.ComparisonResourceSnapshot()


This two APIs have been unified into a single "Comparison" concept in the plugin o.e.emf.compare. This comparison holds references to a tree of "Match", each of them may hold some "Diff". We started to describe concepts in the metamodel here http://wiki.eclipse.org/EMF_Compare/Developer_Guide#The_Comparison_Model

Quote:
org.eclipse.emf.compare.ui_1.3.1 for
org.eclipse.emf.compare.ui.internal.ModelComparator ()
org.eclipse.emf.compare.ui.ModelCompareInput ()
org.eclipse.emf.compare.ui.services.CompareServices ()


All have disappeared and their features are accessible from different points. Could you provide us more information about your need on these classes as long as I can not find any reference to that in any branch of the R4E repository?

Quote:
org.eclipse.emf.compare.diagram_1.3.1 for
org.eclipse.emf.compare.diagram.diff.util.DiffUtil.getElement()


There is no such method anymore, you may need to copy/paste the code in your own. The ElementRequestor used within the call graph will need to be refactored to take the new Comparison model into account (see http://wiki.eclipse.org/EMF_Compare/Developer_Guide#The_Comparison_Model for more details).

Quote:
org.eclipse.emf.compare_1.3.1 for
org.eclipse.emf.compare.util.AdapterUtils.getItemProviderText()


We are not referring to a static singleton anymore for the AdapterFactory so this AdapterUtils class has been removed. If you need an adapter factory, you should instantiate it by yourself with the following code:

AdapterFactory af = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE)

and by disposing it when not needed anymore (af.dispose()).

BTW we revamped the wiki with information that may be interesting for you. Check the developer guide especially (far from complete, but may give you some hints) http://wiki.eclipse.org/EMF_Compare/Developer_Guide

Hope this help.


Best regards,

Mikael Barbero
Obeo
Re: [EMF Compare] Migration from version 1.3 to 2.1 [message #1011090 is a reply to message #1008591] Mon, 18 February 2013 20:49 Go to previous messageGo to next message
Jacques Bouthillier is currently offline Jacques BouthillierFriend
Messages: 5
Registered: May 2011
Junior Member
Question:
In R4E, we need to store the object Id and a small description from the Diff (With version 1.3 of EMF Compare, we were extracting the information from a DiffElement structure ). It seems I have the objectId and not the description in the new data structure " (Diff) or (Match) " . Where can I extract the information needed for R4E ?

With the following code, I can get the Diff and Match element from the comparison, but I don't have the information needed to extract the description


public static List<IR4EUIPosition> createModelDeltas(R4ECompareEditorInput input) throws CoreException {

...
...

// Compare the two models
IComparisonScope scope = EMFCompare.createDefaultScope(leftResourceSet, rightResourceSet);
Comparison comparaison = comparator.compare(scope);


// Get the Diff for the left side only

// Construct the predicate
Predicate<? super Diff> predicate = and(fromSide(DifferenceSource.LEFT),
not(hasConflict(ConflictKind.REAL, ConflictKind.PSEUDO)));
// Filter out the diff that do not satisfy the predicate
Iterable<Diff> nonConflictualDifferencesFromLeft = filter(comparaison.getDifferences(), predicate);

Iterator<Diff> iter = nonConflictualDifferencesFromLeft.iterator();
while (iter.hasNext()) {
Diff diffLeft = iter.next();
System.out.println("nonConflictualDifferencesFromLeft : " + diffLeft.eContainer());
Match diffMatch = diffLeft.getMatch();
EObject eObj = diffMatch.getLeft();
Resource eObjRes = eObj.eResource();
String objectId = eObjRes.getURIFragment(eObj);
System.out.println("\t eObjLeft .resource: " + eObjRes + "\n\t fragmentId: "
+ objectId + "\t : " + eObjRes.getClass());

}
}

Method I used with EMF Compare 1.3 to extract the required information about the objectID and the description
public R4EUIModelPosition(DiffElement aDiff) {
EObject obj = DiffUtil.getElement(aDiff, Side.LEFT, EObject.class);
fObjectID = obj.eResource().getURIFragment(obj);
fDescription = AdapterUtils.getItemProviderText(aDiff);
}

Re: [EMF Compare] Migration from version 1.3 to 2.1 [message #1011779 is a reply to message #1011090] Wed, 20 February 2013 08:39 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1638
Registered: July 2009
Senior Member
Jacques,

We no longer use a long textual description for the differences. We may create an API to provide such descriptions from EMF Compare core in the future, but for now you will have to construct it yourself. You might want to look at what I wrote in the "user interface" part of this blog post about these descriptions.

The description of "Diff" element on the wiki should help you getting started about where to retrieve the necessary information from. Please raise an enhancement request on the bugzilla if you wish to see an API to that work for you.

Laurent Goubet
Obeo
Previous Topic: org.eclipse.emf.mwe.utils.Reader is not working
Next Topic:Proper way to update UI from EContentAdapter
Goto Forum:
  


Current Time: Fri Nov 28 04:34:39 GMT 2014

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

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