Search in sources :

Example 11 with Shortcut

use of com.intellij.openapi.actionSystem.Shortcut in project intellij-plugins by StepicOrg.

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 = deletedShortcuts.computeIfAbsent(keymap, k -> new ArrayList<>());
        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 : KeyboardShortcut(com.intellij.openapi.actionSystem.KeyboardShortcut) KeyboardShortcut(com.intellij.openapi.actionSystem.KeyboardShortcut) StudyActionWithShortcut(org.stepik.core.actions.StudyActionWithShortcut) Shortcut(com.intellij.openapi.actionSystem.Shortcut) KeymapManagerEx(com.intellij.openapi.keymap.ex.KeymapManagerEx) Keymap(com.intellij.openapi.keymap.Keymap) Pair(com.intellij.openapi.util.Pair)

Example 12 with Shortcut

use of com.intellij.openapi.actionSystem.Shortcut in project android by JetBrains.

the class HotswapAction method getShortcutText.

@Nullable
private static String getShortcutText() {
    Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap();
    Shortcut[] shortcuts = activeKeymap.getShortcuts("Android.HotswapChanges");
    return shortcuts.length > 0 ? " (" + KeymapUtil.getShortcutText(shortcuts[0]) + ") " : "";
}
Also used : Shortcut(com.intellij.openapi.actionSystem.Shortcut) Keymap(com.intellij.openapi.keymap.Keymap) Nullable(org.jetbrains.annotations.Nullable)

Example 13 with Shortcut

use of com.intellij.openapi.actionSystem.Shortcut in project intellij-community by JetBrains.

the class GotoTestOrCodeHandler method getAdText.

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

Example 14 with Shortcut

use of com.intellij.openapi.actionSystem.Shortcut in project intellij-community by JetBrains.

the class ShortcutFilteringPanel method setShortcut.

void setShortcut(Shortcut shortcut) {
    Shortcut old = myShortcut;
    if (old != null || shortcut != null) {
        myShortcut = shortcut;
        firePropertyChange("shortcut", old, shortcut);
    }
}
Also used : KeyboardShortcut(com.intellij.openapi.actionSystem.KeyboardShortcut) Shortcut(com.intellij.openapi.actionSystem.Shortcut) MouseShortcut(com.intellij.openapi.actionSystem.MouseShortcut)

Example 15 with Shortcut

use of com.intellij.openapi.actionSystem.Shortcut in project intellij-community by JetBrains.

the class JBTerminalSystemSettingsProviderBase method getKeyStrokesByActionId.

private KeyStroke[] getKeyStrokesByActionId(String actionId) {
    java.util.List<KeyStroke> keyStrokes = new ArrayList<>();
    Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(actionId);
    for (Shortcut sc : shortcuts) {
        if (sc instanceof KeyboardShortcut) {
            KeyStroke ks = ((KeyboardShortcut) sc).getFirstKeyStroke();
            keyStrokes.add(ks);
        }
    }
    return keyStrokes.toArray(new KeyStroke[keyStrokes.size()]);
}
Also used : java.util(java.util) KeyboardShortcut(com.intellij.openapi.actionSystem.KeyboardShortcut) KeyboardShortcut(com.intellij.openapi.actionSystem.KeyboardShortcut) Shortcut(com.intellij.openapi.actionSystem.Shortcut)

Aggregations

Shortcut (com.intellij.openapi.actionSystem.Shortcut)20 Keymap (com.intellij.openapi.keymap.Keymap)14 KeyboardShortcut (com.intellij.openapi.actionSystem.KeyboardShortcut)9 Nullable (org.jetbrains.annotations.Nullable)5 NotNull (org.jetbrains.annotations.NotNull)4 AnAction (com.intellij.openapi.actionSystem.AnAction)3 THashSet (gnu.trove.THashSet)3 ActionManager (com.intellij.openapi.actionSystem.ActionManager)2 KeymapManagerEx (com.intellij.openapi.keymap.ex.KeymapManagerEx)2 MacOSDefaultKeymap (com.intellij.openapi.keymap.impl.MacOSDefaultKeymap)2 FactoryMap (com.intellij.util.containers.FactoryMap)2 THashMap (gnu.trove.THashMap)2 java.util (java.util)2 NonNls (org.jetbrains.annotations.NonNls)2 ThemeEditorComponent (com.android.tools.idea.editors.theme.ThemeEditorComponent)1 CodeInsightActionHandler (com.intellij.codeInsight.CodeInsightActionHandler)1 MouseShortcut (com.intellij.openapi.actionSystem.MouseShortcut)1 ShortcutProvider (com.intellij.openapi.actionSystem.ShortcutProvider)1 ShortcutSet (com.intellij.openapi.actionSystem.ShortcutSet)1 ActionManagerEx (com.intellij.openapi.actionSystem.ex.ActionManagerEx)1