Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Undo/Redo Actions Disabled(Undo and Redo actions disabled although a command stack with EMF Commands is maintained)
Undo/Redo Actions Disabled [message #1214026] Wed, 27 November 2013 14:01 Go to next message
Evica Ilieva is currently offline Evica IlievaFriend
Messages: 4
Registered: November 2013
Junior Member
Hi,

I am new to EMF and in general to developing RCP application. I've been developing my first EMF based RCP application where I develop a multipage editor. I reused some of the methods from the default editor, and in addition to this I developed custom editor parts with multiple JFace Viewers per page which are used for viewing and editing the EMF objects. My problem now is that the undo and redo actions in the global actions menu are disabled. I checked with debugging that my CommandStack is maintained properly and I am only using EMF Commands. Another thing I notice is that if an actions is executed in the editor I developed, the undo/redo actions remain disabled. If I afterwards change some of the attributes of the objects using the Properties View, the undo/redo actions get enabled and the commands executed within my editor can be undone as well. Could you maybe give me some direction of what could my problem be and how can I solve it?

Thanks,
Evica
Re: Undo/Redo Actions Disabled [message #1214446 is a reply to message #1214026] Wed, 27 November 2013 17:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30372
Registered: July 2009
Senior Member
Evica,

Have a look in
org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor and
make sure that lines like this are being executed when your viewers have
focus.

actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undoAction);

On 27/11/2013 3:08 PM, Evica Ilieva wrote:
> Hi,
>
> I am new to EMF and in general to developing RCP application. I've
> been developing my first EMF based RCP application where I develop a
> multipage editor. I reused some of the methods from the default
> editor, and in addition to this I developed custom editor parts with
> multiple JFace Viewers per page which are used for viewing and editing
> the EMF objects. My problem now is that the undo and redo actions in
> the global actions menu are disabled. I checked with debugging that my
> CommandStack is maintained properly and I am only using EMF Commands.
> Another thing I notice is that if an actions is executed in the editor
> I developed, the undo/redo actions remain disabled. If I afterwards
> change some of the attributes of the objects using the Properties
> View, the undo/redo actions get enabled and the commands executed
> within my editor can be undone as well. Could you maybe give me some
> direction of what could my problem be and how can I solve it?
>
> Thanks,
> Evica
Re: Undo/Redo Actions Disabled [message #1216095 is a reply to message #1214446] Thu, 28 November 2013 10:15 Go to previous messageGo to next message
Evica Ilieva is currently offline Evica IlievaFriend
Messages: 4
Registered: November 2013
Junior Member
Hi Ed,

Thanks for the fast response. I've been playing a bit with my editor while having a break-point at the code that you pointed out.

The statements

actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undoAction);

is executed during the initialization and creating of my editor and only then. As far as a could noticed same is with the default editor generated from EMF.
However as a execute actions in my editor and change between the properties view (edit some properties of the objects there) and my editor, at some point of time the undo actions get enabled, and this line of code does not get executed again. However the undo action at some point gets enabled.

I also think that I am not handling properly the selection change in my editor. Can that be causing the problem that I am having?

Thanks,
Evica
Re: Undo/Redo Actions Disabled [message #1216298 is a reply to message #1216095] Thu, 28 November 2013 12:06 Go to previous messageGo to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Evica,

I'm also using a multi-page editor for editing EMF objects and the undo/redo functionality works fine (however, I don't use the property view anymore).

Your undo/redo actions are disabled in the menu, but is the undo/redo working when you trigger it with the keyboard instead of via the menu ?
Did you register the actions in your ApplicationActionBarAdvisor ?

	@Override
	protected void makeActions(IWorkbenchWindow window) {
		register(ActionFactory.UNDO.create(window));
		register(ActionFactory.REDO.create(window));
	}


On a side note, you can also use JFace databinding in conjunction with EMF models, it makes things much easier in a lot of cases (e.g. you don't have to "refresh" the view when the model changes, since this is done for you; this is particularly useful for the undo/redo).

There's a great tutorial about it here
To bind EMF models, you can then read this article.
Re: Undo/Redo Actions Disabled [message #1216645 is a reply to message #1216298] Thu, 28 November 2013 15:19 Go to previous messageGo to next message
Evica Ilieva is currently offline Evica IlievaFriend
Messages: 4
Registered: November 2013
Junior Member
Hi Cedric,

No undo/redo is not working when I trigger it with the keyboard. I do not have an ApplicationActionBarAdvisor. As I am working on only customizing the default editor generated for an EMF model (a did not create the EMF model nor I can change it in any way) this is what I did:

I generated the default editor for the model that was already created.
I copied the the editor class and ActionBarContributor from the generated default editor in my own eclipse plugin project.
I removed from the default editor class the default viewer panes and viewers.
I created new custom classes that extend EditorPart, each of them being one page in my MultiPageEditor.
In each of these EditorParts I have few Jface Viewers (Tree or Table). In order to show my model objects in the Viewers, or customize the default behavior of the viewers, I mostly follow the book EMF Eclipse Modeling 2nd Edition. To change the default behavior of the modeled classes I extend the default ItemProviders and add custom behavior there. To edit the objects I use cell editors. I only use EMF commands to change my model. For example:

editor.getEditingDomain().getCommandStack().execute(SetCommand.create(editor.getEditingDomain(),item.getData(), feature, value));


This is the first eclipse plugin that I am developing, and the first time I am working with EMF, so my knowledge is quite basic.

Thanks,
Evica

[Updated on: Thu, 28 November 2013 15:20]

Report message to a moderator

Re: Undo/Redo Actions Disabled [message #1216878 is a reply to message #1216645] Thu, 28 November 2013 17:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30372
Registered: July 2009
Senior Member
Evica,

Sorry, but these things work in the generated editor, so if they don't
work for you, you've done something that's not helping, and I can't
guess what it might be. All I can suggest is you look at that things
I've suggested you look at, i.e., when are the global action handlers
informed that they need to handle actions for the view that you've given
focus?


On 28/11/2013 4:19 PM, Evica Ilieva wrote:
> Hi Cedric,
>
> No undo/redo is not working when I trigger it with the keyboard. I do
> not have an ApplicationActionBarAdvisor. As I am working on only
> customizing the default editor generated for an EMF model (a did not
> create the EMF model nor I can change it in any way) this is what I did:
>
> I generated the default editor for the model that was already created.
> I copied the the editor class and ActionBarContributor from the
> generated default editor in my own eclipse plugin project.
> I removed from the default editor class the default viewer panes and
> viewers. I created new custom classes that extend EditorPart, each of
> the being one page in my MultiPageEditor.
> In each of these EditorParts I have few Jface Viewers (Tree or Table).
> In order to show my model objects in the Viewers, or customize the
> default behavior of the viewers, I mostly follow the book EMF Eclipse
> Modeling 2nd Edition. To change the default behavior of the modeled
> classes I extend the default ItemProviders and add custom behavior
> there. To edit the objects I use cell editors. I only use EMF commands
> to change my model. For example:
>
>
> editor.getEditingDomain().getCommandStack().execute(SetCommand.create(editor.getEditingDomain(),item.getData(),
> feature, value));
>
>
> This is the first eclipse plugin that I am developing, and the first
> time I am working with EMF, so my knowledge is quite basic.
>
> Thanks,
> Evica
Re: Undo/Redo Actions Disabled [message #1219985 is a reply to message #1216878] Sun, 08 December 2013 11:04 Go to previous message
Evica Ilieva is currently offline Evica IlievaFriend
Messages: 4
Registered: November 2013
Junior Member
I finally figured out why the undo/redo actions were disabled in my MultiPageEditor. It turned out that the problem was the default TextEditor ( org.eclipse.ui.editors.text.TextEditor) that I was creating as a last page in my MultiPageEditor. This was disabling my previously enabled undo/redo actions.

Best,
Evica
Previous Topic:[CDO] Trouble resolving packages using OCL within CDO
Next Topic:Extending Ecore XMI serialization
Goto Forum:
  


Current Time: Fri Aug 23 20:00:48 GMT 2019

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

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

Back to the top