Search in sources :

Example 1 with AddModuleWizard

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

the class NewProjectCheckoutListener method processCheckedOutDirectory.

@Override
public boolean processCheckedOutDirectory(Project project, File directory) {
    VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(directory);
    LOG.assertTrue(file != null, "Can't find " + directory);
    int rc = Messages.showYesNoDialog(project, VcsBundle.message("checkout.create.project.prompt", ProjectCheckoutListener.getProductNameWithArticle(), directory.getAbsolutePath()), VcsBundle.message("checkout.title"), Messages.getQuestionIcon());
    if (rc == Messages.YES) {
        AddModuleWizard wizard = createImportWizard(file);
        if (wizard == null)
            return false;
        if (wizard.showAndGet()) {
            ImportModuleAction.createFromWizard(null, wizard);
        }
        return true;
    }
    return false;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AddModuleWizard(com.intellij.ide.util.newProjectWizard.AddModuleWizard)

Example 2 with AddModuleWizard

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

the class AndroidImportProjectAction method importAdtProject.

private static void importAdtProject(@NotNull VirtualFile file) {
    AdtImportProvider adtImportProvider = new AdtImportProvider(true);
    AddModuleWizard wizard = new AddModuleWizard(null, ProjectImportProvider.getDefaultPath(file), adtImportProvider);
    if (wizard.showAndGet()) {
        try {
            doCreate(wizard);
        } catch (final IOException e) {
            invokeLaterIfNeeded(new Runnable() {

                @Override
                public void run() {
                    Messages.showErrorDialog(e.getMessage(), "Project Initialization Failed");
                }
            });
        }
    }
}
Also used : AdtImportProvider(com.android.tools.idea.gradle.eclipse.AdtImportProvider) AddModuleWizard(com.intellij.ide.util.newProjectWizard.AddModuleWizard) IOException(java.io.IOException)

Example 3 with AddModuleWizard

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

the class GradleStartupActivity method showNotificationForUnlinkedGradleProject.

private static void showNotificationForUnlinkedGradleProject(@NotNull final Project project) {
    if (!PropertiesComponent.getInstance(project).getBoolean(SHOW_UNLINKED_GRADLE_POPUP, true) || !GradleSettings.getInstance(project).getLinkedProjectsSettings().isEmpty() || project.getUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT) == Boolean.TRUE || project.getBaseDir() == null) {
        return;
    }
    File baseDir = VfsUtilCore.virtualToIoFile(project.getBaseDir());
    final File gradleFile = new File(baseDir, GradleConstants.DEFAULT_SCRIPT_NAME);
    if (gradleFile.exists()) {
        String message = String.format("%s<br>\n%s", GradleBundle.message("gradle.notifications.unlinked.project.found.msg", IMPORT_EVENT_DESCRIPTION), GradleBundle.message("gradle.notifications.do.not.show"));
        GradleNotification.getInstance(project).showBalloon(GradleBundle.message("gradle.notifications.unlinked.project.found.title"), message, NotificationType.INFORMATION, new NotificationListener.Adapter() {

            @Override
            protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
                notification.expire();
                if (IMPORT_EVENT_DESCRIPTION.equals(e.getDescription())) {
                    final ProjectDataManager projectDataManager = ServiceManager.getService(ProjectDataManager.class);
                    GradleProjectImportBuilder gradleProjectImportBuilder = new GradleProjectImportBuilder(projectDataManager);
                    final GradleProjectImportProvider gradleProjectImportProvider = new GradleProjectImportProvider(gradleProjectImportBuilder);
                    AddModuleWizard wizard = new AddModuleWizard(project, gradleFile.getPath(), gradleProjectImportProvider);
                    if ((wizard.getStepCount() <= 0 || wizard.showAndGet())) {
                        ImportModuleAction.createFromWizard(project, wizard);
                    }
                } else if (DO_NOT_SHOW_EVENT_DESCRIPTION.equals(e.getDescription())) {
                    PropertiesComponent.getInstance(project).setValue(SHOW_UNLINKED_GRADLE_POPUP, false, true);
                }
            }
        });
    }
}
Also used : GradleProjectImportProvider(org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectImportProvider) HyperlinkEvent(javax.swing.event.HyperlinkEvent) ProjectDataManager(com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager) GradleProjectImportBuilder(org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectImportBuilder) AddModuleWizard(com.intellij.ide.util.newProjectWizard.AddModuleWizard) File(java.io.File) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Example 4 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)

Example 5 with AddModuleWizard

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

the class ImportModuleAction method createImportWizard.

@Nullable
public static AddModuleWizard createImportWizard(@Nullable final Project project, @Nullable Component dialogParent, @NotNull final VirtualFile file, ProjectImportProvider... providers) {
    List<ProjectImportProvider> available = ContainerUtil.filter(providers, provider -> provider.canImport(file, project));
    if (available.isEmpty()) {
        Messages.showInfoMessage(project, "Cannot import anything from " + file.getPath(), "Cannot Import");
        return null;
    }
    String path;
    if (available.size() == 1) {
        path = available.get(0).getPathToBeImported(file);
    } else {
        path = ProjectImportProvider.getDefaultPath(file);
    }
    ProjectImportProvider[] availableProviders = available.toArray(new ProjectImportProvider[available.size()]);
    return dialogParent == null ? new AddModuleWizard(project, path, availableProviders) : new AddModuleWizard(project, dialogParent, path, availableProviders);
}
Also used : ProjectImportProvider(com.intellij.projectImport.ProjectImportProvider) AddModuleWizard(com.intellij.ide.util.newProjectWizard.AddModuleWizard) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

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