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 10e10ecdbb..2541d04b43 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,6 +2,7 @@ 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; @@ -119,7 +120,7 @@ public class NotificationCenterDialog extends JDialog { if (winSize.width > screenSize.width) { winSize.width = screenSize.width; } - //这里设置位置:水平居中,竖直偏上 - win.setLocation(screenSize.width - winSize.width - 90, 50); + win.setLocation((DesignerContext.getDesignerFrame().getWidth() - winSize.width - 100 + DesignerContext.getDesignerFrame().getX()), + DesignerContext.getDesignerFrame().getY() + winSize.height); } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index 4601c268a6..1c45fc2b64 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java @@ -13,6 +13,7 @@ import com.fr.design.designer.creator.operate.XCreatorBaseOperate; import com.fr.design.designer.creator.operate.DefaultXCreatorBaseOperate; import com.fr.design.designer.treeview.DefaultXCreatorTreeCellRender; import com.fr.design.designer.treeview.XCreatorTreeCellRender; +import com.fr.design.designer.ui.PopupDialogContext; import com.fr.design.designer.ui.SelectedPopupDialog; import com.fr.design.fun.ShareWidgetUIProcessor; import com.fr.design.fun.WidgetPropertyUIProvider; @@ -796,6 +797,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo if (popup == null) { popup = new SelectedPopupDialog(this, designer); } + PopupDialogContext.checkSelectedPop(this); JFrame frame = LogMessageBar.getInstance().getLogFrame(); if (frame!= null && frame.isActive()) { return; @@ -894,6 +896,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo if (popup != null) { popup.setVisible(false); } + PopupDialogContext.checkSelectedPop(this); } public void processPopup(boolean canVisible) { diff --git a/designer-form/src/main/java/com/fr/design/designer/ui/PopupDialogContext.java b/designer-form/src/main/java/com/fr/design/designer/ui/PopupDialogContext.java new file mode 100644 index 0000000000..06fb2cb765 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/ui/PopupDialogContext.java @@ -0,0 +1,47 @@ +package com.fr.design.designer.ui; + +import com.fr.design.designer.creator.XCreator; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + + +/** + * 把弹窗统一管理起来 防止出现异常情况下游离的弹窗 + * + * @author hades + * @version 10.0 + * Created by hades on 2021/11/02 + */ +public class PopupDialogContext { + + private static List dialogs = new ArrayList<>(); + + public static void add(SelectedPopupDialog selectedPopupDialog) { + if (dialogs.contains(selectedPopupDialog)) { + return; + } + dialogs.add(selectedPopupDialog); + } + + public static void remove(SelectedPopupDialog selectedPopupDialog) { + dialogs.remove(selectedPopupDialog); + } + + public static void checkSelectedPop(XCreator creator) { + Iterator iterator = dialogs.iterator(); + List removedDialog = new ArrayList<>(); + while (iterator.hasNext()) { + SelectedPopupDialog dialog = iterator.next(); + if (dialog.isVisible() && creator != dialog.getCreator()) { + iterator.remove(); + removedDialog.add(dialog); + } + } + for (SelectedPopupDialog dialog : removedDialog) { + dialog.setVisible(false); + } + } + +} diff --git a/designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java b/designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java index 44978ad667..22f0d3760d 100644 --- a/designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java +++ b/designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java @@ -25,11 +25,14 @@ public class SelectedPopupDialog extends JDialog { private boolean canVisible = true; + private final XCreator creator; + public SelectedPopupDialog(XCreator creator, FormDesigner designer) { super(OperatingSystem.isMacos() ? new JFrame() : DesignerContext.getDesignerFrame()); this.setUndecorated(true); this.setModal(false); this.setFocusableWindowState(false); + this.creator = creator; controlPanel = new PopupControlPanel(creator, designer); this.getContentPane().add(controlPanel); this.setSize(controlPanel.getDefaultDimension()); @@ -44,6 +47,16 @@ public class SelectedPopupDialog extends JDialog { return controlPanel.hasVisibleButtons(); } + @Override + public void setVisible(boolean visible) { + super.setVisible(visible); + if (visible) { + PopupDialogContext.add(this); + } else { + PopupDialogContext.remove(this); + } + } + public void setRelativeBounds(Rectangle rectangle) { this.controlPanel.setRelativeBounds(rectangle); } @@ -55,4 +68,8 @@ public class SelectedPopupDialog extends JDialog { public void setCanVisible(boolean canVisible) { this.canVisible = canVisible; } + + public XCreator getCreator() { + return this.creator; + } }