public void updateLists(List<? extends ChangeList> lists) { //noinspection unchecked myChooser.setModel(new DefaultComboBoxModel(lists.toArray())); myChooser.setEnabled(lists.size() > 1); if (lists.contains(mySelectedChangeList)) { myChooser.setSelectedItem(mySelectedChangeList); } else { if (myChooser.getItemCount() > 0) { myChooser.setSelectedIndex(0); } } mySelectedChangeList = (ChangeList) myChooser.getSelectedItem(); }
@NotNull JComponent createComponent() { myRemoteCombobox = new JComboBox(); myRemoteCombobox.setRenderer(new RemoteCellRenderer(myRemoteCombobox.getRenderer())); for (GitRemote remote : myRemotes) { myRemoteCombobox.addItem(remote); } myRemoteCombobox.setToolTipText("Select remote"); if (myRemotes.size() == 1) { myRemoteCombobox.setEnabled(false); } return myRemoteCombobox; }
void setEnabled(boolean selected) { if (myRemotes.size() > 1) { myRemoteCombobox.setEnabled(selected); } }