Search in sources :

Example 1 with ProjectConfigurationWorkingCopy

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();
                }
            }
        }
    }
}
Also used : FileSet(net.sf.eclipsecs.core.projectconfig.FileSet) IProjectConfiguration(net.sf.eclipsecs.core.projectconfig.IProjectConfiguration) ProjectConfigurationWorkingCopy(net.sf.eclipsecs.core.projectconfig.ProjectConfigurationWorkingCopy) IProject(org.eclipse.core.resources.IProject)

Example 2 with ProjectConfigurationWorkingCopy

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);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IProjectConfiguration(net.sf.eclipsecs.core.projectconfig.IProjectConfiguration) CheckstylePluginException(net.sf.eclipsecs.core.util.CheckstylePluginException) ProjectConfigurationWorkingCopy(net.sf.eclipsecs.core.projectconfig.ProjectConfigurationWorkingCopy) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource)

Example 3 with ProjectConfigurationWorkingCopy

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);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IProjectConfiguration(net.sf.eclipsecs.core.projectconfig.IProjectConfiguration) ProjectConfigurationWorkingCopy(net.sf.eclipsecs.core.projectconfig.ProjectConfigurationWorkingCopy)

Aggregations

IProjectConfiguration (net.sf.eclipsecs.core.projectconfig.IProjectConfiguration)3 ProjectConfigurationWorkingCopy (net.sf.eclipsecs.core.projectconfig.ProjectConfigurationWorkingCopy)3 IProject (org.eclipse.core.resources.IProject)2 CoreException (org.eclipse.core.runtime.CoreException)2 FileSet (net.sf.eclipsecs.core.projectconfig.FileSet)1 CheckstylePluginException (net.sf.eclipsecs.core.util.CheckstylePluginException)1 IResource (org.eclipse.core.resources.IResource)1