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