|Re: Undo/Redo Buttons stay disabled [message #882615 is a reply to message #882604]
||Wed, 06 June 2012 21:09
|| Alexander Nyßen
Registered: July 2009
from what you describe a cannot precisely determine the underlying cause, so let me clarify some things and point you to some pitfalls you should check:
1) The EditPolicies are not responsible for executing command on the command stack. They only have the responsibility to return commands in oder to respond to request (see getCommand(Request)). The commands returned by the edit policies are chained together by their host edit part and returned in its getCommand(Request) method respectively. This method gets called by either the currently active tool, or by a selected action, which is responsible of finally executing the returned compound command on the stack. In order to get undo/redo working, the compound command returned by your edit part has to be undoable (isUndoable() has to return true), which is the case if all chained commands returned by its edit policies are undoable.
2) The undo and redo actions are not updated upon model changes, but upon changes of the command stack (they are referred to as stack actions). Besides the action bar contributor with the retarget actions, the mechanism for undo/redo requires that undo and redo actions are registered in the action registry of your editor and that these actions are updated by means of a CommandStackChangeListener whenever the stack changes. If your editor inherits from GraphicalEditor this should be the case. It registeres the action in the action registry in its initializeActionRegistry() method, maintains them in the list of stack actions, and updates them from within commandStackChanged(EventObject); the editor registered itself as CommandStackListener in its init(IEditorSite, IEditorInput).
Hope that clears things up a bit....
Powered by FUDForum
. Page generated in 0.16045 seconds