IDEA-187873 Use Custom popup in Win10 and Mac lafs too

This commit is contained in:
Kirill Kirichenko
2018-03-16 18:13:56 +03:00
parent a9416b0e37
commit 037d3764f5
3 changed files with 18 additions and 18 deletions
@@ -78,7 +78,7 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border, ErrorB
@Override
protected ComboPopup createPopup() {
return (comboBox instanceof ComboBoxWithWidePopup) ? new WidePopup(comboBox) : super.createPopup();
return new CustomComboPopup(comboBox);
}
protected PropertyChangeListener createPropertyListener() {
@@ -505,26 +505,27 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border, ErrorB
}
// Wide popup that uses preferred size
private static class WidePopup extends BasicComboPopup {
public WidePopup(JComboBox combo) {
protected static class CustomComboPopup extends BasicComboPopup {
public CustomComboPopup(JComboBox combo) {
super(combo);
}
@Override
public void show(Component invoker, int x, int y) {
Dimension popupSize = comboBox.getSize();
Dimension prefSize = comboBox.getPreferredSize();
Insets insets = getInsets();
if (comboBox instanceof ComboBoxWithWidePopup) {
Dimension popupSize = comboBox.getSize();
Dimension prefSize = comboBox.getPreferredSize();
Insets insets = getInsets();
popupSize.width = Math.max(popupSize.width, prefSize.width);
popupSize.setSize(popupSize.width - (insets.right + insets.left), getPopupHeightForRowCount(comboBox.getMaximumRowCount()));
popupSize.width = Math.max(popupSize.width, prefSize.width);
popupSize.setSize(popupSize.width - (insets.right + insets.left), getPopupHeightForRowCount(comboBox.getMaximumRowCount()));
scroller.setMaximumSize(popupSize);
scroller.setPreferredSize(popupSize);
scroller.setMinimumSize(popupSize);
list.revalidate();
scroller.setMaximumSize(popupSize);
scroller.setPreferredSize(popupSize);
scroller.setMinimumSize(popupSize);
list.revalidate();
}
super.show(invoker, x, y);
}
}
@@ -31,7 +31,6 @@ import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicArrowButton;
import javax.swing.plaf.basic.BasicComboBoxEditor;
import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.plaf.basic.ComboPopup;
import java.awt.*;
import java.awt.event.FocusAdapter;
@@ -277,7 +276,7 @@ public class MacIntelliJComboBoxUI extends DarculaComboBoxUI {
@Override
protected ComboPopup createPopup() {
return new BasicComboPopup(comboBox) {
return new CustomComboPopup(comboBox) {
@Override
protected void configurePopup() {
super.configurePopup();
@@ -34,7 +34,6 @@ import javax.swing.event.PopupMenuEvent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicArrowButton;
import javax.swing.plaf.basic.BasicComboBoxEditor;
import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.plaf.basic.ComboPopup;
import javax.swing.text.JTextComponent;
import java.awt.*;
@@ -517,8 +516,9 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
}
@Override protected ComboPopup createPopup() {
return new BasicComboPopup(comboBox) {
@Override
protected ComboPopup createPopup() {
return new CustomComboPopup(comboBox) {
@Override
protected void configurePopup() {
super.configurePopup();