From 3f0ccd24db289417b7b4cbfd2ccfb5627093f7d4 Mon Sep 17 00:00:00 2001 From: Konstantin Kolosovsky Date: Mon, 8 Jan 2018 00:56:11 +0300 Subject: [PATCH] Fix option button tooltip text --- .../src/com/intellij/openapi/ui/DialogWrapper.java | 9 +++++---- .../src/com/intellij/ui/components/JBOptionButton.java | 6 +----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java index 94b952270440..cd3363fd1bef 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java @@ -15,7 +15,6 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.help.HelpManager; -import com.intellij.openapi.keymap.KeymapUtil; import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.popup.*; @@ -56,6 +55,8 @@ import java.util.*; import java.util.List; import java.util.stream.Collectors; +import static com.intellij.openapi.keymap.KeymapUtil.getKeystrokeText; + /** * The standard base class for modal dialog boxes. The dialog wrapper could be used only on event dispatch thread. * In case when the dialog must be created from other threads use @@ -738,9 +739,9 @@ public abstract class DialogWrapper { @NotNull private JButton createJOptionsButton(@NotNull OptionAction action) { JBOptionButton optionButton = new JBOptionButton(action, action.getOptions()); + String tooltip = String.format("Show drop-down menu (%s)", getKeystrokeText(SHOW_OPTION_KEYSTROKE)); + optionButton.setOptionTooltipText(tooltip); optionButton.setOkToProcessDefaultMnemonics(false); - optionButton.setOptionTooltipText( - "Press " + KeymapUtil.getKeystrokeText(SHOW_OPTION_KEYSTROKE) + " to expand or use a mnemonic of a contained action"); final Set infos = optionButton.getOptionInfos(); for (final JBOptionButton.OptionInfo eachInfo : infos) { @@ -1867,7 +1868,7 @@ public abstract class DialogWrapper { private void recordAction(String name, AWTEvent event) { if (event instanceof KeyEvent) { - String shortcut = KeymapUtil.getKeystrokeText(KeyStroke.getKeyStrokeForEvent((KeyEvent)event)); + String shortcut = getKeystrokeText(KeyStroke.getKeyStrokeForEvent((KeyEvent)event)); ActionsCollector.getInstance().record(name + " " + shortcut); } } diff --git a/platform/platform-api/src/com/intellij/ui/components/JBOptionButton.java b/platform/platform-api/src/com/intellij/ui/components/JBOptionButton.java index a804f6dde93e..50820a507c97 100644 --- a/platform/platform-api/src/com/intellij/ui/components/JBOptionButton.java +++ b/platform/platform-api/src/com/intellij/ui/components/JBOptionButton.java @@ -81,11 +81,7 @@ public class JBOptionButton extends JButton implements Weighted { @Override public String getToolTipText(MouseEvent event) { - if (!isSimpleButton() && myMoreRec.x < event.getX()) { - return myOptionTooltipText; - } else { - return super.getToolTipText(event); - } + return !isSimpleButton() ? myOptionTooltipText : super.getToolTipText(event); } @Override