org.eclipse.jdt.internal.core
Class JavaModelOperation

java.lang.Object
  extended by org.eclipse.jdt.internal.core.JavaModelOperation
All Implemented Interfaces:
IWorkspaceRunnable, org.eclipse.core.runtime.IProgressMonitor
Direct Known Subclasses:
BatchOperation, BecomeWorkingCopyOperation, ChangeClasspathOperation, CommitWorkingCopyOperation, CopyPackageFragmentRootOperation, CreateCompilationUnitOperation, CreateElementInCUOperation, CreatePackageFragmentOperation, CreateTypeHierarchyOperation, DeletePackageFragmentRootOperation, DiscardWorkingCopyOperation, MultiOperation, ReconcileWorkingCopyOperation, SortElementsOperation

public abstract class JavaModelOperation
extends java.lang.Object
implements IWorkspaceRunnable, org.eclipse.core.runtime.IProgressMonitor

Defines behavior common to all Java Model operations


Field Summary
static java.lang.String HAS_MODIFIED_RESOURCE_ATTR
           
 org.eclipse.core.runtime.IProgressMonitor progressMonitor
          The progress monitor passed into this operation
static java.lang.String TRUE
           
 
Fields inherited from interface org.eclipse.core.runtime.IProgressMonitor
UNKNOWN
 
Method Summary
 void beginTask(java.lang.String name, int totalWork)
           
 void done()
           
 void executeNestedOperation(JavaModelOperation operation, int subWorkAmount)
          Convenience method to run an operation within this operation
 IJavaModel getJavaModel()
          Returns the Java Model this operation is operating in.
 IJavaElement[] getResultElements()
          Returns the elements created by this operation.
 boolean hasModifiedResource()
          Returns whether this operation has performed any resource modifications.
 void internalWorked(double work)
           
 boolean isCanceled()
           
 boolean isReadOnly()
          Returns true if this operation performs no resource modifications, otherwise false.
 JavaElementDelta newJavaElementDelta()
          Creates and returns a new IJavaElementDelta on the Java Model.
 void run(org.eclipse.core.runtime.IProgressMonitor monitor)
          Runs this operation and registers any deltas created.
 void runOperation(org.eclipse.core.runtime.IProgressMonitor monitor)
          Main entry point for Java Model operations.
 void setCanceled(boolean b)
           
 void setTaskName(java.lang.String name)
           
 void subTask(java.lang.String name)
           
 void worked(int work)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HAS_MODIFIED_RESOURCE_ATTR

public static final java.lang.String HAS_MODIFIED_RESOURCE_ATTR
See Also:
Constant Field Values

TRUE

public static final java.lang.String TRUE
See Also:
Constant Field Values

progressMonitor

public org.eclipse.core.runtime.IProgressMonitor progressMonitor
The progress monitor passed into this operation

Method Detail

beginTask

public void beginTask(java.lang.String name,
                      int totalWork)
Specified by:
beginTask in interface org.eclipse.core.runtime.IProgressMonitor
See Also:
IProgressMonitor

done

public void done()
Specified by:
done in interface org.eclipse.core.runtime.IProgressMonitor
See Also:
IProgressMonitor

executeNestedOperation

public void executeNestedOperation(JavaModelOperation operation,
                                   int subWorkAmount)
                            throws JavaModelException
Convenience method to run an operation within this operation

Throws:
JavaModelException

getJavaModel

public IJavaModel getJavaModel()
Returns the Java Model this operation is operating in.


getResultElements

public IJavaElement[] getResultElements()
Returns the elements created by this operation.


hasModifiedResource

public boolean hasModifiedResource()
Returns whether this operation has performed any resource modifications. Returns false if this operation has not been executed yet.


internalWorked

public void internalWorked(double work)
Specified by:
internalWorked in interface org.eclipse.core.runtime.IProgressMonitor

isCanceled

public boolean isCanceled()
Specified by:
isCanceled in interface org.eclipse.core.runtime.IProgressMonitor
See Also:
IProgressMonitor

isReadOnly

public boolean isReadOnly()
Returns true if this operation performs no resource modifications, otherwise false. Subclasses must override.


newJavaElementDelta

public JavaElementDelta newJavaElementDelta()
Creates and returns a new IJavaElementDelta on the Java Model.


run

public void run(org.eclipse.core.runtime.IProgressMonitor monitor)
         throws org.eclipse.core.runtime.CoreException
Runs this operation and registers any deltas created.

Specified by:
run in interface IWorkspaceRunnable
Parameters:
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Throws:
org.eclipse.core.runtime.CoreException - if the operation fails
See Also:
IWorkspaceRunnable

runOperation

public void runOperation(org.eclipse.core.runtime.IProgressMonitor monitor)
                  throws JavaModelException
Main entry point for Java Model operations. Runs a Java Model Operation as an IWorkspaceRunnable if not read-only.

Throws:
JavaModelException

setCanceled

public void setCanceled(boolean b)
Specified by:
setCanceled in interface org.eclipse.core.runtime.IProgressMonitor
See Also:
IProgressMonitor

setTaskName

public void setTaskName(java.lang.String name)
Specified by:
setTaskName in interface org.eclipse.core.runtime.IProgressMonitor
See Also:
IProgressMonitor

subTask

public void subTask(java.lang.String name)
Specified by:
subTask in interface org.eclipse.core.runtime.IProgressMonitor
See Also:
IProgressMonitor

worked

public void worked(int work)
Specified by:
worked in interface org.eclipse.core.runtime.IProgressMonitor
See Also:
IProgressMonitor