当前位置: 首页>>代码示例>>Java>>正文


Java Keymap.getShortcuts方法代码示例

本文整理汇总了Java中com.intellij.openapi.keymap.Keymap.getShortcuts方法的典型用法代码示例。如果您正苦于以下问题:Java Keymap.getShortcuts方法的具体用法?Java Keymap.getShortcuts怎么用?Java Keymap.getShortcuts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.keymap.Keymap的用法示例。


在下文中一共展示了Keymap.getShortcuts方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getKeyboardShortcutsText

import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:halirutan,项目名称:IntelliJ-Key-Promoter-X,代码行数:22,代码来源:KeyPromoterUtils.java

示例2: getActivateToolWindowVKs

import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
public static Set<Integer> getActivateToolWindowVKs() {
  if (ApplicationManager.getApplication() == null) return new HashSet<Integer>();

  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 QuickAccessSettings.getModifiersVKs(baseModifiers);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ToolWindowManagerImpl.java

示例3: isActionFiltered

import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
public static Condition<AnAction> isActionFiltered(final ActionManager actionManager,
                                                   final Keymap keymap,
                                                   final KeyboardShortcut keyboardShortcut) {
  return new Condition<AnAction>() {
    public boolean value(final AnAction action) {
      if (keyboardShortcut == null) return true;
      if (action == null) return false;
      final Shortcut[] actionShortcuts =
        keymap.getShortcuts(action instanceof ActionStub ? ((ActionStub)action).getId() : actionManager.getId(action));
      for (Shortcut shortcut : actionShortcuts) {
        if (shortcut instanceof KeyboardShortcut) {
          final KeyboardShortcut keyboardActionShortcut = (KeyboardShortcut)shortcut;
          if (Comparing.equal(keyboardActionShortcut, keyboardShortcut)) {
            return true;
          }
        }
      }
      return false;
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ActionsTreeUtil.java

示例4: getMnemonicForToolWindow

import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
/**
 * @return mnemonic for action if it has Alt+digit/Meta+digit shortcut.
 * Otherwise the method returns <code>-1</code>. Meta mask is OK for
 * Mac OS X user, because Alt+digit types strange characters into the
 * editor.
 */
public static int getMnemonicForToolWindow(String id) {
  Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap();
  Shortcut[] shortcuts = activeKeymap.getShortcuts(getActionIdForToolWindow(id));
  for (Shortcut shortcut : shortcuts) {
    if (shortcut instanceof KeyboardShortcut) {
      KeyStroke keyStroke = ((KeyboardShortcut)shortcut).getFirstKeyStroke();
      int modifiers = keyStroke.getModifiers();
      if (
        modifiers == (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK) ||
        modifiers == InputEvent.ALT_MASK ||
        modifiers == InputEvent.ALT_DOWN_MASK ||
        modifiers == (InputEvent.META_DOWN_MASK | InputEvent.META_MASK) ||
        modifiers == InputEvent.META_MASK ||
        modifiers == InputEvent.META_DOWN_MASK
        ) {
        int keyCode = keyStroke.getKeyCode();
        if (KeyEvent.VK_0 <= keyCode && keyCode <= KeyEvent.VK_9) {
          char c = (char)('0' + keyCode - KeyEvent.VK_0);
          return (int)c;
        }
      }
    }
  }
  return -1;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:ActivateToolWindowAction.java

示例5: getShortcuts

import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
@NotNull
private static Set<KeyStroke> getShortcuts(@NotNull String actionId) {
  Set<KeyStroke> result = new HashSet<KeyStroke>();
  Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
  Shortcut[] shortcuts = keymap.getShortcuts(actionId);
  if (shortcuts == null) {
    return result;
  }
  for (Shortcut shortcut : shortcuts) {
    if (shortcut instanceof KeyboardShortcut) {
      KeyboardShortcut keyboardShortcut = (KeyboardShortcut)shortcut;
      result.add(keyboardShortcut.getFirstKeyStroke());
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ChooseByNameBase.java

示例6: getMnemonicForToolWindow

import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
/**
 * @return mnemonic for action if it has Alt+digit/Meta+digit shortcut.
 * Otherwise the method returns <code>-1</code>. Meta mask is OK for
 * Mac OS X user, because Alt+digit types strange characters into the
 * editor.
 */
public static int getMnemonicForToolWindow(String id) {
  Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap();
  Shortcut[] shortcuts = activeKeymap.getShortcuts(getActionIdForToolWindow(id));
  for (Shortcut shortcut : shortcuts) {
    if (shortcut instanceof KeyboardShortcut) {
      KeyStroke keyStroke = ((KeyboardShortcut)shortcut).getFirstKeyStroke();
      int modifiers = keyStroke.getModifiers();
      if (modifiers == (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK) ||
          modifiers == InputEvent.ALT_MASK ||
          modifiers == InputEvent.ALT_DOWN_MASK ||
          modifiers == (InputEvent.META_DOWN_MASK | InputEvent.META_MASK) ||
          modifiers == InputEvent.META_MASK ||
          modifiers == InputEvent.META_DOWN_MASK) {
        int keyCode = keyStroke.getKeyCode();
        if (KeyEvent.VK_0 <= keyCode && keyCode <= KeyEvent.VK_9) {
          char c = (char)('0' + keyCode - KeyEvent.VK_0);
          return (int)c;
        }
      }
    }
  }
  return -1;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:30,代码来源:ActivateToolWindowAction.java

示例7: getShortcuts

import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
@Nonnull
private static Set<KeyStroke> getShortcuts(@Nonnull String actionId) {
  Set<KeyStroke> result = new HashSet<>();
  Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
  Shortcut[] shortcuts = keymap.getShortcuts(actionId);
  if (shortcuts == null) {
    return result;
  }
  for (Shortcut shortcut : shortcuts) {
    if (shortcut instanceof KeyboardShortcut) {
      KeyboardShortcut keyboardShortcut = (KeyboardShortcut)shortcut;
      result.add(keyboardShortcut.getFirstKeyStroke());
    }
  }
  return result;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:ChooseByNameBase.java

示例8: getActivateToolWindowVKs

import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
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);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:DesktopToolWindowManagerImpl.java

示例9: registerHandlerForComplementaryAction

import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
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());
              }
            });
          }
        }
    );
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:OverrideImplementUtil.java

示例10: AbstractAddGroup

import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
protected AbstractAddGroup(String text, Icon icon) {
  super(text, true);

  final Presentation presentation = getTemplatePresentation();
  presentation.setIcon(icon);

  final Keymap active = KeymapManager.getInstance().getActiveKeymap();
  if (active != null) {
    final Shortcut[] shortcuts = active.getShortcuts("NewElement");
    setShortcutSet(new CustomShortcutSet(shortcuts));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:BaseStructureConfigurable.java

示例11: getShortcuts

import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
@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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:ExternalSystemShortcutsManager.java

示例12: isActionChanged

import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
private static boolean isActionChanged(String actionId, Keymap oldKeymap, Keymap newKeymap) {
  if (!newKeymap.canModify()) return false;

  Shortcut[] oldShortcuts = oldKeymap.getShortcuts(actionId);
  Shortcut[] newShortcuts = newKeymap.getShortcuts(actionId);
  return !Comparing.equal(oldShortcuts, newShortcuts);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:ActionsTree.java

示例13: getAdvertisementText

import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
@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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:GrInplaceVariableIntroducer.java

示例14: getShortcuts

import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
@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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:MavenShortcutsManager.java

示例15: addShortcutText

import com.intellij.openapi.keymap.Keymap; //导入方法依赖的package包/类
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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:AntTargetNodeDescriptor.java


注:本文中的com.intellij.openapi.keymap.Keymap.getShortcuts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。