use of com.intellij.ui.EnumComboBoxModel 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.ui.EnumComboBoxModel in project intellij-community by JetBrains.
the class GitVcsPanel method createUIComponents.
private void createUIComponents() {
myProtectedBranchesButton = new TextFieldWithBrowseButton.NoPathCompletion(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Messages.showTextAreaDialog(myProtectedBranchesButton.getTextField(), "Protected Branches", "Git.Force.Push.Protected.Branches", ParametersListUtil.COLON_LINE_PARSER, ParametersListUtil.COLON_LINE_JOINER);
}
});
myProtectedBranchesButton.setButtonIcon(AllIcons.Actions.ShowViewer);
myUpdateMethodComboBox = new ComboBox(new EnumComboBoxModel<>(UpdateMethod.class));
myUpdateMethodComboBox.setRenderer(new ListCellRendererWrapper<UpdateMethod>() {
@Override
public void customize(JList list, UpdateMethod value, int index, boolean selected, boolean hasFocus) {
setText(StringUtil.capitalize(StringUtil.toLowerCase(value.name().replace('_', ' '))));
}
});
}
Aggregations