com.intellij.openapi.module.ModuleWithNameAlreadyExists Java Examples

The following examples show how to use com.intellij.openapi.module.ModuleWithNameAlreadyExists. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InitializrModuleBuilder.java    From intellij-spring-assistant with MIT License 6 votes vote down vote up
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel)
    throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException,
    ConfigurationException {
  Module module = super.createModule(moduleModel);
  getApplication().invokeLater(() -> {
    ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
      try {
        InitializerDownloader downloader = new InitializerDownloader(this);
        downloader.execute(ProgressManager.getInstance().getProgressIndicator());
      } catch (IOException var2) {
        getApplication()
            .invokeLater(() -> showErrorDialog("Error: " + var2.getMessage(), "Creation Failed"));
      }
    }, "Downloading Required Files...", true, null);
    ModuleBuilderPostProcessor[] postProcessors =
        ModuleBuilderPostProcessor.EXTENSION_POINT_NAME.getExtensions();
    for (ModuleBuilderPostProcessor postProcessor : postProcessors) {
      if (!postProcessor.postProcess(module)) {
        return;
      }
    }
  }, current());
  return module;
}
 
Example #2
Source File: QuarkusModuleBuilder.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
    processDownload();
    Module module = super.createModule(moduleModel);
    wizardContext.getUserData(QuarkusConstants.WIZARD_TOOL_KEY).processImport(module);
    return module;
}
 
Example #3
Source File: FlutterModuleBuilder.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void addAndroidModule(@NotNull Project project,
                                     @Nullable ModifiableModuleModel model,
                                     @NotNull String baseDirPath,
                                     @NotNull String flutterModuleName) {
  final VirtualFile baseDir = LocalFileSystem.getInstance().refreshAndFindFileByPath(baseDirPath);
  if (baseDir == null) {
    return;
  }

  final VirtualFile androidFile = findAndroidModuleFile(baseDir, flutterModuleName);
  if (androidFile == null) return;

  try {
    final ModifiableModuleModel toCommit;
    if (model == null) {
      toCommit = ModuleManager.getInstance(project).getModifiableModel();
      //noinspection AssignmentToMethodParameter
      model = toCommit;
    }
    else {
      toCommit = null;
    }

    model.loadModule(androidFile.getPath());

    if (toCommit != null) {
      WriteAction.run(toCommit::commit);
    }
  }
  catch (ModuleWithNameAlreadyExists | IOException e) {
    FlutterUtils.warn(LOG, e);
  }
}
 
Example #4
Source File: FlutterModuleBuilder.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void addAndroidModule(@NotNull Project project,
                                     @Nullable ModifiableModuleModel model,
                                     @NotNull String baseDirPath,
                                     @NotNull String flutterModuleName) {
  final VirtualFile baseDir = LocalFileSystem.getInstance().refreshAndFindFileByPath(baseDirPath);
  if (baseDir == null) {
    return;
  }

  final VirtualFile androidFile = findAndroidModuleFile(baseDir, flutterModuleName);
  if (androidFile == null) return;

  try {
    final ModifiableModuleModel toCommit;
    if (model == null) {
      toCommit = ModuleManager.getInstance(project).getModifiableModel();
      //noinspection AssignmentToMethodParameter
      model = toCommit;
    }
    else {
      toCommit = null;
    }

    model.loadModule(androidFile.getPath());

    if (toCommit != null) {
      WriteAction.run(toCommit::commit);
    }
  }
  catch (ModuleWithNameAlreadyExists | IOException e) {
    FlutterUtils.warn(LOG, e);
  }
}
 
Example #5
Source File: TalendModuleBuilder.java    From component-runtime with Apache License 2.0 4 votes vote down vote up
@Override
public Module createModule(final ModifiableModuleModel moduleModel) throws InvalidDataException, IOException,
        ModuleWithNameAlreadyExists, ConfigurationException, JDOMException {
    final Module module = super.createModule(moduleModel);
    getApplication().invokeLater(() -> {
        ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
            final ProjectDownloader downloader = new ProjectDownloader(this, request);
            try {
                downloader.download(ProgressManager.getInstance().getProgressIndicator());
            } catch (IOException e) {
                getApplication()
                        .invokeLater(() -> MessagesEx
                                .showErrorDialog(e.getMessage(), getMessage("download.project.file.error")));
            }
        }, getMessage("download.project.file"), true, null);

        final Project moduleProject = module.getProject();
        switch (jsonProject.get("buildType").getAsString()) {
        case "Maven":
            final VirtualFile pomFile = findFileUnderRootInModule(module, "pom.xml");
            if (pomFile != null) {
                final MavenProjectsManager mavenProjectsManager = MavenProjectsManager.getInstance(moduleProject);
                mavenProjectsManager.addManagedFiles(singletonList(pomFile));
            }
            break;
        case "Gradle":
            final VirtualFile gradleFile = findFileUnderRootInModule(module, "build.gradle");
            if (gradleFile != null) {
                final ProjectDataManager projectDataManager = getService(ProjectDataManager.class);
                // todo: move to JavaGradleProjectImportBuilder
                final GradleProjectImportBuilder importBuilder = new GradleProjectImportBuilder(projectDataManager);
                final GradleProjectImportProvider importProvider = new GradleProjectImportProvider(importBuilder);
                final AddModuleWizard addModuleWizard =
                        new AddModuleWizard(moduleProject, gradleFile.getPath(), importProvider);
                if (addModuleWizard.getStepCount() == 0 && addModuleWizard.showAndGet()) {
                    // user chose to import via the gradle import prompt
                    importBuilder.commit(moduleProject, null, null);
                }
            }
            break;
        default:
            break;
        }

    }, ModalityState.current());
    return module;
}