Search in sources :

Example 1 with AbstractExternalProjectImportProvider

use of com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalProjectImportProvider in project intellij-community by JetBrains.

the class AttachExternalProjectAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    ProjectSystemId externalSystemId = ExternalSystemDataKeys.EXTERNAL_SYSTEM_ID.getData(e.getDataContext());
    if (externalSystemId == null) {
        return;
    }
    ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
    if (manager == null) {
        return;
    }
    Project project = e.getProject();
    if (project == null) {
        return;
    }
    ProjectImportProvider[] projectImportProviders = new ProjectImportProvider[1];
    for (ProjectImportProvider provider : ProjectImportProvider.PROJECT_IMPORT_PROVIDER.getExtensions()) {
        if (provider instanceof AbstractExternalProjectImportProvider && externalSystemId.equals(((AbstractExternalProjectImportProvider) provider).getExternalSystemId())) {
            projectImportProviders[0] = provider;
            break;
        }
    }
    if (projectImportProviders[0] == null) {
        return;
    }
    AddModuleWizard wizard = ImportModuleAction.selectFileAndCreateWizard(project, null, manager.getExternalProjectDescriptor(), projectImportProviders);
    if (wizard != null && (wizard.getStepCount() <= 0 || wizard.showAndGet())) {
        ImportModuleAction.createFromWizard(project, wizard);
    }
}
Also used : Project(com.intellij.openapi.project.Project) AbstractExternalProjectImportProvider(com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalProjectImportProvider) ProjectImportProvider(com.intellij.projectImport.ProjectImportProvider) AbstractExternalProjectImportProvider(com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalProjectImportProvider) AddModuleWizard(com.intellij.ide.util.newProjectWizard.AddModuleWizard) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId)

Example 2 with AbstractExternalProjectImportProvider

use of com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalProjectImportProvider in project azure-tools-for-java by Microsoft.

the class SbtProjectGenerator method importSbtProject.

private void importSbtProject(String root) {
    Project project = this.module.getProject();
    final ProjectSystemId externalSystemId = new ProjectSystemId("SBT");
    final ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
    if (manager == null) {
        return;
    }
    ProjectImportProvider[] projectImportProviders = new ProjectImportProvider[1];
    for (ProjectImportProvider provider : ProjectImportProvider.PROJECT_IMPORT_PROVIDER.getExtensions()) {
        if (provider instanceof AbstractExternalProjectImportProvider && externalSystemId.equals(((AbstractExternalProjectImportProvider) provider).getExternalSystemId())) {
            projectImportProviders[0] = provider;
            break;
        }
    }
    if (projectImportProviders[0] == null) {
        return;
    }
    final VirtualFile projectFile = VfsUtil.findFile(Paths.get(root, "build.sbt"), true);
    if (projectFile != null) {
        AzureTaskManager.getInstance().runLater(() -> {
            AddModuleWizard wizard = ImportModuleAction.createImportWizard(project, null, projectFile, projectImportProviders);
            if (wizard != null && (wizard.getStepCount() <= 0 || wizard.showAndGet())) {
                ImportModuleAction.createFromWizard(project, wizard);
            }
        });
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) AbstractExternalProjectImportProvider(com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalProjectImportProvider) ProjectImportProvider(com.intellij.projectImport.ProjectImportProvider) AbstractExternalProjectImportProvider(com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalProjectImportProvider) AddModuleWizard(com.intellij.ide.util.newProjectWizard.AddModuleWizard) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId)

Aggregations

AddModuleWizard (com.intellij.ide.util.newProjectWizard.AddModuleWizard)2 ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)2 AbstractExternalProjectImportProvider (com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalProjectImportProvider)2 Project (com.intellij.openapi.project.Project)2 ProjectImportProvider (com.intellij.projectImport.ProjectImportProvider)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1