Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » Undo a Merge
Undo a Merge [message #1768831] Mon, 24 July 2017 08:24 Go to next message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 54
Registered: March 2015
Member
Hello there,

i need to undo a already completed merge. How can i do that?

This is my code:

Registry createStandaloneInstance = IMerger.RegistryImpl.createStandaloneInstance();
IMerger highestRankingMerger = createStandaloneInstance.getHighestRankingMerger(diff);
highestRankingMerger.copyLeftToRight(diff, null);


Now i want to undo the merge. how can i do that? The EMF-Compare Editor is able to achieve this.

Thank you,
Simon

Edit: I probably found a way with help of an ChangeRecorder. Is there a different way? Or is this the best one?

[Updated on: Mon, 24 July 2017 13:20]

Report message to a moderator

Re: Undo a Merge [message #1768948 is a reply to message #1768831] Tue, 25 July 2017 07:46 Go to previous messageGo to next message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 54
Registered: March 2015
Member
I tryed it and it worked. the problem is, that if i make more changes and then reroll them all the egeneric-refernce is lost. any help plz?
Re: Undo a Merge [message #1769859 is a reply to message #1768948] Fri, 04 August 2017 09:09 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1858
Registered: July 2009
Senior Member
Hi Simon,

The EMF Compare editor uses the help of an IEditingDomain to implement its un/redo actions. That is the most efficient (and less bug-prone) way to achieve this and is probably what you should strive for. I am not sure IEditingDomains can be used standalone since I never had to implement that, you might want to ask on the EMF forum if you don't manage to make it work on your use case.

Laurent Goubet
Obeo
Re: Undo a Merge [message #1771033 is a reply to message #1769859] Mon, 21 August 2017 11:37 Go to previous messageGo to next message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 54
Registered: March 2015
Member
Hello Laurent, thanks for your response.

i know how to use undo and redo actions with EMF/CommandStack. The problem is, that the merger wont provide or use a command to change the model. Thats the reason i cant undo it.
Re: Undo a Merge [message #1771179 is a reply to message #1771033] Tue, 22 August 2017 16:09 Go to previous messageGo to next message
Philip Langer is currently offline Philip LangerFriend
Messages: 84
Registered: March 2015
Location: Vienna, Austria
Member

Hi Simon,

you are right, the merger modifies the model directly. Have a look at org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.actions.MergeAction, org.eclipse.emf.compare.domain.impl.EMFCompareEditingDomain and org.eclipse.emf.compare.command.impl.MergeCommand.MergeCommand to see how the merge operation is wrapped within a command that can be undone and redone.

For your usecase, it'd probably be enough to create a change recorder and re-use MergeCommand. You can then undo the merge command based on the change recorder.

Hope this helps!

Best wishes,

Philip


--
Philip Langer

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: Undo a Merge [message #1771777 is a reply to message #1771179] Wed, 30 August 2017 10:24 Go to previous messageGo to next message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 54
Registered: March 2015
Member
Hello Phillip, than you for your response.

i tryed to create a MergeCommand but i am not sure about the parameters. i always get a NPE if i try to execute the command.

Can you give me a better explanation for the constructor parameters then the actucal java doc provides?

Thank you

Edit: i got it work. Problem is now, that if i save my model, i get the following error: The object 'org.eclipse.emf.ecore.impl.EGenericTypeImpl@3a199b9a (expression: ?)' is not contained in a resource.

I know that this means that there is an eobject that has still a refernce from the model put is not contained in any parent anymore so the model cant be saved.

[Updated on: Wed, 30 August 2017 11:19]

Report message to a moderator

Re: Undo a Merge [message #1771831 is a reply to message #1771777] Thu, 31 August 2017 08:08 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1858
Registered: July 2009
Senior Member
Hi Simon,

I assume this means you've merged a difference without merging all of its dependencies (or that a post-processor on the model removed one such dependency). I don't really know what kind of merge could give you a dangling EGenericType though...

Could you check that you're merging all differences and not just part of them?

Laurent Goubet
Obeo
Previous Topic:Merge issue "because its parent hasn't been merged yet"
Next Topic:How handle only merge the right difference into left?
Goto Forum:
  


Current Time: Fri Sep 21 19:12:10 GMT 2018

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

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

Back to the top