Search in sources :

Example 11 with DefaultModulesProvider

use of com.intellij.openapi.roots.ui.configuration.DefaultModulesProvider in project moe-ide-integration by multi-os-engine.

the class MOENewModuleAction method createModuleFromWizard.

@Override
public Module createModuleFromWizard(Project project, @Nullable Object dataFromContext, AbstractProjectWizard wizard) {
    ProjectBuilder builder = wizard.getProjectBuilder();
    if (builder instanceof ModuleBuilder) {
        ModuleBuilder module = (ModuleBuilder) builder;
        if (module.getName() == null) {
            module.setName(wizard.getProjectName());
        }
        if (module.getModuleFilePath() == null) {
            module.setModuleFilePath(wizard.getModuleFilePath());
        } else {
            // TODO: get fake temp module to change with the correct one with info from wizard
            File tempModuleFile = new File(module.getModuleFilePath());
            String endOfFile = tempModuleFile.getName();
            File tempFolder = tempModuleFile.getParentFile();
            if (tempFolder != null && tempFolder.getParent() != null) {
                String correctedContentEntryPath = tempFolder.getParent() + File.separator + module.getName();
                String correctedModuleFilePath = correctedContentEntryPath + File.separator + endOfFile;
                ((ModuleBuilder) builder).setModuleFilePath(correctedModuleFilePath);
                ((ModuleBuilder) builder).setContentEntryPath(correctedContentEntryPath);
            }
        }
    }
    if (!builder.validate(project, project)) {
        return null;
    } else {
        Module module1;
        if (builder instanceof ModuleBuilder) {
            module1 = ((ModuleBuilder) builder).commitModule(project, (ModifiableModuleModel) null);
            if (module1 != null) {
                this.processCreatedModule(module1, dataFromContext);
            }
            return module1;
        } else {
            List modules = builder.commit(project, (ModifiableModuleModel) null, new DefaultModulesProvider(project));
            if (builder.isOpenProjectSettingsAfter()) {
                ModulesConfigurator.showDialog(project, (String) null, (String) null);
            }
            module1 = modules != null && !modules.isEmpty() ? (Module) modules.get(0) : null;
            project.save();
            return module1;
        }
    }
}
Also used : ProjectBuilder(com.intellij.ide.util.projectWizard.ProjectBuilder) ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel) DefaultModulesProvider(com.intellij.openapi.roots.ui.configuration.DefaultModulesProvider) ModuleBuilder(com.intellij.ide.util.projectWizard.ModuleBuilder) List(java.util.List) Module(com.intellij.openapi.module.Module) File(java.io.File)

Aggregations

DefaultModulesProvider (com.intellij.openapi.roots.ui.configuration.DefaultModulesProvider)11 Module (com.intellij.openapi.module.Module)5 ModuleBuilder (com.intellij.ide.util.projectWizard.ModuleBuilder)3 ProjectBuilder (com.intellij.ide.util.projectWizard.ProjectBuilder)3 Project (com.intellij.openapi.project.Project)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 Nullable (org.jetbrains.annotations.Nullable)3 NewProjectWizard (com.intellij.ide.projectWizard.NewProjectWizard)2 ModulesProvider (com.intellij.openapi.roots.ui.configuration.ModulesProvider)2 File (java.io.File)2 DetectedFrameworkDescription (com.intellij.framework.detection.DetectedFrameworkDescription)1 ConfigureDetectedFrameworksDialog (com.intellij.framework.detection.impl.ui.ConfigureDetectedFrameworksDialog)1 LibraryDescriptor (com.intellij.ide.util.importProject.LibraryDescriptor)1 ModuleDescriptor (com.intellij.ide.util.importProject.ModuleDescriptor)1 ProjectDescriptor (com.intellij.ide.util.importProject.ProjectDescriptor)1 ExistingModuleLoader (com.intellij.ide.util.projectWizard.ExistingModuleLoader)1 ModifiableModuleModel (com.intellij.openapi.module.ModifiableModuleModel)1 ModuleConfigurationStateImpl (com.intellij.openapi.module.impl.ModuleConfigurationStateImpl)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 IndexNotReadyException (com.intellij.openapi.project.IndexNotReadyException)1