Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be 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