/** * Convenience method. Rather than store the is-this-vmd-configured-on-this-IProject algorithm * in two places, refer back to the reader's cache. */ public boolean isConfiguredOnProject(IProject project) { return ValidationRegistryReader.getReader().isConfiguredOnProject(this, project); }
/** * @deprecated For use by the validation framework only. */ public boolean isConfigured(IProject project, ValidatorMetaData vmd) { return ValidationRegistryReader.getReader().isConfiguredOnProject(vmd, project); }
protected static ValidatorMetaData getVMD(IValidator validator) throws IllegalArgumentException { ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(validator); if (vmd == null) { throw new IllegalArgumentException(); // already logged in the ValidationRegistryReader } return vmd; }
/** * @deprecated For use by the validation framework only. */ public ValidatorMetaData getValidatorMetaData(IValidator validator) { return ValidationRegistryReader.getReader().getValidatorMetaData(validator); }
private void releaseCachedMaps() { if (ValidationRegistryReader.getReader().projectValidationMetaData != null) { ValidationRegistryReader.getReader().projectValidationMetaData.clear(); ValidationRegistryReader.getReader().projectValidationMetaData = null; } IProjectValidationHelper helper = ValidationHelperRegistryReader.getInstance().getValidationHelper(); if (helper != null) helper.disposeInstance(); }
public IValidator getValidator(String validatorUniqueId) throws InstantiationException { ValidationRegistryReader reader = ValidationRegistryReader.getReader(); return reader.getValidator(validatorUniqueId); }
public static Set getStringAsEnabledElements(String elements) { if (elements == null) { return null; } HashSet result = new HashSet(); StringTokenizer tokenizer = new StringTokenizer(elements, ConfigurationConstants.ELEMENT_SEPARATOR); while (tokenizer.hasMoreTokens()) { String elem = tokenizer.nextToken(); ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(elem); if (vmd != null) { result.add(vmd); } } return result; }
protected void setEnabledValidators(Set evmds) { // Check that every VMD in the set is configured on this project. // Necessary because the user can manually choose which validators // to launch, and the validator may not be installed. _enabledValidators.clear(); Iterator iterator = evmds.iterator(); while (iterator.hasNext()) { ValidatorMetaData vmd = (ValidatorMetaData) iterator.next(); if (ValidationRegistryReader.getReader().isConfiguredOnProject(vmd, getProject())) { _enabledValidators.add(vmd); } } }
/** * Given an array of fully-qualified class names of validators, create the list of validators to * be run. The array is not checked for duplicates or for invalid validators (i.e., a validator * of that class type is not loaded, or the validator is loaded but cannot run against this type * of IProject.) */ public void setValidators(String[] validatorNames) throws IllegalArgumentException { Set enabled = new HashSet(); for (int i = 0; i < validatorNames.length; i++) { ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(validatorNames[i]); if (vmd == null) { // No validator, with that plugin id, can be run on that project. // Either the validator isn't installed, or the IProject passed in // doesn't have the necessary nature. throw new IllegalArgumentException(validatorNames[i]); } enabled.add(vmd); } setEnabledValidators(enabled); }
/** * Return true if the validator is enabled on this preference. */ public boolean isEnabled(String validatorClassName) throws InvocationTargetException { if (validatorClassName == null) { return false; } ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(validatorClassName); return isEnabled(vmd); }
/** * This constructor should be used in all cases except for the Preference page's values. */ public GlobalConfiguration(IWorkspaceRoot root) throws InvocationTargetException { super(root, convertToArray(ValidationRegistryReader.getReader().getAllValidators())); // Can't put the call to load() and passivate() in the ValidationConfiguration constructor // due // to the order of initialization. // 1. First the ValidationConfiguration constructor is called, and that loads the stored // values. // 2. Then this class's <init> method is called, and that initializes the "override" field // to the default, // which may be different than the stored value. }
public void enableValidator(String validatorId) { try { ValidatorMetaData vmd = ValidationRegistryReader.getReader() .getValidatorMetaData(validatorId); GlobalConfiguration gf = ConfigurationManager.getManager() .getGlobalConfiguration(); gf.enableSingleValidator(vmd); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public void disableValidator(String validatorId){ try { ValidatorMetaData vmd = ValidationRegistryReader.getReader() .getValidatorMetaData(validatorId); GlobalConfiguration gf = ConfigurationManager.getManager() .getGlobalConfiguration(); gf.disableSingleValidator(vmd); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
/** * This constructor should be used in all cases except for the Properties page's values. */ protected ProjectConfiguration(IProject project) throws InvocationTargetException { // The extractProjectValidators method extracts just this project's validators from the // global list. super(project, extractProjectValidators(convertToArray(ValidationRegistryReader.getReader().getAllValidators()), project)); // Can't put the call to load() and passivate() in the ValidationConfiguration constructor // due // to the order of initialization. // 1. First the ValidationConfiguration constructor is called, and that loads the stored // values. // 2. Then this class's <init> method is called, and that initializes the "override" field // to the default, // which may be different than the stored value. }
/** * @param reporter * @param referencialFileValidator */ private void postValidateProject(WorkbenchReporter reporter, ReferencialFileValidator refFileValidator) { Set set = ValidationRegistryReader.getReader().getValidatorMetaData(_project); Iterator it = set.iterator(); while (it.hasNext()) { ValidatorMetaData data = (ValidatorMetaData) it.next(); List filters = data.getNameFilters(); List files = getAllFilesForFilter(filters); if (!files.isEmpty()) { List fileForValidation = refFileValidator.getReferencedFile(files); try { validateReferencingFiles(reporter, fileForValidation); } catch (Exception e) { Logger.getLogger().log(e); } } } }
public static Logger getMsgLogger(IValidator validator) { ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(validator); if (vmd == null) { return ValidationPlugin.getPlugin().getMsgLogger(); } return vmd.getMsgLogger(); }
protected boolean isDelegateValidatorEnabled(IFile file) { boolean enabled = true; try { ProjectConfiguration configuration = ConfigurationManager.getManager().getProjectConfiguration(file.getProject()); ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(VALIDATOR_CLASS); if (configuration.isBuildEnabled(vmd) || configuration.isManualEnabled(vmd)) enabled = true; else enabled = false; } catch (InvocationTargetException e) { Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); } return enabled; } }
public void enableValidator(String validatorId, IProject project, boolean manualValidation, boolean buildValidation) { try { ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project); prjp.setDoesProjectOverride(true); ValidatorMetaData vmd = ValidationRegistryReader.getReader() .getValidatorMetaData(validatorId); if(manualValidation){ prjp.enableSingleManualValidator(vmd); } if (buildValidation){ prjp.enableSingleBuildValidator(vmd); } prjp.store(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
protected boolean isDelegateValidatorEnabled(IFile file) { boolean enabled = true; try { ProjectConfiguration configuration = ConfigurationManager.getManager().getProjectConfiguration(file.getProject()); ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(VALIDATOR_CLASS); if (configuration.isBuildEnabled(vmd) || configuration.isManualEnabled(vmd)) { enabled = true; } else { enabled = false; } } catch (InvocationTargetException e) { Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); } return enabled; } }
public void disableValidator(String validatorId, IProject project, boolean manualValidation, boolean buildValidation){ try { ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project); prjp.setDoesProjectOverride(true); ValidatorMetaData vmd = ValidationRegistryReader.getReader() .getValidatorMetaData(validatorId); if(manualValidation){ prjp.disableSingleManualValidator(vmd); } if (buildValidation){ prjp.disableSingleBuildValidator(vmd); } prjp.store(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } }