IDEA-161368 Ctrl+Shift+Up/Down in Search Everywhere changes height of the search box

This commit is contained in:
Sergey Malenkov
2016-09-16 21:29:44 +03:00
parent cd15fa7b9f
commit 83a7cb91fd
3 changed files with 33 additions and 32 deletions
@@ -927,12 +927,6 @@ public abstract class ChooseByNameBase {
}
});
myTextPopup.show(layeredPane);
if (myTextPopup instanceof AbstractPopup) {
Window window = ((AbstractPopup)myTextPopup).getPopupWindow();
if (window instanceof JDialog) {
((JDialog)window).getRootPane().putClientProperty(WindowAction.NO_WINDOW_ACTIONS, Boolean.TRUE);
}
}
}
private JLayeredPane getLayeredPane() {
@@ -18,7 +18,6 @@ package com.intellij.ide.actions;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.util.registry.Registry;
@@ -29,6 +28,27 @@ import java.awt.*;
public abstract class WindowAction extends AnAction implements DumbAware {
public static void setEnabledFor(Window window, boolean enabled) {
JRootPane root = getRootPane(window);
if (root != null) root.putClientProperty(NO_WINDOW_ACTIONS, !enabled);
}
private static boolean isEnabledFor(Window window) {
if (window == null || window instanceof IdeFrame) return false;
JRootPane root = getRootPane(window);
if (root == null) return true;
Object property = root.getClientProperty(NO_WINDOW_ACTIONS);
return property == null || !property.toString().equals("true");
}
private static JRootPane getRootPane(Window window) {
if (window instanceof RootPaneContainer) {
RootPaneContainer container = (RootPaneContainer)window;
return container.getRootPane();
}
return null;
}
public static final String NO_WINDOW_ACTIONS = "no.window.actions";
protected Window myWindow;
@@ -39,31 +59,15 @@ public abstract class WindowAction extends AnAction implements DumbAware {
}
@Override
public final void update(AnActionEvent e) {
Window wnd = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
e.getPresentation().setEnabled(wnd != null && !(wnd instanceof IdeFrame));
Object noActions = null;
if (wnd instanceof JDialog) {
noActions = ((JDialog)wnd).getRootPane().getClientProperty(NO_WINDOW_ACTIONS);
} else if (wnd instanceof JFrame) {
noActions = ((JFrame)wnd).getRootPane().getClientProperty(NO_WINDOW_ACTIONS);
}
if (noActions != null && "true".equalsIgnoreCase(noActions.toString())) {
e.getPresentation().setEnabled(false);
}
final Editor editor = e.getData(CommonDataKeys.EDITOR);
if (editor != null && editor.getContentComponent().hasFocus()) {
e.getPresentation().setEnabled(false);
}
if (e.getPresentation().isEnabled()) {
myWindow = wnd;
} else {
myWindow = null;
public final void update(AnActionEvent event) {
Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
boolean enabled = isEnabledFor(window);
if (enabled) {
Editor editor = event.getData(CommonDataKeys.EDITOR);
enabled = editor == null || !editor.getContentComponent().hasFocus();
}
event.getPresentation().setEnabled(enabled);
myWindow = enabled ? window : null;
}
public abstract static class BaseSizeAction extends WindowAction {
@@ -85,7 +89,7 @@ public abstract class WindowAction extends AnAction implements DumbAware {
int baseValue = myHorizontal ? mySizeHelper.getPreferredSize().width : mySizeHelper.getPreferredSize().height;
int inc = baseValue *
(myHorizontal ? Registry.intValue("ide.windowSystem.hScrollChars") : Registry.intValue("ide.windowSystem.vScrollChars"));
Registry.intValue(myHorizontal ? "ide.windowSystem.hScrollChars" : "ide.windowSystem.vScrollChars");
if (!myPositive) {
inc = -inc;
}
@@ -21,6 +21,7 @@ import com.intellij.ide.DataManager;
import com.intellij.ide.IdeEventQueue;
import com.intellij.ide.UiActivity;
import com.intellij.ide.UiActivityMonitor;
import com.intellij.ide.actions.WindowAction;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
@@ -915,6 +916,8 @@ public class AbstractPopup implements JBPopup {
myPopup.setRequestFocus(myRequestFocus);
myPopup.show();
WindowAction.setEnabledFor(myPopup.getWindow(), myResizable);
final Window window = getContentWindow(myContent);
myWindow = window;