Eclipse Platform
Release 3.0

org.eclipse.ui.actions
Class WorkspaceModifyOperation

java.lang.Object
  extended byorg.eclipse.ui.actions.WorkspaceModifyOperation
All Implemented Interfaces:
IRunnableWithProgress
Direct Known Subclasses:
ImportOperation, WorkspaceModifyDelegatingOperation

public abstract class WorkspaceModifyOperation
extends Object
implements IRunnableWithProgress

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 deferred until the outermost operation has successfully completed.

If a scheduling rule is provided, the operation will obtain that scheduling rule for the duration of its execute method. 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 execute to do the work of the operation.

See Also:
ISchedulingRule, IWorkspace.run(IWorkspaceRunnable, IProgressMonitor)

Constructor Summary
protected WorkspaceModifyOperation()
          Creates a new operation.
protected WorkspaceModifyOperation(ISchedulingRule rule)
          Creates a new operation that will run using the provided scheduling rule.
 
Method Summary
protected abstract  void execute(IProgressMonitor monitor)
          Performs the steps that are to be treated as a single logical workspace change.
 void run(IProgressMonitor monitor)
          The WorkspaceModifyOperation implementation of this IRunnableWithProgress method initiates a batch of changes by invoking the execute method as a workspace runnable (IWorkspaceRunnable).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 or null.
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 CoreException
InvocationTargetException - if the operation fails due to an exception other than CoreException
InterruptedException - if the operation detects a request to cancel, using IProgressMonitor.isCanceled(), it should exit by throwing InterruptedException. It is also possible to throw OperationCanceledException, which gets mapped to InterruptedException by the run method.

run

public final void run(IProgressMonitor monitor)
               throws InvocationTargetException,
                      InterruptedException
The WorkspaceModifyOperation implementation of this IRunnableWithProgress method initiates a batch of changes by invoking the execute method as a workspace runnable (IWorkspaceRunnable).

Specified by:
run in interface IRunnableWithProgress
Parameters:
monitor - the progress monitor to use to display progress and receive requests for cancelation
Throws:
InterruptedException - if the operation detects a request to cancel, using IProgressMonitor.isCanceled(), it should exit by throwing InterruptedException
InvocationTargetException - if the run method must propagate a checked exception, it should wrap it inside an InvocationTargetException; runtime exceptions are automatically wrapped in an InvocationTargetException by the calling context
See Also:
IRunnableContext.run(boolean, boolean, org.eclipse.jface.operation.IRunnableWithProgress)

Eclipse Platform
Release 3.0

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.