cleanup
authorpeter <peter@jetbrains.com>
Thu, 26 Jan 2012 18:13:04 +0000 (19:13 +0100)
committerpeter <peter@jetbrains.com>
Fri, 27 Jan 2012 18:11:48 +0000 (19:11 +0100)
platform/platform-impl/src/com/intellij/notification/impl/NotificationModel.java
platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java
platform/platform-impl/src/com/intellij/notification/impl/ProjectNotificationsComponent.java

index 80d2bf1d413f0bf2c93a8ee2494ae840a084920c..d83a4f834a7e2ae7a084722978836e847da57cf2 100644 (file)
@@ -97,34 +97,14 @@ public class NotificationModel {
     }
   }
 
-  public List<Notification> getByType(@Nullable final NotificationType type, @NotNull PairFunction<Notification, Project, Boolean> filter) {
-    if (type == null) {
-      try {
-        myLock.acquire();
-        return Collections.unmodifiableList(filterNotifications(filter));
-      }
-      finally {
-        myLock.release();
-      }
-    }
-
-    final List<Notification> filtered;
+  public List<Notification> getFilteredNotifications(@NotNull PairFunction<Notification, Project, Boolean> filter) {
     try {
       myLock.acquire();
-      filtered = filterNotifications(filter);
+      return Collections.unmodifiableList(filterNotifications(filter));
     }
     finally {
       myLock.release();
     }
-
-    final List<Notification> result = new ArrayList<Notification>();
-    for (final Notification notification : filtered) {
-      if (type == notification.getType()) {
-        result.add(notification);
-      }
-    }
-
-    return result;
   }
 
   @Nullable
index 50968d23171b62354f6bca68afd33e9807dddc28..6d41095bf51b6bed794a76c1fad463596bae292c 100644 (file)
@@ -91,7 +91,7 @@ public class NotificationsManagerImpl extends NotificationsManager implements No
 
   @Override
   public <T extends Notification> T[] getNotificationsOfType(Class<T> klass, @Nullable final Project project) {
-    final List<Notification> notifications = myModel.getByType(null, createFilter(project, false));
+    final List<Notification> notifications = myModel.getFilteredNotifications(createFilter(project, false));
     final List<T> result = new ArrayList<T>();
     for (final Notification notification : notifications) {
       if (klass.isInstance(notification)) {
@@ -327,8 +327,8 @@ public class NotificationsManagerImpl extends NotificationsManager implements No
     return myModel.remove(notification);
   }
 
-  public Collection<Notification> getByType(@Nullable final NotificationType type, @Nullable final Project project) {
-    return myModel.getByType(type, createFilter(project, false));
+  public Collection<Notification> getAllNotifications(@Nullable final Project project) {
+    return myModel.getFilteredNotifications(createFilter(project, false));
   }
 
   private static class ProjectFilter implements PairFunction<Notification, Project, Boolean> {
index 240b3b3081c6a2c49eab832c0c872e790ef81974..3056a2b4b95f613f77a3448353f8af148fdd2a51 100644 (file)
@@ -23,12 +23,9 @@ import com.intellij.openapi.application.Application;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.components.ProjectComponent;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.popup.Balloon;
 import com.intellij.openapi.util.Disposer;
 import org.jetbrains.annotations.NotNull;
 
-import java.util.Collection;
-
 /**
  * @author spleaner
  */
@@ -72,10 +69,8 @@ public class ProjectNotificationsComponent implements Notifications, ProjectComp
   }
 
   public void projectClosed() {
-    final Collection<Notification> collection = NotificationsManagerImpl.getNotificationsManagerImpl().getByType(null, myProject);
-    for (final Notification notification : collection) {
-      final Balloon balloon = notification.getBalloon();
-      if (balloon != null) balloon.hide();
+    for (final Notification notification : NotificationsManagerImpl.getNotificationsManagerImpl().getAllNotifications(myProject)) {
+      notification.expire();
     }
   }