Browse Source

REPORT-54277 消息推送-消息中心-看不到推送的消息

final/10.0
pengda 3 years ago
parent
commit
c0357f98e6
  1. 21
      designer-base/src/main/java/com/fr/design/notification/NotificationCenter.java
  2. 14
      designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterDialog.java
  3. 4
      designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterPane.java

21
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 com.fr.design.notification.ui.NotificationCenterPane;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
public class NotificationCenter { public class NotificationCenter {
private static NotificationCenter notificationCenter = new NotificationCenter(); private static NotificationCenter notificationCenter = new NotificationCenter();
private List<Notification> notifications; private List<Notification> notifications;
private NotificationCenter(){ private NotificationCenter(){
notifications = Collections.synchronizedList(new ArrayList<>()); notifications = new ArrayList<>();
} }
public static NotificationCenter getInstance(){ public static NotificationCenter getInstance(){
@ -18,10 +17,8 @@ public class NotificationCenter {
} }
public void addNotification(Notification message){ public void addNotification(Notification message){
synchronized (this) { notifications.add(message);
notifications.add(message); NotificationCenterPane.getNotificationCenterPane().refreshButton();
NotificationCenterPane.getNotificationCenterPane().refreshButton();
}
} }
public int getNotificationsCount(){ public int getNotificationsCount(){
@ -29,10 +26,8 @@ public class NotificationCenter {
} }
public void removeNotification(int index){ public void removeNotification(int index){
synchronized (this) { notifications.remove(index);
notifications.remove(index); NotificationCenterPane.getNotificationCenterPane().refreshButton();
NotificationCenterPane.getNotificationCenterPane().refreshButton();
}
} }
public Notification getNotification(int index){ public Notification getNotification(int index){
@ -40,10 +35,8 @@ public class NotificationCenter {
} }
public void clearAllNotifications(){ public void clearAllNotifications(){
synchronized (this) { notifications.clear();
notifications.clear(); NotificationCenterPane.getNotificationCenterPane().refreshButton();
NotificationCenterPane.getNotificationCenterPane().refreshButton();
}
} }
} }

14
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.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.notification.Notification; import com.fr.design.notification.Notification;
import com.fr.design.notification.NotificationCenter; import com.fr.design.notification.NotificationCenter;
import java.awt.BorderLayout; import java.awt.BorderLayout;
@ -26,9 +25,8 @@ public class NotificationCenterDialog extends JDialog {
private UILabel deleteLabel; private UILabel deleteLabel;
private static final int NOTIFICATIONCOUNT = 5; private static final int NOTIFICATIONCOUNT = 5;
private static NotificationCenterDialog instance;
private NotificationCenterDialog(Frame parent) { public NotificationCenterDialog(Frame parent) {
super(parent); super(parent);
setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Notification")); setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Notification"));
setResizable(false); setResizable(false);
@ -42,13 +40,6 @@ public class NotificationCenterDialog extends JDialog {
initComponents(); initComponents();
} }
public static NotificationCenterDialog getInstance() {
if (instance == null) {
instance = new NotificationCenterDialog(DesignerContext.getDesignerFrame());
}
return instance;
}
private void initComponents() { private void initComponents() {
centerPanel = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(1); centerPanel = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(1);
addNotification(); addNotification();
@ -89,9 +80,6 @@ public class NotificationCenterDialog extends JDialog {
return deleteLabel; return deleteLabel;
} }
public void showDialog() {
this.setVisible(true);
}
public void hideDialog() { public void hideDialog() {
this.dispose(); this.dispose();

4
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.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.notification.NotificationCenter; import com.fr.design.notification.NotificationCenter;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import java.awt.BorderLayout; import java.awt.BorderLayout;
@ -27,7 +28,8 @@ public class NotificationCenterPane extends BasicPane {
notificationCenterButton.addMouseListener(new MouseAdapter() { notificationCenterButton.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
NotificationCenterDialog.getInstance().showDialog(); NotificationCenterDialog notificationCenterDialog = new NotificationCenterDialog(DesignerContext.getDesignerFrame());
notificationCenterDialog.setVisible(true);
} }
}); });
this.setBackground(UIConstants.TEMPLATE_TAB_PANE_BACKGROUND); this.setBackground(UIConstants.TEMPLATE_TAB_PANE_BACKGROUND);

Loading…
Cancel
Save