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 1c05b23a5c..67e4ed905f 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -51,6 +51,7 @@ import com.fr.workspace.engine.rpc.WorkspaceProxyPool; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; +import java.awt.Window; import java.lang.reflect.Method; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -411,8 +412,12 @@ public class EnvChangeEntrance { } public void chooseEnv(final String envName) { + chooseEnv(envName, SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); + } + + public void chooseEnv(final String envName, Window window) { final EnvListPane envListPane = new EnvListPane(); - final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); + final BasicDialog envListDialog = envListPane.showWindow(window); envListPane.populateEnvManager(envName); envListDialog.addDialogActionListener(new DialogActionAdapter() { @@ -430,7 +435,6 @@ public class EnvChangeEntrance { // todo 断开了但是没选择新的环境,那么尝试重连旧环境,等接口 } }); - envListDialog.setAlwaysOnTop(true); envListDialog.setVisible(true); } diff --git a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java index 43c3f43ad8..382732dd97 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -1774,4 +1774,12 @@ public class FILEChooserPane extends BasicPane { } } } + + public boolean isDialogVisible() { + return dialog != null && dialog.isVisible(); + } + + public UIDialog getDialog() { + return dialog; + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index 48b6eec563..19754bfc4a 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -12,6 +12,7 @@ import com.fr.design.ui.util.UIUtil; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener; +import com.fr.file.FILEChooserPane; import com.fr.log.FineLoggerFactory; import com.fr.report.RemoteDesignConstants; import com.fr.serialization.SerializerHelper; @@ -27,6 +28,7 @@ import io.socket.client.IO; import io.socket.client.Socket; import io.socket.emitter.Emitter; +import java.awt.Window; import java.util.Arrays; import javax.swing.*; import java.io.IOException; @@ -175,17 +177,18 @@ public class DesignerSocketIO { UIUtil.invokeAndWaitIfNeeded(new Runnable() { @Override public void run() { - JDialog jDialog = new JDialog(); - jDialog.setAlwaysOnTop(true); - jDialog.setVisible(false); + // 因为有可能在文件保存界面的时候,弹出连接失败弹窗,为了避免二级弹窗问题,这边对父窗口做个判断 + boolean isFileChooserPaneExist = FILEChooserPane.getInstance().isDialogVisible(); + Window window = isFileChooserPaneExist ? FILEChooserPane.getInstance().getDialog() : DesignerContext.getDesignerFrame(); FineJOptionPane.showMessageDialog( - jDialog, + window, Toolkit.i18nText("Fine-Design_Basic_Remote_Disconnected"), UIManager.getString("OptionPane.messageDialogTitle"), JOptionPane.ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); - jDialog.dispose(); - EnvChangeEntrance.getInstance().chooseEnv(); + // 紧接着弹出的选择工作环境的窗口也判断一下父窗口,否则会被文件保存界面覆盖掉 + Window window1 = isFileChooserPaneExist ? FILEChooserPane.getInstance().getDialog() : SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()); + EnvChangeEntrance.getInstance().chooseEnv(DesignerEnvManager.getEnvManager().getCurEnvName(), window1); } }); } catch (Exception e) {