| org.eclipse.ui.ide.undo.AbstractWorkspaceOperation
All known Subclasses: org.eclipse.ui.ide.undo.AbstractResourcesOperation, org.eclipse.ui.ide.undo.AbstractMarkersOperation,
AbstractWorkspaceOperation | abstract public class AbstractWorkspaceOperation extends AbstractOperation implements IAdvancedUndoableOperation,IAdvancedUndoableOperation2(Code) | | An AbstractWorkspaceOperation represents an undoable operation that affects
the workspace. It handles common workspace operation activities such as
tracking which resources are affected by an operation, prompting the user
when there are possible side effects of operations, building execution
exceptions from core exceptions, etc. Clients may call the public API from a
background thread.
This class is not intended to be subclassed by clients.
since: 3.3 |
Method Summary | |
public void | aboutToNotify(OperationHistoryEvent event) | protected void | appendDescriptiveText(StringBuffer text) Append any descriptive text to the specified string buffer to be shown in
the receiver's
AbstractWorkspaceOperation.toString() text. | public boolean | canExecute() | public boolean | canRedo() | public boolean | canUndo() | public IStatus | computeExecutionStatus(IProgressMonitor monitor) Return a status indicating the projected outcome of executing the
receiver. | public IStatus | computeRedoableStatus(IProgressMonitor monitor) Return a status indicating the projected outcome of redoing the receiver.
This method is not called by the operation history, but instead is used
by clients (such as implementers of
org.eclipse.core.commands.operations.IOperationApprover2 ) who
wish to perform advanced validation of an operation before attempting to
redo it.
If an ERROR status is returned, the redo will not proceed and the user
notified if deemed necessary by the caller. | public IStatus | computeUndoableStatus(IProgressMonitor monitor) Return a status indicating the projected outcome of undoing the receiver.
This method is not called by the operation history, but instead is used
by clients (such as implementers of
org.eclipse.core.commands.operations.IOperationApprover2 ) who
wish to perform advanced validation of an operation before attempting to
undo it.
If an ERROR status is returned, the undo will not proceed and the user
notified if deemed necessary by the caller. | abstract protected void | doExecute(IProgressMonitor monitor, IAdaptable uiInfo) Perform the specific work involved in executing this operation.
Parameters: monitor - the progress monitor to use for the operation Parameters: uiInfo - the IAdaptable (or null ) provided by thecaller in order to supply UI information for prompting theuser if necessary. | abstract protected void | doUndo(IProgressMonitor monitor, IAdaptable uiInfo) Perform the specific work involved in undoing this operation.
Parameters: monitor - the progress monitor to use for the operation Parameters: uiInfo - the IAdaptable (or null ) provided by thecaller in order to supply UI information for prompting theuser if necessary. | public IStatus | execute(IProgressMonitor monitor, IAdaptable uiInfo) Execute the specified operation. | public Object[] | getAffectedObjects() | protected IStatus | getErrorStatus(String message) Return an error status describing an invalid operation using the provided
message. | protected ISchedulingRule | getExecuteSchedulingRule() Return a scheduling rule appropriate for executing this operation.
The default implementation is to return a rule that locks out the entire
workspace. | protected ISchedulingRule | getRedoSchedulingRule() Return a scheduling rule appropriate for redoing this operation. | protected Shell | getShell(IAdaptable uiInfo) Return the shell described by the specified adaptable, or the active
shell if no shell has been specified in the adaptable.
Parameters: uiInfo - the IAdaptable (or null ) provided by thecaller in order to supply UI information for prompting theuser if necessary. | protected ISchedulingRule | getUndoSchedulingRule() Return a scheduling rule appropriate for undoing this operation.
The default implementation is to return a rule that locks out the entire
workspace. | protected IStatus | getWarningStatus(String message, int code) Return a warning status describing the warning state of an operation
using the provided message and code. | protected IWorkspace | getWorkspace() Return the workspace manipulated by this operation. | protected IResourceRuleFactory | getWorkspaceRuleFactory() Return the workspace rule factory associated with this operation. | protected boolean | isValid() Return whether the proposed operation is valid. | protected void | markInvalid() Mark this operation invalid due to some external change. | public IStatus | redo(IProgressMonitor monitor, IAdaptable uiInfo) Redo the specified operation. | protected boolean | resourcesExist() Return whether the resources known by this operation currently exist. | protected boolean | resourcesIncludesProjects() Return whether the resources known by this operation contain any
projects. | public boolean | runInBackground() | public void | setModelProviderIds(String[] ids) Set the ids of any model providers for the resources involved. | public void | setQuietCompute(boolean quiet) | protected void | setTargetResources(IResource[] resources) | public String | toString() | public IStatus | undo(IProgressMonitor monitor, IAdaptable uiInfo) Undo the specified operation. | protected boolean | updateResourceChangeDescriptionFactory(IResourceChangeDescriptionFactory factory, int operation) Update the provided resource change description factory so it can
generate a resource delta describing the result of an undo or redo.
Return a boolean indicating whether any update was done. |
EXECUTE | protected static int EXECUTE(Code) | | |
REDO | protected static int REDO(Code) | | |
UNDO | protected static int UNDO(Code) | | |
quietCompute | protected boolean quietCompute(Code) | | |
resources | protected IResource[] resources(Code) | | |
AbstractWorkspaceOperation | AbstractWorkspaceOperation(String name)(Code) | | Create an AbstractWorkspaceOperation with the specified name.
Parameters: name - the name used to describe the operation |
aboutToNotify | public void aboutToNotify(OperationHistoryEvent event)(Code) | | |
appendDescriptiveText | protected void appendDescriptiveText(StringBuffer text)(Code) | | Append any descriptive text to the specified string buffer to be shown in
the receiver's
AbstractWorkspaceOperation.toString() text.
Note that this method is not intend to be subclassed by clients.
Parameters: text - the StringBuffer on which to append the text |
canExecute | public boolean canExecute()(Code) | | |
canRedo | public boolean canRedo()(Code) | | |
canUndo | public boolean canUndo()(Code) | | |
computeExecutionStatus | public IStatus computeExecutionStatus(IProgressMonitor monitor)(Code) | | Return a status indicating the projected outcome of executing the
receiver. This method is not called by the operation history, but instead
is used by clients (such as implementers of
org.eclipse.core.commands.operations.IOperationApprover2 ) who
wish to perform advanced validation of an operation before attempting to
execute it.
If an ERROR status is returned, the operation will not proceed and the
user notified if deemed necessary by the caller. The validity flag on the
operation should be marked as invalid. If an OK status is returned, the
operation will proceed. The caller must interpret any other returned
status severity, and may choose to prompt the user as to how to proceed.
If there are multiple conditions that result in an ambiguous status
severity, it is best for the implementor of this method to consult the
user as to how to proceed for each one, and return an OK or ERROR status
that accurately reflects the user's wishes, or to return a multi-status
that accurately describes all of the issues at hand, so that the caller
may potentially consult the user. (Note that the user should not be
consulted at all if a client has called
AbstractWorkspaceOperation.setQuietCompute(boolean) with a value of true .)
This implementation computes the validity of execution by computing the
resource delta that would be generated on execution, and checking whether
any registered model providers are affected by the operation.
Parameters: monitor - the progress monitor to be used for computing the status the status indicating the projected outcome of executing thereceiver See Also: org.eclipse.core.commands.operations.IAdvancedUndoableOperation.computeUndoableStatus(org.eclipse.core.runtime.IProgressMonitor) See Also: AbstractWorkspaceOperation.setQuietCompute(boolean) |
computeRedoableStatus | public IStatus computeRedoableStatus(IProgressMonitor monitor)(Code) | | Return a status indicating the projected outcome of redoing the receiver.
This method is not called by the operation history, but instead is used
by clients (such as implementers of
org.eclipse.core.commands.operations.IOperationApprover2 ) who
wish to perform advanced validation of an operation before attempting to
redo it.
If an ERROR status is returned, the redo will not proceed and the user
notified if deemed necessary by the caller. The validity flag on the
operation should be marked as invalid. If an OK status is returned, the
redo will proceed. The caller must interpret any other returned status
severity, and may choose to prompt the user as to how to proceed.
If there are multiple conditions that result in an ambiguous status
severity, it is best for the implementor of this method to consult the
user as to how to proceed for each one, and return an OK or ERROR status
that accurately reflects the user's wishes, or to return a multi-status
that accurately describes all of the issues at hand, so that the caller
may potentially consult the user. (Note that the user should not be
consulted at all if a client has called
AbstractWorkspaceOperation.setQuietCompute(boolean) with a value of true .)
This implementation computes the validity of redo by computing the
resource delta that would be generated on redo, and checking whether any
registered model providers are affected by the operation.
Parameters: monitor - the progress monitor to be used for computing the status the status indicating the projected outcome of redoing thereceiver See Also: org.eclipse.core.commands.operations.IAdvancedUndoableOperation.computeUndoableStatus(org.eclipse.core.runtime.IProgressMonitor) See Also: AbstractWorkspaceOperation.setQuietCompute(boolean) |
computeUndoableStatus | public IStatus computeUndoableStatus(IProgressMonitor monitor)(Code) | | Return a status indicating the projected outcome of undoing the receiver.
This method is not called by the operation history, but instead is used
by clients (such as implementers of
org.eclipse.core.commands.operations.IOperationApprover2 ) who
wish to perform advanced validation of an operation before attempting to
undo it.
If an ERROR status is returned, the undo will not proceed and the user
notified if deemed necessary by the caller. The validity flag on the
operation should be marked as invalid. If an OK status is returned, the
undo will proceed. The caller must interpret any other returned status
severity, and may choose to prompt the user as to how to proceed.
If there are multiple conditions that result in an ambiguous status
severity, it is best for the implementor of this method to consult the
user as to how to proceed for each one, and return an OK or ERROR status
that accurately reflects the user's wishes, or to return a multi-status
that accurately describes all of the issues at hand, so that the caller
may potentially consult the user. (Note that the user should not be
consulted at all if a client has called
AbstractWorkspaceOperation.setQuietCompute(boolean) with a value of true .)
This implementation computes the validity of undo by computing the
resource delta that would be generated on undo, and checking whether any
registered model providers are affected by the operation.
Parameters: monitor - the progress monitor to be used for computing the status the status indicating the projected outcome of undoing thereceiver See Also: org.eclipse.core.commands.operations.IAdvancedUndoableOperation.computeUndoableStatus(org.eclipse.core.runtime.IProgressMonitor) See Also: AbstractWorkspaceOperation.setQuietCompute(boolean) |
doExecute | abstract protected void doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws CoreException(Code) | | Perform the specific work involved in executing this operation.
Parameters: monitor - the progress monitor to use for the operation Parameters: uiInfo - the IAdaptable (or null ) provided by thecaller in order to supply UI information for prompting theuser if necessary. When this parameter is notnull , it contains an adapter for theorg.eclipse.swt.widgets.Shell.class throws: CoreException - propagates any CoreExceptions thrown from the resources API |
doUndo | abstract protected void doUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws CoreException(Code) | | Perform the specific work involved in undoing this operation.
Parameters: monitor - the progress monitor to use for the operation Parameters: uiInfo - the IAdaptable (or null ) provided by thecaller in order to supply UI information for prompting theuser if necessary. When this parameter is notnull , it contains an adapter for theorg.eclipse.swt.widgets.Shell.class throws: CoreException - propagates any CoreExceptions thrown from the resources API |
execute | public IStatus execute(IProgressMonitor monitor, IAdaptable uiInfo) throws ExecutionException(Code) | | Execute the specified operation. This implementation executes the
operation in a workspace runnable and catches any CoreExceptions
resulting from the operation. Unhandled CoreExceptions are propagated as
ExecutionExceptions.
Parameters: monitor - the progress monitor to use for the operation Parameters: uiInfo - the IAdaptable (or null ) provided by thecaller in order to supply UI information for prompting theuser if necessary. When this parameter is notnull , it contains an adapter for theorg.eclipse.swt.widgets.Shell.class the IStatus of the execution. The status severity should be setto OK if the operation was successful, andERROR if it was not. Any other status is assumedto represent an incompletion of the execution. throws: ExecutionException - if an exception occurred during execution. See Also: org.eclipse.core.commands.operations.IUndoableOperation.execute(org.eclipse.core.runtime.IProgressMonitororg.eclipse.core.runtime.IAdaptable) |
getAffectedObjects | public Object[] getAffectedObjects()(Code) | | |
getErrorStatus | protected IStatus getErrorStatus(String message)(Code) | | Return an error status describing an invalid operation using the provided
message.
Parameters: message - the message to be used in the status, or null if a generic message should be used the error status |
getExecuteSchedulingRule | protected ISchedulingRule getExecuteSchedulingRule()(Code) | | Return a scheduling rule appropriate for executing this operation.
The default implementation is to return a rule that locks out the entire
workspace. Subclasses are encouraged to provide more specific rules that
affect only their resources.
the scheduling rule to use when executing this operation, ornull if there are no scheduling restrictions forthis operation. See Also: IWorkspace.run(IWorkspaceRunnableISchedulingRuleintIProgressMonitor) |
getRedoSchedulingRule | protected ISchedulingRule getRedoSchedulingRule()(Code) | | Return a scheduling rule appropriate for redoing this operation.
The default implementation considers the redo scheduling rule the same as
the original execution scheduling rule.
the scheduling rule to use when redoing this operation, ornull if there are no scheduling restrictions forthis operation. See Also: IWorkspace.run(IWorkspaceRunnableISchedulingRuleintIProgressMonitor) |
getShell | protected Shell getShell(IAdaptable uiInfo)(Code) | | Return the shell described by the specified adaptable, or the active
shell if no shell has been specified in the adaptable.
Parameters: uiInfo - the IAdaptable (or null ) provided by thecaller in order to supply UI information for prompting theuser if necessary. When this parameter is notnull , it contains an adapter for theorg.eclipse.swt.widgets.Shell.class the shell specified in the adaptable, or the active shell if noshell has been specified |
getUndoSchedulingRule | protected ISchedulingRule getUndoSchedulingRule()(Code) | | Return a scheduling rule appropriate for undoing this operation.
The default implementation is to return a rule that locks out the entire
workspace. Subclasses are encouraged to provide more specific rules that
affect only their resources.
the scheduling rule to use when undoing this operation, ornull if there are no scheduling restrictions forthis operation. See Also: IWorkspace.run(IWorkspaceRunnableISchedulingRuleintIProgressMonitor) |
getWarningStatus | protected IStatus getWarningStatus(String message, int code)(Code) | | Return a warning status describing the warning state of an operation
using the provided message and code.
Parameters: message - the message to be used in the status, or null if a generic message should be used Parameters: code - the integer code to be assigned to the status the warning status |
getWorkspace | protected IWorkspace getWorkspace()(Code) | | Return the workspace manipulated by this operation.
the IWorkspace used by this operation. |
getWorkspaceRuleFactory | protected IResourceRuleFactory getWorkspaceRuleFactory()(Code) | | Return the workspace rule factory associated with this operation.
the IResourceRuleFactory associated with this operation. |
isValid | protected boolean isValid()(Code) | | Return whether the proposed operation is valid. The default
implementation simply checks to see if the flag has been marked as
invalid, relying on subclasses to mark the flag invalid when appropriate.
the validity flag |
markInvalid | protected void markInvalid()(Code) | | Mark this operation invalid due to some external change. May be used by
subclasses.
|
redo | public IStatus redo(IProgressMonitor monitor, IAdaptable uiInfo) throws ExecutionException(Code) | | Redo the specified operation. This implementation redoes the operation in
a workspace runnable and catches any CoreExceptions resulting from the
operation. Unhandled CoreExceptions are propagated as
ExecutionExceptions.
Parameters: monitor - the progress monitor to use for the operation Parameters: uiInfo - the IAdaptable (or null ) provided by thecaller in order to supply UI information for prompting theuser if necessary. When this parameter is notnull , it contains an adapter for theorg.eclipse.swt.widgets.Shell.class the IStatus of the redo. The status severity should be set toOK if the operation was successful, andERROR if it was not. Any other status is assumedto represent an incompletion of the redo. throws: ExecutionException - if an exception occurred during execution. See Also: org.eclipse.core.commands.operations.IUndoableOperation.redo(org.eclipse.core.runtime.IProgressMonitororg.eclipse.core.runtime.IAdaptable) |
resourcesExist | protected boolean resourcesExist()(Code) | | Return whether the resources known by this operation currently exist.
true if there are existing resources andfalse if there are no known resources or any oneof them does not exist |
resourcesIncludesProjects | protected boolean resourcesIncludesProjects()(Code) | | Return whether the resources known by this operation contain any
projects.
true if there is one or more projects known bythis operation and false if there are no projects. |
runInBackground | public boolean runInBackground()(Code) | | |
setModelProviderIds | public void setModelProviderIds(String[] ids)(Code) | | Set the ids of any model providers for the resources involved.
Parameters: ids - the array of String model provider ids that provide modelsassociated with the resources involved in this operation |
setQuietCompute | public void setQuietCompute(boolean quiet)(Code) | | |
setTargetResources | protected void setTargetResources(IResource[] resources)(Code) | | Set the resources which are affected by this operation
Parameters: resources - an array of resources |
undo | public IStatus undo(IProgressMonitor monitor, IAdaptable uiInfo) throws ExecutionException(Code) | | Undo the specified operation. This implementation undoes the operation in
a workspace runnable and catches any CoreExceptions resulting from the
operation. Unhandled CoreExceptions are propagated as
ExecutionExceptions.
Parameters: monitor - the progress monitor to use for the operation Parameters: uiInfo - the IAdaptable (or null ) provided by thecaller in order to supply UI information for prompting theuser if necessary. When this parameter is notnull , it contains an adapter for theorg.eclipse.swt.widgets.Shell.class the IStatus of the undo. The status severity should be set toOK if the operation was successful, andERROR if it was not. Any other status is assumedto represent an incompletion of the undo. * throws: ExecutionException - if an exception occurred during execution. See Also: org.eclipse.core.commands.operations.IUndoableOperation.undo(org.eclipse.core.runtime.IProgressMonitororg.eclipse.core.runtime.IAdaptable) |
updateResourceChangeDescriptionFactory | protected boolean updateResourceChangeDescriptionFactory(IResourceChangeDescriptionFactory factory, int operation)(Code) | | Update the provided resource change description factory so it can
generate a resource delta describing the result of an undo or redo.
Return a boolean indicating whether any update was done. The default
implementation does not update the factory. Subclasses are expected to
override this method to more specifically describe their modifications to
the workspace.
Parameters: factory - the factory to update Parameters: operation - an integer indicating whether the change is part of anexecute, undo, or redo a boolean indicating whether the factory was updated. |
|
|