mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-131272 check if user edits something before close a dialog
This commit is contained in:
@@ -37,10 +37,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.openapi.wm.IdeGlassPaneUtil;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.UIBundle;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.JBOptionButton;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.util.Alarm;
|
||||
@@ -1657,6 +1654,20 @@ public abstract class DialogWrapper {
|
||||
}
|
||||
final StackingPopupDispatcher popupDispatcher = StackingPopupDispatcher.getInstance();
|
||||
if (popupDispatcher != null && !popupDispatcher.isPopupFocused()) {
|
||||
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
|
||||
|
||||
JTree tree = UIUtil.getParentOfType(JTree.class, focusOwner);
|
||||
JTable table = UIUtil.getParentOfType(JTable.class, focusOwner);
|
||||
|
||||
if (tree != null && tree.isEditing()) {
|
||||
tree.cancelEditing();
|
||||
return;
|
||||
}
|
||||
if (table != null && table.isEditing()) {
|
||||
TableUtil.stopEditing(table);
|
||||
return;
|
||||
}
|
||||
|
||||
doCancelAction(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,15 +505,15 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
|
||||
}
|
||||
|
||||
if (StackingPopupDispatcher.getInstance().isPopupFocused()) return;
|
||||
|
||||
if (focusOwner instanceof JTree) {
|
||||
JTree tree = (JTree)focusOwner;
|
||||
JTree tree = UIUtil.getParentOfType(JTree.class, focusOwner);
|
||||
JTable table = UIUtil.getParentOfType(JTable.class, focusOwner);
|
||||
|
||||
if (tree != null) {
|
||||
if (!tree.isEditing()) {
|
||||
e.getPresentation().setEnabled(true);
|
||||
}
|
||||
}
|
||||
else if (focusOwner instanceof JTable) {
|
||||
JTable table = (JTable)focusOwner;
|
||||
else if (table != null) {
|
||||
if (!table.isEditing()) {
|
||||
e.getPresentation().setEnabled(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user