org.eclipse.ltk.core.refactoring.resource
Class ResourceChange
java.lang.Object
org.eclipse.ltk.core.refactoring.Change
org.eclipse.ltk.core.refactoring.resource.ResourceChange
-
All Implemented Interfaces:
-
IAdaptable
-
Direct Known Subclasses:
-
DeleteResourceChange,
MoveResourceChange,
RenameResourceChange
-
public abstract class ResourceChange
- extends
Change
Abstract change for resource based changes. The change controls the resource time stamp
and read only state of the resource and makes sure it is not changed before executing the change.
-
Since:
- 3.4
Field Summary
|
static int
|
SAVE_IF_DIRTY
The 'save if dirty' validation method performs the default validations (see
VALIDATE_DEFAULT ) and will
save all unsaved modifications to the resource. |
static int
|
VALIDATE_DEFAULT
The default validation method. |
static int
|
VALIDATE_NOT_DIRTY
The 'not dirty' validation method performs the default validations (see
VALIDATE_DEFAULT ) and additionally ensures that the element
does not contain unsaved modifications. |
static int
|
VALIDATE_NOT_READ_ONLY
The 'not read only' validation method performs the default validations (see
VALIDATE_DEFAULT ) and additionally ensures that the element
is not read only. |
VALIDATE_DEFAULT
public static final int VALIDATE_DEFAULT
- The default validation method. It tests the modified element for existence and makes sure it has not been modified
since the change has been created.
-
See Also:
-
Constant Field Values
VALIDATE_NOT_READ_ONLY
public static final int VALIDATE_NOT_READ_ONLY
- The 'not read only' validation method performs the default validations (see
VALIDATE_DEFAULT
) and additionally ensures that the element
is not read only.
-
See Also:
-
Constant Field Values
VALIDATE_NOT_DIRTY
public static final int VALIDATE_NOT_DIRTY
- The 'not dirty' validation method performs the default validations (see
VALIDATE_DEFAULT
) and additionally ensures that the element
does not contain unsaved modifications.
-
See Also:
-
Constant Field Values
SAVE_IF_DIRTY
public static final int SAVE_IF_DIRTY
- The 'save if dirty' validation method performs the default validations (see
VALIDATE_DEFAULT
) and will
save all unsaved modifications to the resource.
-
See Also:
-
Constant Field Values
ResourceChange
public ResourceChange()
- Creates the resource change. The modification state will be
getModifiedResource
protected abstract
IResource getModifiedResource()
- Returns the resource of this change.
-
-
Returns:
- the resource of this change
initializeValidationData
public void initializeValidationData(
IProgressMonitor pm)
-
Description copied from class:
Change
- Hook method to initialize some internal state to provide an adequate answer
for the
isValid
method. This method gets called after a change
or a whole change tree has been created.
Typically this method is implemented in one of the following ways:
- the change hooks up a listener on some delta notification mechanism
and marks itself as invalid if it receives a certain delta. Is this
the case the implementor must take care of unhooking the listener
in
dispose
.
- the change remembers some information allowing to decide if a change
object is still valid when
isValid
is called.
For example, a change object that manipulates the content of an IFile
could either listen to resource changes and detect that the file got changed or
it could remember some content stamp and compare it with the actual content stamp
when isValid
is called.
-
-
Specified by:
-
initializeValidationData
in class
Change
-
-
Parameters:
-
pm
- a progress monitor
setValidationMethod
public void setValidationMethod(int validationMethod)
- Sets the validation methods used when the current resource is validated in
isValid(IProgressMonitor)
.
By default the validation method is
VALIDATE_DEFAULT
. Change implementors can add
VALIDATE_NOT_DIRTY
,
VALIDATE_NOT_READ_ONLY
or
SAVE_IF_DIRTY
.
-
-
Parameters:
-
validationMethod
- the validation method used in
isValid(IProgressMonitor)
.
Supported validation methods currently are:
or combinations of these variables.
isValid
public
RefactoringStatus isValid(
IProgressMonitor pm)
throws
CoreException,
OperationCanceledException
- This implementation of
Change.isValid(IProgressMonitor)
tests the modified resource using the validation method
specified by
setValidationMethod(int)
.
-
-
Specified by:
-
isValid
in class
Change
-
-
Parameters:
-
pm
- a progress monitor.
-
Returns:
- a refactoring status describing the outcome of the validation check
-
Throws:
-
CoreException
- if an error occurred during validation check. The change
is to be treated as invalid if an exception occurs
-
OperationCanceledException
- if the validation check got canceled
checkIfModifiable
protected static void checkIfModifiable(
RefactoringStatus result,
IResource resource,
int validationMethod)
- Utility method to validate a resource to be modified.
-
-
Parameters:
-
result
- the status where the result will be added to -
resource
- the resource to validate -
validationMethod
- the validation method used in
isValid(IProgressMonitor)
.
Supported validation methods currently are:
or combinations of these methods.
getModifiedElement
public
Object getModifiedElement()
-
Description copied from class:
Change
- Returns the element modified by this
Change
. The method may return
null
if the change isn't related to an element.
-
-
Specified by:
-
getModifiedElement
in class
Change
-
-
Returns:
- the element modified by this change
toString
public
String toString()
-
-
Overrides:
-
toString
in class
Object
-
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.