diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java
index 22f5eddf54c8..ea2e71ebb1ba 100644
--- a/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java
+++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java
@@ -302,4 +302,6 @@ public interface IdeActions {
String ACTION_RECENT_FILES = "RecentFiles";
String ACTION_SEARCH_EVERYWHERE = "SearchEverywhere";
+
+ String ACTION_MARK_ALL_NOTIFICATIONS_AS_READ = "MarkNotificationsAsRead";
}
diff --git a/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java b/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java
index 4bdb3b0d68d4..484320db8614 100644
--- a/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java
+++ b/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java
@@ -19,6 +19,7 @@ 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;
@@ -37,6 +38,7 @@ 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;
@@ -83,13 +85,21 @@ public class EventLogToolWindowFactory implements ToolWindowFactory, DumbAware {
group.add(new DisplayBalloons());
group.add(new ToggleSoftWraps(editor));
group.add(new ScrollToTheEndToolbarAction(editor));
- group.add(new MarkAllAsRead(project));
+ group.add(createMarkNotificationsAsReadAction(project, editor));
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);
@@ -134,30 +144,6 @@ public class EventLogToolWindowFactory implements ToolWindowFactory, DumbAware {
}
}
- private static class MarkAllAsRead extends DumbAwareAction {
- private final Project myProject;
-
- public MarkAllAsRead(Project project) {
- super("Mark all as read", "Mark all unread notifications as read", AllIcons.Actions.Selectall);
- myProject = project;
- }
-
- @Override
- public void update(AnActionEvent e) {
- if (myProject.isDisposed()) return;
- e.getPresentation().setEnabled(!EventLog.getLogModel(myProject).getNotifications().isEmpty());
- }
-
- @Override
- public void actionPerformed(AnActionEvent e) {
- LogModel model = EventLog.getLogModel(myProject);
- for (Notification notification : model.getNotifications()) {
- model.removeNotification(notification);
- notification.expire();
- }
- }
- }
-
private static class LogShownTracker extends AncestorListenerAdapter {
private final Project myProject;
diff --git a/platform/platform-impl/src/com/intellij/notification/LogModel.java b/platform/platform-impl/src/com/intellij/notification/LogModel.java
index 438b81c1f3ac..da4801eb988e 100644
--- a/platform/platform-impl/src/com/intellij/notification/LogModel.java
+++ b/platform/platform-impl/src/com/intellij/notification/LogModel.java
@@ -115,7 +115,7 @@ public class LogModel implements Disposable {
return myStamps.get(notification);
}
- void removeNotification(Notification notification) {
+ public void removeNotification(Notification notification) {
synchronized (myNotifications) {
myNotifications.remove(notification);
}
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
new file mode 100644
index 000000000000..5c8b24d9a1bb
--- /dev/null
+++ b/platform/platform-impl/src/com/intellij/notification/impl/actions/MarkAllNotificationsAsReadAction.java
@@ -0,0 +1,51 @@
+package com.intellij.notification.impl.actions;
+
+import com.intellij.icons.AllIcons;
+import com.intellij.notification.EventLog;
+import com.intellij.notification.LogModel;
+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());
+ }
+
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+ LogModel model = EventLog.getLogModel(getProject(e));
+ 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;
+ }
+}
diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml
index 332934c0fcfd..05c267a7b065 100644
--- a/platform/platform-resources/src/idea/PlatformActions.xml
+++ b/platform/platform-resources/src/idea/PlatformActions.xml
@@ -704,5 +704,7 @@
+
+