Browse Source

REPORT-44666 多屏情况下 部分弹窗显示在另一块屏幕

feature/big-screen
Hades 4 years ago
parent
commit
a17002e48f
  1. 2
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 2
      designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java
  3. 2
      designer-base/src/main/java/com/fr/design/gui/controlpane/UIListControlPane.java
  4. 3
      designer-base/src/main/java/com/fr/design/style/background/image/ExpandFileChooser.java
  5. 26
      designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java

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

@ -437,7 +437,7 @@ public class EnvChangeEntrance {
public void chooseEnv(final String envName) { public void chooseEnv(final String envName) {
final EnvListPane envListPane = new EnvListPane(); final EnvListPane envListPane = new EnvListPane();
final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); final BasicDialog envListDialog = envListPane.showWindow(DesignerContext.getDesignerFrame());
envListPane.populateEnvManager(envName); envListPane.populateEnvManager(envName);
envListDialog.addDialogActionListener(new DialogActionAdapter() { envListDialog.addDialogActionListener(new DialogActionAdapter() {

2
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.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.ui.util.UIUtil; import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.function.TIME; import com.fr.function.TIME;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -168,6 +169,7 @@ public class PreviewTablePane extends BasicPane {
this.add(new JScrollPane(preveiwTable), BorderLayout.CENTER); this.add(new JScrollPane(preveiwTable), BorderLayout.CENTER);
if (this.dialog == null) { if (this.dialog == null) {
this.dialog = this.showWindow(new JFrame()); 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) { progressBar = new AutoProgressBar(this, Toolkit.i18nText("Fine-Design_Basic_Loading_Data"), "", 0, 100) {
public void doMonitorCanceled() { public void doMonitorCanceled() {

2
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(); 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) { if (resultPos.x > maxX) {
resultPos.x = maxX; resultPos.x = maxX;
} }

3
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.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -19,6 +20,7 @@ import java.awt.Container;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Insets; import java.awt.Insets;
import java.awt.LayoutManager; import java.awt.LayoutManager;
import java.awt.Rectangle;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
/** /**
@ -85,6 +87,7 @@ public class ExpandFileChooser extends JFileChooser {
@Override @Override
public int showDialog(Component parent, String approveButtonText) { public int showDialog(Component parent, String approveButtonText) {
dialog.setModal(true); dialog.setModal(true);
GUICoreUtils.centerWindow(parent, dialog);
dialog.setVisible(true); dialog.setVisible(true);
return retVal; return retVal;
} }

26
designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java

@ -292,6 +292,24 @@ public final class GUICoreUtils {
return button; 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()在有多个显示器也只能获取到主屏的大小 // Toolkit.getDefaultToolkit().getScreenSize()在有多个显示器也只能获取到主屏的大小
// getGraphicsConfiguration().getBounds()能获取多个屏时 设计器主体界面所在屏的大小和对应的坐标 // getGraphicsConfiguration().getBounds()能获取多个屏时 设计器主体界面所在屏的大小和对应的坐标
Rectangle rectangle = win.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 screenSize = rectangle.getSize();
Dimension winSize = win.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); win.setLocation(rectangle.x + (screenSize.width - winSize.width) / 2, rectangle.y + (screenSize.height - winSize.height) / 2 - WINDOW_GAP);
} }
/** /**
* Gets window/frame to screen center. * Gets window/frame to screen center.
* @param owerWin 父窗口 * @param owerWin 父窗口

Loading…
Cancel
Save