Search in sources :

Example 1 with RuleVisitor

use of net.sourceforge.pmd.eclipse.ui.preferences.br.RuleVisitor in project pmd-eclipse-plugin by pmd.

the class RulePanelManager method buildLanguageVersionCombo.

private Combo buildLanguageVersionCombo(Composite parent, final boolean isMinVersion) {
    int style = creatingNewRule() ? SWT.SINGLE | SWT.BORDER : SWT.READ_ONLY | SWT.BORDER;
    final Combo combo = new Combo(parent, style);
    combo.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (rules == null) {
                return;
            }
            final int selIdx = combo.getSelectionIndex();
            final LanguageVersion version = selIdx == 0 ? null : selectedLanguage().getVersions().get(selIdx - 1);
            RuleVisitor visitor = new RuleVisitor() {

                public boolean accept(Rule rule) {
                    if (isMinVersion) {
                        rule.setMinimumLanguageVersion(version);
                    } else {
                        rule.setMaximumLanguageVersion(version);
                    }
                    return true;
                }
            };
            rules.rulesDo(visitor);
            valueChanged(null, version == null ? "" : version.getName());
        }
    });
    return combo;
}
Also used : RuleVisitor(net.sourceforge.pmd.eclipse.ui.preferences.br.RuleVisitor) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LanguageVersion(net.sourceforge.pmd.lang.LanguageVersion) Combo(org.eclipse.swt.widgets.Combo) XPathRule(net.sourceforge.pmd.lang.rule.XPathRule) Rule(net.sourceforge.pmd.Rule)

Aggregations

Rule (net.sourceforge.pmd.Rule)1 RuleVisitor (net.sourceforge.pmd.eclipse.ui.preferences.br.RuleVisitor)1 LanguageVersion (net.sourceforge.pmd.lang.LanguageVersion)1 XPathRule (net.sourceforge.pmd.lang.rule.XPathRule)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Combo (org.eclipse.swt.widgets.Combo)1