Java Code Examples for com.intellij.ide.util.newProjectWizard.AddModuleWizard#showAndGet()
The following examples show how to use
com.intellij.ide.util.newProjectWizard.AddModuleWizard#showAndGet() .
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: 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 4
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(); } }