diff --git a/platform/platform-api/resources/messages/IdeBundle.properties b/platform/platform-api/resources/messages/IdeBundle.properties index 2c44d8916bf7..8acd05b39f0d 100644 --- a/platform/platform-api/resources/messages/IdeBundle.properties +++ b/platform/platform-api/resources/messages/IdeBundle.properties @@ -471,7 +471,9 @@ button.http.proxy.settings=&HTTP Proxy Settings... group.vendor=Vendor plugin.status.installed=Installed plugin.status.not.allowed=Blocked +plugin.status.not.allowed.but.enabled=Disable! plugin.status.not.allowed.tooltip=The plugin is not approved by your organization +plugin.status.not.allowed.tooltip.but.enabled=Please disable the plugin, it is not approved by your organization plugin.status.bundled=bundled progress.downloading.plugin=Downloading plugin ''{0}'' error.cannot.create.temp.dir=Unable to create temp directory ''{0}'' diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/newui/InstallButton.java b/platform/platform-impl/src/com/intellij/ide/plugins/newui/InstallButton.java index 785357c16841..313b033eb58c 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/newui/InstallButton.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/newui/InstallButton.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.plugins.newui; import com.intellij.ide.IdeBundle; @@ -28,6 +28,10 @@ public class InstallButton extends ColorButton { private static final Color BorderColor = JBColor.namedColor("Plugins.Button.installBorderColor", GreenColor); public InstallButton(boolean fill) { + setButtonColors(fill); + } + + public void setButtonColors(boolean fill) { if (fill) { setTextColor(FillForegroundColor); setBgColor(FillBackgroundColor); diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/newui/ListPluginComponent.java b/platform/platform-impl/src/com/intellij/ide/plugins/newui/ListPluginComponent.java index afe519a04cfd..af7e4dd6776d 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/newui/ListPluginComponent.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/newui/ListPluginComponent.java @@ -170,13 +170,31 @@ public class ListPluginComponent extends JPanel { } private void createNotAllowedMarker() { - myInstallButton = new InstallButton(true); - myInstallButton.setEnabled(false, IdeBundle.message("plugin.status.not.allowed")); - myInstallButton.setToolTipText(IdeBundle.message("plugin.status.not.allowed.tooltip")); - ColorButton.setWidth72(myInstallButton); + myInstallButton = new InstallButton(false); + setupNotAllowedMarkerButton(); myLayout.addButtonComponent(myInstallButton); } + private void setupNotAllowedMarkerButton() { + if (myMarketplace || myPluginModel.getState(myPlugin).isDisabled()) { + myInstallButton.setButtonColors(false); + myInstallButton.setEnabled(false, IdeBundle.message("plugin.status.not.allowed")); + myInstallButton.setToolTipText(IdeBundle.message("plugin.status.not.allowed.tooltip")); + } else { + myInstallButton.setButtonColors(false); + myInstallButton.setEnabled(true, IdeBundle.message("plugin.status.not.allowed.but.enabled")); + myInstallButton.setText(IdeBundle.message("plugin.status.not.allowed.but.enabled")); + myInstallButton.setToolTipText(IdeBundle.message("plugin.status.not.allowed.tooltip")); + myInstallButton.setBorderColor(JBColor.red); + myInstallButton.setTextColor(JBColor.red); + myInstallButton.addActionListener(e -> { + myPluginModel.setEnabledState(List.of(myPlugin), PluginEnableDisableAction.globally(false)); + setupNotAllowedMarkerButton(); + }); + } + ColorButton.setWidth72(myInstallButton); + } + private void createButtons() { if (myMarketplace) { if (InstalledPluginsState.getInstance().wasInstalled(myPlugin.getPluginId())) {