use of com.intellij.util.ListWithSelection 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;
}
use of com.intellij.util.ListWithSelection in project intellij-community by JetBrains.
the class ComboBoxTableCellRenderer method getTableCellRendererComponent.
@Override
public JComponent getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (value instanceof ListWithSelection) {
final ListWithSelection tags = (ListWithSelection) value;
if (tags.getSelection() == null) {
tags.selectFirst();
}
myCombo.removeAllItems();
for (Object tag : tags) {
myCombo.addItem(tag);
}
myCombo.setSelectedItem(tags.getSelection());
} else {
if (value != null) {
LOG.error("value " + LogUtil.objectAndClass(value) + ", at " + row + ":" + column + ", in " + table.getModel());
}
myCombo.removeAllItems();
myCombo.setSelectedIndex(-1);
}
return this;
}
use of com.intellij.util.ListWithSelection 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) {
final ListWithSelection options = (ListWithSelection) value;
if (options.getSelection() == null) {
options.selectFirst();
}
myComboBox.removeAllItems();
for (Object option : options) {
//noinspection unchecked
myComboBox.addItem(option);
}
myComboBox.setSelectedItem(options.getSelection());
return myPanel;
}
Aggregations