Class ResourceChangeValidator
- java.lang.Object
-
- org.eclipse.core.resources.mapping.ResourceChangeValidator
-
public final class ResourceChangeValidator extends Object
The resource change validator is used to validate that changes made to resources will not adversely affect the models stored in those resources.The validator is used by first creating a resource delta describing the proposed changes. A delta can be generated using a
IResourceChangeDescriptionFactory
. The change is then validated by calling thevalidateChange(IResourceDelta, IProgressMonitor)
method. This example validates a change to a single file:IFile file = ..;//some file that is going to be changed ResourceChangeValidator validator = ResourceChangeValidator.getValidator(); IResourceChangeDescriptionFactory factory = validator.createDeltaFactory(); factory.change(file); IResourceDelta delta = factory.getDelta(); IStatus result = validator.validateChange(delta, null);
If the result status does not have severityIStatus.OK
, then the changes may cause problems for models that are built on those resources. In this case the user should be presented with the status message to determine if they want to proceed with the modification.- Since:
- 3.2
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IResourceChangeDescriptionFactory
createDeltaFactory()
Return an empty change description factory that can be used to build a proposed resource delta.static ResourceChangeValidator
getValidator()
Return the singleton change validator.IStatus
validateChange(IResourceDelta delta, IProgressMonitor monitor)
Validate the proposed changes contained in the given delta by consulting all model providers to determine if the changes have any adverse side effects.
-
-
-
Method Detail
-
getValidator
public static ResourceChangeValidator getValidator()
Return the singleton change validator.- Returns:
- the singleton change validator
-
createDeltaFactory
public IResourceChangeDescriptionFactory createDeltaFactory()
Return an empty change description factory that can be used to build a proposed resource delta.- Returns:
- an empty change description factory that can be used to build a proposed resource delta
-
validateChange
public IStatus validateChange(IResourceDelta delta, IProgressMonitor monitor)
Validate the proposed changes contained in the given delta by consulting all model providers to determine if the changes have any adverse side effects.This method returns either a
ModelStatus
, or aMultiStatus
whose children areModelStatus
. In either case, the severity of the status indicates the severity of the possible side-effects of the operation. Any severity other thanOK
should be shown to the user. The message should be a human readable message that will allow the user to make a decision on whether to continue with the operation. The model provider id should indicate which model is flagging the the possible side effects.- Parameters:
delta
- a delta tree containing the proposed changes- Returns:
- a status indicating any potential side effects on models stored in the affected resources.
-
-