Example usage for com.intellij.openapi.actionSystem.ex ActionUtil getActions

List of usage examples for com.intellij.openapi.actionSystem.ex ActionUtil getActions

Introduction

In this page you can find the example usage for com.intellij.openapi.actionSystem.ex ActionUtil getActions.

Prototype

@NotNull
    public static List<AnAction> getActions(@NotNull JComponent component) 

Source Link

Usage

From source file:com.maddyhome.idea.vim.group.KeyGroup.java

License:Open Source License

@NotNull
private static List<AnAction> getLocalActions(@NotNull Component component, @NotNull KeyStroke keyStroke) {
    final List<AnAction> results = new ArrayList<AnAction>();
    final KeyboardShortcut keyStrokeShortcut = new KeyboardShortcut(keyStroke, null);
    for (Component c = component; c != null; c = c.getParent()) {
        if (c instanceof JComponent) {
            final List<AnAction> actions = ActionUtil.getActions((JComponent) c);
            for (AnAction action : actions) {
                if (action instanceof VimShortcutKeyAction) {
                    continue;
                }//  w  w w  .j a  va  2s . co m
                final com.intellij.openapi.actionSystem.Shortcut[] shortcuts = action.getShortcutSet()
                        .getShortcuts();
                for (com.intellij.openapi.actionSystem.Shortcut shortcut : shortcuts) {
                    if (shortcut.isKeyboard() && shortcut.startsWith(keyStrokeShortcut)
                            && !results.contains(action)) {
                        results.add(action);
                    }
                }
            }
        }
    }
    return results;
}