EA-80753 - assert: AnAction.setShortcutSet
authorEgor.Ushakov <egor.ushakov@jetbrains.com>
Fri, 18 Mar 2016 16:12:45 +0000 (19:12 +0300)
committerEgor.Ushakov <egor.ushakov@jetbrains.com>
Fri, 18 Mar 2016 16:13:25 +0000 (19:13 +0300)
platform/platform-resources/src/idea/Keymap_Default.xml
platform/platform-resources/src/idea/LangActions.xml
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesViewImpl.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTree.java

index a843d5c6cf53c2ba01b43f60a15f306dcba66aa0..66d81bbbd67988e9bc1ad5c832a804fef972dc88 100644 (file)
   <action id="ToggleTemporaryLineBreakpoint">
     <keyboard-shortcut first-keystroke="control shift alt F8"/>
   </action>
+  <action id="XDebugger.SetValue">
+    <keyboard-shortcut first-keystroke="F2"/>
+  </action>
+  <action id="XDebugger.EditWatch">
+    <keyboard-shortcut first-keystroke="F2"/>
+  </action>
+  <action id="XDebugger.NewWatch">
+    <keyboard-shortcut first-keystroke="INSERT"/>
+  </action>
   <action id="Debugger.EditTypeSource">
     <keyboard-shortcut first-keystroke="shift F4"/>
   </action>
-  <action id="ToggleBookmark">
+    <action id="ToggleBookmark">
     <keyboard-shortcut first-keystroke="F11"/>
   </action>
   <action id="ToggleBookmarkWithMnemonic">
index dfba57cd93e1ccf46d706acf8a9d9dd485168145..1b76370488e4de481b2cdfa113eb9f49eab775e7 100644 (file)
 
     <group id="XDebugger.Actions">
       <action id="XDebugger.SetValue" class="com.intellij.xdebugger.impl.ui.tree.actions.XSetValueAction"/>
-      <action id="XDebugger.CopyValue" class="com.intellij.xdebugger.impl.ui.tree.actions.XCopyValueAction"/>
+      <action id="XDebugger.CopyValue" class="com.intellij.xdebugger.impl.ui.tree.actions.XCopyValueAction" use-shortcut-of="$Copy"/>
       <action id="XDebugger.CompareValueWithClipboard" class="com.intellij.xdebugger.impl.ui.tree.actions.XCompareWithClipboardAction"/>
       <action id="XDebugger.CopyName" class="com.intellij.xdebugger.impl.ui.tree.actions.XCopyNameAction"/>
       <action id="XDebugger.Inspect" class="com.intellij.xdebugger.impl.ui.tree.actions.XInspectAction"/>
-      <action id="XDebugger.JumpToSource" class="com.intellij.xdebugger.impl.ui.tree.actions.XJumpToSourceAction"/>
-      <action id="XDebugger.JumpToTypeSource" class="com.intellij.xdebugger.impl.ui.tree.actions.XJumpToTypeSourceAction"/>
+      <action id="XDebugger.JumpToSource" class="com.intellij.xdebugger.impl.ui.tree.actions.XJumpToSourceAction"
+              use-shortcut-of="EditSource"/>
+      <action id="XDebugger.JumpToTypeSource" class="com.intellij.xdebugger.impl.ui.tree.actions.XJumpToTypeSourceAction"
+              use-shortcut-of="Debugger.EditTypeSource"/>
 
       <action id="Debugger.Tree.AddToWatches" class="com.intellij.xdebugger.impl.ui.tree.actions.XAddToWatchesAction" icon="AllIcons.Debugger.AddToWatch"/>
       <action id="Debugger.Tree.EvaluateInConsole" class="com.intellij.xdebugger.impl.ui.tree.actions.EvaluateInConsoleFromTreeAction"/>
 
       <action id="XDebugger.NewWatch" class="com.intellij.xdebugger.impl.frame.actions.XNewWatchAction" icon="AllIcons.Debugger.NewWatch"/>
       <action id="XDebugger.EditWatch" class="com.intellij.xdebugger.impl.frame.actions.XEditWatchAction"/>
-      <action id="XDebugger.CopyWatch" class="com.intellij.xdebugger.impl.frame.actions.XCopyWatchAction" icon="AllIcons.Actions.Copy" text="Copy Watch"/>
-      <action id="XDebugger.RemoveWatch" class="com.intellij.xdebugger.impl.frame.actions.XRemoveWatchAction" icon="AllIcons.Actions.Delete"/>
+      <action id="XDebugger.CopyWatch" class="com.intellij.xdebugger.impl.frame.actions.XCopyWatchAction" icon="AllIcons.Actions.Copy"
+              text="Copy Watch" use-shortcut-of="EditorDuplicate"/>
+      <action id="XDebugger.RemoveWatch" class="com.intellij.xdebugger.impl.frame.actions.XRemoveWatchAction" icon="AllIcons.Actions.Delete"
+              use-shortcut-of="$Delete"/>
       <action id="XDebugger.RemoveAllWatches" class="com.intellij.xdebugger.impl.frame.actions.XRemoveAllWatchesAction"/>
       <action id="XDebugger.MuteBreakpoints" class="com.intellij.xdebugger.impl.actions.MuteBreakpointAction"
               icon="AllIcons.Debugger.MuteBreakpoints"/>
       <action id="XDebugger.ToggleSortValues" class="com.intellij.xdebugger.impl.ui.tree.actions.SortValuesToggleAction" icon="AllIcons.ObjectBrowser.Sorted"/>
-      <action id="Debugger.MarkObject" class="com.intellij.xdebugger.impl.actions.MarkObjectAction"/>
+      <action id="Debugger.MarkObject" class="com.intellij.xdebugger.impl.actions.MarkObjectAction" use-shortcut-of="ToggleBookmark"/>
       <action id="Debugger.FocusOnBreakpoint" class="com.intellij.xdebugger.impl.actions.FocusOnBreakpointAction"/>
       <action id="Debugger.ShowReferring" class="com.intellij.xdebugger.impl.ui.tree.actions.ShowReferringObjectsAction"/>
     </group>
index 516b4468e99ed5e92068d925e3b3f1c84002cad1..88595f071501ff1195b79f62ec2bd7e476eb5bdf 100644 (file)
@@ -43,6 +43,7 @@ import com.intellij.xdebugger.impl.XDebugSessionImpl;
 import com.intellij.xdebugger.impl.actions.XDebuggerActions;
 import com.intellij.xdebugger.impl.breakpoints.XExpressionImpl;
 import com.intellij.xdebugger.impl.frame.actions.XWatchesTreeActionBase;
+import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
 import com.intellij.xdebugger.impl.ui.XDebugSessionData;
 import com.intellij.xdebugger.impl.ui.XDebugSessionTab;
 import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
@@ -80,19 +81,11 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget,
 
     XDebuggerTree tree = getTree();
     createNewRootNode(null);
-    AnAction newWatchAction = actionManager.getAction(XDebuggerActions.XNEW_WATCH);
-    AnAction removeWatchAction = actionManager.getAction(XDebuggerActions.XREMOVE_WATCH);
-    AnAction copyAction = actionManager.getAction(XDebuggerActions.XCOPY_WATCH);
-    AnAction editWatchAction = actionManager.getAction(XDebuggerActions.XEDIT_WATCH);
-
-    newWatchAction.registerCustomShortcutSet(CommonShortcuts.INSERT, tree, myDisposables);
-    removeWatchAction.registerCustomShortcutSet(CommonShortcuts.getDelete(), tree, myDisposables);
 
-    CustomShortcutSet f2Shortcut = new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0));
-    editWatchAction.registerCustomShortcutSet(f2Shortcut, tree, myDisposables);
-
-    copyAction.registerCustomShortcutSet(
-      ActionManager.getInstance().getAction(IdeActions.ACTION_EDITOR_DUPLICATE).getShortcutSet(), tree, myDisposables);
+    DebuggerUIUtil.registerActionOnComponent(XDebuggerActions.XNEW_WATCH, tree, myDisposables);
+    DebuggerUIUtil.registerActionOnComponent(XDebuggerActions.XREMOVE_WATCH, tree, myDisposables);
+    DebuggerUIUtil.registerActionOnComponent(XDebuggerActions.XCOPY_WATCH, tree, myDisposables);
+    DebuggerUIUtil.registerActionOnComponent(XDebuggerActions.XEDIT_WATCH, tree, myDisposables);
 
     DnDManager.getInstance().registerTarget(this, tree);
 
@@ -113,8 +106,9 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget,
     final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(getTree()).disableUpDownActions();
 
     decorator.setAddAction(button -> executeAction(XDebuggerActions.XNEW_WATCH));
-    decorator.setAddActionName(newWatchAction.getTemplatePresentation().getText());
+    decorator.setAddActionName(actionManager.getAction(XDebuggerActions.XNEW_WATCH).getTemplatePresentation().getText());
 
+    AnAction removeWatchAction = actionManager.getAction(XDebuggerActions.XREMOVE_WATCH);
     decorator.setRemoveAction(button -> executeAction(XDebuggerActions.XREMOVE_WATCH));
     decorator.setRemoveActionName(removeWatchAction.getTemplatePresentation().getText());
 
@@ -122,7 +116,7 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget,
       removeWatchAction.update(e);
       return e.getPresentation().isEnabled();
     });
-    decorator.addExtraAction(AnActionButton.fromAction(copyAction));
+    decorator.addExtraAction(AnActionButton.fromAction(actionManager.getAction(XDebuggerActions.XCOPY_WATCH)));
     decorator.addExtraAction(
       new ToggleActionButton(XDebuggerBundle.message("debugger.session.tab.show.watches.in.variables"), AllIcons.Debugger.Watches) {
         @Override
index ddd95fc54aceccd472906a1c1a51dbbde3e49468..4764e4047bc7398bfb393d7d23770925707470c4 100644 (file)
@@ -16,7 +16,9 @@
 package com.intellij.xdebugger.impl.ui;
 
 import com.intellij.codeInsight.hint.HintUtil;
+import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.ActionManager;
+import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.editor.LogicalPosition;
@@ -370,6 +372,11 @@ public class DebuggerUIUtil {
     return true;
   }
 
+  public static void registerActionOnComponent(String name, JComponent component, Disposable parentDisposable) {
+    AnAction action = ActionManager.getInstance().getAction(name);
+    action.registerCustomShortcutSet(action.getShortcutSet(), component, parentDisposable);
+  }
+
   public static void registerExtraHandleShortcuts(final ListPopupImpl popup, String... actionNames) {
     for (String name : actionNames) {
       KeyStroke stroke = KeymapUtil.getKeyStroke(ActionManager.getInstance().getAction(name).getShortcutSet());
index 08360d67d2aa3a539353c45682fa5e5519094e66..6c18386ed254e4a1c12aa503602d2c253b47d059 100644 (file)
@@ -350,16 +350,11 @@ public class XDebuggerTree extends DnDAwareTree implements DataProvider, Disposa
   }
 
   private void registerShortcuts() {
-    ActionManager actionManager = ActionManager.getInstance();
-    actionManager.getAction(XDebuggerActions.SET_VALUE)
-      .registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)), this, this);
-    actionManager.getAction(XDebuggerActions.COPY_VALUE).registerCustomShortcutSet(CommonShortcuts.getCopy(), this, this);
-    actionManager.getAction(XDebuggerActions.JUMP_TO_SOURCE).registerCustomShortcutSet(CommonShortcuts.getEditSource(), this, this);
-    Shortcut[] editTypeShortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(XDebuggerActions.EDIT_TYPE_SOURCE);
-    actionManager.getAction(XDebuggerActions.JUMP_TO_TYPE_SOURCE).registerCustomShortcutSet(
-      new CustomShortcutSet(editTypeShortcuts), this, this);
-    actionManager.getAction(XDebuggerActions.MARK_OBJECT).registerCustomShortcutSet(
-      new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("ToggleBookmark")), this, this);
+    DebuggerUIUtil.registerActionOnComponent(XDebuggerActions.SET_VALUE, this, this);
+    DebuggerUIUtil.registerActionOnComponent(XDebuggerActions.COPY_VALUE, this, this);
+    DebuggerUIUtil.registerActionOnComponent(XDebuggerActions.JUMP_TO_SOURCE, this, this);
+    DebuggerUIUtil.registerActionOnComponent(XDebuggerActions.JUMP_TO_TYPE_SOURCE, this, this);
+    DebuggerUIUtil.registerActionOnComponent(XDebuggerActions.MARK_OBJECT, this, this);
   }
 
   private static void markNodesObsolete(final XValueContainerNode<?> node) {