Search in sources :

Example 1 with NotificationGroup

use of com.intellij.notification.NotificationGroup in project intellij-community by JetBrains.

the class ExternalSystemNotificationManager method showNotification.

public void showNotification(@NotNull final ProjectSystemId externalSystemId, @NotNull final NotificationData notificationData) {
    myUpdater.submit(() -> {
        if (myProject.isDisposed())
            return;
        final Application app = ApplicationManager.getApplication();
        Runnable action = () -> {
            if (!initializedExternalSystem.contains(externalSystemId)) {
                app.runWriteAction(() -> {
                    if (myProject.isDisposed())
                        return;
                    ExternalSystemUtil.ensureToolWindowContentInitialized(myProject, externalSystemId);
                    initializedExternalSystem.add(externalSystemId);
                });
            }
            if (myProject.isDisposed())
                return;
            NotificationGroup group;
            if (notificationData.getBalloonGroup() == null) {
                ExternalProjectsView externalProjectsView = ExternalProjectsManager.getInstance(myProject).getExternalProjectsView(externalSystemId);
                group = externalProjectsView instanceof ExternalProjectsViewImpl ? ((ExternalProjectsViewImpl) externalProjectsView).getNotificationGroup() : null;
            } else {
                final NotificationGroup registeredGroup = NotificationGroup.findRegisteredGroup(notificationData.getBalloonGroup());
                group = registeredGroup != null ? registeredGroup : NotificationGroup.balloonGroup(notificationData.getBalloonGroup());
            }
            if (group == null)
                return;
            final Notification notification = group.createNotification(notificationData.getTitle(), notificationData.getMessage(), notificationData.getNotificationCategory().getNotificationType(), notificationData.getListener());
            myNotifications.add(notification);
            if (notificationData.isBalloonNotification()) {
                applyNotification(notification);
            } else {
                addMessage(notification, externalSystemId, notificationData);
            }
        };
        app.invokeLater(action, ModalityState.defaultModalityState(), myProject.getDisposed());
    });
}
Also used : ExternalProjectsViewImpl(com.intellij.openapi.externalSystem.view.ExternalProjectsViewImpl) ExternalProjectsView(com.intellij.openapi.externalSystem.view.ExternalProjectsView) NotificationGroup(com.intellij.notification.NotificationGroup) Application(com.intellij.openapi.application.Application) Notification(com.intellij.notification.Notification)

Example 2 with NotificationGroup

use of com.intellij.notification.NotificationGroup in project intellij-community by JetBrains.

the class GitPushResultNotification method create.

@NotNull
static GitPushResultNotification create(@NotNull Project project, @NotNull GitPushResult pushResult, boolean multiRepoProject) {
    GroupedPushResult grouped = GroupedPushResult.group(pushResult.getResults());
    String title;
    NotificationType type;
    if (!grouped.errors.isEmpty()) {
        if (!grouped.successful.isEmpty()) {
            title = "Push partially failed";
        } else {
            title = "Push failed";
        }
        type = NotificationType.ERROR;
    } else if (!grouped.rejected.isEmpty() || !grouped.customRejected.isEmpty()) {
        if (!grouped.successful.isEmpty()) {
            title = "Push partially rejected";
        } else {
            title = "Push rejected";
        }
        type = NotificationType.WARNING;
    } else {
        title = "Push successful";
        type = NotificationType.INFORMATION;
    }
    String description = formDescription(pushResult.getResults(), multiRepoProject);
    ViewUpdatedFilesNotificationListener listener = null;
    UpdatedFiles updatedFiles = pushResult.getUpdatedFiles();
    if (!updatedFiles.isEmpty()) {
        description += "<br/>" + VIEW_FILES_UPDATED_DURING_THE_PUSH;
        listener = new ViewUpdatedFilesNotificationListener(project, updatedFiles, pushResult.getBeforeUpdateLabel(), pushResult.getAfterUpdateLabel());
    }
    NotificationGroup group = type == NotificationType.INFORMATION ? VcsNotifier.NOTIFICATION_GROUP_ID : VcsNotifier.IMPORTANT_ERROR_NOTIFICATION;
    return new GitPushResultNotification(group.getDisplayId(), title, description, type, listener);
}
Also used : NotificationType(com.intellij.notification.NotificationType) UpdatedFiles(com.intellij.openapi.vcs.update.UpdatedFiles) NotificationGroup(com.intellij.notification.NotificationGroup) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with NotificationGroup

use of com.intellij.notification.NotificationGroup in project flutter-intellij by flutter.

the class FlutterReloadManager method getNotificationGroup.

private static NotificationGroup getNotificationGroup(String toolWindowId) {
    if (!toolWindowNotificationGroups.containsKey(toolWindowId)) {
        final NotificationGroup notificationGroup = NotificationGroup.toolWindowGroup("Flutter " + toolWindowId, toolWindowId, false);
        toolWindowNotificationGroups.put(toolWindowId, notificationGroup);
    }
    return toolWindowNotificationGroups.get(toolWindowId);
}
Also used : NotificationGroup(com.intellij.notification.NotificationGroup)

Example 4 with NotificationGroup

use of com.intellij.notification.NotificationGroup in project flutter-intellij by flutter.

the class FlutterReloadManager method showAnalysisNotification.

private void showAnalysisNotification(@NotNull String title, @NotNull String content, boolean isError) {
    if (!ToolWindowManager.getInstance(myProject).getToolWindow(DartProblemsView.TOOLWINDOW_ID).isVisible()) {
        content += " (<a href='open.analysis.view'>view issues</a>)";
    }
    final NotificationGroup notificationGroup = getNotificationGroup(DartProblemsView.TOOLWINDOW_ID);
    final Notification notification = notificationGroup.createNotification(title, content, isError ? NotificationType.ERROR : NotificationType.INFORMATION, new NotificationListener.Adapter() {

        @Override
        protected void hyperlinkActivated(@NotNull final Notification notification, @NotNull final HyperlinkEvent e) {
            notification.expire();
            ToolWindowManager.getInstance(myProject).getToolWindow(DartProblemsView.TOOLWINDOW_ID).activate(null);
        }
    });
    notification.setIcon(FlutterIcons.Flutter);
    notification.notify(myProject);
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) NotificationGroup(com.intellij.notification.NotificationGroup) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Example 5 with NotificationGroup

use of com.intellij.notification.NotificationGroup in project flutter-intellij by flutter.

the class FlutterReloadManager method showRunNotification.

private Notification showRunNotification(@NotNull FlutterApp app, @Nullable String title, @NotNull String content, boolean isError) {
    final String toolWindowId = app.getMode() == RunMode.DEBUG ? ToolWindowId.DEBUG : ToolWindowId.RUN;
    final NotificationGroup notificationGroup = getNotificationGroup(toolWindowId);
    final Notification notification;
    if (title == null) {
        notification = notificationGroup.createNotification(content, isError ? NotificationType.ERROR : NotificationType.INFORMATION);
    } else {
        notification = notificationGroup.createNotification(title, content, isError ? NotificationType.ERROR : NotificationType.INFORMATION, null);
    }
    notification.setIcon(FlutterIcons.Flutter);
    notification.notify(myProject);
    return notification;
}
Also used : NotificationGroup(com.intellij.notification.NotificationGroup) Notification(com.intellij.notification.Notification)

Aggregations

NotificationGroup (com.intellij.notification.NotificationGroup)13 Notification (com.intellij.notification.Notification)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 NotificationListener (com.intellij.notification.NotificationListener)1 NotificationType (com.intellij.notification.NotificationType)1 Application (com.intellij.openapi.application.Application)1 ExternalProjectsView (com.intellij.openapi.externalSystem.view.ExternalProjectsView)1 ExternalProjectsViewImpl (com.intellij.openapi.externalSystem.view.ExternalProjectsViewImpl)1 UpdatedFiles (com.intellij.openapi.vcs.update.UpdatedFiles)1 THashSet (gnu.trove.THashSet)1 HyperlinkEvent (javax.swing.event.HyperlinkEvent)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1