Search in sources :

Example 1 with KeymapManager

use of com.intellij.openapi.keymap.KeymapManager in project kotlin by JetBrains.

the class AndroidLintExternalAnnotator method getShowMoreShortCut.

private String getShowMoreShortCut() {
    if (myShortcutText == null) {
        final KeymapManager keymapManager = KeymapManager.getInstance();
        if (keymapManager != null) {
            final Keymap keymap = keymapManager.getActiveKeymap();
            myShortcutText = keymap == null ? "" : "(" + KeymapUtil.getShortcutsText(keymap.getShortcuts(IdeActions.ACTION_SHOW_ERROR_DESCRIPTION)) + ")";
        } else {
            myShortcutText = "";
        }
    }
    return myShortcutText;
}
Also used : KeymapManager(com.intellij.openapi.keymap.KeymapManager) Keymap(com.intellij.openapi.keymap.Keymap)

Example 2 with KeymapManager

use of com.intellij.openapi.keymap.KeymapManager in project intellij-community by JetBrains.

the class IdeMouseEventDispatcher method fillActionsList.

private void fillActionsList(Component component, MouseShortcut mouseShortcut, boolean isModalContext) {
    myActions.clear();
    // here we try to find "local" shortcuts
    for (; component != null; component = component.getParent()) {
        if (component instanceof JComponent) {
            for (AnAction action : ActionUtil.getActions((JComponent) component)) {
                for (Shortcut shortcut : action.getShortcutSet().getShortcuts()) {
                    if (mouseShortcut.equals(shortcut) && !myActions.contains(action)) {
                        myActions.add(action);
                    }
                }
            }
            // once we've found a proper local shortcut(s), we exit
            if (!myActions.isEmpty()) {
                return;
            }
        }
    }
    // search in main keymap
    KeymapManager keymapManager = KeymapManagerImpl.ourKeymapManagerInitialized ? KeymapManager.getInstance() : null;
    if (keymapManager != null) {
        Keymap keymap = keymapManager.getActiveKeymap();
        ActionManager actionManager = ActionManager.getInstance();
        for (String actionId : keymap.getActionIds(mouseShortcut)) {
            AnAction action = actionManager.getAction(actionId);
            if (action == null || isModalContext && !action.isEnabledInModalContext()) {
                continue;
            }
            if (!myActions.contains(action)) {
                myActions.add(action);
            }
        }
    }
}
Also used : KeymapManager(com.intellij.openapi.keymap.KeymapManager) Keymap(com.intellij.openapi.keymap.Keymap)

Example 3 with KeymapManager

use of com.intellij.openapi.keymap.KeymapManager in project intellij-community by JetBrains.

the class CommonShortcuts method shortcutsById.

@NotNull
private static CustomShortcutSet shortcutsById(String actionId) {
    Application application = ApplicationManager.getApplication();
    KeymapManager keymapManager = application == null ? null : application.getComponent(KeymapManager.class);
    if (keymapManager == null) {
        return new CustomShortcutSet(Shortcut.EMPTY_ARRAY);
    }
    return new CustomShortcutSet(keymapManager.getActiveKeymap().getShortcuts(actionId));
}
Also used : KeymapManager(com.intellij.openapi.keymap.KeymapManager) Application(com.intellij.openapi.application.Application) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with KeymapManager

use of com.intellij.openapi.keymap.KeymapManager in project intellij-community by JetBrains.

the class MacGestureSupportForEditor method fillActionsList.

private void fillActionsList(MouseShortcut mouseShortcut, boolean isModalContext) {
    myActions.clear();
    // search in main keymap
    if (KeymapManagerImpl.ourKeymapManagerInitialized) {
        final KeymapManager keymapManager = KeymapManager.getInstance();
        if (keymapManager != null) {
            final Keymap keymap = keymapManager.getActiveKeymap();
            final String[] actionIds = keymap.getActionIds(mouseShortcut);
            ActionManager actionManager = ActionManager.getInstance();
            for (String actionId : actionIds) {
                AnAction action = actionManager.getAction(actionId);
                if (action == null)
                    continue;
                if (isModalContext && !action.isEnabledInModalContext())
                    continue;
                if (!myActions.contains(action)) {
                    myActions.add(action);
                }
            }
        }
    }
}
Also used : KeymapManager(com.intellij.openapi.keymap.KeymapManager) Keymap(com.intellij.openapi.keymap.Keymap)

Example 5 with KeymapManager

use of com.intellij.openapi.keymap.KeymapManager in project intellij-community by JetBrains.

the class ShadowAction method _connect.

private void _connect() {
    disconnect();
    final KeymapManager mgr = getKeymapManager();
    if (mgr == null)
        return;
    mgr.addKeymapManagerListener(myKeymapManagerListener);
    rebound();
}
Also used : KeymapManager(com.intellij.openapi.keymap.KeymapManager)

Aggregations

KeymapManager (com.intellij.openapi.keymap.KeymapManager)9 Keymap (com.intellij.openapi.keymap.Keymap)5 Application (com.intellij.openapi.application.Application)1 AttributedString (java.text.AttributedString)1 NotNull (org.jetbrains.annotations.NotNull)1