Package org.eclipse.ui.actions
Class WorkspaceModifyOperation
- java.lang.Object
-
- org.eclipse.ui.actions.WorkspaceModifyOperation
-
- All Implemented Interfaces:
IRunnableWithProgress,IThreadListener
- Direct Known Subclasses:
ImportOperation,WorkspaceModifyDelegatingOperation
public abstract class WorkspaceModifyOperation extends Object implements IRunnableWithProgress, IThreadListener
An operation which potentially makes changes to the workspace. All resource modification should be performed using this operation. The primary consequence of using this operation is that events which typically occur as a result of workspace changes (such as the firing of resource deltas, performance of autobuilds, etc.) are generally deferred until the outermost operation has successfully completed. The platform may still decide to broadcast periodic resource change notifications during the scope of the operation if the operation runs for a long time or another thread modifies the workspace concurrently.If a scheduling rule is provided, the operation will obtain that scheduling rule for the duration of its
executemethod. If no scheduling rule is provided, the operation will obtain a scheduling rule that locks the entire workspace for the duration of the operation.Subclasses must implement
executeto do the work of the operation.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedWorkspaceModifyOperation()Creates a new operation.protectedWorkspaceModifyOperation(ISchedulingRule rule)Creates a new operation that will run using the provided scheduling rule.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidexecute(IProgressMonitor monitor)Performs the steps that are to be treated as a single logical workspace change.ISchedulingRulegetRule()The scheduling rule.voidrun(IProgressMonitor monitor)TheWorkspaceModifyOperationimplementation of thisIRunnableWithProgressmethod initiates a batch of changes by invoking theexecutemethod as a workspace runnable (IWorkspaceRunnable).voidthreadChange(Thread thread)Notification that a thread change is occurring.
-
-
-
Constructor Detail
-
WorkspaceModifyOperation
protected WorkspaceModifyOperation()
Creates a new operation.
-
WorkspaceModifyOperation
protected WorkspaceModifyOperation(ISchedulingRule rule)
Creates a new operation that will run using the provided scheduling rule.- Parameters:
rule- The ISchedulingRule to use ornull.- Since:
- 3.0
-
-
Method Detail
-
execute
protected abstract void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException
Performs the steps that are to be treated as a single logical workspace change.Subclasses must implement this method.
- Parameters:
monitor- the progress monitor to use to display progress and field user requests to cancel- Throws:
CoreException- if the operation fails due to a CoreExceptionInvocationTargetException- if the operation fails due to an exception other than CoreExceptionInterruptedException- if the operation detects a request to cancel, usingIProgressMonitor.isCanceled(), it should exit by throwingInterruptedException. It is also possible to throwOperationCanceledException, which gets mapped toInterruptedExceptionby therunmethod.
-
run
public final void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
TheWorkspaceModifyOperationimplementation of thisIRunnableWithProgressmethod initiates a batch of changes by invoking theexecutemethod as a workspace runnable (IWorkspaceRunnable).- Specified by:
runin interfaceIRunnableWithProgress- Parameters:
monitor- the progress monitor to use to display progress and receive requests for cancelation- Throws:
InvocationTargetException- if the run method must propagate a checked exception, it should wrap it inside anInvocationTargetException; runtime exceptions are automatically wrapped in anInvocationTargetExceptionby the calling contextInterruptedException- if the operation detects a request to cancel, usingIProgressMonitor.isCanceled(), it should exit by throwingInterruptedException- See Also:
IRunnableContext.run(boolean, boolean, org.eclipse.jface.operation.IRunnableWithProgress)
-
threadChange
public void threadChange(Thread thread)
Description copied from interface:IThreadListenerNotification that a thread change is occurring.- Specified by:
threadChangein interfaceIThreadListener- Parameters:
thread- The new thread
-
getRule
public ISchedulingRule getRule()
The scheduling rule. Should not be modified.- Returns:
- the scheduling rule, or
null. - Since:
- 3.4
-
-