Java Code Examples for com.intellij.openapi.keymap.Keymap#getShortcuts()
The following examples show how to use
com.intellij.openapi.keymap.Keymap#getShortcuts() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActionsTreeUtil.java From consulo with Apache License 2.0 | 6 votes |
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; } }; }
Example 2
Source File: ActivateToolWindowAction.java From consulo with Apache License 2.0 | 6 votes |
/** * @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; }
Example 3
Source File: DesktopToolWindowManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
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); }
Example 4
Source File: KeyPromoterUtils.java From IntelliJ-Key-Promoter-X with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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; if (mySettings.isShowKeyboardShortcutsOnly()) { shortcuts = Arrays.stream( activeKeymap.getShortcuts(myIdeaActionID) ).filter(Shortcut::isKeyboard).toArray(Shortcut[]::new); } else { 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(); }
Example 5
Source File: AbstractSlingServerNodeDescriptor.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 5 votes |
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; }
Example 6
Source File: ActionsTree.java From consulo with Apache License 2.0 | 5 votes |
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); }
Example 7
Source File: ActionsTreeUtil.java From consulo with Apache License 2.0 | 5 votes |
public static Condition<AnAction> isActionFiltered(final ActionManager actionManager, final Keymap keymap, final Condition<? super Shortcut> predicat) { return action -> { if (action == null) return false; final Shortcut[] actionShortcuts = keymap.getShortcuts(action instanceof ActionStub ? ((ActionStub)action).getId() : actionManager.getId(action)); for (Shortcut actionShortcut : actionShortcuts) { if (predicat.value(actionShortcut)) return true; } return false; }; }
Example 8
Source File: DiffSideView.java From consulo with Apache License 2.0 | 5 votes |
private static boolean isEventHandled(MouseEvent e) { Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap(); Shortcut[] shortcuts = activeKeymap.getShortcuts(IdeActions.ACTION_GOTO_DECLARATION); for (Shortcut shortcut : shortcuts) { if (shortcut instanceof MouseShortcut) { return ((MouseShortcut)shortcut).getButton() == e.getButton() && ((MouseShortcut)shortcut).getModifiers() == e.getModifiersEx(); } } return false; }
Example 9
Source File: TipUIUtil.java From consulo with Apache License 2.0 | 5 votes |
@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; }
Example 10
Source File: BaseStructureConfigurableNoDaemon.java From consulo with Apache License 2.0 | 5 votes |
protected AbstractAddGroup(String text, Image 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)); } }
Example 11
Source File: BaseStructureConfigurable.java From consulo with Apache License 2.0 | 5 votes |
protected AbstractAddGroup(String text, Image 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)); } }
Example 12
Source File: GotoTestOrCodeHandler.java From consulo with Apache License 2.0 | 5 votes |
@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; }
Example 13
Source File: InplaceRefactoring.java From consulo with Apache License 2.0 | 5 votes |
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"); } }
Example 14
Source File: ConsoleViewImpl.java From consulo with Apache License 2.0 | 4 votes |
private static void registerActionHandler(@Nonnull Editor editor, @Nonnull String actionId, @Nonnull AnAction action) { final Keymap keymap = KeymapManager.getInstance().getActiveKeymap(); final Shortcut[] shortcuts = keymap.getShortcuts(actionId); action.registerCustomShortcutSet(new CustomShortcutSet(shortcuts), editor.getContentComponent()); }