Search in sources :

Example 6 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)

Example 7 with KeymapManager

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

the class ShadowAction method disconnect.

private void disconnect() {
    final KeymapManager mgr = getKeymapManager();
    if (mgr == null)
        return;
    mgr.removeKeymapManagerListener(myKeymapManagerListener);
    if (myKeymap != null) {
        myKeymap.removeShortcutChangeListener(myKeymapListener);
    }
}
Also used : KeymapManager(com.intellij.openapi.keymap.KeymapManager)

Example 8 with KeymapManager

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

the class ShadowAction method rebound.

private void rebound() {
    final KeymapManager mgr = getKeymapManager();
    if (mgr == null)
        return;
    myActionId = ActionManager.getInstance().getId(myCopyFromAction);
    if (myPresentation == null) {
        myAction.copyFrom(myCopyFromAction);
    } else {
        myAction.getTemplatePresentation().copyFrom(myPresentation);
        myAction.copyShortcutFrom(myCopyFromAction);
    }
    unregisterAll();
    myKeymap = mgr.getActiveKeymap();
    myKeymap.addShortcutChangeListener(myKeymapListener);
    if (myActionId == null)
        return;
    final Shortcut[] shortcuts = myKeymap.getShortcuts(myActionId);
    myShortcutSet = new CustomShortcutSet(shortcuts);
    myAction.registerCustomShortcutSet(myShortcutSet, myComponent);
}
Also used : KeymapManager(com.intellij.openapi.keymap.KeymapManager)

Example 9 with KeymapManager

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

the class EditorImpl method isMouseActionEvent.

private static boolean isMouseActionEvent(@NotNull MouseEvent e, String actionId) {
    KeymapManager keymapManager = KeymapManager.getInstance();
    if (keymapManager == null)
        return false;
    Keymap keymap = keymapManager.getActiveKeymap();
    if (keymap == null)
        return false;
    MouseShortcut mouseShortcut = KeymapUtil.createMouseShortcut(e);
    String[] mappedActions = keymap.getActionIds(mouseShortcut);
    if (!ArrayUtil.contains(actionId, mappedActions))
        return false;
    if (mappedActions.length < 2)
        return true;
    ActionManager actionManager = ActionManager.getInstance();
    for (String mappedActionId : mappedActions) {
        if (actionId.equals(mappedActionId))
            continue;
        AnAction action = actionManager.getAction(mappedActionId);
        AnActionEvent actionEvent = AnActionEvent.createFromAnAction(action, e, ActionPlaces.MAIN_MENU, DataManager.getInstance().getDataContext(e.getComponent()));
        if (ActionUtil.lastUpdateAndCheckDumb(action, actionEvent, false))
            return false;
    }
    return true;
}
Also used : KeymapManager(com.intellij.openapi.keymap.KeymapManager) AttributedString(java.text.AttributedString) Keymap(com.intellij.openapi.keymap.Keymap)

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