use of org.jdesktop.swingx.combobox.ListComboBoxModel in project intellij-community by JetBrains.
the class ParameterNameHintsConfigurable method initLanguageCombo.
private void initLanguageCombo(Language selected, List<Language> languages) {
ListComboBoxModel<Language> model = new ListComboBoxModel<>(languages);
myCurrentLanguageCombo = new ComboBox<>(model);
myCurrentLanguageCombo.setSelectedItem(selected);
myCurrentLanguageCombo.setRenderer(new ListCellRendererWrapper<Language>() {
@Override
public void customize(JList list, Language value, int index, boolean selected, boolean hasFocus) {
setText(value.getDisplayName());
}
});
myCurrentLanguageCombo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
Language language = (Language) e.getItem();
if (e.getStateChange() == ItemEvent.SELECTED) {
showLanguagePanel(language);
}
}
});
}
use of org.jdesktop.swingx.combobox.ListComboBoxModel in project intellij-community by JetBrains.
the class ComboBoxTableCellEditor method getTableCellEditorComponent.
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
if (value instanceof ListWithSelection) {
ListWithSelection options = (ListWithSelection) value;
//noinspection unchecked
comboBox.setModel(new ListComboBoxModel(options));
if (options.getSelection() == null) {
options.selectFirst();
}
comboBox.setSelectedItem(options.getSelection());
} else {
Enum enumValue = (Enum) value;
Class enumClass = enumValue.getDeclaringClass();
//noinspection unchecked
ComboBoxModel model = comboBox.getModel();
if (!(model instanceof EnumComboBoxModel && model.getSize() > 0 && ((Enum) model.getElementAt(0)).getDeclaringClass() == enumClass)) {
//noinspection unchecked
comboBox.setModel(new EnumComboBoxModel(enumClass));
}
comboBox.setSelectedItem(value);
}
return comboBox;
}
Aggregations