From 5e07dc67f4b96c49fea89d228705f38df89b237f Mon Sep 17 00:00:00 2001 From: Lanlan Date: Wed, 23 Jun 2021 15:01:15 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-54332=20mac=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=EF=BC=9A=E5=B8=86=E8=BD=AF=E9=80=9A=E8=A1=8C=E8=AF=81=E5=9C=A8?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E7=AE=A1=E7=90=86=E6=89=93=E5=BC=80=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E6=8F=90=E7=A4=BA=E6=96=87=E6=9C=AC=E8=A2=AB=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E7=AE=A1=E7=90=86=E9=81=AE=E6=8C=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/extra/WebViewDlgHelper.java | 2 +- .../login/utils/DesignerLoginUtils.java | 6 +++-- .../mainframe/toast/DesignerToastMsgUtil.java | 23 +++++++++++++++---- .../mainframe/toast/ToastMsgDialog.java | 16 ++++++++++--- .../java/com/fr/design/upm/UpmFinder.java | 2 +- 5 files changed, 38 insertions(+), 11 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java b/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java index 88bfdecbd..f35fbdf11 100644 --- a/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java +++ b/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java @@ -207,7 +207,7 @@ public class WebViewDlgHelper { UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane); PluginWebBridge.getHelper().setDialogHandle(dlg); dlg.setVisible(true); - DesignerLoginUtils.showPluginRemindOnFirstLaunch(); + DesignerLoginUtils.showPluginRemindOnFirstLaunch(dlg); } catch (Exception e) { // ignored FineLoggerFactory.getLogger().error(e.getMessage(), e); diff --git a/designer-base/src/main/java/com/fr/design/login/utils/DesignerLoginUtils.java b/designer-base/src/main/java/com/fr/design/login/utils/DesignerLoginUtils.java index 5dd49a00b..26e095df6 100644 --- a/designer-base/src/main/java/com/fr/design/login/utils/DesignerLoginUtils.java +++ b/designer-base/src/main/java/com/fr/design/login/utils/DesignerLoginUtils.java @@ -8,6 +8,7 @@ import com.fr.general.log.MessageFormatter; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.third.org.bouncycastle.util.encoders.Hex; +import java.awt.Window; import java.security.SecureRandom; import java.util.HashMap; import java.util.Map; @@ -32,14 +33,15 @@ public class DesignerLoginUtils { return map4Tpl; } - public static void showPluginRemindOnFirstLaunch() { + public static void showPluginRemindOnFirstLaunch(Window parent) { DesignerEnvManager manager = DesignerEnvManager.getEnvManager(); int uid = manager.getDesignerLoginUid(); if (uid > 0) { boolean pluginRemindOnFirstLaunch = manager.isPluginRemindOnFirstLaunch(); if (pluginRemindOnFirstLaunch) { DesignerToastMsgUtil.toastWarning( - com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Plugin_Tip") + com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Plugin_Tip"), + parent ); manager.setPluginRemindOnFirstLaunch(false); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toast/DesignerToastMsgUtil.java b/designer-base/src/main/java/com/fr/design/mainframe/toast/DesignerToastMsgUtil.java index e77cf8b86..4e69c34c5 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toast/DesignerToastMsgUtil.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toast/DesignerToastMsgUtil.java @@ -6,6 +6,9 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.stable.Constants; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Window; import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JEditorPane; @@ -30,12 +33,15 @@ public class DesignerToastMsgUtil { public static void toastPrompt(JPanel contendPane) { - toastPane(PROMPT_ICON, contendPane); + toastPane(PROMPT_ICON, contendPane, DesignerContext.getDesignerFrame()); } public static void toastWarning(JPanel contendPane) { - toastPane(WARNING_ICON, contendPane); + toastPane(WARNING_ICON, contendPane, DesignerContext.getDesignerFrame()); + } + public static void toastWarning(JPanel contendPane, Window parent) { + toastPane(WARNING_ICON, contendPane, parent); } public static void toastPrompt(String promptInfo) { @@ -46,6 +52,10 @@ public class DesignerToastMsgUtil { toastWarning(toastPane(warningInfo)); } + public static void toastWarning(String warningInfo, Window parent) { + toastWarning(toastPane(warningInfo), parent); + } + private static JPanel toastPane(String text) { UILabel promptLabel = new UILabel("" + text + ""); JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); @@ -58,7 +68,7 @@ public class DesignerToastMsgUtil { return jPanel; } - private static void toastPane(Icon icon, JPanel contendPane) { + private static void toastPane(Icon icon, JPanel contendPane, Window parent) { JPanel pane = FRGUIPaneFactory.createBorderLayout_S_Pane(); UILabel uiLabel = new UILabel(icon); uiLabel.setVerticalAlignment(SwingConstants.TOP); @@ -67,7 +77,12 @@ public class DesignerToastMsgUtil { pane.add(contendPane, BorderLayout.CENTER); pane.setBorder(BorderFactory.createEmptyBorder(8, 15, 8, 15)); contendPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); - ToastMsgDialog dialog = new ToastMsgDialog(DesignerContext.getDesignerFrame(), pane); + ToastMsgDialog dialog; + if (parent instanceof Dialog) { + dialog = new ToastMsgDialog((Dialog) parent, pane); + } else { + dialog = new ToastMsgDialog((Frame) parent, pane); + } dialog.setVisible(true); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toast/ToastMsgDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/toast/ToastMsgDialog.java index 8fee83378..00f4f95ea 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toast/ToastMsgDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toast/ToastMsgDialog.java @@ -5,6 +5,7 @@ import com.fr.design.dialog.UIDialog; import com.fr.design.mainframe.DesignerContext; import com.fr.module.ModuleContext; +import java.awt.Dialog; import javax.swing.JPanel; import java.awt.Dimension; import java.awt.Frame; @@ -26,14 +27,23 @@ public class ToastMsgDialog extends UIDialog { public ToastMsgDialog(Frame parent, JPanel panel) { super(parent); + init(panel); + } + + public ToastMsgDialog(Dialog parent, JPanel panel) { + super(parent); + init(panel); + } + + private void init(JPanel panel) { setFocusable(false); setAutoRequestFocus(false); setUndecorated(true); contentPane = panel; - initComponent(parent); + initComponent(); } - private void initComponent(Frame parent) { + private void initComponent() { this.getContentPane().setLayout(null); this.getContentPane().add(contentPane); Dimension dimension = calculatePreferSize(); @@ -42,7 +52,7 @@ public class ToastMsgDialog extends UIDialog { contentPane.setSize(dimension); setLocationRelativeTo(DesignerContext.getDesignerFrame().getContentFrame()); int positionY = DesignerContext.getDesignerFrame().getContentFrame().getLocationOnScreen().y + 10; - setLocation((parent.getWidth() - dimension.width) / 2, positionY); + setLocation((DesignerContext.getDesignerFrame().getWidth() - dimension.width) / 2, positionY); addMouseEvent(contentPane); } diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java index 74bbcb73f..2ea539faf 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java @@ -98,7 +98,7 @@ public class UpmFinder { dialog = new UpmShowDialog(DesignerContext.getDesignerFrame(), upmPane); } dialog.setVisible(true); - DesignerLoginUtils.showPluginRemindOnFirstLaunch(); + DesignerLoginUtils.showPluginRemindOnFirstLaunch(dialog); } }