}
}
- 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
@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)) {
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> {
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
*/
}
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();
}
}