Standard Undo menu item never enables [message #540628] |
Wed, 16 June 2010 18:19 |
Joel Messages: 16 Registered: October 2009 |
Junior Member |
|
|
Hi, I added the standard undo/redo menu items to my menu, but when I add an IUndoableOperation to the global operation history, the undo menu item never enables as i would expect it to. What am i missing?
Here is my menu contribution with the undo/redo items:
<menu
label="Edit"
mnemonic="E">
<command
commandId="org.eclipse.ui.edit.undo"
style="push">
</command>
<command
commandId="org.eclipse.ui.edit.redo"
style="push">
</command>
</menu>
The items show up fine with their standard labels and even icons.
Here is the code that adds the operation to the history:
IWorkbench workbench = getSite().getWorkbenchWindow().getWorkbench();
IOperationHistory operationHistory = workbench.getOperationSupport().getOperationHistory();
IUndoContext undoContext = workbench.getOperationSupport().getUndoContext();
locationOp.addContext(undoContext);
OperationHistoryFactory.getOperationHistory().execute(locationOp, null, null);
operationHistory.execute(locationOp, null, null);
(edit: I also found through debug tracing that the UndoActionHandler is never created. I could create it myself, but then I don't know how I would add it to the menu with standard icon/label, as all my menus are command-contributed and thus no in-code menu creation can be used.)
Thanks in advance.
[Updated on: Wed, 16 June 2010 18:52] Report message to a moderator
|
|
|
|
Re: Standard Undo menu item never enables [message #540896 is a reply to message #540795] |
Thu, 17 June 2010 14:53 |
Joel Messages: 16 Registered: October 2009 |
Junior Member |
|
|
Hi, Paul, thanks for you reply. I'm afraid I can't create them in my ActionBarAdvisor because the Edit menu is contributed by my plugin and should only be visible in my plugin's perspective.
I did test adding it to the action bar advisor and it does work that way (i had to take it out). Is there a way to add them as an extension (action or command) and still get the standard functionality? Or a way to add it in my plugin activator?
The mixing of creating action extensions, creating actions in the ActionBarAdvisor, and creating commands, has been the biggest time waster and frustrator for me in my using the eclipse platform. I wish there was a thorough resource on the in's and out's of mixing them (since one who dares to use the new-ish command framework is forced to do so).
Edit: So far, the closest I've come is to contribute the "undo" item as a command, using the predefined id (org.eclipse.ui.edit.undo), and have the commandHandler delegate to the UndoActionHandler (i have to create a new one for each event since the ctor takes a part and i don't know the part until handling the event). The problem with this is that the Undo item does not enable/disable, and does not append the operation label to "undo", e.g. "Undo delete selection".
[Updated on: Thu, 17 June 2010 15:41] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03275 seconds