use of net.sourceforge.pmd.eclipse.runtime.properties.PropertiesException in project pmd-eclipse-plugin by pmd.
the class BuildProjectCommand method execute.
/**
* @see name.herlin.command.AbstractProcessableCommand#execute()
*/
public void execute() throws CommandException {
try {
project().build(IncrementalProjectBuilder.FULL_BUILD, this.getMonitor());
projectProperties().setNeedRebuild(false);
} catch (CoreException e) {
throw new CommandException(e);
} catch (PropertiesException e) {
throw new CommandException(e);
} finally {
this.setTerminated(true);
}
}
use of net.sourceforge.pmd.eclipse.runtime.properties.PropertiesException in project pmd-eclipse-plugin by pmd.
the class ProjectPropertiesImpl method setRuleSetStoredInProject.
/**
* @see net.sourceforge.pmd.eclipse.runtime.properties.IProjectProperties#setRuleSetStoredInProject(boolean)
*/
public void setRuleSetStoredInProject(final boolean ruleSetStoredInProject) throws PropertiesException {
LOG.debug("Set rule set stored in project for project " + this.project.getName() + ": " + ruleSetStoredInProject);
this.needRebuild |= this.ruleSetStoredInProject != ruleSetStoredInProject;
this.ruleSetStoredInProject = ruleSetStoredInProject;
if (this.ruleSetStoredInProject) {
if (!isRuleSetFileExist()) {
// TODO: NLS
throw new PropertiesException("The project ruleset file cannot be found for project " + this.project.getName());
}
File f = getResolvedRuleSetFile();
if (f != null) {
projectRuleFileLastModified = f.lastModified();
}
}
}
use of net.sourceforge.pmd.eclipse.runtime.properties.PropertiesException in project pmd-eclipse-plugin by pmd.
the class ProjectPropertiesImpl method createDefaultRuleSetFile.
/**
* Create a project ruleset file from the current configured rules
*/
public void createDefaultRuleSetFile() throws PropertiesException {
LOG.info("Create a default rule set file for project " + this.project.getName());
ByteArrayOutputStream baos = null;
ByteArrayInputStream bais = null;
try {
IRuleSetWriter writer = PMDPlugin.getDefault().getRuleSetWriter();
baos = new ByteArrayOutputStream();
writer.write(baos, projectRuleSet);
final IFile file = project.getFile(PROJECT_RULESET_FILE);
if (file.exists() && file.isAccessible()) {
throw new PropertiesException("Project ruleset file already exists");
} else {
bais = new ByteArrayInputStream(baos.toByteArray());
file.create(bais, true, null);
}
} catch (WriterException e) {
throw new PropertiesException(e);
} catch (CoreException e) {
throw new PropertiesException(e);
} finally {
IOUtil.closeQuietly(baos);
IOUtil.closeQuietly(bais);
}
}
use of net.sourceforge.pmd.eclipse.runtime.properties.PropertiesException in project pmd-eclipse-plugin by pmd.
the class ProjectPropertiesManagerImpl method writeProjectProperties.
/**
* Save project properties
*
* @param project
* a project
* @param projectProperties
* the project properties to save
* @param monitor
* a progress monitor
* @throws DAOException
*/
private void writeProjectProperties(final IProject project, final ProjectPropertiesTO projectProperties) throws PropertiesException {
try {
String writer = convertProjectPropertiesToString(projectProperties);
final IFile propertiesFile = project.getFile(PROPERTIES_FILE);
if (propertiesFile.exists() && propertiesFile.isAccessible()) {
propertiesFile.setContents(new ByteArrayInputStream(writer.getBytes()), false, false, null);
} else {
propertiesFile.create(new ByteArrayInputStream(writer.getBytes()), false, null);
}
} catch (CoreException e) {
throw new PropertiesException(e);
}
}
use of net.sourceforge.pmd.eclipse.runtime.properties.PropertiesException in project pmd-eclipse-plugin by pmd.
the class PMDPropertyPageController method getPropertyPageBean.
/**
* populates teh property page bean from the loaded properties
*
* @return Returns the propertyPageBean.
*/
public PMDPropertyPageBean getPropertyPageBean() {
if (this.propertyPageBean == null) {
LOG.debug("Building a property page bean");
try {
final IProjectProperties properties = PMDPlugin.getDefault().loadProjectProperties(this.project);
propertyPageBean = new PMDPropertyPageBean();
propertyPageBean.setPmdEnabled(properties.isPmdEnabled());
propertyPageBean.setProjectWorkingSet(properties.getProjectWorkingSet());
propertyPageBean.setProjectRuleSet(properties.getProjectRuleSet());
propertyPageBean.setRuleSetStoredInProject(properties.isRuleSetStoredInProject());
propertyPageBean.setRuleSetFile(properties.getRuleSetFile());
propertyPageBean.setIncludeDerivedFiles(properties.isIncludeDerivedFiles());
propertyPageBean.setFullBuildEnabled(properties.isFullBuildEnabled());
propertyPageBean.setViolationsAsErrors(properties.violationsAsErrors());
pmdAlreadyActivated = properties.isPmdEnabled();
} catch (PropertiesException e) {
PMDPlugin.getDefault().showError(e.getMessage(), e);
}
}
return this.propertyPageBean;
}
Aggregations