@ -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,16 +240,42 @@ public abstract class UIControlPane extends JControlPane {
}
private void hideDialog ( ) {
if ( needToHidePopupEditDialog ( ) ) {
saveSettings ( ) ;
setVisible ( false ) ;
PopupDialogSaveAction saveAction = OSSupportCenter . getAction ( PopupDialogSaveAction . class ) ;
saveAction . unregister ( ) ;
}
}
private void initListener ( ) {
addWindowFocusListener ( new WindowAdapter ( ) {
@Override
public void windowLostFocus ( WindowEvent e ) {
//在Linux上拉回焦点,不然导致一些面板关不掉
if ( OperatingSystem . isLinux ( ) ) {
requestFocus ( ) ;
}
hideDialog ( ) ;
}
} ) ;
}
}
/ * *
* 是否需要隐藏popupEditDialog
* /
protected boolean needToHidePopupEditDialog ( ) {
// 检查是否有子弹窗,如果有,则不隐藏
for ( Window window : getOwnedWindows ( ) ) {
for ( Window window : popupEditDialog . getOwnedWindows ( ) ) {
if ( window . isVisible ( ) ) {
return ;
return false ;
}
}
// 如果有可见模态对话框,则不隐藏
for ( Window window : DesignerContext . getDesignerFrame ( ) . getOwnedWindows ( ) ) {
if ( window instanceof JDialog & & window . isVisible ( ) & & ( ( JDialog ) window ) . isModal ( ) ) {
return ;
return false ;
}
}
@ -260,7 +285,7 @@ public abstract class UIControlPane extends JControlPane {
for ( Window window : sharedOwnerFrame . getOwnedWindows ( ) ) {
if ( window instanceof JDialog & & window . isVisible ( ) & & ( ( JDialog ) window ) . isModal ( ) ) {
// 如果有可见模态对话框,则不隐藏
return ;
return false ;
}
}
} catch ( Exception ignore ) {
@ -273,33 +298,16 @@ public abstract class UIControlPane extends JControlPane {
checkValid ( ) ;
} catch ( Exception exp ) {
// 存在非法输入 拒绝隐藏
this . setAlwaysOnTop ( true ) ;
popupEditDialog . setAlwaysOnTop ( true ) ;
FineJOptionPane . showMessageDialog ( this , exp . getMessage ( ) ) ;
this . requestFocus ( ) ;
return ;
popupEditDialog . requestFocus ( ) ;
return false ;
}
if ( JavaFxNativeFileChooser . isShowDialogState ( ) ) {
JavaFxNativeFileChooser . setShowDialogState ( false ) ;
return ;
}
saveSettings ( ) ;
setVisible ( false ) ;
PopupDialogSaveAction saveAction = OSSupportCenter . getAction ( PopupDialogSaveAction . class ) ;
saveAction . unregister ( ) ;
}
private void initListener ( ) {
addWindowFocusListener ( new WindowAdapter ( ) {
@Override
public void windowLostFocus ( WindowEvent e ) {
//在Linux上拉回焦点,不然导致一些面板关不掉
if ( OperatingSystem . isLinux ( ) ) {
requestFocus ( ) ;
}
hideDialog ( ) ;
}
} ) ;
return false ;
}
return true ;
}
// 移动弹出编辑面板的工具条