public final class NonLocalUndoUserApprover extends Object implements IOperationApprover
An operation approver that prompts the user to see if a non-local undo should
proceed inside an editor. A non-local undo is detected when an operation
being undone or redone affects elements other than those described by the
editor itself. Clients can optionally specify a class, the preferred
comparison class, that should be used when comparing objects affected by the
editor with objects affected by an undo or redo operation. Comparisons
between the affected objects inside the editor and those described by the
operation will first be done by simply performing an equality check, using
Object.equals(java.lang.Object)
. If an object described by
an operation is not equal to one of the objects affected by the editor, and
if it is not an instance of the preferred comparison class, but is an
instance of IAdaptable
, then the operation
approver will also attempt to retrieve an adapter on that object for the
preferred comparison class and perform a second equality check using the
adapter.
This class may be instantiated by clients.
Constructor and Description |
---|
NonLocalUndoUserApprover(IUndoContext context,
IEditorPart part,
Object[] affectedObjects,
Class preferredComparisonClass)
Create a NonLocalUndoUserApprover associated with the specified editor
and undo context
|
Modifier and Type | Method and Description |
---|---|
IStatus |
proceedRedoing(IUndoableOperation operation,
IOperationHistory history,
IAdaptable uiInfo)
Return a status indicating whether the specified operation should be
redone.
|
IStatus |
proceedUndoing(IUndoableOperation operation,
IOperationHistory history,
IAdaptable uiInfo)
Return a status indicating whether the specified operation should be
undone.
|
public NonLocalUndoUserApprover(IUndoContext context, IEditorPart part, Object[] affectedObjects, Class preferredComparisonClass)
context
- the undo context of operations in question.part
- the editor part that is displaying the elementaffectedObjects
- the objects that are affected by the editor and considered to
be objects local to the editor. The objects are typically
instances of the preferredComparisonClass or else provide
adapters for the preferredComparisonClass, although this is
not required.preferredComparisonClass
- the preferred class to be used when comparing the editor's
affectedObjects with those provided by the undoable operation
using
IAdvancedUndoableOperation.getAffectedObjects()
.
If the operation's affected objects are not instances of the
specified class, but are instances of
IAdaptable
, then an adapter
for this class will be requested. The preferredComparisonClass
may be null
, which indicates that there is no
expected class or adapter necessary for the comparison.public IStatus proceedRedoing(IUndoableOperation operation, IOperationHistory history, IAdaptable uiInfo)
IOperationApprover
IStatus.OK
will not be approved. Implementers should not assume that the redo will
be performed when the status is OK
, since other operation
approvers may veto the redo.proceedRedoing
in interface IOperationApprover
operation
- the operation to be redonehistory
- the history redoing the operationuiInfo
- the IAdaptable (or null
) provided by the
caller in order to supply UI information for prompting the
user if necessary. When this parameter is not
null
, it should minimally contain an adapter
for the org.eclipse.swt.widgets.Shell.class. Even if UI
information is provided, the implementation of this method
must be prepared for being called from a background thread.
Any UI access must be properly synchronized using the
techniques specified by the client's widget library.OK
, and the caller requesting the redo will be
returned the status that caused the rejection. Any other status
severities will not be interpreted by the history.public IStatus proceedUndoing(IUndoableOperation operation, IOperationHistory history, IAdaptable uiInfo)
IOperationApprover
IStatus.OK
will not be approved. Implementers should not assume that the undo will
be performed when the status is OK
, since other operation
approvers can veto the undo.proceedUndoing
in interface IOperationApprover
operation
- the operation to be undonehistory
- the history undoing the operationuiInfo
- the IAdaptable (or null
) provided by the
caller in order to supply UI information for prompting the
user if necessary. When this parameter is not
null
, it should minimally contain an adapter
for the org.eclipse.swt.widgets.Shell.class. Even if UI
information is provided, the implementation of this method
must be prepared for being called from a background thread.
Any UI access must be properly synchronized using the
techniques specified by the client's widget library.OK
, and the caller requesting the undo will be
returned the status that caused the rejection. Any other status
severities will not be interpreted by the history.
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.