// 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;
    private boolean valid;

    public EasyPmdOptionsPanelController() {
        profileContextRepository = Injector.lookup(ProfileContextRepository.class);
        optionsService = Injector.lookup(OptionsService.class);

        optionsService.addOptionsSetListener((options, optionsChanges) -> {
            optionsChanged = (optionsChanges != OptionsChanges.NONE);

            if (optionsChanged) {
                pcs.firePropertyChange(EASY_PMD_OPTIONS_NAME_IN_EVENT, null, options);
            }
        });
    }

    private void internalValidate() {
        logger.info(() -> "Internally validating the options, for the options controller...");
        try {
            Options activeOptions = easyPmdPanel.getProfileContextDTO().getProfileContext().getActiveOptions();
            optionsService.validateOptions(activeOptions);
            valid = true;
            logger.info("Options valid");
        } catch (InvalidOptionsException ex) {
            valid = false;
            logger.info("Options NOT valid");
        }
    }

    @Override
    public void update() {
// 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;

    private boolean valid;

    public EasyPmdOptionsPanelController() {
        profileContextRepository = Injector.lookup(ProfileContextRepository.class);
        optionsService = Injector.lookup(OptionsService.class);

        optionsService.addOptionsSetListener((options, optionsChanges) -> {
            optionsChanged = (optionsChanges != OptionsChanges.NONE);

            if (optionsChanged) {
                pcs.firePropertyChange(EASY_PMD_OPTIONS_NAME_IN_EVENT, null, options);
            }
        });
    }

    private void internalValidate() {
        logger.info(() -> "Internally validating the options, for the options controller...");
        try {
            Options activeOptions = easyPmdPanel.getProfileContextDTO().getProfileContext().getActiveOptions();
            optionsService.validateOptions(activeOptions);
            valid = true;
            logger.info("Options valid");
        } catch (InvalidOptionsException ex) {
            valid = false;
            logger.info("Options NOT valid");
        }
    }

    @Override
    public void update() {
        ProfileContext profileContext = profileContextRepository.getProfileContext();