Search in sources :

Example 1 with PyConfigurableInterpreterList

use of com.jetbrains.python.configuration.PyConfigurableInterpreterList in project intellij-community by JetBrains.

the class PythonSdkChooserCombo method showOptions.

private void showOptions(final Project project) {
    final PyConfigurableInterpreterList interpreterList = PyConfigurableInterpreterList.getInstance(project);
    final Sdk[] sdks = interpreterList.getModel().getSdks();
    //noinspection unchecked
    final JComboBox<Sdk> comboBox = getComboBox();
    final Sdk oldSelectedSdk = (Sdk) comboBox.getSelectedItem();
    PythonSdkDetailsStep.show(project, sdks, null, this, getButton().getLocationOnScreen(), sdk -> {
        if (sdk == null)
            return;
        final ProjectSdksModel projectSdksModel = interpreterList.getModel();
        if (projectSdksModel.findSdk(sdk) == null) {
            projectSdksModel.addSdk(sdk);
            try {
                projectSdksModel.apply();
            } catch (ConfigurationException e) {
                LOG.error("Error adding new python interpreter " + e.getMessage());
            }
        }
        final List<Sdk> committedSdks = interpreterList.getAllPythonSdks();
        final Sdk copiedSdk = interpreterList.getModel().findSdk(sdk.getName());
        comboBox.setModel(new CollectionComboBoxModel<>(committedSdks, oldSelectedSdk));
        comboBox.setSelectedItem(copiedSdk);
    }, true);
}
Also used : PyConfigurableInterpreterList(com.jetbrains.python.configuration.PyConfigurableInterpreterList) ProjectSdksModel(com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel) ConfigurationException(com.intellij.openapi.options.ConfigurationException) Sdk(com.intellij.openapi.projectRoots.Sdk)

Example 2 with PyConfigurableInterpreterList

use of com.jetbrains.python.configuration.PyConfigurableInterpreterList in project intellij-community by JetBrains.

the class PyIdeCommonOptionsForm method subscribe.

@Override
public void subscribe() {
    PyConfigurableInterpreterList myInterpreterList = PyConfigurableInterpreterList.getInstance(myProject);
    ProjectSdksModel myProjectSdksModel = myInterpreterList.getModel();
    myProjectSdksModel.addListener(new MyListener(this, myInterpreterList));
    updateSdkList(true, myInterpreterList);
}
Also used : PyConfigurableInterpreterList(com.jetbrains.python.configuration.PyConfigurableInterpreterList) ProjectSdksModel(com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel)

Aggregations

ProjectSdksModel (com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel)2 PyConfigurableInterpreterList (com.jetbrains.python.configuration.PyConfigurableInterpreterList)2 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1