Search in sources :

Example 1 with FileMatchPattern

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

the class FileMatchPatternEditDialog method okPressed.

/**
 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
 */
@Override
protected void okPressed() {
    String pattern = mFileMatchPatternText.getText();
    try {
        // 
        // Try compiling the pattern using the regular expression compiler.
        // 
        Pattern.compile(pattern);
        if (mPattern == null) {
            mPattern = new FileMatchPattern(pattern);
        } else {
            mPattern.setMatchPattern(pattern);
        }
        mPattern.setIsIncludePattern(mIncludeButton.getSelection());
    } catch (PatternSyntaxException e) {
        this.setErrorMessage(e.getLocalizedMessage());
        return;
    } catch (CheckstylePluginException e) {
        this.setErrorMessage(e.getLocalizedMessage());
        return;
    }
    super.okPressed();
}
Also used : FileMatchPattern(net.sf.eclipsecs.core.projectconfig.FileMatchPattern) CheckstylePluginException(net.sf.eclipsecs.core.util.CheckstylePluginException) PatternSyntaxException(java.util.regex.PatternSyntaxException)

Example 2 with FileMatchPattern

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

the class FileSetEditDialog method downFileMatchPattern.

private void downFileMatchPattern() {
    IStructuredSelection selection = (IStructuredSelection) mPatternViewer.getSelection();
    FileMatchPattern pattern = (FileMatchPattern) selection.getFirstElement();
    if (pattern == null) {
        // 
        return;
    }
    int index = mFileSet.getFileMatchPatterns().indexOf(pattern);
    if ((index >= 0) && (index < mFileSet.getFileMatchPatterns().size() - 1)) {
        mFileSet.getFileMatchPatterns().remove(pattern);
        if (index < mFileSet.getFileMatchPatterns().size() - 1) {
            mFileSet.getFileMatchPatterns().add(index + 1, pattern);
        } else {
            mFileSet.getFileMatchPatterns().add(pattern);
        }
        mPatternViewer.refresh();
    }
}
Also used : FileMatchPattern(net.sf.eclipsecs.core.projectconfig.FileMatchPattern) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 3 with FileMatchPattern

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

the class FileSetEditDialog method editFileMatchPattern.

private void editFileMatchPattern() {
    IStructuredSelection selection = (IStructuredSelection) mPatternViewer.getSelection();
    FileMatchPattern pattern = (FileMatchPattern) selection.getFirstElement();
    if (pattern == null) {
        // 
        return;
    }
    FileMatchPatternEditDialog dialog = new FileMatchPatternEditDialog(getShell(), pattern.clone());
    if (Window.OK == dialog.open()) {
        FileMatchPattern editedPattern = dialog.getPattern();
        mFileSet.getFileMatchPatterns().set(mFileSet.getFileMatchPatterns().indexOf(pattern), editedPattern);
        mPatternViewer.refresh();
        mPatternViewer.setChecked(editedPattern, editedPattern.isIncludePattern());
    }
}
Also used : FileMatchPattern(net.sf.eclipsecs.core.projectconfig.FileMatchPattern) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 4 with FileMatchPattern

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

the class FileSetEditDialog method addFileMatchPattern.

private void addFileMatchPattern() {
    FileMatchPatternEditDialog dialog = new FileMatchPatternEditDialog(getShell(), null);
    if (Window.OK == dialog.open()) {
        FileMatchPattern pattern = dialog.getPattern();
        mFileSet.getFileMatchPatterns().add(pattern);
        mPatternViewer.refresh();
        mPatternViewer.setChecked(pattern, pattern.isIncludePattern());
    }
}
Also used : FileMatchPattern(net.sf.eclipsecs.core.projectconfig.FileMatchPattern)

Example 5 with FileMatchPattern

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

the class FileSetEditDialog method upFileMatchPattern.

private void upFileMatchPattern() {
    IStructuredSelection selection = (IStructuredSelection) mPatternViewer.getSelection();
    FileMatchPattern pattern = (FileMatchPattern) selection.getFirstElement();
    if (pattern == null) {
        // 
        return;
    }
    int index = mFileSet.getFileMatchPatterns().indexOf(pattern);
    if (index > 0) {
        mFileSet.getFileMatchPatterns().remove(pattern);
        mFileSet.getFileMatchPatterns().add(index - 1, pattern);
        mPatternViewer.refresh();
    }
}
Also used : FileMatchPattern(net.sf.eclipsecs.core.projectconfig.FileMatchPattern) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

FileMatchPattern (net.sf.eclipsecs.core.projectconfig.FileMatchPattern)8 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 CheckConfigurationWorkingCopy (net.sf.eclipsecs.core.config.CheckConfigurationWorkingCopy)1 ICheckConfiguration (net.sf.eclipsecs.core.config.ICheckConfiguration)1 FileSet (net.sf.eclipsecs.core.projectconfig.FileSet)1 CheckstylePluginException (net.sf.eclipsecs.core.util.CheckstylePluginException)1 CoreException (org.eclipse.core.runtime.CoreException)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1