mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-22324 Split Local Interpreter into Virtual Environment and System Interpreter options
This commit is contained in:
@@ -54,7 +54,8 @@ class PyAddSdkDialog(private val project: Project?,
|
||||
val sdks = existingSdks
|
||||
.filter { it.sdkType is PythonSdkType && !PythonSdkType.isInvalid(it) }
|
||||
.sortedWith(PreferredSdkComparator())
|
||||
return createCardSplitter(listOf(createLocalInterpreterPanel(project, sdks, newProjectPath),
|
||||
return createCardSplitter(listOf(createVirtualEnvPanel(project, sdks, newProjectPath),
|
||||
PyAddSystemWideInterpreterPanel(existingSdks),
|
||||
createAnacondaPanel()))
|
||||
}
|
||||
|
||||
@@ -97,25 +98,23 @@ class PyAddSdkDialog(private val project: Project?,
|
||||
}
|
||||
}
|
||||
|
||||
private fun createLocalInterpreterPanel(project: Project?,
|
||||
existingSdks: List<Sdk>,
|
||||
newProjectPath: String?): PyAddSdkPanel {
|
||||
private fun createVirtualEnvPanel(project: Project?,
|
||||
existingSdks: List<Sdk>,
|
||||
newProjectPath: String?): PyAddSdkPanel {
|
||||
val newVirtualEnvPanel = if (project != null || PlatformUtils.isPyCharmEducational())
|
||||
PyAddNewVirtualEnvPanel(project, existingSdks, newProjectPath)
|
||||
else
|
||||
null
|
||||
val existingVirtualEnvPanel = PyAddExistingVirtualEnvPanel(project, existingSdks, newProjectPath)
|
||||
val systemInterpreterPanel = PyAddSystemWideInterpreterPanel(existingSdks)
|
||||
val panels = listOf(newVirtualEnvPanel,
|
||||
existingVirtualEnvPanel,
|
||||
systemInterpreterPanel)
|
||||
existingVirtualEnvPanel)
|
||||
.filterNotNull()
|
||||
val defaultPanel = when {
|
||||
detectVirtualEnvs(project, existingSdks).any { it.isAssociatedWithProject(project) } -> existingVirtualEnvPanel
|
||||
newVirtualEnvPanel != null -> newVirtualEnvPanel
|
||||
else -> systemInterpreterPanel
|
||||
else -> existingVirtualEnvPanel
|
||||
}
|
||||
return PyAddSdkGroupPanel("Local interpreter", PythonIcons.Python.Python, panels, defaultPanel)
|
||||
return PyAddSdkGroupPanel("Virtual environment", PythonIcons.Python.Virtualenv, panels, defaultPanel)
|
||||
}
|
||||
|
||||
private fun createAnacondaPanel(): PyAddSdkPanel {
|
||||
|
||||
@@ -37,7 +37,11 @@ class PyAddSdkGroupPanel(name: String,
|
||||
|
||||
init {
|
||||
layout = BorderLayout()
|
||||
add(createRadioButtonPanel(panels, defaultPanel), BorderLayout.NORTH)
|
||||
val contentPanel = when (panels.size) {
|
||||
1 -> panels[0]
|
||||
else -> createRadioButtonPanel(panels, defaultPanel)
|
||||
}
|
||||
add(contentPanel, BorderLayout.NORTH)
|
||||
}
|
||||
|
||||
override fun validateAll() = panels.filter { it.isEnabled }.flatMap { it.validateAll() }
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.awt.BorderLayout
|
||||
* @author vlan
|
||||
*/
|
||||
class PyAddSystemWideInterpreterPanel(private val existingSdks: List<Sdk>) : PyAddSdkPanel() {
|
||||
override val panelName = "System-wide interpreter"
|
||||
override val panelName = "System interpreter"
|
||||
private val sdkComboBox = PySdkPathChoosingComboBox(detectSystemWideSdks(existingSdks), null)
|
||||
|
||||
init {
|
||||
|
||||
Reference in New Issue
Block a user