From 20618f05fa9a906f33202497dfa8acfbea54fdfd Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 27 Apr 2015 14:06:11 +0200 Subject: [PATCH] CPP-3150 Warn users about Vim plugin on Welcome screen --- .../CustomizeFeaturedPluginsStepPanel.java | 43 ++++++++++++++----- .../intellij/ide/customize/PluginGroups.java | 4 +- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java index c0f35eb7dccc..0279925e3b43 100644 --- a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java +++ b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java @@ -22,6 +22,7 @@ import com.intellij.ide.plugins.PluginManagerCore; import com.intellij.openapi.progress.util.AbstractProgressIndicatorExBase; import com.intellij.openapi.ui.VerticalFlowLayout; import com.intellij.openapi.updateSettings.impl.PluginDownloader; +import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.wm.ex.ProgressIndicatorEx; import com.intellij.ui.ColorUtil; import com.intellij.ui.JBColor; @@ -30,6 +31,8 @@ import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.components.labels.LinkLabel; import com.intellij.ui.components.labels.LinkListener; import com.intellij.util.ConcurrencyUtil; +import com.intellij.util.ui.UIUtil; +import org.jetbrains.annotations.NotNull; import javax.swing.*; import javax.swing.border.CompoundBorder; @@ -87,19 +90,26 @@ public class CustomizeFeaturedPluginsStepPanel extends AbstractCustomizeWizardSt + final boolean isVIM = PluginGroups.IDEA_VIM_PLUGIN_ID.equals(descriptor.getPluginId().getIdString()); + JLabel titleLabel = new JLabel("

" + title + "

"); JLabel topicLabel = new JLabel("

" + topic + "

"); - JLabel descriptionLabel = new JLabel("" + description + "") { - @Override - public Dimension getPreferredSize() { - Dimension size = super.getPreferredSize(); - size.width = Math.min(size.width, 200); - return size; - } - }; + + JLabel descriptionLabel = createHTMLLabel("" + description + ""); + JLabel warningLabel = null; + if (isVIM) { + warningLabel = createHTMLLabel("This plugin enables Vim-keymap and 'insert' mode for editing. " + + "If you are not familiar with Vim, it's not recommended to install it."); + + if (SystemInfo.isMac) UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, warningLabel); + warningLabel.setBackground(new JBColor(ColorUtil.fromHex("F6F199"), ColorUtil.fromHex("52503A"))); + warningLabel.setOpaque(true); + } + final CardLayout wrapperLayout = new CardLayout(); final JPanel buttonWrapper = new JPanel(wrapperLayout); - final JButton installButton = new JButton("Install"); + final JButton installButton = new JButton(isVIM ? "Install and Enable Vim Editor" : "Install"); + final JProgressBar progressBar = new JProgressBar(0, 100); progressBar.setStringPainted(true); JPanel progressPanel = new JPanel(new VerticalFlowLayout(true, false)); @@ -109,7 +119,7 @@ public class CustomizeFeaturedPluginsStepPanel extends AbstractCustomizeWizardSt linkWrapper.add(cancelLink); progressPanel.add(linkWrapper); - JPanel buttonPanel = new JPanel(new VerticalFlowLayout(0, 0)); + final JPanel buttonPanel = new JPanel(new VerticalFlowLayout(0, 0)); buttonPanel.add(installButton); buttonWrapper.add(buttonPanel, "button"); @@ -219,6 +229,7 @@ public class CustomizeFeaturedPluginsStepPanel extends AbstractCustomizeWizardSt gbc.weighty = 1; groupPanel.add(Box.createVerticalGlue(), gbc); gbc.weighty = 0; + if (warningLabel != null) groupPanel.add(warningLabel, gbc); groupPanel.add(buttonWrapper, gbc); gridPanel.add(groupPanel); } @@ -241,6 +252,18 @@ public class CustomizeFeaturedPluginsStepPanel extends AbstractCustomizeWizardSt add(scrollPane); } + @NotNull + private static JLabel createHTMLLabel(final String text) { + return new JLabel("" + text + "") { + @Override + public Dimension getPreferredSize() { + Dimension size = super.getPreferredSize(); + size.width = Math.min(size.width, 200); + return size; + } + }; + } + @Override public String getTitle() { return "Featured plugins"; diff --git a/platform/platform-impl/src/com/intellij/ide/customize/PluginGroups.java b/platform/platform-impl/src/com/intellij/ide/customize/PluginGroups.java index 199a2d1e3ea7..0486f9ceb69c 100644 --- a/platform/platform-impl/src/com/intellij/ide/customize/PluginGroups.java +++ b/platform/platform-impl/src/com/intellij/ide/customize/PluginGroups.java @@ -36,6 +36,8 @@ import java.util.*; public class PluginGroups { static final String CORE = "Core"; private static final int MAX_DESCR_LENGTH = 55; + + public static final String IDEA_VIM_PLUGIN_ID = "IdeaVIM"; final Map>> myTree = new LinkedHashMap>>(); final Map myFeaturedPlugins = new LinkedHashMap(); @@ -202,7 +204,7 @@ public class PluginGroups { } protected static void addVimPlugin(Map featuredPlugins) { - featuredPlugins.put("IdeaVIM", "Editor:Vim emulation plug-in for IDEs based on the IntelliJ platform:IdeaVIM"); + featuredPlugins.put("IdeaVIM", "Editor:Emulates Vim behavior and shortcuts:" + IDEA_VIM_PLUGIN_ID); } protected static void addLuaPlugin(Map featuredPlugins) {