Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Adding undo operation to history not showing up in menu
Adding undo operation to history not showing up in menu [message #1690343] Thu, 26 March 2015 17:05 Go to next message
Tamar Cohen is currently offline Tamar CohenFriend
Messages: 103
Registered: July 2009
Senior Member
I have a strange problem here. I'm building an RCP application in which I contribute operations to the undo/redo history.

Some of my operations make the undo / redo actions appear in the menu, and others do not.

Here is an example of code that inserts one that does:

UndoablePOJOSetOperation operation = new UndoablePOJOSetOperation(getModel(), m_feature, event);
m_undoContext = new ObjectUndoContext(m_model);
operation.addContext(m_undoContext);
PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().add(operation);


Here is an example of code that inserts one that does not:
m_undoableOperation = new UndoableOperation(undoable);
s_undoContext = new ObjectUndoContext(UndoableHistoryManager.INSTANCE);
m_undoableOperation.addContext(s_undoContext);
PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().add(m_undoableOperation);


both undoable operations have the correct enablement for canUndo and canRedo (and canExecute).

When I look in org.eclipse.ui.operations.OperationHistoryActionHandler at the update() and step through, both operations are returning the same enabled state.

I'm building to Eclipse 3.7.x

What could cause the latter operation to not show up in the undo/redo history? I have tried different undo contexts. Advice would be greatly appreciated as I am baffled.

thanks
Tamar Cohen
NASA Ames Research Center
Re: Adding undo operation to history not showing up in menu [message #1690361 is a reply to message #1690343] Thu, 26 March 2015 21:00 Go to previous message
Tamar Cohen is currently offline Tamar CohenFriend
Messages: 103
Registered: July 2009
Senior Member
Aha! I forgot to call this method I made to make my view contribute to undo & redo:

public static void createViewUndoRedo(IWorkbenchPartSite site) {
UndoActionHandler undoAction = new UndoActionHandler(site, IOperationHistory.GLOBAL_UNDO_CONTEXT);
RedoActionHandler redoAction = new RedoActionHandler(site, IOperationHistory.GLOBAL_UNDO_CONTEXT);

if (site instanceof IViewSite){
IViewSite viewSite = (IViewSite)site;
IActionBars actionBars = viewSite.getActionBars();
actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(),undoAction);
actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(),redoAction);
}
}
Previous Topic:Widget disposed too early exception
Next Topic:Replacing "Confirm exit" dialogue by custom exit dialogue
Goto Forum:
  


Current Time: Fri Apr 26 10:12:50 GMT 2024

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

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

Back to the top