use of net.sf.eclipsecs.core.projectconfig.ProjectConfigurationWorkingCopy in project eclipse-cs by checkstyle.
the class GlobalCheckConfigurationWorkingSet method updateProjectConfigurations.
/**
* Updates the project configurations that use the changed check configurations.
*
* @param configurations
* the check configurations
* @throws CheckstylePluginException
* an unexpected exception occurred
*/
private void updateProjectConfigurations() throws CheckstylePluginException {
for (CheckConfigurationWorkingCopy checkConfig : mWorkingCopies) {
ICheckConfiguration original = checkConfig.getSourceCheckConfiguration();
// only if the name of the check config differs from the original
if (original != null && original.getName() != null && !checkConfig.getName().equals(original.getName())) {
List<IProject> projects = ProjectConfigurationFactory.getProjectsUsingConfig(checkConfig);
for (IProject project : projects) {
IProjectConfiguration projectConfig = ProjectConfigurationFactory.getConfiguration(project);
ProjectConfigurationWorkingCopy workingCopy = new ProjectConfigurationWorkingCopy(projectConfig);
List<FileSet> fileSets = workingCopy.getFileSets();
for (FileSet fileSet : fileSets) {
// Check if the fileset uses the check config
if (original.equals(fileSet.getCheckConfig())) {
// set the new check configuration
fileSet.setCheckConfig(checkConfig);
}
}
// store the project configuration
if (workingCopy.isDirty()) {
workingCopy.store();
}
}
}
}
}
use of net.sf.eclipsecs.core.projectconfig.ProjectConfigurationWorkingCopy in project eclipse-cs by checkstyle.
the class CheckstylePropertyPage method setElement.
/**
* {@inheritDoc}
*/
@Override
public void setElement(IAdaptable element) {
super.setElement(element);
IProject project = null;
try {
//
// Get the project.
//
IResource resource = (IResource) element;
if (resource.getType() == IResource.PROJECT) {
project = (IProject) resource;
}
IProjectConfiguration projectConfig = ProjectConfigurationFactory.getConfiguration(project);
mProjectConfig = new ProjectConfigurationWorkingCopy(projectConfig);
mCheckstyleInitiallyActivated = project.hasNature(CheckstyleNature.NATURE_ID);
} catch (CoreException e) {
handleConfigFileError(e, project);
} catch (CheckstylePluginException e) {
handleConfigFileError(e, project);
}
}
use of net.sf.eclipsecs.core.projectconfig.ProjectConfigurationWorkingCopy in project eclipse-cs by checkstyle.
the class CheckstylePropertyPage method handleConfigFileError.
private void handleConfigFileError(Exception e, IProject project) {
CheckstyleLog.log(e, Messages.errorOpeningPropertiesPage);
CheckstyleUIPlugin.warningDialog(null, Messages.errorOpeningPropertiesPage, e);
IProjectConfiguration projectConfig = ProjectConfigurationFactory.createDefaultProjectConfiguration(project);
mProjectConfig = new ProjectConfigurationWorkingCopy(projectConfig);
try {
mCheckstyleInitiallyActivated = project.hasNature(CheckstyleNature.NATURE_ID);
} catch (CoreException e1) {
CheckstyleUIPlugin.errorDialog(null, e1.getMessage(), e1, true);
}
}
Aggregations