Search in sources :

Example 1 with NotificationAction

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

the class GitDeleteBranchOperation method notifySuccess.

@Override
protected void notifySuccess() {
    boolean unmergedCommits = !myUnmergedToBranches.isEmpty();
    String message = "<b>Deleted Branch:</b> " + myBranchName;
    if (unmergedCommits)
        message += "<br/>Unmerged commits were discarded";
    Notification notification = STANDARD_NOTIFICATION.createNotification("", message, NotificationType.INFORMATION, null);
    notification.addAction(new NotificationAction(RESTORE) {

        @Override
        public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
            restoreInBackground(notification);
        }
    });
    if (unmergedCommits) {
        notification.addAction(new NotificationAction(VIEW_COMMITS) {

            @Override
            public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
                viewUnmergedCommitsInBackground(notification);
            }
        });
    }
    if (!myTrackedBranches.isEmpty() && hasOnlyTrackingBranch(myTrackedBranches, myBranchName)) {
        notification.addAction(new NotificationAction(DELETE_TRACKED_BRANCH) {

            @Override
            public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
                deleteTrackedBranchInBackground();
            }
        });
    }
    myNotifier.notify(notification);
}
Also used : NotificationAction(com.intellij.notification.NotificationAction) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Notification(com.intellij.notification.Notification)

Example 2 with NotificationAction

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

the class PowerSaveModeNotifier method notifyOnPowerSaveMode.

static void notifyOnPowerSaveMode(@Nullable Project project) {
    if (PropertiesComponent.getInstance().getBoolean(IGNORE_POWER_SAVE_MODE)) {
        return;
    }
    Notification notification = POWER_SAVE_MODE.createNotification("Power save mode is on", "Code insight and background tasks are disabled.", NotificationType.WARNING, null);
    notification.addAction(new NotificationAction("Do Not Show Again") {

        @Override
        public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
            PropertiesComponent.getInstance().setValue(IGNORE_POWER_SAVE_MODE, true);
            notification.expire();
        }
    });
    notification.addAction(new NotificationAction("Disable Power Save Mode") {

        @Override
        public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
            PowerSaveMode.setEnabled(false);
            notification.expire();
        }
    });
    notification.notify(project);
    Balloon balloon = notification.getBalloon();
    if (balloon != null) {
        MessageBus bus = project == null ? ApplicationManager.getApplication().getMessageBus() : project.getMessageBus();
        MessageBusConnection connection = bus.connect();
        connection.subscribe(PowerSaveMode.TOPIC, () -> notification.expire());
        Disposer.register(balloon, connection);
    }
}
Also used : MessageBus(com.intellij.util.messages.MessageBus) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) NotificationAction(com.intellij.notification.NotificationAction) Balloon(com.intellij.openapi.ui.popup.Balloon) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Notification(com.intellij.notification.Notification)

Example 3 with NotificationAction

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

the class IdeMessagePanel method showErrorNotification.

private void showErrorNotification(@Nullable String notificationText, @NotNull Project project) {
    Notification notification = new Notification("", AllIcons.Ide.FatalError, notificationText == null ? ERROR_TITLE : "", null, notificationText == null ? "" : notificationText, NotificationType.ERROR, null);
    if (notificationText == null) {
        notification.addAction(new NotificationAction(ERROR_LINK) {

            @Override
            public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
                notification.expire();
                _openFatals(null);
            }
        });
    }
    BalloonLayout layout = myFrame.getBalloonLayout();
    assert layout != null;
    BalloonLayoutData layoutData = BalloonLayoutData.createEmpty();
    layoutData.fadeoutTime = 5000;
    layoutData.fillColor = new JBColor(0XF5E6E7, 0X593D41);
    layoutData.borderColor = new JBColor(0XE0A8A9, 0X73454B);
    assert myBalloon == null;
    myBalloon = NotificationsManagerImpl.createBalloon(myFrame, notification, false, false, new Ref<>(layoutData), project);
    Disposer.register(myBalloon, () -> myBalloon = null);
    layout.add(myBalloon);
}
Also used : Ref(com.intellij.openapi.util.Ref) BalloonLayout(com.intellij.ui.BalloonLayout) NotificationAction(com.intellij.notification.NotificationAction) BalloonLayoutData(com.intellij.ui.BalloonLayoutData) JBColor(com.intellij.ui.JBColor) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Notification(com.intellij.notification.Notification)

Aggregations

Notification (com.intellij.notification.Notification)3 NotificationAction (com.intellij.notification.NotificationAction)3 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)3 Balloon (com.intellij.openapi.ui.popup.Balloon)1 Ref (com.intellij.openapi.util.Ref)1 BalloonLayout (com.intellij.ui.BalloonLayout)1 BalloonLayoutData (com.intellij.ui.BalloonLayoutData)1 JBColor (com.intellij.ui.JBColor)1 MessageBus (com.intellij.util.messages.MessageBus)1 MessageBusConnection (com.intellij.util.messages.MessageBusConnection)1