From 110fe78aab0056b8f07692eaabb1db8af45fb9a5 Mon Sep 17 00:00:00 2001 From: Vitaly Legchilkin Date: Fri, 20 Feb 2026 19:55:32 +0100 Subject: [PATCH] [python] PY-87445 Disable module dependencies UI when managed by pyproject.toml GitOrigin-RevId: fa4e35248e7f8e33784cdbad06fb4010c3ea40e9 --- .../PyModuleDependenciesConfigurable.java | 26 +++++++++++++++++++ .../messages/PyBundle.properties | 1 + 2 files changed, 27 insertions(+) diff --git a/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/configuration/PyModuleDependenciesConfigurable.java b/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/configuration/PyModuleDependenciesConfigurable.java index cb64f06cb7bc..33a7edff9475 100644 --- a/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/configuration/PyModuleDependenciesConfigurable.java +++ b/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/configuration/PyModuleDependenciesConfigurable.java @@ -10,18 +10,23 @@ import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.ModuleOrderEntry; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.OrderEntry; +import com.intellij.python.pyproject.model.PyProjectModelSettings; +import com.intellij.ui.AncestorListenerAdapter; import com.intellij.ui.CheckBoxList; import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.components.JBLabel; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ui.EditableListModelDecorator; +import com.intellij.util.ui.UIUtil; +import com.jetbrains.python.PyBundle; import org.jetbrains.annotations.Nullable; import javax.swing.DefaultListModel; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.event.AncestorEvent; import java.awt.BorderLayout; import java.awt.Insets; import java.lang.reflect.Method; @@ -37,6 +42,7 @@ public class PyModuleDependenciesConfigurable implements UnnamedConfigurable { private final JPanel myMainPanel; private final JPanel myListHolderPanel; private final CheckBoxList myDependenciesList; + private final JBLabel myTitleLabel; public PyModuleDependenciesConfigurable(Module module) { myModule = module; @@ -66,6 +72,26 @@ public class PyModuleDependenciesConfigurable implements UnnamedConfigurable { (DefaultListModel)myDependenciesList.getModel())); decorator.disableRemoveAction(); myListHolderPanel.add(decorator.createPanel(), BorderLayout.CENTER); + myTitleLabel = (JBLabel)myMainPanel.getComponent(0); + myMainPanel.addAncestorListener(new AncestorListenerAdapter() { + @Override + public void ancestorAdded(AncestorEvent event) { + updateEnabledState(); + } + }); + } + + private void updateEnabledState() { + boolean managed = PyProjectModelSettings.getInstance(myModule.getProject()).getUsePyprojectToml(); + myDependenciesList.setEnabled(!managed); + if (managed) { + myTitleLabel.setText(PyBundle.message("python.pyproject.toml.dependencies.managed.hint")); + myTitleLabel.setForeground(UIUtil.getContextHelpForeground()); + } + else { + myTitleLabel.setText(PyBundle.message("py.module.dependencies.configurable.list.title")); + myTitleLabel.setForeground(UIUtil.getLabelForeground()); + } } private static Method $$$cachedGetBundleMethod$$$ = null; diff --git a/python/pluginResources/messages/PyBundle.properties b/python/pluginResources/messages/PyBundle.properties index 07fcc06e1be9..c701b9ca4fc5 100644 --- a/python/pluginResources/messages/PyBundle.properties +++ b/python/pluginResources/messages/PyBundle.properties @@ -1384,6 +1384,7 @@ python.pyproject.install.self.as.editable.progress=Running 'pip install -e .' python.pyproject.install.self.error=Error Running 'pip install -e .' python.pyproject.toml.based.project.model=Use pyproject.toml-based project model python.pyproject.toml.based.project.model.comment=When enabled, the project structure is derived from pyproject.toml instead of manual configuration +python.pyproject.toml.dependencies.managed.hint=Dependencies are managed by pyproject.toml # Python Packages toolwindow python.toolwindow.packages.installed.label=Installed