Search in sources :

Example 1 with CheckConfigurationWorkingCopy

use of net.sf.eclipsecs.core.config.CheckConfigurationWorkingCopy in project eclipse-cs by checkstyle.

the class CheckConfigurationWorkingSetEditor method copyCheckConfig.

/**
 * Copy an existing config.
 */
private void copyCheckConfig() {
    IStructuredSelection selection = (IStructuredSelection) mViewer.getSelection();
    ICheckConfiguration sourceConfig = (ICheckConfiguration) selection.getFirstElement();
    if (sourceConfig == null) {
        // 
        return;
    }
    try {
        // Open the properties dialog to change default name and description
        CheckConfigurationPropertiesDialog dialog = new CheckConfigurationPropertiesDialog(getShell(), null, mWorkingSet);
        dialog.setTemplateConfiguration(sourceConfig);
        dialog.setBlockOnOpen(true);
        if (Window.OK == dialog.open()) {
            CheckConfigurationWorkingCopy newConfig = dialog.getCheckConfiguration();
            // Copy the source configuration into the new internal config
            CheckConfigurationFactory.copyConfiguration(sourceConfig, newConfig);
            mWorkingSet.addCheckConfiguration(newConfig);
            mViewer.setInput(mWorkingSet.getWorkingCopies());
            mViewer.refresh();
        }
    } catch (CheckstylePluginException e) {
        CheckstyleUIPlugin.errorDialog(getShell(), e, true);
    }
}
Also used : ICheckConfiguration(net.sf.eclipsecs.core.config.ICheckConfiguration) CheckConfigurationWorkingCopy(net.sf.eclipsecs.core.config.CheckConfigurationWorkingCopy) CheckstylePluginException(net.sf.eclipsecs.core.util.CheckstylePluginException) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 2 with CheckConfigurationWorkingCopy

use of net.sf.eclipsecs.core.config.CheckConfigurationWorkingCopy in project eclipse-cs by checkstyle.

the class CheckConfigurationWorkingSetEditor method configureCheckConfig.

private void configureCheckConfig() {
    CheckConfigurationWorkingCopy config = (CheckConfigurationWorkingCopy) ((IStructuredSelection) mViewer.getSelection()).getFirstElement();
    if (config != null) {
        try {
            // test if file exists
            config.getCheckstyleConfiguration();
            CheckConfigurationConfigureDialog dialog = new CheckConfigurationConfigureDialog(getShell(), config);
            dialog.setBlockOnOpen(true);
            dialog.open();
        } catch (CheckstylePluginException e) {
            CheckstyleUIPlugin.warningDialog(getShell(), NLS.bind(Messages.errorCannotResolveCheckLocation, config.getLocation(), config.getName()), e);
        }
    }
}
Also used : CheckConfigurationWorkingCopy(net.sf.eclipsecs.core.config.CheckConfigurationWorkingCopy) CheckstylePluginException(net.sf.eclipsecs.core.util.CheckstylePluginException)

Example 3 with CheckConfigurationWorkingCopy

use of net.sf.eclipsecs.core.config.CheckConfigurationWorkingCopy in project eclipse-cs by checkstyle.

the class CheckConfigurationWorkingSetEditor method editCheckConfig.

/**
 * Edit the properties of a check configuration.
 */
private void editCheckConfig() {
    CheckConfigurationWorkingCopy config = (CheckConfigurationWorkingCopy) ((IStructuredSelection) mViewer.getSelection()).getFirstElement();
    if (config != null) {
        CheckConfigurationPropertiesDialog dialog = new CheckConfigurationPropertiesDialog(getShell(), config, mWorkingSet);
        dialog.setBlockOnOpen(true);
        if (Window.OK == dialog.open()) {
            mViewer.refresh(true);
        }
    }
}
Also used : CheckConfigurationWorkingCopy(net.sf.eclipsecs.core.config.CheckConfigurationWorkingCopy)

Example 4 with CheckConfigurationWorkingCopy

use of net.sf.eclipsecs.core.config.CheckConfigurationWorkingCopy in project eclipse-cs by checkstyle.

the class CheckConfigurationWorkingSetEditor method setDefaultCheckConfig.

private void setDefaultCheckConfig() {
    IStructuredSelection selection = (IStructuredSelection) mViewer.getSelection();
    CheckConfigurationWorkingCopy checkConfig = (CheckConfigurationWorkingCopy) selection.getFirstElement();
    if (checkConfig == null) {
        // 
        return;
    }
    if (mWorkingSet instanceof GlobalCheckConfigurationWorkingSet) {
        ((GlobalCheckConfigurationWorkingSet) mWorkingSet).setDefaultCheckConfig(checkConfig);
    }
    mViewer.refresh();
}
Also used : GlobalCheckConfigurationWorkingSet(net.sf.eclipsecs.core.config.GlobalCheckConfigurationWorkingSet) CheckConfigurationWorkingCopy(net.sf.eclipsecs.core.config.CheckConfigurationWorkingCopy) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 5 with CheckConfigurationWorkingCopy

use of net.sf.eclipsecs.core.config.CheckConfigurationWorkingCopy 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);
}
Also used : FileMatchPattern(net.sf.eclipsecs.core.projectconfig.FileMatchPattern) FileSet(net.sf.eclipsecs.core.projectconfig.FileSet) ICheckConfiguration(net.sf.eclipsecs.core.config.ICheckConfiguration) CheckConfigurationWorkingCopy(net.sf.eclipsecs.core.config.CheckConfigurationWorkingCopy)

Aggregations

CheckConfigurationWorkingCopy (net.sf.eclipsecs.core.config.CheckConfigurationWorkingCopy)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 ICheckConfiguration (net.sf.eclipsecs.core.config.ICheckConfiguration)2 CheckstylePluginException (net.sf.eclipsecs.core.util.CheckstylePluginException)2 GlobalCheckConfigurationWorkingSet (net.sf.eclipsecs.core.config.GlobalCheckConfigurationWorkingSet)1 FileMatchPattern (net.sf.eclipsecs.core.projectconfig.FileMatchPattern)1 FileSet (net.sf.eclipsecs.core.projectconfig.FileSet)1