Undo a Merge [message #1768831] |
Mon, 24 July 2017 08:24 |
Simon BBBBBBB Messages: 63 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 #1769859 is a reply to message #1768948] |
Fri, 04 August 2017 09:09 |
|
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 #1771179 is a reply to message #1771033] |
Tue, 22 August 2017 16:09 |
|
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 |
Simon BBBBBBB Messages: 63 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 |
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03579 seconds