|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.wst.validation.ValidationFramework
public final class ValidationFramework
The central class of the Validation Framework.
This is a singleton class that is accessed through the getDefault() method.
Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.
Nested Class Summary | |
---|---|
static class |
ValidationFramework.ResourceAdder
|
Method Summary | |
---|---|
void |
addValidationBuilder(IProject project)
Add the validation builder to the project, so that the project can support build time validation. |
void |
applyChanges(MutableProjectSettings settings,
boolean persist)
Apply the changes that have been been to the validation settings. |
void |
applyChanges(MutableWorkspaceSettings settings,
boolean persist)
Apply the changes that have been been to the validation settings. |
void |
clearMessages(IResource resource,
java.lang.String validatorId)
Clear any validation markers that may have been set by this validator. |
void |
disableValidation(IResource resource)
Disable all validation for the given resource. |
void |
enableValidation(IResource resource)
Enable validation for the given resource. |
static ValidationFramework |
getDefault()
Answer the singleton, default instance of this class. |
IDependencyIndex |
getDependencyIndex()
Answer the dependency index. |
java.util.Set<Validator> |
getDisabledValidatorsFor(IResource resource)
Answer all the validators that should not validate the resource, either because their filters don't support the resource, or the validator has been disabled for both build validation and manual validation. |
IPerformanceMonitor |
getPerformanceMonitor()
Answer a performance monitor for the validators. |
IEclipsePreferences |
getPreferenceStore()
Answer the preference store that holds the persisted global validation settings. |
MutableProjectSettings |
getProjectSettings(IProject project)
Answer the validation settings that have been defined on the project. |
IReporter |
getReporter(IProject project,
IProgressMonitor monitor)
|
Validator |
getValidator(java.lang.String id)
Deprecated. Use getValidator(String id, IProject project) with a null project instead. |
Validator |
getValidator(java.lang.String id,
IProject project)
Answer the validator with the given id that is in effect for the given project. |
Validator[] |
getValidators()
Answer copies of all the registered validators. |
Validator[] |
getValidatorsConfiguredForProject(IProject project)
Validators can use project level settings (Project natures and facets) to determine if they are applicable to the project or not. |
Validator[] |
getValidatorsFor(IResource resource)
Answer all the validators that are applicable for the given resource. |
Validator[] |
getValidatorsFor(IResource resource,
boolean isManual,
boolean isBuild)
Answer all the validators that are applicable for the given resource. |
MutableWorkspaceSettings |
getWorkspaceSettings()
Answer the validation settings that have been defined at the workspace level. |
boolean |
hasValidators(IResource resource,
boolean isManual,
boolean isBuild)
Answer true if the resource has any enabled validators. |
boolean |
isLoaded(Validator validator)
Answer whether or not the validator has been activated, i.e. has the bundle that defines the validator been loaded. |
boolean |
isProjectSuspended(IProject project)
This method should be called by any code that is preparing to suspend validation on a project. |
boolean |
isSuspended()
Return true if "suspend all" is enabled, false otherwise. |
boolean |
isSuspended(IProject project)
Returns true if validation will not run on the project because it's been suspended. |
void |
join(IProgressMonitor monitor)
Waits until all the validation jobs and all the other auto build jobs are finished. |
void |
joinValidationOnly(IProgressMonitor monitor)
Waits until all the validation jobs are finished. |
void |
saveValidators(Validator[] validators)
Save the validators settings into the persistent store, there by making their settings the active settings. |
void |
suspendAllValidation(boolean suspend)
Suspends, or undoes the suspension of, validation on all projects in the workbench. |
void |
suspendValidation(IProject project,
boolean suspend)
Suspends, or undoes the suspension of, validation on the current project. |
ValidationResults |
validate(IFile file,
IProgressMonitor monitor)
Validate a specific file resource. |
ValidationResults |
validate(IProject[] projects,
boolean isManual,
boolean isBuild,
IProgressMonitor monitor)
Validate the projects. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static ValidationFramework getDefault()
public void addValidationBuilder(IProject project)
project
- The project that the builder is added to.public void clearMessages(IResource resource, java.lang.String validatorId) throws CoreException
resource
- The resource that may have it's markers cleared.validatorId
- The id of validator that created the marker.
CoreException
public void disableValidation(IResource resource)
Use the enableValidation method to restore validation.
resource
- The resource that is having validation disabled. It must be an IFolder or an IFile.enableValidation(IResource)
public void enableValidation(IResource resource)
resource
- The resource that is having validation re-enabled.disableValidation(IResource)
public IDependencyIndex getDependencyIndex()
public IPerformanceMonitor getPerformanceMonitor()
public IEclipsePreferences getPreferenceStore()
public IReporter getReporter(IProject project, IProgressMonitor monitor)
public Validator[] getValidatorsFor(IResource resource, boolean isManual, boolean isBuild)
The caller may still need to test if the validator has been turned off by the user, by using the isBuildValidation() and isManualValidation() methods.
resource
- The resource that determines which validators are applicable.isManual
- If true then the validator must be turned on for manual validation.
If false then the isManualValidation setting isn't used to filter
out validators.isBuild
- If true then the validator must be turned on for build based
validation. If false then the isBuildValidation setting isn't used
to filter out validators.Validator.isBuildValidation()
,
Validator.isManualValidation()
public java.util.Set<Validator> getDisabledValidatorsFor(IResource resource)
resource
- The resource this is being tested.public Validator getValidator(java.lang.String id)
id
-
public Validator getValidator(java.lang.String id, IProject project)
Individual projects may override the global validation preference settings. If this is allowed and if the project has it's own settings, then those validators are returned via this method.
The following approach is used. For version 1 validators, the validator is only returned if it is defined to operate on this project type. This is the way that the previous version of the framework did it. For version 2 validators, they are all returned.
id
- Validator id.project
- This can be null, in which case all the registered validators are
checked.
public Validator[] getValidators()
public MutableProjectSettings getProjectSettings(IProject project)
applyChanges(MutableProjectSettings, boolean)
method needs to be
called.
project
- The project who's settings you wish to examine or change.
public MutableWorkspaceSettings getWorkspaceSettings() throws java.lang.reflect.InvocationTargetException
applyChanges(MutableWorkspaceSettings, boolean)
method needs to be
called.
java.lang.reflect.InvocationTargetException
public void applyChanges(MutableProjectSettings settings, boolean persist)
settings
- The project settings.persist
- If true then the changes are persisted to the property files.
If false the changes are applied to the validators, but are
not persisted.public void applyChanges(MutableWorkspaceSettings settings, boolean persist)
settings
- The workspace settings.persist
- If true then the changes are persisted to the property files.
If false the changes are applied to the validators, but are
not persisted.public Validator[] getValidatorsConfiguredForProject(IProject project) throws org.eclipse.wst.validation.internal.ProjectUnavailableError
project
- The project that the configuration is based on.
org.eclipse.wst.validation.internal.ProjectUnavailableError
public Validator[] getValidatorsFor(IResource resource)
resource
- the resource that determines which validators are applicable.public boolean hasValidators(IResource resource, boolean isManual, boolean isBuild)
resource
- A file, folder or project.isManual
- If true then the validator must be turned on for manual validation.
If false then the isManualValidation setting isn't used to filter
out validators.isBuild
- If true then the validator must be turned on for build based
validation. If false then the isBuildValidation setting isn't used
to filter out validators.public boolean isLoaded(Validator validator)
validator
- The validator that is being tested.
public void join(IProgressMonitor monitor) throws java.lang.InterruptedException, OperationCanceledException
If this method is called while the job manager is suspended, only jobs
that are currently running will be joined. Once there are no jobs in the
family in the Job#RUNNING
state, this method returns.
Note that there is a deadlock risk when using join. If the calling thread owns a lock or object monitor that the joined thread is waiting for, deadlock will occur. This method can also result in starvation of the current thread if another thread continues to add jobs of the given family, or if a job in the given family reschedules itself in an infinite loop.
If you are interested in only waiting for the validation jobs, see the joinValidationOnly method.
monitor
- Progress monitor for reporting progress on how the wait is
progressing, or null
if no progress monitoring is
required.
java.lang.InterruptedException
- if this thread is interrupted while waiting
OperationCanceledException
- if the progress monitor is canceled while waitingjoinValidationOnly(IProgressMonitor)
public void joinValidationOnly(IProgressMonitor monitor) throws java.lang.InterruptedException, OperationCanceledException
If this method is called while the job manager is suspended, only jobs
that are currently running will be joined. Once there are no jobs in the
family in the Job#RUNNING
state, this method returns.
Note that there is a deadlock risk when using join. If the calling thread owns a lock or object monitor that the joined thread is waiting for, deadlock will occur. This method can also result in starvation of the current thread if another thread continues to add jobs of the given family, or if a job in the given family reschedules itself in an infinite loop.
monitor
- Progress monitor for reporting progress on how the wait is
progressing, or null
if no progress monitoring is
required.
java.lang.InterruptedException
- if this thread is interrupted while waiting
OperationCanceledException
- if the progress monitor is canceled while waitingpublic void suspendValidation(IProject project, boolean suspend)
Be very careful when you use this method! Turn validation back on in a finally block because if the code which suspended validation crashes, the user has no way to reset the suspension. The user will have to shut down and restart the workbench to get validation to work again.
project
- The project that is to be suspended or unsuspended.suspend
- If true, validation on the project will be suspend. If false it will
not be suspended.public void saveValidators(Validator[] validators) throws java.lang.reflect.InvocationTargetException
A common use of this method would be to change whether particular validators are enabled or not. For example if you only wanted the JSP validator enabled, you could use code similar to this:
ValidationFramework vf = ValidationFramework.getDefault(); Validator[] vals = vf.getValidators(); for (Validator v : vals){ boolean enabled = false; if (v.getValidatorClassname().equals("org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator"))enabled = true; v.setBuildValidation(enabled); v.setManualValidation(enabled); } vf.saveValidators(vals);
validators
- The validators that you are saving.
java.lang.reflect.InvocationTargetException
public void suspendAllValidation(boolean suspend)
Be very careful when you use this method! Turn validation back on in a finally block because if the code which suspended validation crashes, the user has no way to reset the suspension. The user will have to shut down and restart the workbench to get validation to work again.
public boolean isSuspended()
public boolean isSuspended(IProject project)
public boolean isProjectSuspended(IProject project)
project
- the project that is being tested
public ValidationResults validate(IProject[] projects, boolean isManual, boolean isBuild, IProgressMonitor monitor) throws CoreException
projects
- The projects to be validated.isManual
- Is this being done as part of a manual validation? i.e. did
the user select the Validate menu item?isBuild
- Is this being done as part of a build?monitor
-
CoreException
public ValidationResults validate(IFile file, IProgressMonitor monitor) throws CoreException
file
- The file to be validated.monitor
- Progress monitor.
CoreException
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |