From c2e13969c4e1a99d22bb006b26da84693a2092df Mon Sep 17 00:00:00 2001 From: Alexey Pegov Date: Wed, 1 Jun 2011 18:13:09 +0400 Subject: [PATCH] allow wizard lists to be more than 600px height (3/4 current screen height max) --- .../src/com/intellij/ui/popup/WizardPopup.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ui/popup/WizardPopup.java b/platform/platform-impl/src/com/intellij/ui/popup/WizardPopup.java index 49e48076ba62..70e52083bdd8 100644 --- a/platform/platform-impl/src/com/intellij/ui/popup/WizardPopup.java +++ b/platform/platform-impl/src/com/intellij/ui/popup/WizardPopup.java @@ -286,12 +286,23 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene } public Dimension getPreferredSize() { - return computeNotBiggerDimension(super.getPreferredSize()); + final Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); + Point p = null; + if (focusOwner != null && focusOwner.isVisible()) { + p = focusOwner.getLocationOnScreen(); + } + + return computeNotBiggerDimension(super.getPreferredSize().getSize(), p); } - private static Dimension computeNotBiggerDimension(Dimension ofContent) { - int resultWidth = ofContent.width > MAX_SIZE.width ? MAX_SIZE.width : ofContent.width; + private static Dimension computeNotBiggerDimension(Dimension ofContent, final Point locationOnScreen) { int resultHeight = ofContent.height > MAX_SIZE.height + 50 ? MAX_SIZE.height : ofContent.height; + if (locationOnScreen != null) { + final Rectangle r = ScreenUtil.getScreenRectangle(locationOnScreen); + resultHeight = ofContent.height > r.height - (r.height / 4) ? r.height - (r.height / 4) : ofContent.height; + } + + int resultWidth = ofContent.width > MAX_SIZE.width ? MAX_SIZE.width : ofContent.width; if (ofContent.height > MAX_SIZE.height) { resultWidth += ScrollPaneFactory.createScrollPane().getVerticalScrollBar().getPreferredSize().getWidth();