public abstract class ResourceChange extends Change
Modifier and Type | Field and Description |
---|---|
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. |
Constructor and Description |
---|
ResourceChange()
Creates the resource change.
|
Modifier and Type | Method and Description |
---|---|
protected static void |
checkIfModifiable(RefactoringStatus result,
IResource resource,
int validationMethod)
Utility method to validate a resource to be modified.
|
Object |
getModifiedElement()
Returns the element modified by this
Change . |
protected abstract IResource |
getModifiedResource()
Returns the resource of this change.
|
void |
initializeValidationData(IProgressMonitor pm)
Hook method to initialize some internal state to provide an adequate answer
for the
isValid method. |
RefactoringStatus |
isValid(IProgressMonitor pm)
This implementation of
Change.isValid(IProgressMonitor) tests the modified resource using the validation method
specified by setValidationMethod(int) . |
void |
setValidationMethod(int validationMethod)
Sets the validation methods used when the current resource is validated in
isValid(IProgressMonitor) . |
String |
toString() |
dispose, getAdapter, getAffectedObjects, getDescriptor, getName, getParent, isEnabled, perform, setEnabled, setEnabledShallow
public static final int VALIDATE_DEFAULT
public static final int VALIDATE_NOT_READ_ONLY
VALIDATE_DEFAULT
) and additionally ensures that the element
is not read only.public static final int VALIDATE_NOT_DIRTY
VALIDATE_DEFAULT
) and additionally ensures that the element
does not contain unsaved modifications.public static final int SAVE_IF_DIRTY
VALIDATE_DEFAULT
) and will
save all unsaved modifications to the resource.public ResourceChange()
protected abstract IResource getModifiedResource()
public void initializeValidationData(IProgressMonitor pm)
Change
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:
dispose
.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.
initializeValidationData
in class Change
pm
- a progress monitorpublic void setValidationMethod(int validationMethod)
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
.
validationMethod
- the validation method used in isValid(IProgressMonitor)
.
Supported validation methods currently are:
or combinations of these variables.public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException
Change.isValid(IProgressMonitor)
tests the modified resource using the validation method
specified by setValidationMethod(int)
.isValid
in class Change
pm
- a progress monitor.CoreException
- if an error occurred during validation check. The change
is to be treated as invalid if an exception occursOperationCanceledException
- if the validation check got canceledprotected static void checkIfModifiable(RefactoringStatus result, IResource resource, int validationMethod)
result
- the status where the result will be added toresource
- the resource to validatevalidationMethod
- the validation method used in isValid(IProgressMonitor)
.
Supported validation methods currently are:
or combinations of these methods.public Object getModifiedElement()
Change
Change
. The method may return
null
if the change isn't related to an element.getModifiedElement
in class Change
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.