use of com.intellij.ui.SimpleListCellRenderer in project intellij-elixir by KronicDeth.
the class AdditionalDataConfigurable method createComponent.
public JComponent createComponent() {
JPanel wholePanel = new JPanel(new GridBagLayout());
wholePanel.add(internalErlangSdkLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.emptyInsets(), 0, 0));
wholePanel.add(internalErlangSdksComboBox, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1, 1, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, JBUI.insets(0, 30, 0, 0), 0, 0));
internalErlangSdksComboBox.setRenderer(new SimpleListCellRenderer() {
@Override
public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof Sdk) {
setText(((Sdk) value).getName());
}
}
});
internalErlangSdksComboBox.addItemListener(itemEvent -> {
if (!freeze) {
final int stateChange = itemEvent.getStateChange();
final Sdk internalErlangSdk = (Sdk) itemEvent.getItem();
if (stateChange == ItemEvent.DESELECTED) {
removeCodePathsFromInternalErlangSdk(elixirSdk, internalErlangSdk, sdkModificator);
} else if (stateChange == ItemEvent.SELECTED) {
addNewCodePathsFromInternErlangSdk(elixirSdk, internalErlangSdk, sdkModificator);
modified = true;
}
}
});
modified = true;
return wholePanel;
}
Aggregations