Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF Compare and CompareDialog
EMF Compare and CompareDialog [message #482500] Wed, 26 August 2009 20:09 Go to next message
Wayne Beaton is currently offline Wayne BeatonFriend
Messages: 554
Registered: December 2017
Senior Member
I am trying to use EMF Compare to compare an instance of a model that I
currently have open in an editor with an instance of the same model
obtained via HTTP. I've managed to muddle through most of it with some
help from Google and example code, but am hung up on a couple of issues.

Here is the code that I have:

--
DocumentRoot liveDocumentRoot = (DocumentRoot)
((IplogEditor)activePart).getEditingDomain().getResourceSet( ).getResources().get(0).getContents().get(0);

ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(IplogPackage.eINSTANCE. getNsURI(),
IplogPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "iplog",
new IplogResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getContentTypeToFac toryMap().put( "iplog",
new IplogResourceFactoryImpl());

URI uri1 =
URI.createURI(" http://www.eclipse.org/projects/xml/project_ip_data.php?id=t echnology.dash");
Resource resource = resourceSet.createResource(uri1, "iplog");
resource.load(null);
DocumentRoot serverDocumentRoot = (DocumentRoot)
resource.getContents().get(0);

MatchModel match = MatchService.doContentMatch(liveDocumentRoot,
serverDocumentRoot, null);
DiffModel diff = DiffService.doDiff(match);

ComparisonResourceSnapshot snapshot =
DiffFactory.eINSTANCE.createComparisonResourceSnapshot();
snapshot.setDate(new Date());
snapshot.setMatch(match);
snapshot.setDiff(diff);

ModelCompareEditorInput input = new ModelCompareEditorInput(snapshot);

CompareConfiguration configuration = input.getCompareConfiguration();
configuration.setLeftLabel("Workspace File");
configuration.setRightLabel("Eclipse Foundation Databases");
configuration.setRightEditable(false);

CompareUI.openCompareDialog(input);
--

I manage to open up the CompareDialog, and it basically works. However,
the "Commit" button remains greyed out. Any changes that I make in the
dialog are reflected in the dialog and in the editor, but the editor is
not marked dirty.

What I want to see is changes reflected in the dialog, but not passed on
to the editor until the "Commit" button is clicked. Ideally then, those
committed changes should be undoable.

Is there some example code that shows something close to what I'm trying
to do?
Re: EMF Compare and CompareDialog [message #482835 is a reply to message #482500] Fri, 28 August 2009 09:39 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080805000507060609000107
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi Wayne,

Unfortunately I am not that familiar with the compare dialog. The fact
that it doesn't reflect the dirty state it should have might be due to
the same underlying "feature" as bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=264482 which makes us
automatically save some changes on focus change; the "underlying
feature" I mention here is the fact that there are two ways to call
"saveContents" on the viewer ... with only one of the two that should
indeed save the resource. Unfortunately, we've never received word from
the platform team about this.

I'll try and investigate to find why the Compare dialog has a different
behavior than the compare editor in this case.

Laurent Goubet
Obeo

Wayne Beaton a
Re: EMF Compare and CompareDialog [message #482887 is a reply to message #482835] Fri, 28 August 2009 13:14 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040708020801010800030608
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Wayne,

It would seem that I simply didn't implement properly the
CompareEditorInput :(. This should be fixed in the next I-build. Could
you raise a bugzilla for this so that we can verify the correction?

Laurent Goubet
Obeo

laurent Goubet a
Re: EMF Compare and CompareDialog [message #482984 is a reply to message #482887] Fri, 28 August 2009 21:04 Go to previous message
Wayne Beaton is currently offline Wayne BeatonFriend
Messages: 554
Registered: December 2017
Senior Member
https://bugs.eclipse.org/bugs/show_bug.cgi?id=288002

Thanks,

Wayne

laurent Goubet wrote:
> Wayne,
>
> It would seem that I simply didn't implement properly the
> CompareEditorInput :(. This should be fixed in the next I-build. Could
> you raise a bugzilla for this so that we can verify the correction?
>
> Laurent Goubet
> Obeo
>
> laurent Goubet a écrit :
>> Hi Wayne,
>>
>> Unfortunately I am not that familiar with the compare dialog. The fact
>> that it doesn't reflect the dirty state it should have might be due to
>> the same underlying "feature" as bug
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=264482 which makes us
>> automatically save some changes on focus change; the "underlying
>> feature" I mention here is the fact that there are two ways to call
>> "saveContents" on the viewer ... with only one of the two that should
>> indeed save the resource. Unfortunately, we've never received word
>> from the platform team about this.
>>
>> I'll try and investigate to find why the Compare dialog has a
>> different behavior than the compare editor in this case.
>>
>> Laurent Goubet
>> Obeo
>>
>> Wayne Beaton a écrit :
>>> I am trying to use EMF Compare to compare an instance of a model that
>>> I currently have open in an editor with an instance of the same model
>>> obtained via HTTP. I've managed to muddle through most of it with
>>> some help from Google and example code, but am hung up on a couple of
>>> issues.
>>>
>>> Here is the code that I have:
>>>
>>> --
>>> DocumentRoot liveDocumentRoot = (DocumentRoot)
>>> ((IplogEditor)activePart).getEditingDomain().getResourceSet( ).getResources().get(0).getContents().get(0);
>>>
>>>
>>> ResourceSet resourceSet = new ResourceSetImpl();
>>> resourceSet.getPackageRegistry().put(IplogPackage.eINSTANCE. getNsURI(),
>>> IplogPackage.eINSTANCE);
>>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "iplog",
>>> new IplogResourceFactoryImpl());
>>> resourceSet.getResourceFactoryRegistry().getContentTypeToFac toryMap().put( "iplog",
>>> new IplogResourceFactoryImpl());
>>> URI uri1 =
>>> URI.createURI(" http://www.eclipse.org/projects/xml/project_ip_data.php?id=t echnology.dash");
>>>
>>> Resource resource = resourceSet.createResource(uri1, "iplog");
>>> resource.load(null);
>>> DocumentRoot serverDocumentRoot = (DocumentRoot)
>>> resource.getContents().get(0);
>>> MatchModel match =
>>> MatchService.doContentMatch(liveDocumentRoot, serverDocumentRoot, null);
>>> DiffModel diff = DiffService.doDiff(match);
>>> ComparisonResourceSnapshot snapshot =
>>> DiffFactory.eINSTANCE.createComparisonResourceSnapshot();
>>> snapshot.setDate(new Date());
>>> snapshot.setMatch(match);
>>> snapshot.setDiff(diff);
>>> ModelCompareEditorInput input = new
>>> ModelCompareEditorInput(snapshot);
>>> CompareConfiguration configuration =
>>> input.getCompareConfiguration();
>>> configuration.setLeftLabel("Workspace File");
>>> configuration.setRightLabel("Eclipse Foundation Databases");
>>> configuration.setRightEditable(false);
>>> CompareUI.openCompareDialog(input);
>>> --
>>>
>>> I manage to open up the CompareDialog, and it basically works.
>>> However, the "Commit" button remains greyed out. Any changes that I
>>> make in the dialog are reflected in the dialog and in the editor, but
>>> the editor is not marked dirty.
>>>
>>> What I want to see is changes reflected in the dialog, but not passed
>>> on to the editor until the "Commit" button is clicked. Ideally then,
>>> those committed changes should be undoable.
>>>
>>> Is there some example code that shows something close to what I'm
>>> trying to do?
>>
>
Previous Topic:Send a xml as inputStream
Next Topic:Teneo/Hibernate autogenerated fields indices
Goto Forum:
  


Current Time: Fri Apr 19 19:59:41 GMT 2024

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

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

Back to the top