| org.eclipse.ui.actions.SelectionListenerAction org.eclipse.ui.actions.WorkspaceAction
All known Subclasses: org.eclipse.ui.actions.RefreshAction, org.eclipse.ui.actions.OpenResourceAction, org.eclipse.ui.actions.CloseResourceAction, org.eclipse.ui.actions.ScrubLocalAction, org.eclipse.ui.actions.RenameResourceAction, org.eclipse.ui.actions.BuildAction,
WorkspaceAction | abstract public class WorkspaceAction extends SelectionListenerAction (Code) | | The abstract superclass for actions which invoke commands implemented in
org.eclipse.core.* on a set of selected resources.
It iterates over all selected resources; errors are collected and displayed
to the user via a problems dialog at the end of the operation. User requests
to cancel the operation are passed along to the core.
Subclasses must implement the following methods:
invokeOperation - to perform the operation on one of the
selected resources
getOperationMessage - to furnish a title for the progress
dialog
Subclasses may override the following methods:
shouldPerformResourcePruning - reimplement to turn off
updateSelection - extend to refine enablement criteria
getProblemsTitle - reimplement to furnish a title for the
problems dialog
getProblemsMessage - reimplement to furnish a message for
the problems dialog
run - extend to
|
Constructor Summary | |
protected | WorkspaceAction(Shell shell, String text) Creates a new action with the given text. |
Method Summary | |
protected IRunnableWithProgress | createOperation(IStatus[] errorStatus) Returns the operation to perform when this action runs. | void | displayError(String message) Opens an error dialog to display the given message. | final IStatus | execute(List resources, IProgressMonitor monitor) Runs invokeOperation on each of the selected resources,
reporting progress and fielding cancel requests from the given progress
monitor.
Note that if an action is running in the background, the same action
instance can be executed multiple times concurrently. | protected List | getActionResources() Returns the elements that the action is to be performed on. | abstract protected String | getOperationMessage() Returns the string to display for this action's operation. | protected String | getProblemsMessage() Returns the string to display for this action's problems dialog.
The WorkspaceAction implementation of this method returns
a vague message (localized counterpart of something like "The following
problems occurred."). | protected String | getProblemsTitle() Returns the title for this action's problems dialog.
The WorkspaceAction implementation of this method returns
a generic title (localized counterpart of "Problems"). | Shell | getShell() Returns the shell for this action. | abstract protected void | invokeOperation(IResource resource, IProgressMonitor monitor) Performs this action's operation on each of the selected resources,
reporting progress to, and fielding cancel requests from, the given
progress monitor. | boolean | isDescendent(List resources, IResource child) Returns whether the given resource is a descendent of any of the
resources in the given list. | List | pruneResources(List resourceCollection) Performs pruning on the given list of resources, as described in
shouldPerformResourcePruning . | MultiStatus | recordError(MultiStatus errors, CoreException error) Records the core exception to be displayed to the user once the action is
finished. | public void | run() The CoreWrapperAction implementation of this
IAction method uses a ProgressMonitorDialog
to run the operation. | public void | runInBackground(ISchedulingRule rule) Run the action in the background rather than with the progress dialog. | public void | runInBackground(ISchedulingRule rule, Object jobFamily) Run the action in the background rather than with the progress dialog. | public void | runInBackground(ISchedulingRule rule, Object[] jobFamilies) Run the action in the background rather than with the progress dialog. | protected boolean | shouldPerformResourcePruning() Returns whether this action should attempt to optimize the resources
being operated on. | protected boolean | updateSelection(IStructuredSelection selection) The WorkspaceAction implementation of this
SelectionListenerAction method ensures that this action is
disabled if any of the selected resources are inaccessible. |
WorkspaceAction | protected WorkspaceAction(Shell shell, String text)(Code) | | Creates a new action with the given text.
Parameters: shell - the shell (for the modal progress dialog and error messages) Parameters: text - the string used as the text for the action, ornull if there is no text |
createOperation | protected IRunnableWithProgress createOperation(IStatus[] errorStatus)(Code) | | Returns the operation to perform when this action runs. The returned
operation must be an
IRunnableWithProgress that will perform the
action's work. The default implementation returns an operation that will
iterate over the selected resources and call
WorkspaceAction.invokeOperation(IResource,IProgressMonitor) for each resource.
Subclasses must either implement
WorkspaceAction.invokeOperation(IResource,IProgressMonitor) or override this
method to provide a different operation. Subclasses typically override
this method when an undoable operation is to be provided.
Parameters: errorStatus - an array of error status objects to which the result ofrunning the operation should be added. the operation to perform when this action runs. since: 3.3 |
displayError | void displayError(String message)(Code) | | Opens an error dialog to display the given message.
Note that this method must be called from UI thread.
Parameters: message - the message |
execute | final IStatus execute(List resources, IProgressMonitor monitor)(Code) | | Runs invokeOperation on each of the selected resources,
reporting progress and fielding cancel requests from the given progress
monitor.
Note that if an action is running in the background, the same action
instance can be executed multiple times concurrently. This method must
not access or modify any mutable state on action class.
Parameters: monitor - a progress monitor The result of the execution |
getActionResources | protected List getActionResources()(Code) | | Returns the elements that the action is to be performed on. By default
return the selected resources.
Subclasses may override this method.
list of resource elements (element type: IResource ) |
getOperationMessage | abstract protected String getOperationMessage()(Code) | | Returns the string to display for this action's operation.
Note that this hook method is invoked in a non-UI thread.
Subclasses must implement this method.
the message since: 3.1 |
getProblemsMessage | protected String getProblemsMessage()(Code) | | Returns the string to display for this action's problems dialog.
The WorkspaceAction implementation of this method returns
a vague message (localized counterpart of something like "The following
problems occurred."). Subclasses may reimplement to provide something
more suited to the particular action.
the problems message since: 3.1 |
getProblemsTitle | protected String getProblemsTitle()(Code) | | Returns the title for this action's problems dialog.
The WorkspaceAction implementation of this method returns
a generic title (localized counterpart of "Problems"). Subclasses may
reimplement to provide something more suited to the particular action.
the problems dialog title since: 3.1 |
getShell | Shell getShell()(Code) | | Returns the shell for this action. This shell is used for the modal
progress and error dialogs.
the shell |
invokeOperation | abstract protected void invokeOperation(IResource resource, IProgressMonitor monitor) throws CoreException(Code) | | Performs this action's operation on each of the selected resources,
reporting progress to, and fielding cancel requests from, the given
progress monitor.
Note that this method is invoked in a non-UI thread.
Subclasses must implement this method.
WorkspaceAction.createOperation(IStatus[]) Parameters: resource - one of the selected resources Parameters: monitor - a progress monitor exception: CoreException - if the operation fails since: 3.1 |
isDescendent | boolean isDescendent(List resources, IResource child)(Code) | | Returns whether the given resource is a descendent of any of the
resources in the given list.
Parameters: resources - the list of resources (element type: IResource ) Parameters: child - the resource to check true if child is a descendent ofany of the elements of resources |
pruneResources | List pruneResources(List resourceCollection)(Code) | | Performs pruning on the given list of resources, as described in
shouldPerformResourcePruning .
Parameters: resourceCollection - the list of resources (element type: IResource ) the list of resources (element type: IResource )after pruning. See Also: WorkspaceAction.shouldPerformResourcePruning |
recordError | MultiStatus recordError(MultiStatus errors, CoreException error)(Code) | | Records the core exception to be displayed to the user once the action is
finished.
Parameters: error - a CoreException |
run | public void run()(Code) | | The CoreWrapperAction implementation of this
IAction method uses a ProgressMonitorDialog
to run the operation. The operation calls execute (which,
in turn, calls invokeOperation ). Afterwards, any
CoreException s encountered while running the operation
are reported to the user via a problems dialog.
Subclasses may extend this method.
|
runInBackground | public void runInBackground(ISchedulingRule rule)(Code) | | Run the action in the background rather than with the progress dialog.
Parameters: rule - The rule to apply to the background job or null if there isn't one. |
runInBackground | public void runInBackground(ISchedulingRule rule, Object jobFamily)(Code) | | Run the action in the background rather than with the progress dialog.
Parameters: rule - The rule to apply to the background job or null if there isn't one. Parameters: jobFamily - a single family that the job should belong to ornull if none. since: 3.1 |
runInBackground | public void runInBackground(ISchedulingRule rule, Object[] jobFamilies)(Code) | | Run the action in the background rather than with the progress dialog.
Parameters: rule - The rule to apply to the background job or null if there isn't one. Parameters: jobFamilies - the families the job should belong to or null if none. since: 3.1 |
shouldPerformResourcePruning | protected boolean shouldPerformResourcePruning()(Code) | | Returns whether this action should attempt to optimize the resources
being operated on. This kind of pruning makes sense when the operation
has depth infinity semantics (when the operation is applied explicitly to
a resource then it is also applied implicitly to all the resource's
descendents).
The WorkspaceAction implementation of this method returns
true . Subclasses should reimplement to return
false if pruning is not required.
true if pruning should be performed, andfalse if pruning is not desired since: 3.1 |
updateSelection | protected boolean updateSelection(IStructuredSelection selection)(Code) | | The WorkspaceAction implementation of this
SelectionListenerAction method ensures that this action is
disabled if any of the selected resources are inaccessible. Subclasses
may extend to react to selection changes; however, if the super method
returns false , the overriding method should also return
false .
|
|
|