From dfa8484142a31a27ca83d023c4cf69423f41375d Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 14 Jun 2011 20:06:39 +0200 Subject: [PATCH] don't depend on NotificationModel --- .../com/intellij/notification/EventLog.java | 7 ++++++ .../com/intellij/notification/LogModel.java | 23 ++----------------- .../impl/NotificationsManagerImpl.java | 1 + 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/notification/EventLog.java b/platform/platform-impl/src/com/intellij/notification/EventLog.java index 4c57ed33c5e6..3bfa069862b2 100644 --- a/platform/platform-impl/src/com/intellij/notification/EventLog.java +++ b/platform/platform-impl/src/com/intellij/notification/EventLog.java @@ -85,6 +85,13 @@ public class EventLog implements Notifications { } } + public static void expire(@NotNull Notification notification) { + getApplicationComponent().myModel.removeNotification(notification); + for (Project p : ProjectManager.getInstance().getOpenProjects()) { + getProjectComponent(p).myProjectModel.removeNotification(notification); + } + } + private static EventLog getApplicationComponent() { return ApplicationManager.getApplication().getComponent(EventLog.class); } diff --git a/platform/platform-impl/src/com/intellij/notification/LogModel.java b/platform/platform-impl/src/com/intellij/notification/LogModel.java index 20ee390ad869..d626f73e8f53 100644 --- a/platform/platform-impl/src/com/intellij/notification/LogModel.java +++ b/platform/platform-impl/src/com/intellij/notification/LogModel.java @@ -15,15 +15,12 @@ */ package com.intellij.notification; -import com.intellij.notification.impl.NotificationModelListener; import com.intellij.notification.impl.NotificationsConfiguration; import com.intellij.notification.impl.NotificationsManagerImpl; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Condition; import com.intellij.openapi.wm.StatusBar; import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -40,23 +37,6 @@ public class LogModel { LogModel(@Nullable Project project) { myProject = project; - - NotificationsManagerImpl.getNotificationsManagerImpl().addListener(new NotificationModelListener() { - @Override - public void notificationsAdded(@NotNull Notification... notification) { - } - - @Override - public void notificationsRemoved(@NotNull Notification... notification) { - for (Notification notification1 : notification) { - removeNotification(notification1); - } - } - - @Override - public void notificationsRead(@NotNull Notification... notification) { - } - }, project == null ? ApplicationManager.getApplication() : project); } void addNotification(Notification notification) { @@ -103,7 +83,8 @@ public class LogModel { } } - private void removeNotification(Notification notification) { + void removeNotification(Notification notification) { + NotificationsManagerImpl.getNotificationsManagerImpl().remove(notification); synchronized (myNotifications) { myNotifications.remove(notification); } diff --git a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java index 72df6465b972..de36023a645b 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java @@ -70,6 +70,7 @@ public class NotificationsManagerImpl extends NotificationsManager implements No @Override public void expire(@NotNull Notification notification) { + EventLog.expire(notification); remove(notification); }