use of org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectImportBuilder 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);
}
}
});
}
}
Aggregations