public abstract class Refactoring extends PlatformObject
Change
object
that represents the actual work space modifications.
checkInitialConditions(IProgressMonitor)
is called. The method
can be called more than once.checkFinalConditions(IProgressMonitor)
is called. The method
can be called more than once. The method must not be called if
checkInitialConditions(IProgressMonitor)
returns a refactoring
status of severity RefactoringStatus.FATAL
.createChange(IProgressMonitor)
is called. The method must only be
called once after each call to checkFinalConditions(IProgressMonitor)
and should not be called if one of the condition checking methods
returns a refactoring status of severity RefactoringStatus.FATAL
.
A refactoring can not assume that all resources are saved before any methods are called on it. Therefore a refactoring must be able to deal with unsaved resources.
The class should be subclassed by clients wishing to implement new refactorings.
RefactoringContext
Constructor and Description |
---|
Refactoring() |
Modifier and Type | Method and Description |
---|---|
RefactoringStatus |
checkAllConditions(IProgressMonitor pm)
Checks all conditions.
|
abstract RefactoringStatus |
checkFinalConditions(IProgressMonitor pm)
After
checkInitialConditions has been performed and the user has
provided all input necessary to perform the refactoring this method is called
to check the remaining preconditions. |
abstract RefactoringStatus |
checkInitialConditions(IProgressMonitor pm)
Checks some initial conditions based on the element to be refactored.
|
abstract Change |
createChange(IProgressMonitor pm)
Creates a
Change object that performs the actual workspace
transformation. |
protected RefactoringTickProvider |
doGetRefactoringTickProvider()
Hook method to provide the tick provider used for progress reporting.
|
<T> T |
getAdapter(Class<T> adapter)
Returns an object which is an instance of the given class
associated with this object.
|
abstract String |
getName()
Returns the refactoring's name.
|
RefactoringTickProvider |
getRefactoringTickProvider()
Returns the tick provider used for progress reporting for this
refactoring.
|
Object |
getValidationContext()
Returns the validation context
|
void |
setValidationContext(Object context)
Sets the validation context used when calling
IWorkspace.validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object) . |
String |
toString() |
public final void setValidationContext(Object context)
IWorkspace.validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object)
.context
- the org.eclipse.swt.widgets.Shell
that is
to be used to parent any dialogs with the user, or null
if
there is no UI context (declared as an Object
to avoid any
direct references on the SWT component)public final Object getValidationContext()
null
if no validation
context has been set.public abstract String getName()
null
public final RefactoringTickProvider getRefactoringTickProvider()
protected RefactoringTickProvider doGetRefactoringTickProvider()
Subclasses may override this method
public RefactoringStatus checkAllConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException
checkInitialConditions
and checkFinalConditions
.
Subclasses may extend this method to provide additional condition checks.
pm
- a progress monitor to report progressRefactoringStatus#FATAL
the refactoring has to be considered as not being executable.CoreException
- if an exception occurred during condition checking.
If this happens then the condition checking has to be interpreted as failedOperationCanceledException
- if the condition checking got canceledcheckInitialConditions(IProgressMonitor)
,
checkFinalConditions(IProgressMonitor)
public abstract RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException
The refactoring has to be considered as not being executable if the returned status
has the severity of RefactoringStatus#FATAL
.
This method can be called more than once.
pm
- a progress monitor to report progress. Although initial checks
are supposed to execute fast, there can be certain situations where progress
reporting is necessary. For example rebuilding a corrupted index may report
progress.RefactoringStatus#FATAL
the refactoring has to be considered as not being executable.CoreException
- if an exception occurred during initial condition checking.
If this happens then the initial condition checking has to be interpreted as failedOperationCanceledException
- if the condition checking got canceledcheckFinalConditions(IProgressMonitor)
,
RefactoringStatus.FATAL
public abstract RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException
checkInitialConditions
has been performed and the user has
provided all input necessary to perform the refactoring this method is called
to check the remaining preconditions.
The refactoring has to be considered as not being executable if the returned status
has the severity of RefactoringStatus#FATAL
.
This method can be called more than once.
pm
- a progress monitor to report progressRefactoringStatus#FATAL
the refactoring is considered as not being executable.CoreException
- if an exception occurred during final condition checking
If this happens then the final condition checking is interpreted as failedOperationCanceledException
- if the condition checking got canceledcheckInitialConditions(IProgressMonitor)
,
RefactoringStatus.FATAL
public abstract Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException
Change
object that performs the actual workspace
transformation.pm
- a progress monitor to report progressCoreException
- if an error occurred while creating the changeOperationCanceledException
- if the condition checking got canceledpublic <T> T getAdapter(Class<T> adapter)
PlatformObject
null
if
no such object can be found.
This implementation of the method declared by IAdaptable
passes the request along to the platform's adapter manager; roughly
Platform.getAdapterManager().getAdapter(this, adapter)
.
Subclasses may override this method (however, if they do so, they
should invoke the method on their superclass to ensure that the
Platform's adapter manager is consulted).
getAdapter
in interface IAdaptable
getAdapter
in class PlatformObject
adapter
- the class to adapt tonull
IAdaptable.getAdapter(Class)
Copyright (c) 2000, 2016 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.