/** * The nature of the project has changed; update the enabled validators on the project. */ public void resetProjectNature(IProject project) throws InvocationTargetException { resetProjectNature(getProjectConfiguration(project)); }
/** * Gets current validation project configuration based on current project * (which is based on current document) * * @return ProjectConfiguration */ static private ProjectConfiguration getProjectConfiguration(IFile file) { ProjectConfiguration projectConfiguration = null; if (file != null) { IProject project = file.getProject(); if (project != null) { try { projectConfiguration = ConfigurationManager.getManager().getProjectConfiguration(project); } catch (InvocationTargetException e) { Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); } } } return projectConfiguration; }
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(); } }
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(); } }
/** * Return true if the validator identified by the String is configured on the IProject and * enabled on the IProject. Otherwise return false; */ public boolean isEnabled(IProject project, String validatorName) { try { ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project); return prjp.isEnabled(validatorName); } catch (InvocationTargetException exc) { Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); if (logger.isLoggingLevel(Level.SEVERE)) { LogEntry entry = ValidationPlugin.getLogEntry(); entry.setSourceIdentifier("ValidatorManager.isEnabled(" + project.getName() + ", " + validatorName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ entry.setTargetException(exc); logger.write(Level.SEVERE, entry); if (exc.getTargetException() != null) { entry.setTargetException(exc); logger.write(Level.SEVERE, entry); } } return false; } }
protected Set getManualEnabledValidators(IProject project) { try { ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project); ValidatorMetaData[] vmds = prjp.getManualEnabledValidators(); return InternalValidatorManager.wrapInSet(vmds); } catch (InvocationTargetException exc) { Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); if (logger.isLoggingLevel(Level.SEVERE)) { LogEntry entry = ValidationPlugin.getLogEntry(); entry.setSourceIdentifier("ValidatorManager::getEnabledValidators" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ entry.setTargetException(exc); logger.write(Level.SEVERE, entry); if (exc.getTargetException() != null) { entry.setTargetException(exc); logger.write(Level.SEVERE, entry); } } return Collections.EMPTY_SET; } }
protected Set getBuildEnabledValidators(IProject project) { try { ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project); ValidatorMetaData[] vmds = prjp.getBuildEnabledValidators(); return InternalValidatorManager.wrapInSet(vmds); } catch (InvocationTargetException exc) { Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); if (logger.isLoggingLevel(Level.SEVERE)) { LogEntry entry = ValidationPlugin.getLogEntry(); entry.setSourceIdentifier("ValidatorManager::getEnabledValidators" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ entry.setTargetException(exc); logger.write(Level.SEVERE, entry); if (exc.getTargetException() != null) { entry.setTargetException(exc); logger.write(Level.SEVERE, entry); } } return Collections.EMPTY_SET; } }
public boolean canAutoValidateButtonBeEnabled(IProject project, boolean isGlobalAutoBuildOn) { try { ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project); boolean incrementalValEnabled = (prjp.numberOfEnabledIncrementalValidators() > 0); return canAutoValidateButtonBeEnabled(project, isGlobalAutoBuildOn, incrementalValEnabled); } catch (InvocationTargetException exc) { Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); if (logger.isLoggingLevel(Level.SEVERE)) { LogEntry entry = ValidationPlugin.getLogEntry(); entry.setSourceIdentifier("ValidatorManager::canAutoValidateButtonBeEnabled" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ entry.setTargetException(exc); logger.write(Level.SEVERE, entry); if (exc.getTargetException() != null) { entry.setTargetException(exc); logger.write(Level.SEVERE, entry); } } return false; } }
/** * @deprecated For use by the validation framework only. Return true if the ValidatorMetaData is * enabled for the given project */ public boolean isEnabled(IProject project, ValidatorMetaData vmd) { try { ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project); return prjp.isEnabled(vmd); } catch (InvocationTargetException exc) { Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); if (logger.isLoggingLevel(Level.SEVERE)) { LogEntry entry = ValidationPlugin.getLogEntry(); entry.setSourceIdentifier("ValidatorManager::isEnabled" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ entry.setTargetException(exc); logger.write(Level.SEVERE, entry); if (exc.getTargetException() != null) { entry.setTargetException(exc); logger.write(Level.SEVERE, entry); } } return false; } }
/** * Returns the number of enabled validators on the given project. */ public int numberProjectEnabledValidators(IProject project) { if (project == null) { return 0; } try { ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project); return prjp.numberOfEnabledValidators(); } catch (InvocationTargetException exc) { Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); if (logger.isLoggingLevel(Level.SEVERE)) { LogEntry entry = ValidationPlugin.getLogEntry(); entry.setSourceIdentifier("ValidatorManager::numberProjectEnabledValidators" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ entry.setTargetException(exc); logger.write(Level.SEVERE, entry); if (exc.getTargetException() != null) { entry.setTargetException(exc); logger.write(Level.SEVERE, entry); } } return 0; } }
/** * @deprecated For use by the validation framework only. */ public Set getEnabledIncrementalValidators(IProject project) { try { ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project); ValidatorMetaData[] vmds = prjp.getEnabledIncrementalValidators(true); return InternalValidatorManager.wrapInSet(vmds); } catch (InvocationTargetException exc) { Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); if (logger.isLoggingLevel(Level.SEVERE)) { LogEntry entry = ValidationPlugin.getLogEntry(); entry.setSourceIdentifier("ValidatorManager::getEnabledIncrementalValidators" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ entry.setTargetException(exc); logger.write(Level.SEVERE, entry); if (exc.getTargetException() != null) { entry.setTargetException(exc); logger.write(Level.SEVERE, entry); } } return Collections.EMPTY_SET; } }
/** * Enable all validators for the current project, and does not touch the auto-validate setting. */ public void enableAllValidators(IProject project, IProgressMonitor monitor) { // Turn auto-validate off // setAutoValidate(currentProject, false); // Enable the individual validators try { ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project); prjp.setEnabledValidators(prjp.getValidators()); } catch (InvocationTargetException exc) { Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); if (logger.isLoggingLevel(Level.SEVERE)) { LogEntry entry = ValidationPlugin.getLogEntry(); entry.setSourceID("ValidatorManager::enableAllValidators(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ entry.setTargetException(exc); logger.write(Level.SEVERE, entry); if (exc.getTargetException() != null) { entry.setTargetException(exc); logger.write(Level.SEVERE, entry); } } } }
/** * @deprecated For use by the validation framework only. * * Return a collection of incremental ValidatorMetaData configured on a certain type of IProject * (e.g. EJB Project vs. Web Project). */ public Set getProjectConfiguredIncrementalValidators(IProject project) { try { ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project); return InternalValidatorManager.wrapInSet(prjp.getIncrementalValidators()); } catch (InvocationTargetException exc) { Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); if (logger.isLoggingLevel(Level.SEVERE)) { LogEntry entry = ValidationPlugin.getLogEntry(); entry.setSourceID("ValidatorManager::getProjectConfiguredIncrementalValidators(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ entry.setTargetException(exc); logger.write(Level.SEVERE, entry); if (exc.getTargetException() != null) { entry.setTargetException(exc); logger.write(Level.SEVERE, entry); } } return Collections.EMPTY_SET; } }
public void closing(IProject project) { try { if (isMigrated(project)) { ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project); if(!prjp.useGlobalPreference()) prjp.store(); } } catch (InvocationTargetException exc) { Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); if (logger.isLoggingLevel(Level.SEVERE)) { LogEntry entry = ValidationPlugin.getLogEntry(); entry.setSourceIdentifier("InternalPreferenceManager::closing(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ entry.setTargetException(exc); logger.write(Level.SEVERE, entry); if (exc.getTargetException() != null) { entry.setTargetException(exc); logger.write(Level.SEVERE, entry); } } } }
/** * @deprecated For use by the validation framework only. * * Return a collection of ValidatorMetaData enabled on a certain type of IProject (e.g. EJB * Project vs. Web Project). The second parameter, isIncremental, identifies whether it's the * incremental, or non-incremental, validators which should be returned. If the parameter is * true, return incremental validators. If the parameter is false, return nonincremental * validators. */ public Set getProjectEnabledIncrementalValidators(IProject project) { try { ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project); return InternalValidatorManager.wrapInSet(prjp.getEnabledIncrementalValidators(true)); } catch (InvocationTargetException exc) { Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); if (logger.isLoggingLevel(Level.SEVERE)) { LogEntry entry = ValidationPlugin.getLogEntry(); entry.setSourceIdentifier("ValidatorManager::getProjectEnabledIncrementalValidators" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ entry.setTargetException(exc); logger.write(Level.SEVERE, entry); if (exc.getTargetException() != null) { entry.setTargetException(exc); logger.write(Level.SEVERE, entry); } } return Collections.EMPTY_SET; } }
/** * @deprecated For use by the validation framework only. * * Return a collection of ValidatorMetaData enabled on a certain type of IProject (e.g. EJB * Project vs. Web Project). The second parameter, isIncremental, identifies whether it's the * incremental, or non-incremental, validators which should be returned. If the parameter is * true, return incremental validators. If the parameter is false, return nonincremental * validators. */ public Collection getProjectEnabledNonIncrementalValidators(IProject project) { try { ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project); return InternalValidatorManager.wrapInSet(prjp.getEnabledIncrementalValidators(false)); } catch (InvocationTargetException exc) { Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); if (logger.isLoggingLevel(Level.SEVERE)) { LogEntry entry = ValidationPlugin.getLogEntry(); entry.setSourceIdentifier("ValidatorManager::getProjectEnabledNonIncrementalValidators" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ entry.setTargetException(exc); logger.write(Level.SEVERE, entry); if (exc.getTargetException() != null) { entry.setTargetException(exc); logger.write(Level.SEVERE, entry); } } return Collections.EMPTY_SET; } }
/** * Run all configured validators on the project, regardless of whether the validator is enabled * or disabled by the user. * * If async is true, the validation will run all thread-safe validators in a background thread. * If async is false, no validators will run in a background thread. */ public AllValidatorsOperation(IProject project, boolean async) { super(project, true, async);// always force validation to run try { ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project); setEnabledValidators(InternalValidatorManager.wrapInSet(prjp.getValidators())); } catch (InvocationTargetException exc) { Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); if (logger.isLoggingLevel(Level.SEVERE)) { LogEntry entry = ValidationPlugin.getLogEntry(); entry.setSourceID("EventManager::closing(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ entry.setTargetException(exc); logger.write(Level.SEVERE, exc); if (exc.getTargetException() != null) { entry.setTargetException(exc); logger.write(Level.SEVERE, exc); } } } }
/** * For use by the validation framework only. */ protected Set getEnabledValidators(IProject project) { try { ValidatorMetaData[] vmds = null; ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project); if(!prjp.useGlobalPreference()) vmds = prjp.getEnabledValidators(); else vmds = getStateOfProjectLevelValidatorsFromGlobal(prjp); return InternalValidatorManager.wrapInSet(vmds); } catch (InvocationTargetException exc) { Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); if (logger.isLoggingLevel(Level.SEVERE)) { LogEntry entry = ValidationPlugin.getLogEntry(); entry.setSourceIdentifier("ValidatorManager::getEnabledValidators" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ entry.setTargetException(exc); logger.write(Level.SEVERE, entry); if (exc.getTargetException() != null) { entry.setTargetException(exc); logger.write(Level.SEVERE, entry); } } return Collections.EMPTY_SET; } }