Search in sources :

Example 1 with Keymap

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

the class PyCharmEduInitialConfigurator method patchKeymap.

private static void patchKeymap() {
    Set<String> droppedActions = ContainerUtil.newHashSet("AddToFavoritesPopup", "DatabaseView.ImportDataSources", "CompileDirty", "Compile", // hidden
    "AddNewFavoritesList", "EditFavorites", "RenameFavoritesList", "RemoveFavoritesList");
    KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
    for (Keymap keymap : keymapManager.getAllKeymaps()) {
        if (keymap.canModify())
            continue;
        KeymapImpl keymapImpl = (KeymapImpl) keymap;
        for (String id : keymapImpl.getOwnActionIds()) {
            if (droppedActions.contains(id))
                keymapImpl.clearOwnActionsId(id);
        }
    }
}
Also used : KeymapImpl(com.intellij.openapi.keymap.impl.KeymapImpl) KeymapManagerEx(com.intellij.openapi.keymap.ex.KeymapManagerEx) Keymap(com.intellij.openapi.keymap.Keymap)

Example 2 with Keymap

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

the class MavenShortcutsManager method getShortcuts.

@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);
}
Also used : Keymap(com.intellij.openapi.keymap.Keymap) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with Keymap

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

the class GrInplaceVariableIntroducer method getAdvertisementText.

@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;
}
Also used : Shortcut(com.intellij.openapi.actionSystem.Shortcut) Keymap(com.intellij.openapi.keymap.Keymap) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with Keymap

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

the class StudyProjectComponent method addShortcut.

private void addShortcut(@NotNull final String actionIdString, @NotNull final String[] shortcuts) {
    KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
    for (Keymap keymap : keymapManager.getAllKeymaps()) {
        List<Pair<String, String>> pairs = myDeletedShortcuts.get(keymap);
        if (pairs == null) {
            pairs = new ArrayList<>();
            myDeletedShortcuts.put(keymap, pairs);
        }
        for (String shortcutString : shortcuts) {
            Shortcut studyActionShortcut = new KeyboardShortcut(KeyStroke.getKeyStroke(shortcutString), null);
            String[] actionsIds = keymap.getActionIds(studyActionShortcut);
            for (String actionId : actionsIds) {
                pairs.add(Pair.create(actionId, shortcutString));
                keymap.removeShortcut(actionId, studyActionShortcut);
            }
            keymap.addShortcut(actionIdString, studyActionShortcut);
        }
    }
}
Also used : StudyActionWithShortcut(com.jetbrains.edu.learning.actions.StudyActionWithShortcut) KeymapManagerEx(com.intellij.openapi.keymap.ex.KeymapManagerEx) Keymap(com.intellij.openapi.keymap.Keymap) Pair(com.intellij.openapi.util.Pair)

Example 5 with Keymap

use of com.intellij.openapi.keymap.Keymap in project ideavim by JetBrains.

the class KeyGroup method getKeymapActions.

@NotNull
private static List<AnAction> getKeymapActions(@NotNull KeyStroke keyStroke) {
    final List<AnAction> results = new ArrayList<AnAction>();
    final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
    for (String id : keymap.getActionIds(keyStroke)) {
        final AnAction action = ActionManager.getInstance().getAction(id);
        if (action != null) {
            results.add(action);
        }
    }
    return results;
}
Also used : Keymap(com.intellij.openapi.keymap.Keymap) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Keymap (com.intellij.openapi.keymap.Keymap)48 Shortcut (com.intellij.openapi.actionSystem.Shortcut)14 KeymapManagerEx (com.intellij.openapi.keymap.ex.KeymapManagerEx)10 NotNull (org.jetbrains.annotations.NotNull)10 KeyboardShortcut (com.intellij.openapi.actionSystem.KeyboardShortcut)7 Nullable (org.jetbrains.annotations.Nullable)7 AnAction (com.intellij.openapi.actionSystem.AnAction)6 KeymapManager (com.intellij.openapi.keymap.KeymapManager)6 ActionManager (com.intellij.openapi.actionSystem.ActionManager)4 MacOSDefaultKeymap (com.intellij.openapi.keymap.impl.MacOSDefaultKeymap)4 Pair (com.intellij.openapi.util.Pair)4 FactoryMap (com.intellij.util.containers.FactoryMap)4 THashMap (gnu.trove.THashMap)4 THashSet (gnu.trove.THashSet)4 NonNls (org.jetbrains.annotations.NonNls)3 DefaultKeymap (com.intellij.openapi.keymap.impl.DefaultKeymap)2 KeymapImpl (com.intellij.openapi.keymap.impl.KeymapImpl)2 KeymapManagerImpl (com.intellij.openapi.keymap.impl.KeymapManagerImpl)2 ToolWindow (com.intellij.openapi.wm.ToolWindow)2 KeyEvent (java.awt.event.KeyEvent)2