Search in sources :

Example 6 with AddModuleWizard

use of com.intellij.ide.util.newProjectWizard.AddModuleWizard in project intellij-community by JetBrains.

the class GradleProjectOpenProcessor method doQuickImport.

@Override
protected boolean doQuickImport(VirtualFile file, WizardContext wizardContext) {
    final GradleProjectImportProvider projectImportProvider = new GradleProjectImportProvider(getBuilder());
    getBuilder().setFileToImport(file.getPath());
    getBuilder().prepare(wizardContext);
    final String pathToUse;
    if (!file.isDirectory() && file.getParent() != null) {
        pathToUse = file.getParent().getPath();
    } else {
        pathToUse = file.getPath();
    }
    getBuilder().getControl(null).setLinkedProjectPath(pathToUse);
    final boolean result;
    if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
        result = setupGradleProjectSettingsInHeadlessMode(projectImportProvider, wizardContext);
    } else {
        AddModuleWizard dialog = new AddModuleWizard(null, file.getPath(), projectImportProvider);
        dialog.getWizardContext().setProjectBuilder(getBuilder());
        dialog.navigateToStep(step -> step instanceof SelectExternalProjectStep);
        result = dialog.showAndGet();
    }
    if (result && getBuilder().getExternalProjectNode() != null) {
        wizardContext.setProjectName(getBuilder().getExternalProjectNode().getData().getInternalName());
    }
    return result;
}
Also used : AddModuleWizard(com.intellij.ide.util.newProjectWizard.AddModuleWizard) SelectExternalProjectStep(com.intellij.openapi.externalSystem.service.project.wizard.SelectExternalProjectStep)

Aggregations

AddModuleWizard (com.intellij.ide.util.newProjectWizard.AddModuleWizard)6 ProjectImportProvider (com.intellij.projectImport.ProjectImportProvider)2 AdtImportProvider (com.android.tools.idea.gradle.eclipse.AdtImportProvider)1 Notification (com.intellij.notification.Notification)1 NotificationListener (com.intellij.notification.NotificationListener)1 ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)1 ProjectDataManager (com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager)1 AbstractExternalProjectImportProvider (com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalProjectImportProvider)1 SelectExternalProjectStep (com.intellij.openapi.externalSystem.service.project.wizard.SelectExternalProjectStep)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 File (java.io.File)1 IOException (java.io.IOException)1 HyperlinkEvent (javax.swing.event.HyperlinkEvent)1 Nullable (org.jetbrains.annotations.Nullable)1 GradleProjectImportBuilder (org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectImportBuilder)1 GradleProjectImportProvider (org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectImportProvider)1