From f6ef56ff9da4a570b123c15aada2718754020e52 Mon Sep 17 00:00:00 2001 From: Hades Date: Fri, 22 Jan 2021 15:20:22 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-44666=20=E5=A4=9A=E5=B1=8F=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=20=E9=83=A8=E5=88=86=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=9C=A8=E5=8F=A6=E4=B8=80=E5=9D=97=E5=B1=8F?= =?UTF-8?q?=E5=B9=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 2 +- .../datapane/preview/PreviewTablePane.java | 2 ++ .../gui/controlpane/UIListControlPane.java | 2 +- .../background/image/ExpandFileChooser.java | 3 +++ .../com/fr/design/utils/gui/GUICoreUtils.java | 26 +++++++++++++++++++ 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index 2b36bd45f..c8078777d 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -437,7 +437,7 @@ public class EnvChangeEntrance { public void chooseEnv(final String envName) { final EnvListPane envListPane = new EnvListPane(); - final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); + final BasicDialog envListDialog = envListPane.showWindow(DesignerContext.getDesignerFrame()); envListPane.populateEnvManager(envName); envListDialog.addDialogActionListener(new DialogActionAdapter() { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java index d3881bcd1..da87c10f6 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java @@ -26,6 +26,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.ui.util.UIUtil; +import com.fr.design.utils.gui.GUICoreUtils; import com.fr.function.TIME; import com.fr.general.FRFont; import com.fr.log.FineLoggerFactory; @@ -168,6 +169,7 @@ public class PreviewTablePane extends BasicPane { this.add(new JScrollPane(preveiwTable), BorderLayout.CENTER); if (this.dialog == null) { this.dialog = this.showWindow(new JFrame()); + GUICoreUtils.centerWindow(DesignerContext.getDesignerFrame(), this.dialog); } progressBar = new AutoProgressBar(this, Toolkit.i18nText("Fine-Design_Basic_Loading_Data"), "", 0, 100) { public void doMonitorCanceled() { diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListControlPane.java index 100daf511..ec76f5bf7 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListControlPane.java @@ -247,7 +247,7 @@ public abstract class UIListControlPane extends UIControlPane implements ListCon resultPos.x = listPos.x + nameableList.getParent().getWidth(); } // 如果右侧显示不下,可以向左移动 - int maxX = Toolkit.getDefaultToolkit().getScreenSize().width - popupEditDialog.getWidth() - EDIT_RANGE; + int maxX = frame.getLocationOnScreen().x + frame.getWidth() - popupEditDialog.getWidth() - EDIT_RANGE; if (resultPos.x > maxX) { resultPos.x = maxX; } diff --git a/designer-base/src/main/java/com/fr/design/style/background/image/ExpandFileChooser.java b/designer-base/src/main/java/com/fr/design/style/background/image/ExpandFileChooser.java index ca091cf94..ef6371694 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/image/ExpandFileChooser.java +++ b/designer-base/src/main/java/com/fr/design/style/background/image/ExpandFileChooser.java @@ -5,6 +5,7 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.StringUtils; @@ -19,6 +20,7 @@ import java.awt.Container; import java.awt.Dimension; import java.awt.Insets; import java.awt.LayoutManager; +import java.awt.Rectangle; import java.awt.event.ActionListener; /** @@ -85,6 +87,7 @@ public class ExpandFileChooser extends JFileChooser { @Override public int showDialog(Component parent, String approveButtonText) { dialog.setModal(true); + GUICoreUtils.centerWindow(parent, dialog); dialog.setVisible(true); return retVal; } diff --git a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java index e6b276437..d55382c49 100644 --- a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java @@ -292,6 +292,24 @@ public final class GUICoreUtils { return button; } + + /** + * 将独立弹窗设置在中间位置 适应多屏 跟随设计器主界面 + * 可从父界面获取弹窗应该所在的矩形范围 + * + * @param parent 独立弹窗的父窗口 + * @param win 弹窗自身 + */ + public static void centerWindow(Component parent, Window win) { + Rectangle rectangle; + if (parent == null) { + rectangle = DesignerContext.getDesignerFrame().getGraphicsConfiguration().getBounds(); + } else { + rectangle = parent.getGraphicsConfiguration().getBounds(); + } + centerWindow(win, rectangle); + } + /** * 设置一个窗口 * @@ -301,7 +319,14 @@ public final class GUICoreUtils { // Toolkit.getDefaultToolkit().getScreenSize()在有多个显示器也只能获取到主屏的大小 // getGraphicsConfiguration().getBounds()能获取多个屏时 设计器主体界面所在屏的大小和对应的坐标 Rectangle rectangle = win.getGraphicsConfiguration().getBounds(); + centerWindow(win, rectangle); + } + /** + * @param win + * @param rectangle 窗口所在的一个矩形范围 + */ + public static void centerWindow(Window win, Rectangle rectangle) { Dimension screenSize = rectangle.getSize(); Dimension winSize = win.getSize(); @@ -315,6 +340,7 @@ public final class GUICoreUtils { win.setLocation(rectangle.x + (screenSize.width - winSize.width) / 2, rectangle.y + (screenSize.height - winSize.height) / 2 - WINDOW_GAP); } + /** * Gets window/frame to screen center. * @param owerWin 父窗口