Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

E4/EAS/Undo Redo

< E4‎ | EAS

Components should be able to isolate their own atomic operations for supporting undo/redo. These should be connected to the base platform in some way to ensure that when a user invokes undo/redo, the context of the application can be analyzed and the right operation stack can be processed for undoing/redoing.

Eclipse 3.x API

In Eclipse 3.x, the IWorkbenchOperationSupport interface provided by PlatformUI.getWorkbench().getOperationSupport() can be used for managing undo/redo support.

Execution operation

IWorkbenchOperationSupport operationSupport = PlatformUI.getWorkbench().getOperationSupport();
IOperationHistory operationHistory = operationSupport.getOperationHistory();
IStatus status = operationHistory.execute(undoableOperation, null, null);
if (!status.isOK()) {
  // handle the error
}

Undo operation

IWorkbenchOperationSupport operationSupport = PlatformUI.getWorkbench().getOperationSupport();
IOperationHistory operationHistory = operationSupport.getOperationHistory();
IStatus status = operationHistory.undo(undoableOperation, null, null);
if (!status.isOK()) {
  // handle the error
}

Redo operation

IWorkbenchOperationSupport operationSupport = PlatformUI.getWorkbench().getOperationSupport();
IOperationHistory operationHistory = operationSupport.getOperationHistory();
IStatus status = operationHistory.redo(undoableOperation, null, null);
if (!status.isOK()) {
  // handle the error
}

Back to the top