com.intellij.ide.actions.ImportModuleAction Java Examples

The following examples show how to use com.intellij.ide.actions.ImportModuleAction. 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: L2GitUtil.java    From azure-devops-intellij with MIT License 6 votes vote down vote up
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 #2
Source File: AttachExternalProjectAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  ProjectSystemId externalSystemId = e.getDataContext().getData(ExternalSystemDataKeys.EXTERNAL_SYSTEM_ID);
  if (externalSystemId == null) {
    return;
  }

  ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
  if (manager == null) {
    return;
  }

  Project project = e.getDataContext().getData(CommonDataKeys.PROJECT);
  if (project == null) {
    return;
  }

  ImportModuleAction.executeImportAction(project, manager.getExternalProjectDescriptor());
}
 
Example #3
Source File: RoboVmModuleBuilder.java    From robovm-idea with GNU General Public License v2.0 4 votes vote down vote up
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();
    }
}