From 8c2daa8802b5e4fd9c7c5f8c9a73f195123cd0fe Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Tue, 28 Mar 2017 00:52:44 +0300 Subject: [PATCH] IDEA-160900 Settings dialog doesn't fit the screen when using low screen resolution --- .../com/intellij/openapi/options/newEditor/Banner.java | 2 ++ .../openapi/options/newEditor/ConfigurableEditor.java | 5 ++++- .../openapi/ui/impl/DialogWrapperPeerImpl.java | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/Banner.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/Banner.java index 19d5820c6a37..558028a7cf17 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/Banner.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/Banner.java @@ -28,6 +28,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dimension; /** * @author Sergey.Malenkov @@ -39,6 +40,7 @@ final class Banner extends JPanel { Banner(Action action) { super(new BorderLayout(10, 0)); myLeftPanel.setLayout(new HorizontalLayout(5)); + myProjectIcon.setMinimumSize(new Dimension(0, 0)); myProjectIcon.setIcon(AllIcons.General.ProjectConfigurableBanner); myProjectIcon.setForeground(JBColor.GRAY); myProjectIcon.setVisible(false); diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/ConfigurableEditor.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/ConfigurableEditor.java index 40155a620d3b..17766f5e98ef 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/ConfigurableEditor.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/ConfigurableEditor.java @@ -51,7 +51,10 @@ import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.util.ResourceBundle; +import static com.intellij.ui.ScrollPaneFactory.createScrollPane; import static java.awt.Toolkit.getDefaultToolkit; +import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; +import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; import static javax.swing.SwingUtilities.isDescendingFrom; /** @@ -296,7 +299,7 @@ class ConfigurableEditor extends AbstractEditor implements AnActionListener, AWT } } } - return content; + return createScrollPane(content, VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER); } private static String getString(Configurable configurable, String key) { diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java b/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java index 305708c5d65d..2a4ba9550864 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java @@ -1041,6 +1041,16 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra else { myLastMinimumSize = new Dimension(size); JBInsets.addTo(size, window.getInsets()); + Rectangle screen = ScreenUtil.getScreenRectangle(window); + if (size.width > screen.width || size.height > screen.height) { + Application application = ApplicationManager.getApplication(); + if (application != null && application.isInternal()) { + LOG.warn("minimum size " + size.width + "x" + size.height + + " is bigger than screen " + screen.width + "x" + screen.height); + } + if (size.width > screen.width) size.width = screen.width; + if (size.height > screen.height) size.height = screen.height; + } } window.setMinimumSize(size); }