|
|
|
@ -31,7 +31,6 @@ import java.awt.Color;
|
|
|
|
|
import java.awt.Cursor; |
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
import java.awt.FlowLayout; |
|
|
|
|
import java.awt.Font; |
|
|
|
|
import java.awt.Frame; |
|
|
|
|
import java.awt.Graphics; |
|
|
|
|
import java.awt.Graphics2D; |
|
|
|
@ -241,51 +240,12 @@ public abstract class UIControlPane extends JControlPane {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void hideDialog() { |
|
|
|
|
// 检查是否有子弹窗,如果有,则不隐藏
|
|
|
|
|
for (Window window : getOwnedWindows()) { |
|
|
|
|
if (window.isVisible()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 如果有可见模态对话框,则不隐藏
|
|
|
|
|
for (Window window : DesignerContext.getDesignerFrame().getOwnedWindows()) { |
|
|
|
|
if (window instanceof JDialog && window.isVisible() && ((JDialog) window).isModal()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
//没有指定owner的弹出框用的是SwingUtilities.getSharedOwnerFrame()
|
|
|
|
|
Frame sharedOwnerFrame = Reflect.on(SwingUtilities.class).call("getSharedOwnerFrame").get(); |
|
|
|
|
for (Window window : sharedOwnerFrame.getOwnedWindows()) { |
|
|
|
|
if (window instanceof JDialog && window.isVisible() && ((JDialog) window).isModal()) { |
|
|
|
|
// 如果有可见模态对话框,则不隐藏
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Exception ignore) { |
|
|
|
|
//do nothing
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 要隐藏 先检查有没有非法输入
|
|
|
|
|
// 非法输入检查放在最后,因为可能出现面板弹出新弹框而失去焦点的情况,比如 输入公式时,弹出公式编辑对话框
|
|
|
|
|
try { |
|
|
|
|
checkValid(); |
|
|
|
|
} catch (Exception exp) { |
|
|
|
|
// 存在非法输入 拒绝隐藏
|
|
|
|
|
this.setAlwaysOnTop(true); |
|
|
|
|
FineJOptionPane.showMessageDialog(this, exp.getMessage()); |
|
|
|
|
this.requestFocus(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (JavaFxNativeFileChooser.isShowDialogState()) { |
|
|
|
|
JavaFxNativeFileChooser.setShowDialogState(false); |
|
|
|
|
return; |
|
|
|
|
if (needToHidePopupEditDialog()) { |
|
|
|
|
saveSettings(); |
|
|
|
|
setVisible(false); |
|
|
|
|
PopupDialogSaveAction saveAction = OSSupportCenter.getAction(PopupDialogSaveAction.class); |
|
|
|
|
saveAction.unregister(); |
|
|
|
|
} |
|
|
|
|
saveSettings(); |
|
|
|
|
setVisible(false); |
|
|
|
|
PopupDialogSaveAction saveAction = OSSupportCenter.getAction(PopupDialogSaveAction.class); |
|
|
|
|
saveAction.unregister(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initListener() { |
|
|
|
@ -302,6 +262,54 @@ public abstract class UIControlPane extends JControlPane {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 是否需要隐藏popupEditDialog |
|
|
|
|
*/ |
|
|
|
|
protected boolean needToHidePopupEditDialog() { |
|
|
|
|
// 检查是否有子弹窗,如果有,则不隐藏
|
|
|
|
|
for (Window window : popupEditDialog.getOwnedWindows()) { |
|
|
|
|
if (window.isVisible()) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 如果有可见模态对话框,则不隐藏
|
|
|
|
|
for (Window window : DesignerContext.getDesignerFrame().getOwnedWindows()) { |
|
|
|
|
if (window instanceof JDialog && window.isVisible() && ((JDialog) window).isModal()) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
//没有指定owner的弹出框用的是SwingUtilities.getSharedOwnerFrame()
|
|
|
|
|
Frame sharedOwnerFrame = Reflect.on(SwingUtilities.class).call("getSharedOwnerFrame").get(); |
|
|
|
|
for (Window window : sharedOwnerFrame.getOwnedWindows()) { |
|
|
|
|
if (window instanceof JDialog && window.isVisible() && ((JDialog) window).isModal()) { |
|
|
|
|
// 如果有可见模态对话框,则不隐藏
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Exception ignore) { |
|
|
|
|
//do nothing
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 要隐藏 先检查有没有非法输入
|
|
|
|
|
// 非法输入检查放在最后,因为可能出现面板弹出新弹框而失去焦点的情况,比如 输入公式时,弹出公式编辑对话框
|
|
|
|
|
try { |
|
|
|
|
checkValid(); |
|
|
|
|
} catch (Exception exp) { |
|
|
|
|
// 存在非法输入 拒绝隐藏
|
|
|
|
|
popupEditDialog.setAlwaysOnTop(true); |
|
|
|
|
FineJOptionPane.showMessageDialog(this, exp.getMessage()); |
|
|
|
|
popupEditDialog.requestFocus(); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (JavaFxNativeFileChooser.isShowDialogState()) { |
|
|
|
|
JavaFxNativeFileChooser.setShowDialogState(false); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 移动弹出编辑面板的工具条
|
|
|
|
|
private class PopupToolPane extends JPanel { |
|
|
|
|
private JDialog parentDialog; // 如果不在对话框中,值为null
|
|
|
|
|