|
|
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 |
Jacques Bouthillier 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 |
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03393 seconds