From ea7482bc2ab3117434e5f3f2f21406f6f9c4df53 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Fri, 24 Mar 2017 18:42:18 +0000 Subject: [PATCH] Don't allow "toggle bookmarks with mnemonic" show popup multiple times Follow-up to b5addab Relates to IDEA-169296 Issues found in IDEA-CR-19062 --- .../actions/ToggleBookmarkWithMnemonicAction.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmarkWithMnemonicAction.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmarkWithMnemonicAction.java index 033b28d8f0c9..c3a8f719f330 100644 --- a/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmarkWithMnemonicAction.java +++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmarkWithMnemonicAction.java @@ -22,6 +22,8 @@ import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.popup.JBPopup; import com.intellij.openapi.ui.popup.JBPopupFactory; +import com.intellij.openapi.ui.popup.JBPopupListener; +import com.intellij.openapi.ui.popup.LightweightWindowEvent; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -29,6 +31,8 @@ import org.jetbrains.annotations.NotNull; * @author max */ public class ToggleBookmarkWithMnemonicAction extends ToggleBookmarkAction { + private boolean myPopupShown; + public ToggleBookmarkWithMnemonicAction() { getTemplatePresentation().setText(IdeBundle.message("action.bookmark.toggle.mnemonic")); } @@ -36,6 +40,7 @@ public class ToggleBookmarkWithMnemonicAction extends ToggleBookmarkAction { @Override public void update(@NotNull AnActionEvent e) { super.update(e); + e.getPresentation().setEnabled(!myPopupShown); e.getPresentation().setText(IdeBundle.message("action.bookmark.toggle.mnemonic")); } @@ -80,8 +85,15 @@ public class ToggleBookmarkWithMnemonicAction extends ToggleBookmarkAction { setAdText(bookmarks.hasBookmarksWithMnemonics() ? (UIUtil.isUnderDarcula() ? "Brown" : "Yellow") + " cells are in use" : null). setResizable(false). createPopup(); + popup[0].addListener(new JBPopupListener.Adapter() { + @Override + public void onClosed(LightweightWindowEvent event) { + myPopupShown = false; + } + }); popup[0].showInBestPositionFor(e.getDataContext()); + myPopupShown = true; } } }