Interface IAdvancedUndoableOperation
- All Known Implementing Classes:
AbstractWorkspaceOperation
,CopyProjectOperation
,CopyResourcesOperation
,CreateFileOperation
,CreateFolderOperation
,CreateMarkersOperation
,CreateProjectOperation
,DeleteMarkersOperation
,DeleteResourcesOperation
,MoveProjectOperation
,MoveResourcesOperation
,TriggeredOperations
,UpdateMarkersOperation
IAdvancedUndoableOperation defines an interface for undoable operations that modify one or more elements in a model and attempt to keep model listeners up to date with changes that occur in the undo and redo history involving particular model elements. It also defines methods for computing the validity of an operation for undo or redo before attempting to perform the undo or redo.
This interface is intended to be used by legacy frameworks that are adapting their original undo and redo support to this framework. The methods in this interface allow legacy clients to maintain features not supported in the basic operations framework.
- Since:
- 3.1
-
Method Summary
Modifier and TypeMethodDescriptionvoid
An operation history notification about this operation is about to be sent to operation history listeners.computeRedoableStatus
(IProgressMonitor monitor) Return a status indicating the projected outcome of redoing the receiver.computeUndoableStatus
(IProgressMonitor monitor) Return a status indicating the projected outcome of undoing the receiver.Object[]
Return an array of objects that are affected by executing, undoing, or redoing this operation.
-
Method Details
-
aboutToNotify
An operation history notification about this operation is about to be sent to operation history listeners. Any preparation needed before listeners are notified about this operation should be performed here.
This method has been added to support legacy undo frameworks that are adapting to IUndoableOperation. Operations that previously relied on notification from their containing history or stack before any listeners are notified about changes to the operation should implement this interface.
- Parameters:
event
- the event that is about to be sent with the pending notification
-
getAffectedObjects
Object[] getAffectedObjects()Return an array of objects that are affected by executing, undoing, or redoing this operation. If it cannot be determined which objects are affected, return null.
- Returns:
- the array of Objects modified by this operation, or
null
if the affected objects cannot be determined.
-
computeUndoableStatus
Return a status indicating the projected outcome of undoing the receiver. This method should be used to report the possible outcome of an undo and is used when computing the validity of an undo is too expensive to perform inIUndoableOperation.canUndo()
. It is not called by the operation history, but instead is used by clients (such as implementers ofIOperationApprover
) who wish to perform advanced validation of an operation before attempting to undo it. If the result of this method is the discovery that an operation can in fact not be undone, then the operation is expected to correctly answerfalse
on subsequent calls toIUndoableOperation.canUndo()
.- Parameters:
monitor
- the progress monitor (ornull
) to use for reporting progress to the user while computing the validity.- Returns:
- the IStatus indicating the validity of the undo. The status
severity should be set to
OK
if the undo can successfully be performed, andERROR
if it cannnot. Any other status is assumed to represent an ambiguous state. - Throws:
ExecutionException
- if an exception occurs while computing the validity.
-
computeRedoableStatus
Return a status indicating the projected outcome of redoing the receiver. This method should be used to report the possible outcome of a redo and is used when computing the validity of a redo is too expensive to perform inIUndoableOperation.canRedo()
. It is not called by the operation history, but instead is used by clients (such as implementers ofIOperationApprover
) who wish to perform advanced validation of an operation before attempting to redo it. If the result of this method is the discovery that an operation can in fact not be redone, then the operation is expected to correctly answerfalse
on subsequent calls toIUndoableOperation.canRedo()
.- Parameters:
monitor
- the progress monitor (ornull
) to use for reporting progress to the user while computing the validity.- Returns:
- the IStatus indicating the validity of the redo. The status
severity should be set to
OK
if the redo can successfully be performed, andERROR
if it cannnot. Any other status is assumed to represent an ambiguous state. - Throws:
ExecutionException
- if an exception occurs while computing the validity.
-