Browse Source

Pull request #4654: REPORT-53873 设计器用户登录策略调整-消息提醒-消息提醒框弹出位置

Merge in DESIGN/design from ~PENGDA/design:release/10.0 to release/10.0

* commit 'cfcdb21c80a56e457eb4ebf1bbb6b7ec538f5cc1':
  REPORT-53873 设计器用户登录策略调整-消息提醒-消息提醒框弹出位置
  REPORT-53873 设计器用户登录策略调整-消息提醒-消息提醒框弹出位置
zheng-1641779399395
pengda 3 years ago
parent
commit
ef254e4c3b
  1. 2
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 79
      designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java
  3. 4
      designer-base/src/main/java/com/fr/design/login/message/DesignerMessageHelper.java
  4. 11
      designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterDialog.java
  5. 6
      designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterPane.java
  6. 2
      designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java
  7. 0
      designer-base/src/main/resources/com/fr/design/notification/ui/notificationCenter.png
  8. 0
      designer-base/src/main/resources/com/fr/design/notification/ui/notificationCenterDot.png

2
designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java

@ -17,6 +17,7 @@ import com.fr.design.file.TemplateTreePane;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.notification.NotificationCenter;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.design.versioncheck.VersionCheckUtils; import com.fr.design.versioncheck.VersionCheckUtils;
import com.fr.env.EnvListPane; import com.fr.env.EnvListPane;
@ -182,6 +183,7 @@ public class EnvChangeEntrance {
if (model != null) { if (model != null) {
model.envChanged(); model.envChanged();
} }
NotificationCenter.getInstance().clearAllNotifications();
return true; return true;
} }

79
designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java

@ -1,12 +1,14 @@
package com.fr.design.dialog; package com.fr.design.dialog;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
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 com.fr.design.utils.gui.GUICoreUtils; import com.fr.module.ModuleContext;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
@ -14,6 +16,8 @@ import java.awt.Frame;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JDialog; import javax.swing.JDialog;
@ -24,7 +28,6 @@ import javax.swing.UIManager;
/** /**
* 带查看详情的简要通知框 * 带查看详情的简要通知框
*
*/ */
public class NotificationDialog extends JDialog { public class NotificationDialog extends JDialog {
public static final int ERROR_MESSAGE = 0; public static final int ERROR_MESSAGE = 0;
@ -32,13 +35,15 @@ public class NotificationDialog extends JDialog {
public static final int WARNING_MESSAGE = 2; public static final int WARNING_MESSAGE = 2;
public static final String HTML_TAG_1 = "<html>"; public static final String HTML_TAG_1 = "<html>";
public static final String HTML_TAG_2 = "</html>"; public static final String HTML_TAG_2 = "</html>";
private static final String HIDE_MSG = "HIDE_MSG_TIMER";
private UILabel messageText; private UILabel messageText;
private NotificationDialogAction notificationDialogAction; private NotificationDialogAction notificationDialogAction;
private ScheduledExecutorService TIMER;
public NotificationDialog(Frame owner, String title, boolean isModal, int messageType, String message,NotificationDialogAction action) { public NotificationDialog(Frame owner, String title, boolean isModal, int messageType, String message, NotificationDialogAction action) {
super(owner); super(owner);
setTitle(title); setTitle(title);
initComponents(messageType, message, isModal,action); initComponents(messageType, message, isModal, action);
} }
public NotificationDialog(Builder builder) { public NotificationDialog(Builder builder) {
@ -47,27 +52,32 @@ public class NotificationDialog extends JDialog {
initComponents(builder.messageType, builder.message, builder.modal, builder.action); initComponents(builder.messageType, builder.message, builder.modal, builder.action);
} }
public void initComponents(int messageType, String message, boolean isModal,NotificationDialogAction action) { public void initComponents(int messageType, String message, boolean isModal, NotificationDialogAction action) {
NotificationCenter.getInstance().addNotification(new Notification(messageType,message,action)); NotificationCenter.getInstance().addNotification(new Notification(messageType, message, action));
notificationDialogAction = action; notificationDialogAction = action;
setModal(isModal); setModal(isModal);
setFocusable(false);
setAutoRequestFocus(false);
setResizable(false); setResizable(false);
JPanel body = FRGUIPaneFactory.createBorderLayout_L_Pane();
body.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
//消息内容 //消息内容
UILabel icon = new UILabel(getIconForType(messageType)); UILabel icon = new UILabel(getIconForType(messageType));
JPanel iconPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); JPanel iconPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
iconPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 8)); iconPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 10, 8));
iconPanel.add(icon); iconPanel.add(icon);
add(iconPanel, BorderLayout.WEST); body.add(iconPanel, BorderLayout.WEST);
messageText = new UILabel(HTML_TAG_1 + message + HTML_TAG_2); messageText = new UILabel(HTML_TAG_1 + message + HTML_TAG_2);
messageText.setForeground(new Color(51, 51, 52)); messageText.setForeground(new Color(51, 51, 52));
JPanel centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); JPanel centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 10)); centerPanel.setBorder(BorderFactory.createEmptyBorder(8, 0, 5, 20));
JScrollPane jScrollPane = new JScrollPane(messageText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); JScrollPane jScrollPane = new JScrollPane(messageText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPane.setBorder(BorderFactory.createEmptyBorder()); jScrollPane.setBorder(BorderFactory.createEmptyBorder());
centerPanel.add(jScrollPane, BorderLayout.CENTER); centerPanel.add(jScrollPane, BorderLayout.CENTER);
add(centerPanel, BorderLayout.CENTER); centerPanel.setPreferredSize(new Dimension(230, 95));
body.add(centerPanel, BorderLayout.CENTER);
//查看详情 //查看详情
UILabel detailLabel = new UILabel(); UILabel detailLabel = new UILabel();
@ -75,37 +85,67 @@ public class NotificationDialog extends JDialog {
detailLabel.setForeground(Color.BLUE); detailLabel.setForeground(Color.BLUE);
JPanel detailPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); JPanel detailPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
detailPanel.add(detailLabel, BorderLayout.EAST); detailPanel.add(detailLabel, BorderLayout.EAST);
add(detailPanel, BorderLayout.SOUTH); body.add(detailPanel, BorderLayout.SOUTH);
setPreferredSize(new Dimension(262, 135));
detailLabel.addMouseListener(detailClickListener); detailLabel.addMouseListener(detailClickListener);
messageText.addMouseListener(detailClickListener); messageText.addMouseListener(detailClickListener);
addMouseListener(bodyMouseListener);
pack(); add(body);
if (getOwner() != null) { Dimension dimension = body.getPreferredSize();
GUICoreUtils.setWindowCenter(getOwner(), this); setSize(dimension.width, dimension.height);
} setLocation((DesignerContext.getDesignerFrame().getWidth() - dimension.width - 30 + DesignerContext.getDesignerFrame().getX()),
DesignerContext.getDesignerFrame().getY() + DesignerContext.getDesignerFrame().getHeight() - dimension.height - 30);
disappear();
} }
private MouseListener detailClickListener = new MouseAdapter() { private MouseListener detailClickListener = new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if(notificationDialogAction != null){ if (notificationDialogAction != null) {
hideDialog(); hideDialog();
notificationDialogAction.doClick(); notificationDialogAction.doClick();
} }
} }
}; };
private MouseListener bodyMouseListener = new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
if (TIMER != null) {
TIMER.shutdownNow();
}
}
@Override
public void mouseExited(MouseEvent e) {
disappear();
}
};
public void disappear() {
TIMER = createScheduleExecutorService();
TIMER.schedule(new Runnable() {
@Override
public void run() {
hideDialog();
}
}, 10000, TimeUnit.MILLISECONDS);
}
private ScheduledExecutorService createScheduleExecutorService() {
return ModuleContext.getExecutor().newSingleThreadScheduledExecutor(new NamedThreadFactory(HIDE_MSG));
}
/** /**
* 设置通知消息 * 设置通知消息
*/ */
public void setMessage(String message){ public void setMessage(String message) {
messageText.setText(HTML_TAG_1 + message + HTML_TAG_2); messageText.setText(HTML_TAG_1 + message + HTML_TAG_2);
} }
private void hideDialog(){ private void hideDialog() {
this.setVisible(false);
this.dispose(); this.dispose();
} }
@ -138,6 +178,7 @@ public class NotificationDialog extends JDialog {
public Frame owner = null; public Frame owner = null;
public String title; public String title;
public NotificationDialogAction action; public NotificationDialogAction action;
private Builder() { private Builder() {
} }

4
designer-base/src/main/java/com/fr/design/login/message/DesignerMessageHelper.java

@ -90,7 +90,7 @@ public class DesignerMessageHelper {
NotificationDialog.Builder() NotificationDialog.Builder()
.owner(DesignerContext.getDesignerFrame()) .owner(DesignerContext.getDesignerFrame())
.title(title) .title(title)
.modal(true) .modal(false)
.messageType(NotificationDialog.NEW_MESSAGE) .messageType(NotificationDialog.NEW_MESSAGE)
.message(body) .message(body)
.notificationDialogAction(new NotificationDialogAction() { .notificationDialogAction(new NotificationDialogAction() {
@ -107,7 +107,7 @@ public class DesignerMessageHelper {
NotificationDialog.Builder() NotificationDialog.Builder()
.owner(DesignerContext.getDesignerFrame()) .owner(DesignerContext.getDesignerFrame())
.title(title) .title(title)
.modal(true) .modal(false)
.messageType(NotificationDialog.NEW_MESSAGE) .messageType(NotificationDialog.NEW_MESSAGE)
.message(body) .message(body)
.notificationDialogAction(designerModuleClickType.getAction()) .notificationDialogAction(designerModuleClickType.getAction())

11
designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterDialog.java

@ -15,8 +15,9 @@ import java.awt.Window;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JDialog; import javax.swing.JDialog;
@ -32,10 +33,16 @@ public class NotificationCenterDialog extends JDialog {
private static final int NOTIFICATIONCOUNT = 5; private static final int NOTIFICATIONCOUNT = 5;
public NotificationCenterDialog(Frame parent) { public NotificationCenterDialog(Frame parent) {
super(parent, true); 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);
notificationNeedShow = new ArrayList<>(); notificationNeedShow = new ArrayList<>();
addWindowFocusListener(new WindowAdapter() {
@Override
public void windowLostFocus(WindowEvent e) {
hideDialog();
}
});
initComponents(); initComponents();
} }

6
designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterPane.java

@ -20,7 +20,7 @@ public class NotificationCenterPane extends BasicPane {
setPreferredSize(new Dimension(24, 24)); setPreferredSize(new Dimension(24, 24));
setLayout(new BorderLayout()); setLayout(new BorderLayout());
notificationCenterButton = new UIButton(); notificationCenterButton = new UIButton();
notificationCenterButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/notificationcenter/notificationCenter.png")); notificationCenterButton.setIcon(IOUtils.readIcon("/com/fr/design/notification/ui/notificationCenter.png"));
notificationCenterButton.setToolTipText(Toolkit.i18nText("Fine-Design_Basic_Show_Notification")); notificationCenterButton.setToolTipText(Toolkit.i18nText("Fine-Design_Basic_Show_Notification"));
notificationCenterButton.set4ToolbarButton(); notificationCenterButton.set4ToolbarButton();
notificationCenterButton.setRolloverEnabled(false); notificationCenterButton.setRolloverEnabled(false);
@ -41,9 +41,9 @@ public class NotificationCenterPane extends BasicPane {
public void refreshButton() { public void refreshButton() {
if (NotificationCenter.getInstance().getNotificationsCount() > 0) { if (NotificationCenter.getInstance().getNotificationsCount() > 0) {
notificationCenterButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/notificationcenter/notificationCenterDot.png")); notificationCenterButton.setIcon(IOUtils.readIcon("/com/fr/design/notification/ui/notificationCenterDot.png"));
} else { } else {
notificationCenterButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/notificationcenter/notificationCenter.png")); notificationCenterButton.setIcon(IOUtils.readIcon("/com/fr/design/notification/ui/notificationCenter.png"));
} }
} }

2
designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java

@ -73,7 +73,7 @@ public class VersionCheckUtils {
public static void showVersionCheckDialog(String envName) { public static void showVersionCheckDialog(String envName) {
if (!VersionCheckUtils.versionCheck(envName)) { if (!VersionCheckUtils.versionCheck(envName)) {
NotificationDialog notificationDialog = new NotificationDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Sync_Prompt"), NotificationDialog notificationDialog = new NotificationDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Sync_Prompt"),
true, NotificationDialog.WARNING_MESSAGE, Toolkit.i18nText("Fine-Design_Basic_Sync_Check_Brief_Info"), new NotificationDialogAction() { false, NotificationDialog.WARNING_MESSAGE, Toolkit.i18nText("Fine-Design_Basic_Sync_Check_Brief_Info"), new NotificationDialogAction() {
@Override @Override
public void doClick() { public void doClick() {
CheckServiceDialog checkServiceDialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), GeneralUtils.readFullBuildNO(), getRemoteBranch(envName),getNoExistServiceDescription(envName)); CheckServiceDialog checkServiceDialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), GeneralUtils.readFullBuildNO(), getRemoteBranch(envName),getNoExistServiceDescription(envName));

0
designer-realize/src/main/resources/com/fr/design/mainframe/notificationCenter/notificationCenter.png → designer-base/src/main/resources/com/fr/design/notification/ui/notificationCenter.png

Before

Width:  |  Height:  |  Size: 347 B

After

Width:  |  Height:  |  Size: 347 B

0
designer-realize/src/main/resources/com/fr/design/mainframe/notificationCenter/notificationCenterDot.png → designer-base/src/main/resources/com/fr/design/notification/ui/notificationCenterDot.png

Before

Width:  |  Height:  |  Size: 491 B

After

Width:  |  Height:  |  Size: 491 B

Loading…
Cancel
Save