// 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/PmdScanner.java
// public class PmdScanner {
// 
//     private static final Logger logger = Logger.getLogger(PmdScanner.class.getName());
// 
//     private final PmdScannerStrategy strategy;
// 
//     public PmdScanner(Options options) {
//         if (options.getRuleSets().isEmpty()) {
//             logger.info(() -> "Setting a NOP scanning strategy");
//             strategy = new NoOpPmdScannerStrategy();
//             return;
//         }
// 
//         if (options.isUseScanMessagesCache()) {
//             logger.info(() -> "Setting a cached scanning strategy");
//             strategy = new CacheBasedLinkedPmdScanningStrategy(options);
//         } else {
//             logger.info(() -> "Setting a non-cached scanning strategy");
//             strategy = new LinkedPmdScanningStrategy(options);
//         }
//     }
// 
//     public Set<ScanMessage> scan(Path path) {
//         try {
//             return strategy.scan(path);
//         } catch (Exception ex) {
//             ScanError scanError = new ScanError(ex);
// 
//             return Collections.singleton(
//                     scanError
//             );
//         }
//     }
// }
// 
// Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContext.java
// public interface ProfileContext {
// 
//     ProfileMap getProfiles();
// 
//     String getActiveProfileName();
// 
//     Options getActiveOptions();
// }
// 
// Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContextRepository.java
// public interface ProfileContextRepository {
// 
//     ProfileContext getProfileContext();
// 
//     void saveProfileContext(ProfileContext profileContext);
// }


import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContext;
import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContextRepository;
import java.util.logging.Logger;
import info.gianlucacosta.easypmd.ide.Injector;
import info.gianlucacosta.easypmd.pmdscanner.PmdScanner;
import org.netbeans.spi.options.OptionsPanelController;
import org.openide.util.HelpCtx;
import org.openide.util.Lookup;
import javax.swing.*;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
/*
 * ==========================================================================%%#
 * 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;



/**
 * Controller underlying the plugin's options panel
 */
@OptionsPanelController.TopLevelRegistration(
        id = "info.gianlucacosta.easypmd.ide.options.EasyPmdOptionsPanelController",
        categoryName = "#Option_DisplayName_EasyPmd",
        keywords = "#Option_Keywords_EasyPmd",
        keywordsCategory = "#Option_KeywordsCategory_EasyPmd",
        iconBase = "info/gianlucacosta/easypmd/mainIcon32.png"
)
public class EasyPmdOptionsPanelController extends OptionsPanelController {

    private static final Logger logger = Logger.getLogger(EasyPmdOptionsPanelController.class.getName());
    private static final String EASY_PMD_OPTIONS_NAME_IN_EVENT = "EASYPMD_OPTIONS";
    private final EasyPmdPanel easyPmdPanel = new EasyPmdPanel();
    private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
// 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/PmdScanner.java
// public class PmdScanner {
// 
//     private static final Logger logger = Logger.getLogger(PmdScanner.class.getName());
// 
//     private final PmdScannerStrategy strategy;
// 
//     public PmdScanner(Options options) {
//         if (options.getRuleSets().isEmpty()) {
//             logger.info(() -> "Setting a NOP scanning strategy");
//             strategy = new NoOpPmdScannerStrategy();
//             return;
//         }
// 
//         if (options.isUseScanMessagesCache()) {
//             logger.info(() -> "Setting a cached scanning strategy");
//             strategy = new CacheBasedLinkedPmdScanningStrategy(options);
//         } else {
//             logger.info(() -> "Setting a non-cached scanning strategy");
//             strategy = new LinkedPmdScanningStrategy(options);
//         }
//     }
// 
//     public Set<ScanMessage> scan(Path path) {
//         try {
//             return strategy.scan(path);
//         } catch (Exception ex) {
//             ScanError scanError = new ScanError(ex);
// 
//             return Collections.singleton(
//                     scanError
//             );
//         }
//     }
// }
// 
// Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContext.java
// public interface ProfileContext {
// 
//     ProfileMap getProfiles();
// 
//     String getActiveProfileName();
// 
//     Options getActiveOptions();
// }
// 
// Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContextRepository.java
// public interface ProfileContextRepository {
// 
//     ProfileContext getProfileContext();
// 
//     void saveProfileContext(ProfileContext profileContext);
// }


// Path: src/main/java/info/gianlucacosta/easypmd/ide/options/EasyPmdOptionsPanelController.java
import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContext;
import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContextRepository;
import java.util.logging.Logger;
import info.gianlucacosta.easypmd.ide.Injector;
import info.gianlucacosta.easypmd.pmdscanner.PmdScanner;
import org.netbeans.spi.options.OptionsPanelController;
import org.openide.util.HelpCtx;
import org.openide.util.Lookup;
import javax.swing.*;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

/*
 * ==========================================================================%%#
 * 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;



/**
 * Controller underlying the plugin's options panel
 */
@OptionsPanelController.TopLevelRegistration(
        id = "info.gianlucacosta.easypmd.ide.options.EasyPmdOptionsPanelController",
        categoryName = "#Option_DisplayName_EasyPmd",
        keywords = "#Option_Keywords_EasyPmd",
        keywordsCategory = "#Option_KeywordsCategory_EasyPmd",
        iconBase = "info/gianlucacosta/easypmd/mainIcon32.png"
)
public class EasyPmdOptionsPanelController extends OptionsPanelController {

    private static final Logger logger = Logger.getLogger(EasyPmdOptionsPanelController.class.getName());
    private static final String EASY_PMD_OPTIONS_NAME_IN_EVENT = "EASYPMD_OPTIONS";
    private final EasyPmdPanel easyPmdPanel = new EasyPmdPanel();
    private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
    private final ProfileContextRepository profileContextRepository;