diff --git a/designer-base/src/main/java/com/fr/design/notification/NotificationCenter.java b/designer-base/src/main/java/com/fr/design/notification/NotificationCenter.java index 65f28966e..7ca868db5 100644 --- a/designer-base/src/main/java/com/fr/design/notification/NotificationCenter.java +++ b/designer-base/src/main/java/com/fr/design/notification/NotificationCenter.java @@ -21,8 +21,17 @@ public class NotificationCenter { NotificationCenterPane.getNotificationCenterPane().refreshButton(); } - public List getNotifications(){ - return notifications; + public int getNotificationsCount(){ + return notifications.size(); + } + + public void removeNotification(int index){ + notifications.remove(index); + NotificationCenterPane.getNotificationCenterPane().refreshButton(); + } + + public Notification getNotification(int index){ + return notifications.get(index); } public void clearAllNotifications(){ diff --git a/designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterDialog.java b/designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterDialog.java index 162286a9d..789a02fa9 100644 --- a/designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterDialog.java +++ b/designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterDialog.java @@ -42,7 +42,7 @@ public class NotificationCenterDialog extends JDialog { public void initComponents() { centerPanel = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(1); addNotification(); - deleteLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Clear_Notifications") + "(" + NotificationCenter.getInstance().getNotifications().size() + ")"); + deleteLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Clear_Notifications") + "(" + NotificationCenter.getInstance().getNotificationsCount() + ")"); deleteLabel.setForeground(Color.BLUE); deleteLabel.addMouseListener(new MouseAdapter() { @@ -52,7 +52,7 @@ public class NotificationCenterDialog extends JDialog { centerPanel.removeAll(); addNotification(); pack(); - deleteLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Clear_Notifications") + "(" + NotificationCenter.getInstance().getNotifications().size() + ")"); + deleteLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Clear_Notifications") + "(" + NotificationCenter.getInstance().getNotificationsCount() + ")"); if (notificationNeedShow.size() == 0) { hideDialog(); } @@ -73,12 +73,12 @@ public class NotificationCenterDialog extends JDialog { private void addNotification() { notificationNeedShow.clear(); - List notifications = NotificationCenter.getInstance().getNotifications(); - int size = notifications.size(); + + int size = NotificationCenter.getInstance().getNotificationsCount(); for (int i = NOTIFICATIONCOUNT; i > 0; i--) { int j = size - i; if (j >= 0) { - Notification notification = notifications.get(j); + Notification notification = NotificationCenter.getInstance().getNotification(j); NotificationPane notificationPane = new NotificationPane(notification.getType(), notification.getMessage(), i, notification.getNotificationDialogAction()); notificationNeedShow.add(notificationPane); } @@ -141,10 +141,10 @@ public class NotificationCenterDialog extends JDialog { deleteIconPane.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - NotificationCenter.getInstance().getNotifications().remove(NotificationCenter.getInstance().getNotifications().size() - index); + NotificationCenter.getInstance().removeNotification(NotificationCenter.getInstance().getNotificationsCount() - index); centerPanel.removeAll(); addNotification(); - deleteLabel.setText("清除所有消息" + "(" + NotificationCenter.getInstance().getNotifications().size() + ")"); + deleteLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Clear_Notifications") + "(" + NotificationCenter.getInstance().getNotificationsCount() + ")"); pack(); if (notificationNeedShow.size() == 0) { centerWindow(); diff --git a/designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterPane.java b/designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterPane.java index 55238a5ee..6ed74782b 100644 --- a/designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterPane.java +++ b/designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterPane.java @@ -21,7 +21,7 @@ public class NotificationCenterPane extends BasicPane { setLayout(new BorderLayout()); notificationCenterButton = new UIButton(); notificationCenterButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/notificationcenter/notificationCenter.png")); - notificationCenterButton.setToolTipText(Toolkit.i18nText("显示当前通知")); + notificationCenterButton.setToolTipText(Toolkit.i18nText("Fine-Design_Basic_Show_Notification")); notificationCenterButton.set4ToolbarButton(); notificationCenterButton.setRolloverEnabled(false); this.add(notificationCenterButton); @@ -40,7 +40,7 @@ public class NotificationCenterPane extends BasicPane { } public void refreshButton() { - if (NotificationCenter.getInstance().getNotifications().size() > 0) { + if (NotificationCenter.getInstance().getNotificationsCount() > 0) { notificationCenterButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/notificationcenter/normal.png")); } else { notificationCenterButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/notificationcenter/notificationCenter.png"));