// Path: src/main/java/net/offbeatpioneer/intellij/plugins/grav/extensions/module/wizard/CreateGravProjectWizardStep.java
// public class CreateGravProjectWizardStep extends ModuleWizardStep { //implements Disposable {
//     public static final String LAST_USED_GRAV_HOME = "LAST_USED_GRAV_HOME";
//     private GravModuleBuilder builder;
//     private GravCreateProjectForm form = new GravCreateProjectForm();
//     private GravPersistentStateComponent storage;
//     private final Project project;
// 
//     public CreateGravProjectWizardStep(GravModuleBuilder builder, @Nullable Project project) {
//         this.builder = builder;
//         this.storage = GravPersistentStateComponent.getInstance();
//         this.project = project;
// 
//         String path = storage.getDefaultGravDownloadPath();
//         if ((path == null || path.isEmpty())) {
//             path = System.getProperty("user.home");
//         } else if (PropertiesComponent.getInstance().getValue(LAST_USED_GRAV_HOME) != null) {
//             path = PropertiesComponent.getInstance().getValue(LAST_USED_GRAV_HOME);
//         }
//         form.setDefaultInstallationPath(path);
//         form.initLayout();
//     }
// 
//     @Override
//     public JComponent getComponent() {
//         return form.getContentPane();
//     }
// 
//     @Override
//     public boolean validate() throws ConfigurationException {
//         String finalGravInstallDir = form.getGravFinalInstallationDirectory().trim();
//         if (finalGravInstallDir.isEmpty()) {
//             form.showHint(true);
//             throw new ConfigurationException("The path pointing to Grav is empty for the selected option");
//         } else {
//             VirtualFile vf = LocalFileSystem.getInstance().findFileByIoFile(new File(finalGravInstallDir));
//             if (vf == null) {
//                 form.showHint(true);
//                 throw new ConfigurationException("The path pointing to Grav doesn't exist for the selected option");
//             } else {
//                 if (!GravSdkType.isValidGravSDK(vf)) {
//                     form.showHint(true);
//                     throw new ConfigurationException("The selected Grav 'SDK' seems not valid for the selected option");
//                 }
//             }
//             String gravSdkVersion = GravSdkType.findGravSdkVersion(finalGravInstallDir);
//             form.setDeterminedGravVersion(gravSdkVersion);
//         }
//         form.showHint(false);
//         return true;
//     }
// 
//     /**
//      * Is called after {@link CreateGravProjectWizardStep#validate()}.
//      */
//     @Override
//     public void updateDataModel() {
//         String file = form.getGravFinalInstallationDirectory();
//         builder.setGravInstallPath(LocalFileSystem.getInstance().findFileByIoFile(new File(file)));
//         PropertiesComponent.getInstance().setValue(LAST_USED_GRAV_HOME, new File(file).getAbsolutePath());
//     }
// 
//     @Override
//     public void updateStep() {
//         super.updateStep();
//     }
// 
// //    @Override
// //    public void dispose() {
// //        if (Objects.nonNull(form) && Objects.nonNull(form.getMainPanel())) {
// //            DialogWrapper.cleanupRootPane(form.getMainPanel().getRootPane());
// //        }
// //    }
// }
// 
// Path: src/main/java/net/offbeatpioneer/intellij/plugins/grav/storage/GravProjectSettings.java
// @State(
//         name = "GravProjectSettings",
//         storages = {
//                 @Storage("grav-plugin.xml")
//         }
// )
// public class GravProjectSettings implements PersistentStateComponent<GravProjectSettings> {
//     public String gravInstallationPath = "";
//     public boolean pluginEnabled = false;
//     public boolean dismissEnableNotification = false;
// 
//     public GravProjectSettings() {
//     }
// 
//     @Nullable
//     public static GravProjectSettings getInstance(@NotNull Project project) {
//         return ServiceManager.getService(project, GravProjectSettings.class);
//     }
// 
//     @Nullable
//     @Override
//     public GravProjectSettings getState() {
//         return this;
//     }
// 
//     @Override
//     public void loadState(GravProjectSettings state) {
//         XmlSerializerUtil.copyBean(state, this);
//     }
// }


import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.ide.util.projectWizard.ModuleBuilderListener;
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.popup.Balloon;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.StatusBar;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.ui.awt.RelativePoint;
import net.offbeatpioneer.intellij.plugins.grav.extensions.module.wizard.CreateGravProjectWizardStep;
import net.offbeatpioneer.intellij.plugins.grav.storage.GravProjectSettings;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.nio.file.Paths;
import java.util.Objects;
package net.offbeatpioneer.intellij.plugins.grav.extensions.module;



public class GravModuleBuilder extends ModuleBuilder implements ModuleBuilderListener {

    private VirtualFile gravInstallPath;
    private GravProjectSettings settings;

    public VirtualFile getGravInstallPath() {
        return gravInstallPath;
    }

    public void setGravInstallPath(VirtualFile gravInstallPath) {
        this.gravInstallPath = gravInstallPath;
    }

    public GravModuleBuilder() {
        addListener(this);
    }

    @Override
    public String getBuilderId() {
// Path: src/main/java/net/offbeatpioneer/intellij/plugins/grav/extensions/module/wizard/CreateGravProjectWizardStep.java
// public class CreateGravProjectWizardStep extends ModuleWizardStep { //implements Disposable {
//     public static final String LAST_USED_GRAV_HOME = "LAST_USED_GRAV_HOME";
//     private GravModuleBuilder builder;
//     private GravCreateProjectForm form = new GravCreateProjectForm();
//     private GravPersistentStateComponent storage;
//     private final Project project;
// 
//     public CreateGravProjectWizardStep(GravModuleBuilder builder, @Nullable Project project) {
//         this.builder = builder;
//         this.storage = GravPersistentStateComponent.getInstance();
//         this.project = project;
// 
//         String path = storage.getDefaultGravDownloadPath();
//         if ((path == null || path.isEmpty())) {
//             path = System.getProperty("user.home");
//         } else if (PropertiesComponent.getInstance().getValue(LAST_USED_GRAV_HOME) != null) {
//             path = PropertiesComponent.getInstance().getValue(LAST_USED_GRAV_HOME);
//         }
//         form.setDefaultInstallationPath(path);
//         form.initLayout();
//     }
// 
//     @Override
//     public JComponent getComponent() {
//         return form.getContentPane();
//     }
// 
//     @Override
//     public boolean validate() throws ConfigurationException {
//         String finalGravInstallDir = form.getGravFinalInstallationDirectory().trim();
//         if (finalGravInstallDir.isEmpty()) {
//             form.showHint(true);
//             throw new ConfigurationException("The path pointing to Grav is empty for the selected option");
//         } else {
//             VirtualFile vf = LocalFileSystem.getInstance().findFileByIoFile(new File(finalGravInstallDir));
//             if (vf == null) {
//                 form.showHint(true);
//                 throw new ConfigurationException("The path pointing to Grav doesn't exist for the selected option");
//             } else {
//                 if (!GravSdkType.isValidGravSDK(vf)) {
//                     form.showHint(true);
//                     throw new ConfigurationException("The selected Grav 'SDK' seems not valid for the selected option");
//                 }
//             }
//             String gravSdkVersion = GravSdkType.findGravSdkVersion(finalGravInstallDir);
//             form.setDeterminedGravVersion(gravSdkVersion);
//         }
//         form.showHint(false);
//         return true;
//     }
// 
//     /**
//      * Is called after {@link CreateGravProjectWizardStep#validate()}.
//      */
//     @Override
//     public void updateDataModel() {
//         String file = form.getGravFinalInstallationDirectory();
//         builder.setGravInstallPath(LocalFileSystem.getInstance().findFileByIoFile(new File(file)));
//         PropertiesComponent.getInstance().setValue(LAST_USED_GRAV_HOME, new File(file).getAbsolutePath());
//     }
// 
//     @Override
//     public void updateStep() {
//         super.updateStep();
//     }
// 
// //    @Override
// //    public void dispose() {
// //        if (Objects.nonNull(form) && Objects.nonNull(form.getMainPanel())) {
// //            DialogWrapper.cleanupRootPane(form.getMainPanel().getRootPane());
// //        }
// //    }
// }
// 
// Path: src/main/java/net/offbeatpioneer/intellij/plugins/grav/storage/GravProjectSettings.java
// @State(
//         name = "GravProjectSettings",
//         storages = {
//                 @Storage("grav-plugin.xml")
//         }
// )
// public class GravProjectSettings implements PersistentStateComponent<GravProjectSettings> {
//     public String gravInstallationPath = "";
//     public boolean pluginEnabled = false;
//     public boolean dismissEnableNotification = false;
// 
//     public GravProjectSettings() {
//     }
// 
//     @Nullable
//     public static GravProjectSettings getInstance(@NotNull Project project) {
//         return ServiceManager.getService(project, GravProjectSettings.class);
//     }
// 
//     @Nullable
//     @Override
//     public GravProjectSettings getState() {
//         return this;
//     }
// 
//     @Override
//     public void loadState(GravProjectSettings state) {
//         XmlSerializerUtil.copyBean(state, this);
//     }
// }


// Path: src/main/java/net/offbeatpioneer/intellij/plugins/grav/extensions/module/GravModuleBuilder.java
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.ide.util.projectWizard.ModuleBuilderListener;
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.popup.Balloon;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.StatusBar;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.ui.awt.RelativePoint;
import net.offbeatpioneer.intellij.plugins.grav.extensions.module.wizard.CreateGravProjectWizardStep;
import net.offbeatpioneer.intellij.plugins.grav.storage.GravProjectSettings;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.nio.file.Paths;
import java.util.Objects;

package net.offbeatpioneer.intellij.plugins.grav.extensions.module;



public class GravModuleBuilder extends ModuleBuilder implements ModuleBuilderListener {

    private VirtualFile gravInstallPath;
    private GravProjectSettings settings;

    public VirtualFile getGravInstallPath() {
        return gravInstallPath;
    }

    public void setGravInstallPath(VirtualFile gravInstallPath) {
        this.gravInstallPath = gravInstallPath;
    }

    public GravModuleBuilder() {
        addListener(this);
    }

    @Override
    public String getBuilderId() {
        return "grav-builder";