Java 类com.intellij.openapi.actionSystem.Shortcut 实例源码

项目:IntelliJ-Key-Promoter-X    文件:KeyPromoterUtils.java   
/**
 * Uses an actionID to access the key-map of IDEA and find possible short-cuts
 * @param myIdeaActionID ActionID to look the shortcut up
 * @return a string combining one or more shortcuts
 */
static String getKeyboardShortcutsText(String myIdeaActionID) {
    final Keymap activeKeymap = keyMapManager.getActiveKeymap();
    Shortcut[] shortcuts = activeKeymap.getShortcuts(myIdeaActionID);
    if (shortcuts.length == 0) {
        return "";
    }
    StringBuilder buffer = new StringBuilder();
    for (int i = 0; i < shortcuts.length; i++) {
        Shortcut shortcut = shortcuts[i];
        if (i > 0) {
            buffer.append(" or ");
        }
        buffer.append("'").append(KeymapUtil.getShortcutText(shortcut)).append("'");
    }
    return buffer.toString();
}
项目:tools-idea    文件:CloseOnESCAction.java   
public CloseOnESCAction(EditorSearchComponent editorSearchComponent, JComponent textField) {
  super(editorSearchComponent);

  ArrayList<Shortcut> shortcuts = new ArrayList<Shortcut>();
  if (KeymapUtil.isEmacsKeymap()) {
    shortcuts.add(new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_MASK), null));
    textField.registerKeyboardAction(new ActionListener() {
                                       @Override
                                       public void actionPerformed(final ActionEvent e) {
                                         CloseOnESCAction.this.actionPerformed(null);
                                       }
                                     }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_FOCUSED);
  } else {
    shortcuts.add(new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), null));
  }

  registerCustomShortcutSet(new CustomShortcutSet(shortcuts.toArray(new Shortcut[shortcuts.size()])), textField);
}
项目:consulo-terminal    文件:JBTerminalPanel.java   
private static boolean skipAction(KeyEvent e, List<AnAction> actionsToSkip)
{
    if(actionsToSkip != null)
    {
        final KeyboardShortcut eventShortcut = new KeyboardShortcut(KeyStroke.getKeyStrokeForEvent(e), null);
        for(AnAction action : actionsToSkip)
        {
            for(Shortcut sc : action.getShortcutSet().getShortcuts())
            {
                if(sc.isKeyboard() && sc.startsWith(eventShortcut))
                {
                    return true;
                }
            }
        }
    }
    return false;
}
项目:consulo    文件:DesktopToolWindowManagerImpl.java   
public static Set<Integer> getActivateToolWindowVKs() {
  if (ApplicationManager.getApplication() == null) return new HashSet<>();

  Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
  Shortcut[] baseShortcut = keymap.getShortcuts("ActivateProjectToolWindow");
  int baseModifiers = 0;
  for (Shortcut each : baseShortcut) {
    if (each instanceof KeyboardShortcut) {
      KeyStroke keyStroke = ((KeyboardShortcut)each).getFirstKeyStroke();
      baseModifiers = keyStroke.getModifiers();
      if (baseModifiers > 0) {
        break;
      }
    }
  }
  return getModifiersVKs(baseModifiers);
}
项目:idea-php-class-templates    文件:PhpNewExceptionClassDialog.java   
@Override
protected void subInit() {
    super.subInit();

    this.myMessageTextField = new EditorTextField("");
    this.myKindUpDownHint      = new JLabel();
    this.myKindUpDownHint.setIcon(PlatformIcons.UP_DOWN_ARROWS);
    this.myKindUpDownHint.setToolTipText(PhpBundle.message("actions.new.php.base.arrows.kind.tooltip"));


    this.myKindComboBox = new ComboBox<String>();
    this.myKindComboBox.setMinimumAndPreferredWidth(400);
    this.myKindComboBox.setRenderer(new ListCellRendererWrapper<Trinity>() {
        public void customize(JList list, Trinity value, int index, boolean selected, boolean hasFocus) {
            this.setText((String)value.first);
            this.setIcon((Icon)value.second);
        }
    });
    ComboboxSpeedSearch var10001 = new ComboboxSpeedSearch(this.myKindComboBox) {
        protected String getElementText(Object element) {
            return (String)((Trinity)element).first;
        }
    };
    KeyboardShortcut up = new KeyboardShortcut(KeyStroke.getKeyStroke(38, 0), (KeyStroke)null);
    KeyboardShortcut down = new KeyboardShortcut(KeyStroke.getKeyStroke(40, 0), (KeyStroke)null);
    AnAction kindArrow = PhpNewFileDialog.getCbArrowAction(this.myKindComboBox);
    kindArrow.registerCustomShortcutSet(new CustomShortcutSet(new Shortcut[]{up, down}), this.myNameTextField);
    List<Trinity> exceptionTypes = this.getExceptionTypes();

    for(Trinity type : exceptionTypes) {
        this.myKindComboBox.addItem(type);
    }
}
项目:intellij-ce-playground    文件:OverrideImplementUtil.java   
private static void registerHandlerForComplementaryAction(final Project project,
                                                          final Editor editor,
                                                          final PsiElement aClass,
                                                          final boolean toImplement,
                                                          final MemberChooser<PsiMethodMember> chooser) {
  final JComponent preferredFocusedComponent = chooser.getPreferredFocusedComponent();
  final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();

  @NonNls final String s = toImplement ? "OverrideMethods" : "ImplementMethods";
  final Shortcut[] shortcuts = keymap.getShortcuts(s);

  if (shortcuts.length > 0 && shortcuts[0] instanceof KeyboardShortcut) {
    preferredFocusedComponent.getInputMap().put(
      ((KeyboardShortcut)shortcuts[0]).getFirstKeyStroke(), s
    );

    preferredFocusedComponent.getActionMap().put(
        s,
        new AbstractAction() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            chooser.close(DialogWrapper.CANCEL_EXIT_CODE);

            // invoke later in order to close previous modal dialog
            ApplicationManager.getApplication().invokeLater(new Runnable() {
              @Override
              public void run() {
                final CodeInsightActionHandler handler = toImplement ? new OverrideMethodsHandler(): new ImplementMethodsHandler();
                handler.invoke(project, editor, aClass.getContainingFile());
              }
            });
          }
        }
    );
  }
}
项目:intellij-ce-playground    文件:MarkerType.java   
@NotNull
private static String composeText(@NotNull PsiElement[] methods, @NotNull String start, @NotNull String pattern, @NotNull String actionId) {
  Shortcut[] shortcuts = ActionManager.getInstance().getAction(actionId).getShortcutSet().getShortcuts();
  Shortcut shortcut = ArrayUtil.getFirstElement(shortcuts);
  String postfix = "<br><div style='margin-top: 5px'><font size='2'>Click";
  if (shortcut != null) postfix += " or press " + KeymapUtil.getShortcutText(shortcut);
  postfix += " to navigate</font></div>";
  return GutterIconTooltipHelper.composeText(Arrays.asList(methods), start, pattern, postfix);
}
项目:intellij-ce-playground    文件:QuickAccessSettings.java   
private void removeShortcuts(String actionId) {
  Shortcut[] shortcuts = getKeymap().getShortcuts(actionId);
  for (Shortcut each : shortcuts) {
    if (each instanceof KeyboardShortcut) {
      getKeymap().removeShortcut(actionId, each);
    }
  }
}
项目:intellij-ce-playground    文件:ExternalSystemShortcutsManager.java   
@NotNull
private Shortcut[] getShortcuts(@Nullable String projectPath, @Nullable String taskName) {
  String actionId = getActionId(projectPath, taskName);
  if (actionId == null) return Shortcut.EMPTY_ARRAY;
  Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap();
  return activeKeymap.getShortcuts(actionId);
}
项目:intellij-ce-playground    文件:KeymapsTestCase.java   
private static Shortcut parse(String s) {
  String[] sc = s.split(",");
  KeyStroke fst = ActionManagerEx.getKeyStroke(sc[0]);
  assert fst != null : s;
  KeyStroke snd = null;
  if (sc.length == 2) {
    snd = ActionManagerEx.getKeyStroke(sc[1]);
  }
  return new KeyboardShortcut(fst, snd);
}
项目:intellij-ce-playground    文件:KeymapsTestCase.java   
private static String getText(Shortcut shortcut) {
  if (shortcut instanceof KeyboardShortcut) {
    KeyStroke fst = ((KeyboardShortcut)shortcut).getFirstKeyStroke();
    String s = KeymapImpl.getKeyShortcutString(fst);

    KeyStroke snd = ((KeyboardShortcut)shortcut).getSecondKeyStroke();
    if (snd != null) {
      s += "," + KeymapImpl.getKeyShortcutString(snd);
    }
    return s;
  }
  return KeymapUtil.getShortcutText(shortcut);
}
项目:intellij-ce-playground    文件:KeymapsTestCase.java   
private static void checkLinuxKeymap(final Keymap keymap) {
  for (String actionId : keymap.getActionIds()) {
    for (Shortcut shortcut : keymap.getShortcuts(actionId)) {
      if (shortcut instanceof KeyboardShortcut) {
        checkCtrlAltFn(keymap, shortcut, ((KeyboardShortcut)shortcut).getFirstKeyStroke());
        checkCtrlAltFn(keymap, shortcut, ((KeyboardShortcut)shortcut).getSecondKeyStroke());
      }
    }
  }
}
项目:intellij-ce-playground    文件:KeymapsTestCase.java   
private static void checkCtrlAltFn(final Keymap keymap, final Shortcut shortcut, final KeyStroke stroke) {
  if (stroke != null) {
    final int modifiers = stroke.getModifiers();
    final int keyCode = stroke.getKeyCode();
    if (KeyEvent.VK_F1 <= keyCode && keyCode <= KeyEvent.VK_F12 &&
        (modifiers & InputEvent.CTRL_MASK) != 0 && (modifiers & InputEvent.ALT_MASK) != 0 && (modifiers & InputEvent.SHIFT_MASK) == 0) {
      final String message = "Invalid shortcut '" + shortcut + "' for action(s) " + Arrays.asList(keymap.getActionIds(shortcut)) +
                             " in keymap '" + keymap.getName() + "' " +
                             "(Ctrl-Alt-Fn shortcuts switch Linux virtual terminals (causes newbie panic), " +
                             "so either assign another shortcut, or remove it; see Keymap_XWin.xml for reference).";
      TestCase.fail(message);
    }
  }
}
项目:intellij-ce-playground    文件:MacOSDefaultKeymap.java   
protected Shortcut[] getParentShortcuts(String actionId) {
  Shortcut[] parentShortcuts = super.getParentShortcuts(actionId);
  Shortcut[] macShortcuts = new Shortcut[parentShortcuts.length];
  for (int i = 0; i < parentShortcuts.length; i++) {
    macShortcuts[i] = convertShortcutFromParent(parentShortcuts[i]);
  }
  return macShortcuts;
}
项目:intellij-ce-playground    文件:MacOSDefaultKeymap.java   
public static Shortcut convertShortcutFromParent(Shortcut parentShortcut) {
  if (parentShortcut instanceof MouseShortcut) {
    return convertMouseShortcut((MouseShortcut)parentShortcut);
  }

  KeyboardShortcut key = (KeyboardShortcut)parentShortcut;
  return new KeyboardShortcut(convertKeyStroke(key.getFirstKeyStroke()),
                              convertKeyStroke(key.getSecondKeyStroke()));
}
项目:intellij-ce-playground    文件:TipUIUtil.java   
@Nullable
private static String getShortcutText(String actionId, Keymap keymap) {
  for (final Shortcut shortcut : keymap.getShortcuts(actionId)) {
    if (shortcut instanceof KeyboardShortcut) {
      return KeymapUtil.getShortcutText(shortcut);
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:HighlightUsagesHandler.java   
public static String getShortcutText() {
  final Shortcut[] shortcuts = ActionManager.getInstance()
    .getAction(IdeActions.ACTION_HIGHLIGHT_USAGES_IN_FILE)
    .getShortcutSet()
    .getShortcuts();
  if (shortcuts.length == 0) {
    return "<no key assigned>";
  }
  return KeymapUtil.getShortcutText(shortcuts[0]);
}
项目:intellij-ce-playground    文件:GotoTestOrCodeHandler.java   
@Nullable
@Override
protected String getAdText(PsiElement source, int length) {
  if (length > 0 && !TestFinderHelper.isTest(source)) {
    final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
    final Shortcut[] shortcuts = keymap.getShortcuts(DefaultRunExecutor.getRunExecutorInstance().getContextActionId());
    if (shortcuts.length > 0) {
      return ("Press " + KeymapUtil.getShortcutText(shortcuts[0]) + " to run selected tests");
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:InplaceRefactoring.java   
protected void showDialogAdvertisement(final String actionId) {
  final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
  final Shortcut[] shortcuts = keymap.getShortcuts(actionId);
  if (shortcuts.length > 0) {
    setAdvertisementText("Press " + KeymapUtil.getShortcutText(shortcuts[0]) + " to show dialog with more options");
  }
}
项目:intellij-ce-playground    文件:EditorFixture.java   
private void invokeActionViaKeystroke(@NotNull String actionId) {
  AnAction action = ActionManager.getInstance().getAction(actionId);
  assertNotNull(actionId, action);
  assertTrue(actionId + " is not enabled", action.getTemplatePresentation().isEnabled());

  Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
  Shortcut[] shortcuts = keymap.getShortcuts(actionId);
  assertNotNull(shortcuts);
  assertThat(shortcuts).isNotEmpty();
  Shortcut shortcut = shortcuts[0];
  if (shortcut instanceof KeyboardShortcut) {
    KeyboardShortcut cs = (KeyboardShortcut)shortcut;
    KeyStroke firstKeyStroke = cs.getFirstKeyStroke();
    Component component = getFocusedEditor();
    if (component != null) {
      ComponentDriver driver = new ComponentDriver(robot);
      System.out.println("Invoking editor action " + actionId + " via shortcut "
                         + KeyEvent.getKeyModifiersText(firstKeyStroke.getModifiers())
                          + KeyEvent.getKeyText(firstKeyStroke.getKeyCode()));
      driver.pressAndReleaseKey(component, firstKeyStroke.getKeyCode(), new int[]{firstKeyStroke.getModifiers()});
      KeyStroke secondKeyStroke = cs.getSecondKeyStroke();
      if (secondKeyStroke != null) {
        System.out.println(" and "
                           + KeyEvent.getKeyModifiersText(secondKeyStroke.getModifiers())
                           + KeyEvent.getKeyText(secondKeyStroke.getKeyCode()));
        driver.pressAndReleaseKey(component, secondKeyStroke.getKeyCode(), new int[]{secondKeyStroke.getModifiers()});
      }
    } else {
      fail("Editor not focused for action");
    }
  }
  else {
    fail("Unsupported shortcut type " + shortcut.getClass().getName());
  }
}
项目:intellij-ce-playground    文件:AndroidInitialConfigurator.java   
@Nullable
private static KeyboardShortcut removeFirstKeyboardShortcut(Keymap keymap, String actionId) {
  Shortcut[] shortcuts = keymap.getShortcuts(actionId);
  for (Shortcut each : shortcuts) {
    if (each instanceof KeyboardShortcut) {
      keymap.removeShortcut(actionId, each);
      return (KeyboardShortcut)each;
    }
  }

  return null;
}
项目:intellij-ce-playground    文件:MavenShortcutsManager.java   
@NotNull
private Shortcut[] getShortcuts(MavenProject project, String goal) {
  String actionId = getActionId(project.getPath(), goal);
  if (actionId == null) return Shortcut.EMPTY_ARRAY;
  Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap();
  return activeKeymap.getShortcuts(actionId);
}
项目:intellij-ce-playground    文件:AntTargetNodeDescriptor.java   
public static boolean addShortcutText(String actionId, CompositeAppearance appearance) {
  Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap();
  Shortcut[] shortcuts = activeKeymap.getShortcuts(actionId);
  if (shortcuts != null && shortcuts.length > 0) {
    appearance.getEnding().addText(" (" + KeymapUtil.getShortcutText(shortcuts[0]) + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
    return true;
  } else return false;
}
项目:intellij-ce-playground    文件:GrInplaceVariableIntroducer.java   
@Nullable
private static String getAdvertisementText() {
  final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
  final Shortcut[] shortcuts = keymap.getShortcuts("PreviousTemplateVariable");
  if  (shortcuts.length > 0) {
    return "Press " + KeymapUtil.getShortcutText(shortcuts[0]) + " to change type";
  }
  return null;
}
项目:intellij-ce-playground    文件:JBTerminalSystemSettingsProvider.java   
private KeyStroke[] getKeyStrokesByActionId(String actionId) {
  List<KeyStroke> keyStrokes = new ArrayList<KeyStroke>();
  Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(actionId);
  for (Shortcut sc : shortcuts) {
    if (sc instanceof KeyboardShortcut) {
      KeyStroke ks = ((KeyboardShortcut)sc).getFirstKeyStroke();
      keyStrokes.add(ks);
    }
  }

  return keyStrokes.toArray(new KeyStroke[keyStrokes.size()]);
}
项目:aem-ide-tooling-4-intellij    文件:AbstractSlingServerNodeDescriptor.java   
public static boolean addShortcutText(String actionId, CompositeAppearance appearance) {
    Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap();
    Shortcut[] shortcuts = activeKeymap.getShortcuts(actionId);
    if (shortcuts != null && shortcuts.length > 0) {
        appearance.getEnding().addText(" (" + KeymapUtil.getShortcutText(shortcuts[0]) + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
        return true;
    } else return false;
}
项目:tools-idea    文件:OverrideImplementUtil.java   
private static void registerHandlerForComplementaryAction(final Project project,
                                                          final Editor editor,
                                                          final PsiElement aClass,
                                                          final boolean toImplement,
                                                          final MemberChooser<PsiMethodMember> chooser) {
  final JComponent preferredFocusedComponent = chooser.getPreferredFocusedComponent();
  final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();

  @NonNls final String s = toImplement ? "OverrideMethods" : "ImplementMethods";
  final Shortcut[] shortcuts = keymap.getShortcuts(s);

  if (shortcuts.length > 0 && shortcuts[0] instanceof KeyboardShortcut) {
    preferredFocusedComponent.getInputMap().put(
      ((KeyboardShortcut)shortcuts[0]).getFirstKeyStroke(), s
    );

    preferredFocusedComponent.getActionMap().put(
        s,
        new AbstractAction() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            chooser.close(DialogWrapper.CANCEL_EXIT_CODE);

            // invoke later in order to close previous modal dialog
            ApplicationManager.getApplication().invokeLater(new Runnable() {
              @Override
              public void run() {
                final CodeInsightActionHandler handler = toImplement ? new OverrideMethodsHandler(): new ImplementMethodsHandler();
                handler.invoke(project, editor, aClass.getContainingFile());
              }
            });
          }
        }
    );
  }
}
项目:tools-idea    文件:JavaVariableInplaceIntroducer.java   
@Nullable
private static String getAdvertisementText(final boolean hasTypeSuggestion) {
  final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
  if (hasTypeSuggestion) {
    final Shortcut[] shortcuts = keymap.getShortcuts("PreviousTemplateVariable");
    if (shortcuts.length > 0) {
      return "Press " + shortcuts[0] + " to change type";
    }
  }
  return null;
}
项目:tools-idea    文件:QuickAccessSettings.java   
private void removeShortcuts(String actionId) {
  Shortcut[] shortcuts = myKeymap.getShortcuts(actionId);
  for (Shortcut each : shortcuts) {
    if (each instanceof KeyboardShortcut) {
        myKeymap.removeShortcut(actionId, each);
    }
  }
}
项目:tools-idea    文件:KeymapGenerator.java   
@Override
public void main(String[] args) {
  StringBuilder xml = new StringBuilder();
  xml.append("<Keymaps>\n");

  for (Keymap keymap : KeymapManagerEx.getInstanceEx().getAllKeymaps()) {
    xml.append("  <Keymap name=\"").append(keymap.getName()).append("\">\n");
    for (String id : keymap.getActionIds()) {
      String shortcuts = KeymapUtil.getShortcutsText(keymap.getShortcuts(id));
      if (!StringUtil.isEmpty(shortcuts)) {
        xml.append("    <Action id=\"").append(id).append("\">\n");
        for (Shortcut shortcut : keymap.getShortcuts(id)) {
          xml.append("      <Shortcut>").append(KeymapUtil.getShortcutText(shortcut)).append("</Shortcut>\n");
        }
        xml.append("    </Action>\n");
      }
    }
    xml.append("  </Keymap>\n");
  }
  xml.append("</Keymaps>");

  final String path = args.length == 2 ? args[1] : PathManager.getHomePath() + File.separator + "AllKeymaps.xml";

  File out = new File(path);
  try {
    FileUtil.writeToFile(out, xml.toString());
    System.out.println("Saved to: " + out.getAbsolutePath());
  }
  catch (IOException e) {
    e.printStackTrace();
    System.exit(1);
  }
  System.exit(0);
}
项目:tools-idea    文件:EditorsSplitters.java   
private static String getActionShortcutText(final String actionId) {
  final Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(actionId);
  String shortcutText = "";
  for (final Shortcut shortcut : shortcuts) {
    if (shortcut instanceof KeyboardShortcut) {
      shortcutText = KeymapUtil.getShortcutText(shortcut);
      break;
    }
  }

  return shortcutText;
}
项目:tools-idea    文件:MacOSDefaultKeymap.java   
protected Shortcut[] getParentShortcuts(String actionId) {
  Shortcut[] parentShortcuts = super.getParentShortcuts(actionId);
  Shortcut[] macShortcuts = new Shortcut[parentShortcuts.length];
  for (int i = 0; i < parentShortcuts.length; i++) {
    macShortcuts[i] = convertShortcutFromParent(parentShortcuts[i]);
  }
  return macShortcuts;
}
项目:tools-idea    文件:MacOSDefaultKeymap.java   
public static Shortcut convertShortcutFromParent(Shortcut parentShortcut) {
  if (parentShortcut instanceof MouseShortcut) {
    return convertMouseShortcut((MouseShortcut)parentShortcut);
  }

  KeyboardShortcut key = (KeyboardShortcut)parentShortcut;
  return new KeyboardShortcut(convertKeyStroke(key.getFirstKeyStroke()),
                              convertKeyStroke(key.getSecondKeyStroke()));
}
项目:tools-idea    文件:TipUIUtil.java   
@Nullable
private static String getShortcutText(String actionId, Keymap keymap) {
  for (final Shortcut shortcut : keymap.getShortcuts(actionId)) {
    if (shortcut instanceof KeyboardShortcut) {
      return KeymapUtil.getShortcutText(shortcut);
    }
  }
  return null;
}
项目:tools-idea    文件:HighlightUsagesHandler.java   
public static String getShortcutText() {
  final Shortcut[] shortcuts = ActionManager.getInstance()
    .getAction(IdeActions.ACTION_HIGHLIGHT_USAGES_IN_FILE)
    .getShortcutSet()
    .getShortcuts();
  if (shortcuts.length == 0) {
    return "<no key assigned>";
  }
  return KeymapUtil.getShortcutText(shortcuts[0]);
}
项目:tools-idea    文件:CtrlMouseHandler.java   
private static boolean matchMouseShortcut(final Keymap activeKeymap, @JdkConstants.InputEventMask int modifiers, final String actionId) {
  final MouseShortcut syntheticShortcut = new MouseShortcut(MouseEvent.BUTTON1, modifiers, 1);
  for (Shortcut shortcut : activeKeymap.getShortcuts(actionId)) {
    if (shortcut instanceof MouseShortcut) {
      final MouseShortcut mouseShortcut = (MouseShortcut)shortcut;
      if (mouseShortcut.getModifiers() == syntheticShortcut.getModifiers()) {
        return true;
      }
    }
  }
  return false;
}
项目:tools-idea    文件:ReplaceOnEnterAction.java   
public ReplaceOnEnterAction(EditorSearchComponent editorSearchComponent, JComponent textField) {
  super(editorSearchComponent);
  ArrayList<Shortcut> shortcuts = new ArrayList<Shortcut>();
  shortcuts.add(new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), null));

  registerCustomShortcutSet(new CustomShortcutSet(shortcuts.toArray(new Shortcut[shortcuts.size()])), textField);
}
项目:tools-idea    文件:GotoTestOrCodeHandler.java   
@Nullable
@Override
protected String getAdText(PsiElement source, int length) {
  if (length > 0 && !TestFinderHelper.isTest(source)) {
    final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
    final Shortcut[] shortcuts = keymap.getShortcuts(IdeActions.ACTION_DEFAULT_RUNNER);
    if (shortcuts.length > 0) {
      return ("Press " + KeymapUtil.getShortcutText(shortcuts[0]) + " to run selected tests");
    }
  }
  return null;
}
项目:tools-idea    文件:InplaceRefactoring.java   
protected void showDialogAdvertisement(final String actionId) {
  final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
  final Shortcut[] shortcuts = keymap.getShortcuts(actionId);
  if (shortcuts.length > 0) {
    setAdvertisementText("Press " + KeymapUtil.getShortcutText(shortcuts[0]) + " to show dialog with more options");
  }
}
项目:tools-idea    文件:MavenShortcutsManager.java   
public String getDescription(MavenProject project, String goal) {
  String actionId = getActionId(project.getPath(), goal);
  if (actionId == null) return "";

  Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap();
  Shortcut[] shortcuts = activeKeymap.getShortcuts(actionId);
  if (shortcuts == null || shortcuts.length == 0) return "";

  return KeymapUtil.getShortcutsText(shortcuts);
}