public void initComponent() { myModifiersValue = Registry.get("actionSystem.quickAccessModifiers"); myModifiersValue.addListener( new RegistryValueListener.Adapter() { public void afterValueChanged(RegistryValue value) { applyModifiersFromRegistry(); } }, this); KeymapManager kmMgr = KeymapManager.getInstance(); kmMgr.addKeymapManagerListener(this); activeKeymapChanged(kmMgr.getActiveKeymap()); applyModifiersFromRegistry(); }
private void fillActionsList( Component component, MouseShortcut mouseShortcut, boolean isModalContext) { myActions.clear(); // here we try to find "local" shortcuts 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 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); } } } } }
public void activeKeymapChanged(Keymap keymap) { KeymapManager mgr = KeymapManager.getInstance(); myKeymap = mgr.getActiveKeymap(); }