|
Eclipse Platform Release 3.1 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.core.commands.operations.AbstractOperation
org.eclipse.core.commands.operations.TriggeredOperations
Triggered operations are a specialized implementation of a composite operation that keeps track of operations triggered by the execution of some primary operation. The composite knows which operation was the trigger for subsequent operations, and adds all triggered operations as children. When execution, undo, or redo is performed, only the triggered operation is executed, undone, or redone if it is still present. If the trigger is removed from the triggered operations, then the child operations will replace the triggered operations in the history.
This class may be instantiated by clients.
Constructor Summary | |
---|---|
TriggeredOperations(IUndoableOperation operation,
IOperationHistory history)
Construct a composite triggered operations using the specified undoable operation as the trigger. |
Method Summary | |
---|---|
void |
aboutToNotify(OperationHistoryEvent event)
An operation history notification about this operation is about to be sent to operation history listeners. |
void |
add(IUndoableOperation operation)
Add the specified operation as a child of this operation. |
boolean |
canExecute()
Returns whether the operation can be executed in its current state. |
boolean |
canRedo()
Returns whether the operation can be redone in its current state. |
boolean |
canUndo()
Returns whether the operation can be undone in its current state. |
IStatus |
computeRedoableStatus(IProgressMonitor monitor)
Return a status indicating the projected outcome of redoing the receiver. |
IStatus |
computeUndoableStatus(IProgressMonitor monitor)
Return a status indicating the projected outcome of undoing the receiver. |
void |
dispose()
Dispose of the operation. |
IStatus |
execute(IProgressMonitor monitor,
IAdaptable info)
Execute the operation. |
Object[] |
getAffectedObjects()
Return an array of objects that are affected by executing, undoing, or redoing this operation. |
IUndoableOperation |
getTriggeringOperation()
Return the operation that triggered the other operations in this composite. |
IStatus |
redo(IProgressMonitor monitor,
IAdaptable info)
Redo the operation. |
void |
remove(IUndoableOperation operation)
Remove the specified operation from this operation. |
void |
removeContext(IUndoContext context)
Remove the specified context from the receiver. |
IStatus |
undo(IProgressMonitor monitor,
IAdaptable info)
Undo the operation. |
Methods inherited from class org.eclipse.core.commands.operations.AbstractOperation |
---|
addContext, getContexts, getLabel, hasContext, setLabel, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.eclipse.core.commands.operations.IUndoableOperation |
---|
addContext, getContexts, getLabel, hasContext |
Constructor Detail |
public TriggeredOperations(IUndoableOperation operation, IOperationHistory history)
operation
- the operation that will trigger other operations.history
- the operation history containing the triggered operations.Method Detail |
public void add(IUndoableOperation operation)
ICompositeOperation
Add the specified operation as a child of this operation.
add
in interface ICompositeOperation
operation
- the operation to be added. If the operation instance has
already been added, this method will have no effect.public void remove(IUndoableOperation operation)
ICompositeOperation
Remove the specified operation from this operation.
The composite operation should dispose the operation as part of removing it.
remove
in interface ICompositeOperation
operation
- the operation to be removed. The operation should be disposed
by the receiver. This method will have no effect if the
operation instance is not already a child.public void removeContext(IUndoContext context)
removeContext
in interface IUndoableOperation
removeContext
in class AbstractOperation
context
- the undo context being removed from the receiver.public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
IUndoableOperation
execute
in interface IUndoableOperation
execute
in class AbstractOperation
ExecutionException
public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
IUndoableOperation
redo
in interface IUndoableOperation
redo
in class AbstractOperation
ExecutionException
public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
IUndoableOperation
undo
in interface IUndoableOperation
undo
in class AbstractOperation
ExecutionException
public boolean canUndo()
IUndoableOperation
Returns whether the operation can be undone in its current state.
Note: The computation for this method must be fast, as it is called frequently. If necessary, this method can be optimistic in its computation (returning true) and later perform more time-consuming computations during the actual undo of the operation, returning the appropriate status if the operation cannot actually be undone at that time.
canUndo
in interface IUndoableOperation
canUndo
in class AbstractOperation
public boolean canExecute()
IUndoableOperation
Returns whether the operation can be executed in its current state.
Note: The computation for this method must be fast, as it is called frequently. If necessary, this method can be optimistic in its computation (returning true) and later perform more time-consuming computations during the actual execution of the operation, returning the appropriate status if the operation cannot actually execute at that time.
canExecute
in interface IUndoableOperation
canExecute
in class AbstractOperation
public boolean canRedo()
IUndoableOperation
Returns whether the operation can be redone in its current state.
Note: The computation for this method must be fast, as it is called frequently. If necessary, this method can be optimistic in its computation (returning true) and later perform more time-consuming computations during the actual redo of the operation, returning the appropriate status if the operation cannot actually be redone at that time.
canRedo
in interface IUndoableOperation
canRedo
in class AbstractOperation
public void dispose()
IUndoableOperation
dispose
in interface IUndoableOperation
dispose
in class AbstractOperation
public IUndoableOperation getTriggeringOperation()
public Object[] getAffectedObjects()
IAdvancedUndoableOperation
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.
getAffectedObjects
in interface IAdvancedUndoableOperation
null
if the affected objects cannot be determined.public void aboutToNotify(OperationHistoryEvent event)
IAdvancedUndoableOperation
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.
aboutToNotify
in interface IAdvancedUndoableOperation
event
- the event that is about to be sent with the pending
notificationpublic IStatus computeUndoableStatus(IProgressMonitor monitor) throws ExecutionException
IAdvancedUndoableOperation
IUndoableOperation.canUndo()
. It is not called by the
operation history, but instead is used by clients (such as implementers
of IOperationApprover
) 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 answer
false
on subsequent calls to
IUndoableOperation.canUndo()
.
computeUndoableStatus
in interface IAdvancedUndoableOperation
monitor
- the progress monitor (or null
) to use for
reporting progress to the user while computing the validity.
OK
if the undo can
successfully be performed, and ERROR
if it
cannnot. Any other status is assumed to represent an ambiguous
state.
ExecutionException
- if an exception occurs while computing the validity.public IStatus computeRedoableStatus(IProgressMonitor monitor) throws ExecutionException
IAdvancedUndoableOperation
IUndoableOperation.canRedo()
. It is not called by the
operation history, but instead is used by clients (such as implementers
of IOperationApprover
) 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 answer
false
on subsequent calls to
IUndoableOperation.canRedo()
.
computeRedoableStatus
in interface IAdvancedUndoableOperation
monitor
- the progress monitor (or null
) to use for
reporting progress to the user while computing the validity.
OK
if the redo can
successfully be performed, and ERROR
if it
cannnot. Any other status is assumed to represent an ambiguous
state.
ExecutionException
- if an exception occurs while computing the validity.
|
Eclipse Platform Release 3.1 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.