void (@NotNull String actionId, @NotNull ShortcutRestrictions restrictions, @NotNull Keymap keymapSelected, @NotNull Component parent, @Nullable KeyboardShortcut selectedShortcut, @Nullable SystemShortcuts systemShortcuts, QuickList @NotNull ... quickLists) { if (!restrictions.allowKeyboardShortcut) return; KeyboardShortcutDialog dialog = new KeyboardShortcutDialog(parent, restrictions.allowKeyboardSecondStroke, systemShortcuts == null ? null : systemShortcuts.createKeystroke2SysShortcutMap()); KeyboardShortcut keyboardShortcut = dialog.showAndGet(actionId, keymapSelected, selectedShortcut, quickLists); if (keyboardShortcut == null) return; SafeKeymapAccessor accessor = new SafeKeymapAccessor(parent, keymapSelected); if (dialog.hasConflicts()) { int result = showConfirmationDialog(parent); if (result == Messages.YES) { Keymap keymap = accessor.keymap(); Map<String, List<KeyboardShortcut>> conflicts = keymap.getConflicts(actionId, keyboardShortcut); for (String id : conflicts.keySet()) { for (KeyboardShortcut s : conflicts.get(id)) { keymap.removeShortcut(id, s); } } } else if (result != Messages.NO) { return; } } if (systemShortcuts != null) { // check conflicts with system shortcuts final Keymap keymap = accessor.keymap(); final Map<KeyboardShortcut, String> kscs = systemShortcuts.calculateConflicts(keymap, actionId); if (kscs != null && !kscs.isEmpty()) { for (KeyboardShortcut ksc : kscs.keySet()) { String keyDesc = StringUtil.notNullize(KeymapUtil.getKeystrokeText(ksc.getFirstKeyStroke())); if (ksc.getSecondKeyStroke() != null) keyDesc += ", " + KeymapUtil.getKeystrokeText(ksc.getSecondKeyStroke()); final int result = Messages.showYesNoCancelDialog( parent, IdeBundle.message("message.action.remove.system.assigned.shortcut", keyDesc, kscs.get(ksc)), KeyMapBundle.message("conflict.shortcut.dialog.title"), KeyMapBundle.message("conflict.shortcut.dialog.remove.button"), KeyMapBundle.message("conflict.shortcut.dialog.keep.button"), KeyMapBundle.message("conflict.shortcut.dialog.cancel.button"), Messages.getWarningIcon()); if (result == Messages.YES) { keymap.removeShortcut(actionId, ksc); } } } } accessor.add(actionId, keyboardShortcut); if (systemShortcuts != null) systemShortcuts.updateKeymapConflicts(accessor.keymap()); }