com.intellij.ide.util.newProjectWizard.AddModuleWizard Java Examples
The following examples show how to use
com.intellij.ide.util.newProjectWizard.AddModuleWizard.
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: GradleToolDelegate.java From intellij-quarkus with Eclipse Public License 2.0 | 6 votes |
@Override public void processImport(Module module) { Project project = module.getProject(); File gradleFile = null; for(VirtualFile virtualFile : ModuleRootManager.getInstance(module).getContentRoots()) { File baseDir = VfsUtilCore.virtualToIoFile(virtualFile); File file = new File(baseDir, "build.gradle"); if (file.exists()) { gradleFile = file; break; } } if (gradleFile != null) { ProjectImportProvider gradleProjectImportProvider = getGradleProjectImportProvider(); ProjectImportBuilder gradleProjectImportBuilder = gradleProjectImportProvider.getBuilder(); AddModuleWizard wizard = new AddModuleWizard(project, gradleFile.getPath(), new ProjectImportProvider[]{gradleProjectImportProvider}); if (wizard.getStepCount() == 0 || wizard.showAndGet()) { gradleProjectImportBuilder.commit(project, (ModifiableModuleModel)null, (ModulesProvider)null); } } }
Example #2
Source File: GradleModuleBuilderPostProcessor.java From intellij-spring-assistant with MIT License | 6 votes |
@Override public boolean postProcess(Module module) { // TODO: Find a way to use GradleModuleBuilder instead of GradleProjectImportBuilder when adding a child module to the parent Project project = module.getProject(); VirtualFile gradleFile = findFileUnderRootInModule(module, "build.gradle"); if (gradleFile == null) { // not a gradle project return true; } else { ProjectDataManager projectDataManager = getService(ProjectDataManager.class); GradleProjectImportBuilder importBuilder = new GradleProjectImportBuilder(projectDataManager); GradleProjectImportProvider importProvider = new GradleProjectImportProvider(importBuilder); AddModuleWizard addModuleWizard = new AddModuleWizard(project, gradleFile.getPath(), importProvider); if (addModuleWizard.getStepCount() > 0 && !addModuleWizard .showAndGet()) { // user has cancelled import project prompt return true; } else { // user chose to import via the gradle import prompt importBuilder.commit(project, null, null); return false; } } }
Example #3
Source File: L2GitUtil.java From azure-devops-intellij with MIT License | 6 votes |
private void notifyCheckoutListeners(final File directory, final boolean checkoutCompleted) { final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(directory); final AddModuleWizard wizard = ImportModuleAction.createImportWizard(null, null, file, ProjectImportProvider.PROJECT_IMPORT_PROVIDER.getExtensions()); if (wizard == null) return; ImportModuleAction.createFromWizard(null, wizard); if (!checkoutCompleted) { final VcsAwareCheckoutListener[] vcsAwareExtensions = Extensions.getExtensions(VcsAwareCheckoutListener.EP_NAME); for (VcsAwareCheckoutListener extension : vcsAwareExtensions) { boolean processingCompleted = extension.processCheckedOutDirectory(myProject, directory, myVcsKey); if (processingCompleted) break; } } newProject = Objects.requireNonNull(findProjectByBaseDirLocation(directory)); }
Example #4
Source File: PantsOpenProjectProvider.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
private void link(@NotNull VirtualFile projectFile, @NotNull Project project, AddModuleWizard dialog) { if (dialog == null) return; ProjectBuilder builder = dialog.getBuilder(project); if (builder == null) return; try { ApplicationManager.getApplication().runWriteAction(() -> { Optional.ofNullable(dialog.getNewProjectJdk()) .ifPresent(jdk -> NewProjectUtil.applyJdkToProject(project, jdk)); URI output = projectDir(projectFile).resolve(".out").toUri(); Optional.ofNullable(CompilerProjectExtension.getInstance(project)) .ifPresent(ext -> ext.setCompilerOutputUrl(output.toString())); }); builder.commit(project, null, ModulesProvider.EMPTY_MODULES_PROVIDER); project.putUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT, Boolean.TRUE); project.save(); } finally { builder.cleanup(); } }
Example #5
Source File: PantsOpenProjectProvider.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
private AddModuleWizard openNewProjectWizard(VirtualFile projectFile) { PantsProjectImportProvider provider = new PantsProjectImportProvider(); AddModuleWizard dialog = new AddModuleWizard(null, projectFile.getPath(), provider); ProjectImportBuilder builder = provider.getBuilder(); builder.setUpdate(false); dialog.getWizardContext().setProjectBuilder(builder); // dialog can only be shown in a non-headless environment Application application = ApplicationManager.getApplication(); if (application.isHeadlessEnvironment() || dialog.showAndGet()) { return dialog; } else { return null; } }
Example #6
Source File: PantsOpenProjectProvider.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
@Nullable private Project importPantsProject(@NotNull VirtualFile projectFile) { AddModuleWizard dialog = openNewProjectWizard(projectFile); if (dialog == null) return null; Project project = createProject(projectFile, dialog); if (project == null) return null; link(projectFile, project, dialog); refresh(projectFile, project); return project; }
Example #7
Source File: PantsOpenProjectProvider.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
private Project createProject(VirtualFile file, AddModuleWizard dialog) { Project project = PantsUtil.findBuildRoot(file) .map(root -> Paths.get(root.getPath())) .map(root -> ProjectManagerEx.getInstanceEx().newProject(root, dialog.getProjectName(), new OpenProjectTask())) .orElse(null); if (project != null) { project.putUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT, true); } return project; }
Example #8
Source File: TalendModuleBuilder.java From component-runtime with Apache License 2.0 | 4 votes |
@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; }
Example #9
Source File: RoboVmModuleBuilder.java From robovm-idea with GNU General Public License v2.0 | 4 votes |
private void applyBuildSystem(final Project project) { if (buildSystem == BuildSystem.Gradle) { File baseDir = VfsUtilCore.virtualToIoFile(project.getBaseDir()); File[] files = baseDir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return FileUtil.namesEqual("build.gradle", name); } }); if (files != null && files.length != 0) { project.putUserData(ExternalSystemDataKeys.NEWLY_CREATED_PROJECT, Boolean.TRUE); ProjectDataManager projectDataManager = (ProjectDataManager) ServiceManager .getService(ProjectDataManager.class); GradleProjectImportBuilder gradleProjectImportBuilder = new GradleProjectImportBuilder( projectDataManager); gradleProjectImportBuilder.getControl(project).getProjectSettings() .setDistributionType(DistributionType.WRAPPED); GradleProjectImportProvider gradleProjectImportProvider = new GradleProjectImportProvider( gradleProjectImportBuilder); AddModuleWizard wizard = new AddModuleWizard((Project) null, files[0].getPath(), new ProjectImportProvider[] { gradleProjectImportProvider }); if (wizard.getStepCount() <= 0 || wizard.showAndGet()) { ImportModuleAction.createFromWizard(project, wizard); ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { ModifiableModuleModel modifiableModel = ModuleManager.getInstance(project).getModifiableModel(); for (Module module : modifiableModel.getModules()) { try { LanguageLevelModuleExtensionImpl langModel = (LanguageLevelModuleExtensionImpl) LanguageLevelModuleExtensionImpl.getInstance(module).getModifiableModel(true); langModel.setLanguageLevel(LanguageLevel.JDK_1_8); langModel.commit(); } catch(Throwable t) { // could be a non-Java project t.printStackTrace(); } } modifiableModel.commit(); } }); } } } else { FileDocumentManager.getInstance().saveAllDocuments(); MavenProjectsManager.getInstance(project).forceUpdateAllProjectsOrFindAllAvailablePomFiles(); } }
Example #10
Source File: PantsOpenProjectProvider.java From intellij-pants-plugin with Apache License 2.0 | 4 votes |
@Override public void linkToExistingProject(@NotNull VirtualFile projectFile, @NotNull Project project) { AddModuleWizard dialog = openNewProjectWizard(projectFile); link(projectFile, project, dialog); }