From ae0559fe48d533f441a4543b6cc307e79ce94677 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Thu, 11 Aug 2016 18:46:43 +0300 Subject: [PATCH] use meta+shift+enter to add to watches on mac --- .../src/messages/XDebuggerBundle.properties | 2 +- .../impl/evaluate/ExpressionInputComponent.java | 5 ++++- .../impl/evaluate/XDebuggerEvaluationDialog.java | 9 +++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/platform/platform-resources-en/src/messages/XDebuggerBundle.properties b/platform/platform-resources-en/src/messages/XDebuggerBundle.properties index 07f256cdff9c..4b2ab388d593 100644 --- a/platform/platform-resources-en/src/messages/XDebuggerBundle.properties +++ b/platform/platform-resources-en/src/messages/XDebuggerBundle.properties @@ -70,7 +70,7 @@ xdebugger.button.evaluate=E&valuate xdebugger.evaluate.dialog.close=Close xdebugger.dialog.title.evaluate.expression=Evaluate Expression xdebugger.evaluate.label.expression=Expression: -xdebugger.evaluate.addtowatches.hint=Use Control+Shift+Enter to add to Watches +xdebugger.evaluate.addtowatches.hint=Use {0} to add to Watches dialog.title.evaluate.code.fragment=Evaluate Code Fragment button.text.code.fragment.mode=Code Fragment &Mode button.text.expression.mode=Expression &Mode diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/ExpressionInputComponent.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/ExpressionInputComponent.java index 1e4b9e7a937c..f54c83f0227e 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/ExpressionInputComponent.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/ExpressionInputComponent.java @@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CustomShortcutSet; import com.intellij.openapi.editor.ex.util.EditorUtil; +import com.intellij.openapi.keymap.KeymapUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.FixedSizeButton; import com.intellij.openapi.ui.popup.PopupStep; @@ -72,7 +73,9 @@ public class ExpressionInputComponent extends EvaluationInputComponent { } }); myMainPanel.add(historyButton, BorderLayout.EAST); - final JBLabel help = new JBLabel(XDebuggerBundle.message("xdebugger.evaluate.addtowatches.hint"), SwingConstants.RIGHT); + final JBLabel help = new JBLabel(XDebuggerBundle.message("xdebugger.evaluate.addtowatches.hint", + KeymapUtil.getKeystrokeText(XDebuggerEvaluationDialog.ADD_WATCH_KEYSTROKE)), + SwingConstants.RIGHT); help.setBorder(JBUI.Borders.empty(2, 0, 6, 0)); help.setComponentStyle(UIUtil.ComponentStyle.SMALL); help.setFontColor(UIUtil.FontColor.BRIGHTER); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEvaluationDialog.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEvaluationDialog.java index dce46002610a..c59fd426c230 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEvaluationDialog.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEvaluationDialog.java @@ -22,6 +22,7 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.Condition; +import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.openapi.wm.WindowManager; @@ -58,6 +59,10 @@ import java.awt.event.KeyEvent; public class XDebuggerEvaluationDialog extends DialogWrapper { public static final DataKey KEY = DataKey.create("DEBUGGER_EVALUATION_DIALOG"); + //can not use new SHIFT_DOWN_MASK etc because in this case ActionEvent modifiers do not match + private static final int ADD_WATCH_MODIFIERS = (SystemInfo.isMac ? InputEvent.META_MASK : InputEvent.CTRL_MASK) | InputEvent.SHIFT_MASK; + static KeyStroke ADD_WATCH_KEYSTROKE = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, ADD_WATCH_MODIFIERS); + private final JPanel myMainPanel; private final JPanel myResultPanel; private final XDebuggerTreePanel myTreePanel; @@ -120,7 +125,7 @@ public class XDebuggerEvaluationDialog extends DialogWrapper { doOKAction(); addToWatches(); } - }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)), getRootPane(), myDisposable); + }.registerCustomShortcutSet(new CustomShortcutSet(ADD_WATCH_KEYSTROKE), getRootPane(), myDisposable); new AnAction() { @Override @@ -171,7 +176,7 @@ public class XDebuggerEvaluationDialog extends DialogWrapper { @Override public void actionPerformed(ActionEvent e) { super.actionPerformed(e); - if ((e.getModifiers() & (InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK)) == (InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK)) { + if ((e.getModifiers() & ADD_WATCH_MODIFIERS) == ADD_WATCH_MODIFIERS) { addToWatches(); } }