mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
notifications statusbar icons
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 646 B |
Binary file not shown.
|
After Width: | Height: | Size: 533 B |
Binary file not shown.
|
Before Width: | Height: | Size: 381 B After Width: | Height: | Size: 423 B |
Binary file not shown.
|
Before Width: | Height: | Size: 368 B |
Binary file not shown.
|
After Width: | Height: | Size: 619 B |
@@ -104,7 +104,8 @@ public class NotificationModel {
|
||||
|
||||
private LinkedList<Notification> filterNotifications(@NotNull PairFunction<Notification, Project, Boolean> filter) {
|
||||
final LinkedList<Notification> result = new LinkedList<Notification>();
|
||||
final HashSet<Map.Entry<Notification, Pair<Project, Boolean>>> entries = new HashSet<Map.Entry<Notification, Pair<Project, Boolean>>>(myNotifications.entrySet());
|
||||
final HashSet<Map.Entry<Notification, Pair<Project, Boolean>>> entries =
|
||||
new HashSet<Map.Entry<Notification, Pair<Project, Boolean>>>(myNotifications.entrySet());
|
||||
for (final Map.Entry<Notification, Pair<Project, Boolean>> entry : entries) {
|
||||
if (filter.fun(entry.getKey(), entry.getValue().first)) {
|
||||
result.addFirst(entry.getKey());
|
||||
@@ -183,4 +184,24 @@ public class NotificationModel {
|
||||
public boolean hasRead(PairFunction<Notification, Project, Boolean> filter) {
|
||||
return getUnreadCount(filter) < myNotifications.size();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public NotificationType getMaximumType(PairFunction<Notification, Project, Boolean> filter) {
|
||||
final LinkedList<Notification> notifications = filterNotifications(filter);
|
||||
NotificationType result = null;
|
||||
for (Notification notification : notifications) {
|
||||
if (NotificationType.ERROR == notification.getType()) {
|
||||
return NotificationType.ERROR;
|
||||
}
|
||||
|
||||
if (NotificationType.WARNING == notification.getType()) {
|
||||
result = NotificationType.WARNING;
|
||||
}
|
||||
else if (result == null && NotificationType.INFORMATION == notification.getType()) {
|
||||
result = NotificationType.INFORMATION;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -268,6 +268,11 @@ public class NotificationsManagerImpl extends NotificationsManager implements No
|
||||
return myModel.getByType(type, createFilter(project, false));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public NotificationType getMaximumType(@Nullable final Project project) {
|
||||
return myModel.getMaximumType(createFilter(project, false));
|
||||
}
|
||||
|
||||
public boolean hasUnread(@Nullable final Project project) {
|
||||
return myModel.hasUnread(createFilter(project, false));
|
||||
}
|
||||
|
||||
+18
-6
@@ -17,6 +17,7 @@ package com.intellij.notification.impl.ui;
|
||||
|
||||
import com.intellij.concurrency.JobScheduler;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.impl.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
@@ -39,7 +40,9 @@ import java.util.concurrent.TimeUnit;
|
||||
public class NotificationComponent extends JLabel implements NotificationModelListener {
|
||||
private static final Icon EMPTY_ICON = IconLoader.getIcon("/ide/notifications.png");
|
||||
private static final Icon READ_ICON = IconLoader.getIcon("/ide/read_notifications.png");
|
||||
private static final Icon UNREAD_ICON = IconLoader.getIcon("/ide/unread_notifications.png");
|
||||
private static final Icon ERROR_ICON = IconLoader.getIcon("/ide/error_notifications.png");
|
||||
private static final Icon WARNING_ICON = IconLoader.getIcon("/ide/warning_notifications.png");
|
||||
private static final Icon INFO_ICON = IconLoader.getIcon("/ide/info_notifications.png");
|
||||
|
||||
private WeakReference<JBPopup> myPopupRef;
|
||||
|
||||
@@ -112,11 +115,20 @@ public class NotificationComponent extends JLabel implements NotificationModelLi
|
||||
final NotificationsManagerImpl manager = getManager();
|
||||
|
||||
Icon icon = EMPTY_ICON;
|
||||
if (manager.hasUnread(getProject())) {
|
||||
icon = UNREAD_ICON;
|
||||
}
|
||||
else if (manager.hasRead(getProject())) {
|
||||
icon = READ_ICON;
|
||||
final NotificationType maximumType = manager.getMaximumType(getProject());
|
||||
if (maximumType != null) {
|
||||
switch (maximumType) {
|
||||
case WARNING:
|
||||
icon = WARNING_ICON;
|
||||
break;
|
||||
case ERROR:
|
||||
icon = ERROR_ICON;
|
||||
break;
|
||||
case INFORMATION:
|
||||
default:
|
||||
icon = INFO_ICON;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
myCurrentIcon = new BlinkIconWrapper(icon, false);
|
||||
|
||||
Reference in New Issue
Block a user