From 2ae3446abceb88ec4eb52af4624be8f806645c7e Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Thu, 12 Mar 2015 11:15:56 +0100 Subject: [PATCH] IDEA-119669 Event Log / Mark all as read: allow to assign a keyboard shortcut --- .../EventLogToolWindowFactory.java | 14 ++-------- .../MarkAllNotificationsAsReadAction.java | 26 ++----------------- 2 files changed, 4 insertions(+), 36 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java b/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java index 484320db8614..282ceeb1a51d 100644 --- a/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java +++ b/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java @@ -19,7 +19,6 @@ import com.intellij.icons.AllIcons; import com.intellij.ide.actions.ContextHelpAction; import com.intellij.notification.impl.NotificationsConfigurable; import com.intellij.notification.impl.NotificationsConfigurationImpl; -import com.intellij.notification.impl.actions.MarkAllNotificationsAsReadAction; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.actions.ScrollToTheEndToolbarAction; @@ -38,7 +37,6 @@ import com.intellij.ui.content.ContentFactory; import com.intellij.ui.content.ContentManager; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import javax.swing.event.AncestorEvent; @@ -85,21 +83,13 @@ public class EventLogToolWindowFactory implements ToolWindowFactory, DumbAware { group.add(new DisplayBalloons()); group.add(new ToggleSoftWraps(editor)); group.add(new ScrollToTheEndToolbarAction(editor)); - group.add(createMarkNotificationsAsReadAction(project, editor)); + group.add(ActionManager.getInstance().getAction(IdeActions.ACTION_MARK_ALL_NOTIFICATIONS_AS_READ)); group.add(new EventLogConsole.ClearLogAction(console)); group.add(new ContextHelpAction(EventLog.HELP_ID)); return ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, false); } - - @NotNull - private static MarkAllNotificationsAsReadAction createMarkNotificationsAsReadAction(@Nullable Project project, @NotNull Editor editor) { - MarkAllNotificationsAsReadAction result = new MarkAllNotificationsAsReadAction(project); - ShortcutSet shortcutSet = ActionManager.getInstance().getAction(IdeActions.ACTION_MARK_ALL_NOTIFICATIONS_AS_READ).getShortcutSet(); - result.registerCustomShortcutSet(shortcutSet, editor.getContentComponent()); - return result; - } - + private static class DisplayBalloons extends ToggleAction implements DumbAware { public DisplayBalloons() { super("Show balloons", "Enable or suppress notification balloons", AllIcons.General.Balloon); diff --git a/platform/platform-impl/src/com/intellij/notification/impl/actions/MarkAllNotificationsAsReadAction.java b/platform/platform-impl/src/com/intellij/notification/impl/actions/MarkAllNotificationsAsReadAction.java index 5c8b24d9a1bb..0a626586937d 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/actions/MarkAllNotificationsAsReadAction.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/actions/MarkAllNotificationsAsReadAction.java @@ -7,45 +7,23 @@ import com.intellij.notification.Notification; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.project.DumbAwareAction; -import com.intellij.openapi.project.Project; -import com.intellij.util.ObjectUtils; -import org.jetbrains.annotations.Nullable; public class MarkAllNotificationsAsReadAction extends DumbAwareAction { - @Nullable - private final Project myProject; - - @SuppressWarnings("unused") - // needed for picoContainer public MarkAllNotificationsAsReadAction() { - this(null); - } - - public MarkAllNotificationsAsReadAction(@Nullable Project project) { super("Mark all notifications as read", "Mark all unread notifications as read", AllIcons.Actions.Selectall); - myProject = project; } @Override public void update(AnActionEvent e) { - e.getPresentation().setEnabled(!EventLog.getLogModel(getProject(e)).getNotifications().isEmpty()); + e.getPresentation().setEnabled(!EventLog.getLogModel(e.getData(CommonDataKeys.PROJECT)).getNotifications().isEmpty()); } @Override public void actionPerformed(AnActionEvent e) { - LogModel model = EventLog.getLogModel(getProject(e)); + LogModel model = EventLog.getLogModel(e.getData(CommonDataKeys.PROJECT)); for (Notification notification : model.getNotifications()) { model.removeNotification(notification); notification.expire(); } } - - @Nullable - private Project getProject(AnActionEvent e) { - Project project = ObjectUtils.chooseNotNull(myProject, e.getData(CommonDataKeys.PROJECT)); - if (project != null && (project.isDisposed() || project.isDefault())) { - return null; - } - return project; - } }