Search in sources :

Example 1 with SimpleListCellRenderer

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;
}
Also used : SimpleListCellRenderer(com.intellij.ui.SimpleListCellRenderer) Type.addNewCodePathsFromInternErlangSdk(org.elixir_lang.sdk.elixir.Type.addNewCodePathsFromInternErlangSdk) Sdk(com.intellij.openapi.projectRoots.Sdk) Type.removeCodePathsFromInternalErlangSdk(org.elixir_lang.sdk.elixir.Type.removeCodePathsFromInternalErlangSdk)

Aggregations

Sdk (com.intellij.openapi.projectRoots.Sdk)1 SimpleListCellRenderer (com.intellij.ui.SimpleListCellRenderer)1 Type.addNewCodePathsFromInternErlangSdk (org.elixir_lang.sdk.elixir.Type.addNewCodePathsFromInternErlangSdk)1 Type.removeCodePathsFromInternalErlangSdk (org.elixir_lang.sdk.elixir.Type.removeCodePathsFromInternalErlangSdk)1