// Path: src/main/java/info/gianlucacosta/easypmd/ide/DialogService.java
// public interface DialogService {
// 
//     void showInfo(String message);
// 
//     void showWarning(String message);
// 
//     void showError(String message);
// 
//     String askForString(String message);
// 
//     String askForString(String message, String defaultValue);
// 
//     CommonQuestionOutcome askYesNoQuestion(String message);
// }
// 
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java
// public class Injector {
// 
//     @ServiceProvider(service = TestService.class)
//     public static class TestService {
//     }
// 
//     private static final Lookup lookup = Lookup.getDefault();
// 
//     private static Lookup getLookup() {
//         return lookup;
//     }
// 
//     public static <T> T lookup(Class<T> serviceClass) {
//         T result = getLookup().lookup(serviceClass);
// 
//         validateLookupResult(serviceClass, result);
// 
//         return result;
//     }
// 
//     public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) {
//         Collection<? extends T> result = getLookup().lookupAll(serviceClass);
// 
//         validateLookupResult(serviceClass, result);
// 
//         return result;
//     }
// 
//     private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) {
//         if (lookupResult == null) {
//             if (shouldThrowLookupExceptions(serviceClass)) {
//                 throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName()));
//             }
//         }
//     }
// 
//     //This code prevents exceptions in the visual form editors within NetBeans
//     private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) {
//         if (serviceClass != TestService.class) {
//             TestService testService = lookup.lookup(TestService.class);
//             if (testService == null) {
//                 return false;
//             }
//         }
// 
//         return true;
//     }
// 
//     private Injector() {
//     }
// }
// 
// Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/RuleSetWrapper.java
// public class RuleSetWrapper {
// 
//     private final RuleSet ruleSet;
// 
//     public RuleSetWrapper(RuleSet ruleSet) {
//         this.ruleSet = ruleSet;
//     }
// 
//     public RuleSet getRuleSet() {
//         return ruleSet;
//     }
// 
//     @Override
//     public String toString() {
//         return String.format("%s (%s)", ruleSet.getName(), ruleSet.getFileName());
//     }
// }
// 
// Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/StandardRuleSetsCatalog.java
// public interface StandardRuleSetsCatalog {
// 
//     boolean containsFileName(String ruleSetFileName);
// 
//     Collection<RuleSetWrapper> getRuleSetWrappers();
// }


import java.util.Arrays;
import java.util.Collection;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.filechooser.FileFilter;
import info.gianlucacosta.easypmd.ide.DialogService;
import info.gianlucacosta.easypmd.ide.Injector;
import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.RuleSetWrapper;
import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.StandardRuleSetsCatalog;
import info.gianlucacosta.helios.conversions.CollectionToArrayConverter;
import info.gianlucacosta.helios.product.ProductInfoService;
import info.gianlucacosta.helios.swing.jlist.AdvancedSelectionListModel;
import java.io.File;
/*
 * ==========================================================================%%#
 * EasyPmd
 * ===========================================================================%%
 * Copyright (C) 2009 - 2017 Gianluca Costa
 * ===========================================================================%%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/gpl-3.0.html>.
 * ==========================================================================%##
 */
package info.gianlucacosta.easypmd.ide.options;




/**
 * Panel dedicated to editing rulesets
 */
public class RuleSetsPanel extends JPanel {

    private final AdvancedSelectionListModel<String> ruleSetsModel = new AdvancedSelectionListModel<>();
    private final DialogService dialogService;
    private final ProductInfoService pluginInfoService;
    private final StandardRuleSetsCatalog standardRulesetsCatalog;
    private final JFileChooser ruleSetsFileChooser = new JFileChooser();

    public RuleSetsPanel() {
        initComponents();

// Path: src/main/java/info/gianlucacosta/easypmd/ide/DialogService.java
// public interface DialogService {
// 
//     void showInfo(String message);
// 
//     void showWarning(String message);
// 
//     void showError(String message);
// 
//     String askForString(String message);
// 
//     String askForString(String message, String defaultValue);
// 
//     CommonQuestionOutcome askYesNoQuestion(String message);
// }
// 
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java
// public class Injector {
// 
//     @ServiceProvider(service = TestService.class)
//     public static class TestService {
//     }
// 
//     private static final Lookup lookup = Lookup.getDefault();
// 
//     private static Lookup getLookup() {
//         return lookup;
//     }
// 
//     public static <T> T lookup(Class<T> serviceClass) {
//         T result = getLookup().lookup(serviceClass);
// 
//         validateLookupResult(serviceClass, result);
// 
//         return result;
//     }
// 
//     public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) {
//         Collection<? extends T> result = getLookup().lookupAll(serviceClass);
// 
//         validateLookupResult(serviceClass, result);
// 
//         return result;
//     }
// 
//     private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) {
//         if (lookupResult == null) {
//             if (shouldThrowLookupExceptions(serviceClass)) {
//                 throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName()));
//             }
//         }
//     }
// 
//     //This code prevents exceptions in the visual form editors within NetBeans
//     private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) {
//         if (serviceClass != TestService.class) {
//             TestService testService = lookup.lookup(TestService.class);
//             if (testService == null) {
//                 return false;
//             }
//         }
// 
//         return true;
//     }
// 
//     private Injector() {
//     }
// }
// 
// Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/RuleSetWrapper.java
// public class RuleSetWrapper {
// 
//     private final RuleSet ruleSet;
// 
//     public RuleSetWrapper(RuleSet ruleSet) {
//         this.ruleSet = ruleSet;
//     }
// 
//     public RuleSet getRuleSet() {
//         return ruleSet;
//     }
// 
//     @Override
//     public String toString() {
//         return String.format("%s (%s)", ruleSet.getName(), ruleSet.getFileName());
//     }
// }
// 
// Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/StandardRuleSetsCatalog.java
// public interface StandardRuleSetsCatalog {
// 
//     boolean containsFileName(String ruleSetFileName);
// 
//     Collection<RuleSetWrapper> getRuleSetWrappers();
// }


// Path: src/main/java/info/gianlucacosta/easypmd/ide/options/RuleSetsPanel.java
import java.util.Arrays;
import java.util.Collection;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.filechooser.FileFilter;
import info.gianlucacosta.easypmd.ide.DialogService;
import info.gianlucacosta.easypmd.ide.Injector;
import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.RuleSetWrapper;
import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.StandardRuleSetsCatalog;
import info.gianlucacosta.helios.conversions.CollectionToArrayConverter;
import info.gianlucacosta.helios.product.ProductInfoService;
import info.gianlucacosta.helios.swing.jlist.AdvancedSelectionListModel;
import java.io.File;

/*
 * ==========================================================================%%#
 * EasyPmd
 * ===========================================================================%%
 * Copyright (C) 2009 - 2017 Gianluca Costa
 * ===========================================================================%%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/gpl-3.0.html>.
 * ==========================================================================%##
 */
package info.gianlucacosta.easypmd.ide.options;




/**
 * Panel dedicated to editing rulesets
 */
public class RuleSetsPanel extends JPanel {

    private final AdvancedSelectionListModel<String> ruleSetsModel = new AdvancedSelectionListModel<>();
    private final DialogService dialogService;
    private final ProductInfoService pluginInfoService;
    private final StandardRuleSetsCatalog standardRulesetsCatalog;
    private final JFileChooser ruleSetsFileChooser = new JFileChooser();

    public RuleSetsPanel() {
        initComponents();

        dialogService = Injector.lookup(DialogService.class);