Search in sources :

Example 1 with CollectionComboBoxModel

use of com.intellij.ui.CollectionComboBoxModel in project intellij-community by JetBrains.

the class RepositoryLibraryPropertiesEditor method initVersionsPanel.

private void initVersionsPanel() {
    final int selection = getSelection(model.getVersion(), versions);
    CollectionComboBoxModel<String> versionSelectorModel = new CollectionComboBoxModel<>(versions);
    //noinspection unchecked
    versionSelector.setModel(versionSelectorModel);
    versionSelector.setSelectedIndex(selection);
    setState(State.Loaded);
    initVersionKindSelector();
    versionSelector.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            model.setVersion(getSelectedVersion());
            onChangeListener.onChange(RepositoryLibraryPropertiesEditor.this);
        }
    });
    downloadSourcesCheckBox.setSelected(model.isDownloadSources());
    downloadSourcesCheckBox.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            model.setDownloadSources(downloadSourcesCheckBox.isSelected());
            onChangeListener.onChange(RepositoryLibraryPropertiesEditor.this);
        }
    });
    downloadJavaDocsCheckBox.setSelected(model.isDownloadJavaDocs());
    downloadJavaDocsCheckBox.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            model.setDownloadJavaDocs(downloadJavaDocsCheckBox.isSelected());
            onChangeListener.onChange(RepositoryLibraryPropertiesEditor.this);
        }
    });
}
Also used : ItemEvent(java.awt.event.ItemEvent) ChangeEvent(javax.swing.event.ChangeEvent) CollectionComboBoxModel(com.intellij.ui.CollectionComboBoxModel) ItemListener(java.awt.event.ItemListener) ChangeListener(javax.swing.event.ChangeListener)

Example 2 with CollectionComboBoxModel

use of com.intellij.ui.CollectionComboBoxModel in project intellij-community by JetBrains.

the class PyIdeCommonOptionsForm method updateSdkList.

public void updateSdkList(boolean preserveSelection, PyConfigurableInterpreterList myInterpreterList) {
    myPythonSdks = myInterpreterList.getAllPythonSdks(myProject);
    Sdk selection = preserveSelection ? (Sdk) myInterpreterComboBox.getSelectedItem() : null;
    if (!myPythonSdks.contains(selection)) {
        selection = null;
    }
    myPythonSdks.add(0, null);
    myInterpreterComboBox.setModel(new CollectionComboBoxModel(myPythonSdks, selection));
}
Also used : CollectionComboBoxModel(com.intellij.ui.CollectionComboBoxModel) Sdk(com.intellij.openapi.projectRoots.Sdk)

Example 3 with CollectionComboBoxModel

use of com.intellij.ui.CollectionComboBoxModel in project intellij-community by JetBrains.

the class BuildoutConfigPanel method reset.

public void reset() {
    final List<File> scriptFiles = BuildoutFacet.getScripts(BuildoutFacet.getInstance(myModule), myModule.getProject().getBaseDir());
    final List<String> scripts = ContainerUtil.map(scriptFiles, file -> file.getPath());
    myScript.getComboBox().setModel(new CollectionComboBoxModel(scripts, myConfiguration.getScriptName()));
    myScript.getComboBox().getEditor().setItem(myConfiguration.getScriptName());
}
Also used : CollectionComboBoxModel(com.intellij.ui.CollectionComboBoxModel) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 4 with CollectionComboBoxModel

use of com.intellij.ui.CollectionComboBoxModel in project intellij-community by JetBrains.

the class PyPluginCommonOptionsForm method setSdkHome.

public void setSdkHome(String sdkHome) {
    List<Sdk> sdkList = new ArrayList<>();
    sdkList.add(null);
    final List<Sdk> allSdks = PythonSdkType.getAllSdks();
    Collections.sort(allSdks, new PreferredSdkComparator());
    Sdk selection = null;
    for (Sdk sdk : allSdks) {
        String homePath = sdk.getHomePath();
        if (homePath != null && sdkHome != null && FileUtil.pathsEqual(homePath, sdkHome))
            selection = sdk;
        sdkList.add(sdk);
    }
    myInterpreterComboBox.setModel(new CollectionComboBoxModel(sdkList, selection));
}
Also used : PreferredSdkComparator(com.jetbrains.python.sdk.PreferredSdkComparator) ArrayList(java.util.ArrayList) CollectionComboBoxModel(com.intellij.ui.CollectionComboBoxModel) Sdk(com.intellij.openapi.projectRoots.Sdk)

Example 5 with CollectionComboBoxModel

use of com.intellij.ui.CollectionComboBoxModel in project intellij-community by JetBrains.

the class AddRepositoryLocationDialog method createCenterPanel.

protected JComponent createCenterPanel() {
    JLabel selectText = new JLabel(message("repository.browser.add.location.prompt"));
    selectText.setUI(new MultiLineLabelUI());
    JPanel mainPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gb = new GridBagConstraints(0, 0, 1, 1, 1, 0, NORTHWEST, NONE, insets(5), 0, 0);
    mainPanel.add(selectText, gb);
    ++gb.gridy;
    myCombo = new ComboBox<>(new CollectionComboBoxModel<>(myPreviousLocations));
    myCombo.setEditable(true);
    myCombo.setMinimumSize(size(250, 20));
    gb.fill = HORIZONTAL;
    mainPanel.add(myCombo, gb);
    gb.fill = NONE;
    myComboField = (JTextField) myCombo.getEditor().getEditorComponent();
    myComboField.addInputMethodListener(new InputMethodListener() {

        public void inputMethodTextChanged(InputMethodEvent event) {
            validateMe();
        }

        public void caretPositionChanged(InputMethodEvent event) {
            validateMe();
        }
    });
    myComboField.addKeyListener(new KeyListener() {

        public void keyTyped(KeyEvent e) {
            validateMe();
        }

        public void keyPressed(KeyEvent e) {
            validateMe();
        }

        public void keyReleased(KeyEvent e) {
            validateMe();
        }
    });
    myCombo.addActionListener(e -> validateMe());
    validateMe();
    JPanel wrapper = new JPanel(new GridBagLayout());
    wrapper.add(mainPanel, new GridBagConstraints(0, 0, 1, 1, 1, 1, NORTHWEST, HORIZONTAL, emptyInsets(), 0, 0));
    wrapper.setPreferredSize(size(400, 70));
    return wrapper;
}
Also used : MultiLineLabelUI(com.intellij.openapi.ui.MultiLineLabelUI) KeyEvent(java.awt.event.KeyEvent) GridBagConstraints(java.awt.GridBagConstraints) CollectionComboBoxModel(com.intellij.ui.CollectionComboBoxModel) InputMethodListener(java.awt.event.InputMethodListener) KeyListener(java.awt.event.KeyListener) InputMethodEvent(java.awt.event.InputMethodEvent)

Aggregations

CollectionComboBoxModel (com.intellij.ui.CollectionComboBoxModel)16 ArrayList (java.util.ArrayList)4 Sdk (com.intellij.openapi.projectRoots.Sdk)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 ItemEvent (java.awt.event.ItemEvent)2 ItemListener (java.awt.event.ItemListener)2 NotNull (org.jetbrains.annotations.NotNull)2 InvalidationListener (com.android.tools.idea.ui.properties.InvalidationListener)1 ObservableValue (com.android.tools.idea.ui.properties.ObservableValue)1 CommonProgramParametersPanel (com.intellij.execution.ui.CommonProgramParametersPanel)1 Artifact (com.intellij.facet.frameworks.beans.Artifact)1 Disposable (com.intellij.openapi.Disposable)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 ModalityState (com.intellij.openapi.application.ModalityState)1 ComboBox (com.intellij.openapi.ui.ComboBox)1 MultiLineLabelUI (com.intellij.openapi.ui.MultiLineLabelUI)1 CheckinHandler (com.intellij.openapi.vcs.checkin.CheckinHandler)1 RefreshableOnComponent (com.intellij.openapi.vcs.ui.RefreshableOnComponent)1