From c0357f98e67f4bed7d00af60da3dcfa5bf83f1c1 Mon Sep 17 00:00:00 2001 From: pengda Date: Tue, 22 Jun 2021 19:59:50 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-54277=20=E6=B6=88=E6=81=AF=E6=8E=A8?= =?UTF-8?q?=E9=80=81-=E6=B6=88=E6=81=AF=E4=B8=AD=E5=BF=83-=E7=9C=8B?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E6=8E=A8=E9=80=81=E7=9A=84=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/NotificationCenter.java | 21 +++++++------------ .../ui/NotificationCenterDialog.java | 14 +------------ .../ui/NotificationCenterPane.java | 4 +++- 3 files changed, 11 insertions(+), 28 deletions(-) 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 17b805ab61..3faadf795a 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 @@ -3,14 +3,13 @@ package com.fr.design.notification; import com.fr.design.notification.ui.NotificationCenterPane; import java.util.ArrayList; -import java.util.Collections; import java.util.List; public class NotificationCenter { private static NotificationCenter notificationCenter = new NotificationCenter(); private List notifications; private NotificationCenter(){ - notifications = Collections.synchronizedList(new ArrayList<>()); + notifications = new ArrayList<>(); } public static NotificationCenter getInstance(){ @@ -18,10 +17,8 @@ public class NotificationCenter { } public void addNotification(Notification message){ - synchronized (this) { - notifications.add(message); - NotificationCenterPane.getNotificationCenterPane().refreshButton(); - } + notifications.add(message); + NotificationCenterPane.getNotificationCenterPane().refreshButton(); } public int getNotificationsCount(){ @@ -29,10 +26,8 @@ public class NotificationCenter { } public void removeNotification(int index){ - synchronized (this) { - notifications.remove(index); - NotificationCenterPane.getNotificationCenterPane().refreshButton(); - } + notifications.remove(index); + NotificationCenterPane.getNotificationCenterPane().refreshButton(); } public Notification getNotification(int index){ @@ -40,10 +35,8 @@ public class NotificationCenter { } public void clearAllNotifications(){ - synchronized (this) { - notifications.clear(); - NotificationCenterPane.getNotificationCenterPane().refreshButton(); - } + notifications.clear(); + NotificationCenterPane.getNotificationCenterPane().refreshButton(); } } 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 62b2f9d69b..4868dceb14 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 @@ -2,7 +2,6 @@ package com.fr.design.notification.ui; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.DesignerContext; import com.fr.design.notification.Notification; import com.fr.design.notification.NotificationCenter; import java.awt.BorderLayout; @@ -26,9 +25,8 @@ public class NotificationCenterDialog extends JDialog { private UILabel deleteLabel; private static final int NOTIFICATIONCOUNT = 5; - private static NotificationCenterDialog instance; - private NotificationCenterDialog(Frame parent) { + public NotificationCenterDialog(Frame parent) { super(parent); setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Notification")); setResizable(false); @@ -42,13 +40,6 @@ public class NotificationCenterDialog extends JDialog { initComponents(); } - public static NotificationCenterDialog getInstance() { - if (instance == null) { - instance = new NotificationCenterDialog(DesignerContext.getDesignerFrame()); - } - return instance; - } - private void initComponents() { centerPanel = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(1); addNotification(); @@ -89,9 +80,6 @@ public class NotificationCenterDialog extends JDialog { return deleteLabel; } - public void showDialog() { - this.setVisible(true); - } public void hideDialog() { this.dispose(); 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 dfc89cce29..f5af0bfc06 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 @@ -4,6 +4,7 @@ import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.notification.NotificationCenter; import com.fr.general.IOUtils; import java.awt.BorderLayout; @@ -27,7 +28,8 @@ public class NotificationCenterPane extends BasicPane { notificationCenterButton.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - NotificationCenterDialog.getInstance().showDialog(); + NotificationCenterDialog notificationCenterDialog = new NotificationCenterDialog(DesignerContext.getDesignerFrame()); + notificationCenterDialog.setVisible(true); } }); this.setBackground(UIConstants.TEMPLATE_TAB_PANE_BACKGROUND);