use of net.sourceforge.pmd.eclipse.runtime.properties.IProjectProperties in project pmd-eclipse-plugin by pmd.
the class ReviewCodeCmd method rulesetFrom.
private RuleSet rulesetFrom(IResource resource) throws PropertiesException, CommandException {
IProject project = resource.getProject();
IProjectProperties properties = getProjectProperties(project);
// properties.getProjectRuleSet();
return filteredRuleSet(properties);
}
use of net.sourceforge.pmd.eclipse.runtime.properties.IProjectProperties in project pmd-eclipse-plugin by pmd.
the class ProjectPropertiesManagerImpl method loadProjectProperties.
/**
* Load a project properties
*
* @param project
* a project
*/
public IProjectProperties loadProjectProperties(final IProject project) throws PropertiesException {
LOG.debug("Loading project properties for project " + project.getName());
try {
IProjectProperties projectProperties = this.projectsProperties.get(project);
if (projectProperties == null) {
LOG.debug("Creating new poject properties for " + project.getName());
projectProperties = new PropertiesFactoryImpl().newProjectProperties(project, this);
final ProjectPropertiesTO to = readProjectProperties(project);
fillProjectProperties(projectProperties, to);
this.projectsProperties.put(project, projectProperties);
}
// if the ruleset is stored in the project always reload it
if (projectProperties.isRuleSetStoredInProject()) {
loadRuleSetFromProject(projectProperties);
} else {
// else resynchronize the ruleset
final boolean needRebuild = synchronizeRuleSet(projectProperties);
projectProperties.setNeedRebuild(projectProperties.isNeedRebuild() || needRebuild);
}
return projectProperties;
} catch (CoreException e) {
throw new PropertiesException("Core Exception when loading project properties for project " + project.getName(), e);
}
}
use of net.sourceforge.pmd.eclipse.runtime.properties.IProjectProperties in project pmd-eclipse-plugin by pmd.
the class PreferencesManagerImpl method updateConfiguredProjects.
/**
* Add new rules to already configured projects, and update the
* exclude/include patterns
*/
private void updateConfiguredProjects(RuleSet updatedRuleSet) {
LOG.debug("Updating configured projects");
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (IProject project : projects) {
if (project.isAccessible()) {
try {
IProjectProperties properties = PMDPlugin.getDefault().loadProjectProperties(project);
RuleSet projectRuleSet = properties.getProjectRuleSet();
if (projectRuleSet != null) {
projectRuleSet = RuleSetUtil.addRules(projectRuleSet, getNewRules(updatedRuleSet));
projectRuleSet = RuleSetUtil.setExcludePatterns(projectRuleSet, updatedRuleSet.getExcludePatterns());
projectRuleSet = RuleSetUtil.setIncludePatterns(projectRuleSet, updatedRuleSet.getIncludePatterns());
properties.setProjectRuleSet(projectRuleSet);
properties.sync();
}
} catch (PropertiesException e) {
PMDPlugin.getDefault().logError("Unable to add new rules for project: " + project, e);
}
}
}
}
use of net.sourceforge.pmd.eclipse.runtime.properties.IProjectProperties in project pmd-eclipse-plugin by pmd.
the class PMDPropertyPageController method createDefaultRuleSetFile.
/**
* Create a default ruleset file from the current project ruleset
*/
private void createDefaultRuleSetFile() throws PropertiesException {
final boolean create = MessageDialog.openQuestion(shell, getMessage(StringKeys.QUESTION_TITLE), getMessage(StringKeys.QUESTION_CREATE_RULESET_FILE));
if (create) {
final IProjectProperties properties = PMDPlugin.getDefault().loadProjectProperties(project);
properties.createDefaultRuleSetFile();
} else {
propertyPageBean.setRuleSetStoredInProject(false);
}
}
Aggregations