diff --git a/platform/lang-impl/src/com/intellij/webcore/packaging/InstalledPackagesPanel.java b/platform/lang-impl/src/com/intellij/webcore/packaging/InstalledPackagesPanel.java index 8b341efab6bc..c698c4bfb138 100644 --- a/platform/lang-impl/src/com/intellij/webcore/packaging/InstalledPackagesPanel.java +++ b/platform/lang-impl/src/com/intellij/webcore/packaging/InstalledPackagesPanel.java @@ -279,7 +279,7 @@ public class InstalledPackagesPanel extends JPanel { final int[] selected = myPackagesTable.getSelectedRows(); boolean upgradeAvailable = false; boolean canUninstall = selected.length != 0; - boolean canInstall = true; + boolean canInstall = installEnabled(); boolean canUpgrade = true; if (myPackageManagementService != null && selected.length != 0) { for (int i = 0; i != selected.length; ++i) { @@ -318,6 +318,10 @@ public class InstalledPackagesPanel extends JPanel { return true; } + protected boolean installEnabled() { + return true; + } + protected boolean canUpgradePackage(InstalledPackage pyPackage) { return true; } diff --git a/python/src/com/jetbrains/python/packaging/ui/PyInstalledPackagesPanel.java b/python/src/com/jetbrains/python/packaging/ui/PyInstalledPackagesPanel.java index 3d3e28b4866c..457893b4a585 100644 --- a/python/src/com/jetbrains/python/packaging/ui/PyInstalledPackagesPanel.java +++ b/python/src/com/jetbrains/python/packaging/ui/PyInstalledPackagesPanel.java @@ -138,7 +138,7 @@ public class PyInstalledPackagesPanel extends InstalledPackagesPanel { } myNotificationArea.showWarning(builder.toString()); } - myInstallButton.setEnabled(!invalid && myHasManagement); + myInstallButton.setEnabled(!invalid && installEnabled()); } } } @@ -155,6 +155,11 @@ public class PyInstalledPackagesPanel extends InstalledPackagesPanel { @Override protected boolean canUninstallPackage(InstalledPackage pkg) { if (!myHasManagement) return false; + + if (PythonSdkType.isDocker(getSelectedSdk())) { + return false; + } + if (PythonSdkType.isVirtualEnv(getSelectedSdk()) && pkg instanceof PyPackage) { final String location = ((PyPackage)pkg).getLocation(); if (location != null && location.startsWith(PySdkUtil.getUserSite())) { @@ -173,11 +178,24 @@ public class PyInstalledPackagesPanel extends InstalledPackagesPanel { @Override protected boolean canInstallPackage(@NotNull final InstalledPackage pyPackage) { + return installEnabled(); + } + + @Override + protected boolean installEnabled() { + if (PythonSdkType.isDocker(getSelectedSdk())) { + return false; + } + return myHasManagement; } @Override protected boolean canUpgradePackage(InstalledPackage pyPackage) { + if (PythonSdkType.isDocker(getSelectedSdk())) { + return false; + } + return myHasManagement && !PyCondaPackageManagerImpl.PYTHON.equals(pyPackage.getName()); } } diff --git a/python/src/com/jetbrains/python/sdk/PythonSdkType.java b/python/src/com/jetbrains/python/sdk/PythonSdkType.java index 4bb9cefe4ad6..ea36070b0414 100644 --- a/python/src/com/jetbrains/python/sdk/PythonSdkType.java +++ b/python/src/com/jetbrains/python/sdk/PythonSdkType.java @@ -250,6 +250,12 @@ public class PythonSdkType extends SdkType { return false; } + public static boolean isDocker(@Nullable final Sdk sdk) { + return sdk != null && sdk.getSdkAdditionalData() instanceof RemoteSdkAdditionalData && + ((RemoteSdkAdditionalData) sdk.getSdkAdditionalData()).getRemoteConnectionType() == CredentialsType.DOCKER; + + } + public static boolean isRemote(@Nullable String sdkPath) { return isRemote(findSdkByPath(sdkPath)); }