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

Difference between revisions of "E4/EAS/Undo Redo"

< E4‎ | EAS
(New page: 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 und...)
 
 
Line 3: Line 3:
 
==Eclipse 3.x API==
 
==Eclipse 3.x API==
 
In Eclipse 3.x, the IWorkbenchOperationSupport interface provided by PlatformUI.getWorkbench().getOperationSupport() can be used for managing undo/redo support.
 
In Eclipse 3.x, the IWorkbenchOperationSupport interface provided by PlatformUI.getWorkbench().getOperationSupport() can be used for managing undo/redo support.
 +
 +
===Execution operation===
 +
<source lang="java">
 +
IWorkbenchOperationSupport operationSupport = PlatformUI.getWorkbench().getOperationSupport();
 +
IOperationHistory operationHistory = operationSupport.getOperationHistory();
 +
IStatus status = operationHistory.execute(undoableOperation, null, null);
 +
if (!status.isOK()) {
 +
  // handle the error
 +
}
 +
</source>
 +
 +
===Undo operation===
 +
<source lang="java">
 +
IWorkbenchOperationSupport operationSupport = PlatformUI.getWorkbench().getOperationSupport();
 +
IOperationHistory operationHistory = operationSupport.getOperationHistory();
 +
IStatus status = operationHistory.undo(undoableOperation, null, null);
 +
if (!status.isOK()) {
 +
  // handle the error
 +
}
 +
</source>
 +
 +
===Redo operation===
 +
<source lang="java">
 +
IWorkbenchOperationSupport operationSupport = PlatformUI.getWorkbench().getOperationSupport();
 +
IOperationHistory operationHistory = operationSupport.getOperationHistory();
 +
IStatus status = operationHistory.redo(undoableOperation, null, null);
 +
if (!status.isOK()) {
 +
  // handle the error
 +
}
 +
</source>

Latest revision as of 12:50, 26 October 2009

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