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;
}
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");
}
});
}
}
}
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);
}
}
});
}
}
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;
}
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);
}
Aggregations