// Path: src/org/idea/processing/plugin/ProcessingPluginUtil.java
// public enum ProcessingPluginUtil {
//     INSTANCE;
// 
//     public Collection<VirtualFile> filterFilesAtRoot(@NotNull String path, @NotNull Predicate<VirtualFile> predicate) {
//         VirtualFile importableRoot = LocalFileFinder.findFile(path);
// 
//         if (importableRoot == null) {
//             return new HashSet<>();
//         }
// 
//         return Arrays.stream(importableRoot.getChildren())
//                 .filter(predicate)
//                 .collect(Collectors.toSet());
//     }
// 
//     public GlobalSearchScope sketchesInModuleScope(Module[] modules) {
//         if (modules == null || modules.length == 0) return null;
// 
//         GlobalSearchScope scope = GlobalSearchScope.moduleScope(modules[0]);
// 
//         for (int i = 1; i < modules.length; i++) {
//             scope.uniteWith(GlobalSearchScope.moduleScope(modules[i]));
//         }
// 
//         return scope;
//     }
// }


import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClass;
import com.intellij.psi.search.searches.AllClassesSearch;
import com.intellij.ui.ColorChooser;
import com.intellij.ui.ColorUtil;
import com.intellij.util.Query;
import org.idea.processing.plugin.ProcessingPluginUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection;

    @Override
    protected void resetEditorFrom(@NotNull T t) {
        moduleSelector.fillModules(project);

        Module[] allModules = ModuleManager.getInstance(project).getModules();

        if (allModules.length > 0) {
            moduleSelector.setSelectedModule(allModules[0]);
        }

        Module sketchModule = null;

        for (Module projectModule : allModules) {
            if (projectModule.getName().equals(t.getRunSettings().getModule())) {
                sketchModule = projectModule;
                moduleSelector.setSelectedModule(projectModule);
                break;
            }
        }

        refreshSketchSelectorFromSelectedModule();

        if (sketchModule != null) {
            String savedSketchClassFqn = t.getRunSettings().getSketchClass();

            Module[] moduleSearchScope = {sketchModule};

            PsiClass sketchClass = JavaPsiFacade.getInstance(project)
                    .findClass(savedSketchClassFqn,
// Path: src/org/idea/processing/plugin/ProcessingPluginUtil.java
// public enum ProcessingPluginUtil {
//     INSTANCE;
// 
//     public Collection<VirtualFile> filterFilesAtRoot(@NotNull String path, @NotNull Predicate<VirtualFile> predicate) {
//         VirtualFile importableRoot = LocalFileFinder.findFile(path);
// 
//         if (importableRoot == null) {
//             return new HashSet<>();
//         }
// 
//         return Arrays.stream(importableRoot.getChildren())
//                 .filter(predicate)
//                 .collect(Collectors.toSet());
//     }
// 
//     public GlobalSearchScope sketchesInModuleScope(Module[] modules) {
//         if (modules == null || modules.length == 0) return null;
// 
//         GlobalSearchScope scope = GlobalSearchScope.moduleScope(modules[0]);
// 
//         for (int i = 1; i < modules.length; i++) {
//             scope.uniteWith(GlobalSearchScope.moduleScope(modules[i]));
//         }
// 
//         return scope;
//     }
// }


// Path: src/org/idea/processing/plugin/run_configuration/ProcessingRunConfigurationEditor.java
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClass;
import com.intellij.psi.search.searches.AllClassesSearch;
import com.intellij.ui.ColorChooser;
import com.intellij.ui.ColorUtil;
import com.intellij.util.Query;
import org.idea.processing.plugin.ProcessingPluginUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection;


    @Override
    protected void resetEditorFrom(@NotNull T t) {
        moduleSelector.fillModules(project);

        Module[] allModules = ModuleManager.getInstance(project).getModules();

        if (allModules.length > 0) {
            moduleSelector.setSelectedModule(allModules[0]);
        }

        Module sketchModule = null;

        for (Module projectModule : allModules) {
            if (projectModule.getName().equals(t.getRunSettings().getModule())) {
                sketchModule = projectModule;
                moduleSelector.setSelectedModule(projectModule);
                break;
            }
        }

        refreshSketchSelectorFromSelectedModule();

        if (sketchModule != null) {
            String savedSketchClassFqn = t.getRunSettings().getSketchClass();

            Module[] moduleSearchScope = {sketchModule};

            PsiClass sketchClass = JavaPsiFacade.getInstance(project)
                    .findClass(savedSketchClassFqn,
                            ProcessingPluginUtil.INSTANCE.sketchesInModuleScope(moduleSearchScope)