use of net.sf.eclipsecs.core.projectconfig.FileSet 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.FileSet in project eclipse-cs by checkstyle.
the class ComplexFileSetsEditor method addFileSet.
private void addFileSet() {
try {
FileSetEditDialog dialog = new FileSetEditDialog(mComposite.getShell(), null, mProject, mPropertyPage);
if (Window.OK == dialog.open()) {
FileSet fileSet = dialog.getFileSet();
mFileSets.add(fileSet);
mViewer.refresh();
mViewer.setChecked(fileSet, fileSet.isEnabled());
mPropertyPage.getContainer().updateButtons();
}
} catch (CheckstylePluginException e) {
CheckstyleUIPlugin.errorDialog(mComposite.getShell(), NLS.bind(Messages.errorFailedAddFileset, e.getMessage()), e, true);
}
}
use of net.sf.eclipsecs.core.projectconfig.FileSet in project eclipse-cs by checkstyle.
the class SimpleFileSetsEditor method setFileSets.
/**
* {@inheritDoc}
*/
@Override
public void setFileSets(List<FileSet> fileSets) throws CheckstylePluginException {
mFileSets = fileSets;
ICheckConfiguration config = null;
if (mFileSets.size() > 0) {
config = (mFileSets.get(0)).getCheckConfig();
}
if (config == null) {
CheckConfigurationWorkingCopy[] allConfigs = mPropertyPage.getProjectConfigurationWorkingCopy().getGlobalCheckConfigWorkingSet().getWorkingCopies();
if (allConfigs.length > 0) {
config = allConfigs[0];
}
}
mDefaultFileSet = new FileSet(Messages.SimpleFileSetsEditor_nameAllFileset, config);
// $NON-NLS-1$
mDefaultFileSet.getFileMatchPatterns().add(new FileMatchPattern("."));
mFileSets.clear();
mFileSets.add(mDefaultFileSet);
}
use of net.sf.eclipsecs.core.projectconfig.FileSet in project eclipse-cs by checkstyle.
the class TransformCheckstyleRulesJob method runInWorkspace.
/**
* {@inheritDoc}
*/
@Override
public IStatus runInWorkspace(final IProgressMonitor arg0) throws CoreException {
try {
final IProjectConfiguration conf = ProjectConfigurationFactory.getConfiguration(mProject);
final List<Configuration> rules = new ArrayList<Configuration>();
// collect rules from all configured filesets
for (FileSet fs : conf.getFileSets()) {
ICheckConfiguration checkConfig = fs.getCheckConfig();
CheckstyleConfigurationFile configFile = checkConfig.getCheckstyleConfiguration();
PropertyResolver resolver = configFile.getPropertyResolver();
// context
if (resolver instanceof IContextAware) {
((IContextAware) resolver).setProjectContext(mProject);
}
InputSource in = null;
try {
in = configFile.getCheckConfigFileInputSource();
Configuration configuration = ConfigurationLoader.loadConfiguration(in, resolver, true);
// flatten the nested configuration tree into a list
recurseConfiguration(configuration, rules);
} finally {
Closeables.closeQuietly(in.getByteStream());
}
}
if (rules.isEmpty()) {
return Status.CANCEL_STATUS;
}
final CheckstyleTransformer transformer = new CheckstyleTransformer(mProject, rules);
transformer.transformRules();
} catch (CheckstyleException e) {
Status status = new Status(IStatus.ERROR, CheckstylePlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e);
throw new CoreException(status);
} catch (CheckstylePluginException e) {
Status status = new Status(IStatus.ERROR, CheckstylePlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e);
throw new CoreException(status);
}
return Status.OK_STATUS;
}
Aggregations