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;
}
}
}
Aggregations