IDEA-160900 Settings dialog doesn't fit the screen when using low screen resolution

This commit is contained in:
Sergey Malenkov
2017-03-28 01:39:55 +03:00
parent 84be24a53c
commit 8c2daa8802
3 changed files with 16 additions and 1 deletions
@@ -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);
@@ -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) {
@@ -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);
}