Search in sources :

Example 1 with LocalCheckConfigurationWorkingSet

use of net.sf.eclipsecs.core.projectconfig.LocalCheckConfigurationWorkingSet in project eclipse-cs by checkstyle.

the class ProjectConfigurationEditor method getEditedWorkingCopy.

/**
 * {@inheritDoc}
 */
@Override
public CheckConfigurationWorkingCopy getEditedWorkingCopy() throws CheckstylePluginException {
    mWorkingCopy.setName(mConfigName.getText());
    mWorkingCopy.setDescription(mDescription.getText());
    mWorkingCopy.getAdditionalData().put(ExternalFileConfigurationType.KEY_PROTECT_CONFIG, // $NON-NLS-1$
    "" + mChkProtectConfig.getSelection());
    try {
        mWorkingCopy.setLocation(mLocation.getText());
    } catch (CheckstylePluginException e) {
        String location = mLocation.getText();
        if (Strings.emptyToNull(location) == null) {
            throw e;
        }
        ICheckConfigurationWorkingSet ws = mCheckConfigDialog.getCheckConfigurationWorkingSet();
        IPath tmp = new Path(location);
        boolean isFirstPartProject = ResourcesPlugin.getWorkspace().getRoot().getProject(tmp.segment(0)).exists();
        if (ws instanceof LocalCheckConfigurationWorkingSet && !isFirstPartProject) {
            location = ((LocalCheckConfigurationWorkingSet) ws).getProject().getFullPath().append(location).toString();
            mLocation.setText(location);
        } else if (ws instanceof GlobalCheckConfigurationWorkingSet && !isFirstPartProject) {
            throw new CheckstylePluginException(NLS.bind(Messages.ProjectConfigurationEditor_msgNoProjectInWorkspace, tmp.segment(0)));
        }
        if (ensureFileExists(location)) {
            mWorkingCopy.setLocation(mLocation.getText());
        } else {
            throw e;
        }
    }
    return mWorkingCopy;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) GlobalCheckConfigurationWorkingSet(net.sf.eclipsecs.core.config.GlobalCheckConfigurationWorkingSet) IPath(org.eclipse.core.runtime.IPath) ICheckConfigurationWorkingSet(net.sf.eclipsecs.core.config.ICheckConfigurationWorkingSet) CheckstylePluginException(net.sf.eclipsecs.core.util.CheckstylePluginException) LocalCheckConfigurationWorkingSet(net.sf.eclipsecs.core.projectconfig.LocalCheckConfigurationWorkingSet)

Aggregations

GlobalCheckConfigurationWorkingSet (net.sf.eclipsecs.core.config.GlobalCheckConfigurationWorkingSet)1 ICheckConfigurationWorkingSet (net.sf.eclipsecs.core.config.ICheckConfigurationWorkingSet)1 LocalCheckConfigurationWorkingSet (net.sf.eclipsecs.core.projectconfig.LocalCheckConfigurationWorkingSet)1 CheckstylePluginException (net.sf.eclipsecs.core.util.CheckstylePluginException)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1