Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Undo/Redo refactorings using EMF Refactor
Undo/Redo refactorings using EMF Refactor [message #856408] Wed, 25 April 2012 16:27 Go to next message
Iman Imani is currently offline Iman ImaniFriend
Messages: 4
Registered: April 2012
Junior Member
Hi,
I implemented a refactoring plugin using EMF Refactoring. The plugin refactors EMF model based on a fitness function defined based on metrics. In some cases after refactoring I want to undo applied refactorings. I should probably use BasicCommandStack.undo instruction. I am familiar with this class,but I do not know how and where to get an instance from BasicCommandStack class.

Thanks in advance for your help.

Fazi.

[Updated on: Thu, 26 April 2012 13:47]

Report message to a moderator

Re: How Undo/Redo refactorings using EMF Refactor [message #856983 is a reply to message #856408] Thu, 26 April 2012 06:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33218
Registered: July 2009
Senior Member
Iman,

Hopefully someone from the refactoring team notices the question. I'll
try to help...

On 25/04/2012 6:27 PM, Iman Imani wrote:
> Hi,
> I implemented an refactoring plugin using EMF Refactoring. The plugin
> refactors EMF model based on a fitness function defined based on
> metrics. In some cases after refactoring I want to undo applied
> refactorings. I should probably use BasicCommandStack.undo instruction.
You're sure the refactoring is done as a command? It seems a bit tricky
because I imagine that often multiple resources are affected.
> I am familiar with this class,but I do not know how and where to get
> an instance from BasicCommandStack class.
What kind of context do you have. The generated editors implement
IEditingDomainProvider so from the editor instance you can call
getEditingDomain().getCommandStack(). Also, AdapterFactoryEditingDomain
has static getEditingDomainFor methods that can be used with an EObject
to determine its editing domain (by navigating up to the resource set
and finding the associated editing domain for that resource set).
> I found many topics in the forum related to this topic, however
> complex descriptions prevent me to get more from them.
>
> A step-to-step instruction can help me a lot.(I am not a professional
> plugin developer)
>
> Thanks in advance for your help.
>
> Fazi.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How Undo/Redo refactorings using EMF Refactor [message #857073 is a reply to message #856983] Thu, 26 April 2012 08:12 Go to previous messageGo to next message
Iman Imani is currently offline Iman ImaniFriend
Messages: 4
Registered: April 2012
Junior Member
Thanks Ed.

[Updated on: Thu, 26 April 2012 08:17]

Report message to a moderator

Re: How Undo/Redo refactorings using EMF Refactor [message #857086 is a reply to message #856983] Thu, 26 April 2012 08:25 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33218
Registered: July 2009
Senior Member
Iman,

I did give the details of how to get the command stack from the editing
domain and how to get the editing domain. Did you try that?


On 26/04/2012 8:20 AM, Ed Merks wrote:
> Iman,
>
> Hopefully someone from the refactoring team notices the question.
> I'll try to help...
>
> On 25/04/2012 6:27 PM, Iman Imani wrote:
>> Hi,
>> I implemented an refactoring plugin using EMF Refactoring. The plugin
>> refactors EMF model based on a fitness function defined based on
>> metrics. In some cases after refactoring I want to undo applied
>> refactorings. I should probably use BasicCommandStack.undo instruction.
> You're sure the refactoring is done as a command? It seems a bit
> tricky because I imagine that often multiple resources are affected.
>> I am familiar with this class,but I do not know how and where to get
>> an instance from BasicCommandStack class.
> What kind of context do you have. The generated editors implement
> IEditingDomainProvider so from the editor instance you can call
> getEditingDomain().getCommandStack(). Also,
> AdapterFactoryEditingDomain has static getEditingDomainFor methods
> that can be used with an EObject to determine its editing domain (by
> navigating up to the resource set and finding the associated editing
> domain for that resource set).
>> I found many topics in the forum related to this topic, however
>> complex descriptions prevent me to get more from them.
>>
>> A step-to-step instruction can help me a lot.(I am not a professional
>> plugin developer)
>>
>> Thanks in advance for your help.
>>
>> Fazi.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How Undo/Redo refactorings using EMF Refactor [message #857149 is a reply to message #857086] Thu, 26 April 2012 09:29 Go to previous message
Iman Imani is currently offline Iman ImaniFriend
Messages: 4
Registered: April 2012
Junior Member
Hi,
Thanks for your help Ed. It works.
I used
EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(selectedEObject);
to have access to editingDomain. Also I used
editingDomain.getCommandStack()....
to have access to commanStack.

Iman.

[Updated on: Thu, 26 April 2012 13:45]

Report message to a moderator

Previous Topic:[CDO/Hibernate][Export] Invalid type: org.eclipse.emf.cdo.internal.common.revision.CDORevisionImpl
Next Topic:ClassNotFoundException error
Goto Forum:
  


Current Time: Wed Sep 25 07:23:10 GMT 2024

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

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

Back to the top