diff --git a/platform/platform-api/src/com/intellij/openapi/ui/ComboBox.java b/platform/platform-api/src/com/intellij/openapi/ui/ComboBox.java
index a3d8734e84ff..7a9f7826093e 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/ComboBox.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/ComboBox.java
@@ -32,7 +32,6 @@ import javax.swing.plaf.basic.ComboPopup;
import javax.swing.table.TableCellEditor;
import java.awt.*;
import java.awt.event.*;
-import java.util.List;
/**
* Due to many bugs and "features" in JComboBox implementation we provide
@@ -48,7 +47,7 @@ import java.util.List;
*
* @author Vladimir Kondratyev
*/
-public class ComboBox extends ComboBoxWithWidePopup implements AWTEventListener {
+public class ComboBox extends ComboBoxWithWidePopup implements AWTEventListener {
public static final String TABLE_CELL_EDITOR_PROPERTY = "tableCellEditor";
private int myMinimumAndPreferredWidth;
@@ -60,7 +59,7 @@ public class ComboBox extends ComboBoxWithWidePopup implements AWTEventListener
this(-1);
}
- public ComboBox(final ComboBoxModel model) {
+ public ComboBox(final ComboBoxModel model) {
this(model, -1);
}
@@ -68,11 +67,11 @@ public class ComboBox extends ComboBoxWithWidePopup implements AWTEventListener
* @param width preferred width of the combobox. Value -1 means undefined.
*/
public ComboBox(final int width) {
- this(new DefaultComboBoxModel(), width);
+ this(new DefaultComboBoxModel(), width);
}
- public ComboBox(final ComboBoxModel model, final int width) {
+ public ComboBox(final ComboBoxModel model, final int width) {
super(model);
myMinimumAndPreferredWidth = width;
registerCancelOnEscape();
@@ -163,12 +162,9 @@ public class ComboBox extends ComboBoxWithWidePopup implements AWTEventListener
public void eventDispatched(AWTEvent event) {
if (event.getID() == WindowEvent.WINDOW_OPENED) {
final WindowEvent we = (WindowEvent)event;
- final List popups = JBPopupFactory.getInstance().getChildPopups(this);
- if (popups != null) {
- for (JBPopup each : popups) {
- if (each.getContent() != null && SwingUtilities.isDescendingFrom(each.getContent(), we.getWindow())) {
- super.setPopupVisible(false);
- }
+ for (JBPopup each : JBPopupFactory.getInstance().getChildPopups(this)) {
+ if (each.getContent() != null && SwingUtilities.isDescendingFrom(each.getContent(), we.getWindow())) {
+ super.setPopupVisible(false);
}
}
}
@@ -202,13 +198,13 @@ public class ComboBox extends ComboBoxWithWidePopup implements AWTEventListener
return UIUtil.getComboBoxPopup(this);
}
- public ComboBox(final Object[] items, final int preferredWidth) {
+ public ComboBox(final E[] items, final int preferredWidth) {
super(items);
myMinimumAndPreferredWidth = preferredWidth;
registerCancelOnEscape();
}
- public ComboBox(@NotNull Object[] items) {
+ public ComboBox(@NotNull E[] items) {
this(items, -1);
}
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxWithWidePopup.java b/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxWithWidePopup.java
index f008f33b8c7b..ad8aecbb2946 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxWithWidePopup.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxWithWidePopup.java
@@ -23,24 +23,24 @@ import javax.swing.*;
import java.awt.*;
import java.util.Vector;
-public class ComboBoxWithWidePopup extends JComboBox {
+public class ComboBoxWithWidePopup extends JComboBox {
private boolean myLayingOut = false;
private int myMinLength = 20;
- public ComboBoxWithWidePopup(final ComboBoxModel aModel) {
+ public ComboBoxWithWidePopup(final ComboBoxModel aModel) {
super(aModel);
if (SystemInfo.isMac && UIUtil.isUnderAquaLookAndFeel()) setMaximumRowCount(25);
}
- public ComboBoxWithWidePopup(final Object[] items) {
+ public ComboBoxWithWidePopup(final E[] items) {
super(items);
if (SystemInfo.isMac && UIUtil.isUnderAquaLookAndFeel()) setMaximumRowCount(25);
}
- public ComboBoxWithWidePopup(final Vector> items) {
+ public ComboBoxWithWidePopup(@SuppressWarnings("UseOfObsoleteCollectionType") final Vector items) {
super(items);
if (SystemInfo.isMac && UIUtil.isUnderAquaLookAndFeel()) setMaximumRowCount(25);
@@ -51,7 +51,7 @@ public class ComboBoxWithWidePopup extends JComboBox {
@SuppressWarnings("GtkPreferredJComboBoxRenderer")
@Override
- public void setRenderer(ListCellRenderer renderer) {
+ public void setRenderer(ListCellRenderer super E> renderer) {
super.setRenderer(new AdjustingListCellRenderer(this, renderer));
}
@@ -92,18 +92,18 @@ public class ComboBoxWithWidePopup extends JComboBox {
return getPreferredSize();
}
- private class AdjustingListCellRenderer implements ListCellRenderer {
- private final ListCellRenderer myOldRenderer;
+ private class AdjustingListCellRenderer implements ListCellRenderer {
+ private final ListCellRenderer super E> myOldRenderer;
private final ComboBoxWithWidePopup myComboBox;
- public AdjustingListCellRenderer(ComboBoxWithWidePopup comboBox, ListCellRenderer oldRenderer) {
+ public AdjustingListCellRenderer(ComboBoxWithWidePopup comboBox, ListCellRenderer super E> oldRenderer) {
myComboBox = comboBox;
myOldRenderer = oldRenderer;
}
@Override
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- Object _value = value;
+ public Component getListCellRendererComponent(JList extends E> list, E value, int index, boolean isSelected, boolean cellHasFocus) {
+ E _value = value;
if (index == -1 && _value instanceof String && !myComboBox.isValid()) {
int minLength = getMinLength();
@@ -112,7 +112,8 @@ public class ComboBoxWithWidePopup extends JComboBox {
if (size.width == 0) {
if (stringValue.length() > minLength) {
- _value = stringValue.substring(0, minLength);
+ //noinspection unchecked
+ _value = (E)stringValue.substring(0, minLength);
}
}
}