use of com.intellij.openapi.actionSystem.KeyboardShortcut 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);
}
}
}
use of com.intellij.openapi.actionSystem.KeyboardShortcut in project intellij-community by JetBrains.
the class GrTypeComboBox method registerUpDownHint.
public static void registerUpDownHint(JComponent component, final GrTypeComboBox combo) {
final AnAction arrow = new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
if (e.getInputEvent() instanceof KeyEvent) {
final int code = ((KeyEvent) e.getInputEvent()).getKeyCode();
scrollBy(code == KeyEvent.VK_DOWN ? 1 : code == KeyEvent.VK_UP ? -1 : 0, combo);
}
}
};
final KeyboardShortcut up = new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.ALT_DOWN_MASK), null);
final KeyboardShortcut down = new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.ALT_DOWN_MASK), null);
arrow.registerCustomShortcutSet(new CustomShortcutSet(up, down), component);
}
use of com.intellij.openapi.actionSystem.KeyboardShortcut in project intellij-community by JetBrains.
the class PyStudyInstructionPainter method advertiseActions.
@Override
protected void advertiseActions(@NotNull JComponent splitters, @NotNull UIUtil.TextPainter painter) {
String shortcut = KeymapUtil.getShortcutText(new KeyboardShortcut(KeyStroke.getKeyStroke(StudyNextWindowAction.SHORTCUT2), null));
appendAction(painter, "Navigate to the next answer placeholder", shortcut);
appendAction(painter, "Navigate between answer placeholders", getActionShortcutText(StudyPrevWindowAction.ACTION_ID) + separator + getActionShortcutText(StudyNextWindowAction.ACTION_ID));
appendAction(painter, "Navigate between tasks", getActionShortcutText(StudyPreviousTaskAction.ACTION_ID) + separator + getActionShortcutText(StudyNextTaskAction.ACTION_ID));
appendAction(painter, "Reset current task file", getActionShortcutText(StudyRefreshTaskFileAction.ACTION_ID));
appendAction(painter, "Check task", getActionShortcutText(PyStudyCheckAction.ACTION_ID));
appendAction(painter, "Get hint for the answer placeholder", getActionShortcutText(StudyShowHintAction.ACTION_ID));
}
use of com.intellij.openapi.actionSystem.KeyboardShortcut in project intellij-community by JetBrains.
the class OverrideImplementUtil method registerHandlerForComplementaryAction.
private static void registerHandlerForComplementaryAction(final Project project, final Editor editor, final PsiElement aClass, final boolean toImplement, final MemberChooser<PsiMethodMember> chooser) {
final JComponent preferredFocusedComponent = chooser.getPreferredFocusedComponent();
final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
@NonNls final String s = toImplement ? "OverrideMethods" : "ImplementMethods";
final Shortcut[] shortcuts = keymap.getShortcuts(s);
if (shortcuts.length > 0 && shortcuts[0] instanceof KeyboardShortcut) {
preferredFocusedComponent.getInputMap().put(((KeyboardShortcut) shortcuts[0]).getFirstKeyStroke(), s);
preferredFocusedComponent.getActionMap().put(s, new AbstractAction() {
@Override
public void actionPerformed(final ActionEvent e) {
chooser.close(DialogWrapper.CANCEL_EXIT_CODE);
// invoke later in order to close previous modal dialog
TransactionGuard.getInstance().submitTransactionLater(project, () -> {
CodeInsightActionHandler handler = toImplement ? new OverrideMethodsHandler() : new ImplementMethodsHandler();
handler.invoke(project, editor, aClass.getContainingFile());
});
}
});
}
}
use of com.intellij.openapi.actionSystem.KeyboardShortcut in project intellij-community by JetBrains.
the class KeymapsTestCase method checkLinuxKeymap.
private static void checkLinuxKeymap(final Keymap keymap) {
for (String actionId : keymap.getActionIdList()) {
for (Shortcut shortcut : keymap.getShortcuts(actionId)) {
if (shortcut instanceof KeyboardShortcut) {
checkCtrlAltFn(keymap, shortcut, ((KeyboardShortcut) shortcut).getFirstKeyStroke());
checkCtrlAltFn(keymap, shortcut, ((KeyboardShortcut) shortcut).getSecondKeyStroke());
}
}
}
}
Aggregations