use of com.intellij.openapi.keymap.impl.ActionShortcutRestrictions in project intellij-community by JetBrains.
the class ActionsTreeTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
// create dummy actions
myActionWithoutTextAndDescription = new MyAction(null, null);
myActionWithTextOnly = new MyAction("some text", null);
myActionWithTextAndDescription = new MyAction("text", "description");
myActionExistent = new MyAction("text", "description");
myActionWithUseShortcutOfExistent = new MyAction("text", "description");
myActionWithUseShortcutOfExistentRedefined = new MyAction("text", "description");
myActionWithUseShortcutOfExistentRedefinedInParent = new MyAction("text", "description");
myActionWithUseShortcutOfNonExistent = new MyAction("text", "description");
myActionWithFixedShortcuts = new MyAction("text", "description");
ActionManager actionManager = ActionManager.getInstance();
actionManager.registerAction(ACTION_WITHOUT_TEXT_AND_DESCRIPTION, myActionWithoutTextAndDescription);
actionManager.registerAction(ACTION_WITH_TEXT_ONLY, myActionWithTextOnly);
actionManager.registerAction(ACTION_WITH_TEXT_AND_DESCRIPTION, myActionWithTextAndDescription);
actionManager.registerAction(EXISTENT_ACTION, myActionExistent);
actionManager.registerAction(ACTION_WITH_USE_SHORTCUT_OF_EXISTENT_ACTION, myActionWithUseShortcutOfExistent);
actionManager.registerAction(ACTION_WITH_USE_SHORTCUT_OF_EXISTENT_ACTION_REDEFINED, myActionWithUseShortcutOfExistentRedefined);
actionManager.registerAction(ACTION_WITH_USE_SHORTCUT_OF_EXISTENT_ACTION_REDEFINED_IN_PARENT, myActionWithUseShortcutOfExistentRedefinedInParent);
actionManager.registerAction(ACTION_WITH_USE_SHORTCUT_OF_NON_EXISTENT_ACTION, myActionWithUseShortcutOfNonExistent);
actionManager.registerAction(ACTION_WITH_FIXED_SHORTCUTS, myActionWithFixedShortcuts);
KeymapManagerEx.getInstanceEx().bindShortcuts(EXISTENT_ACTION, ACTION_WITH_USE_SHORTCUT_OF_EXISTENT_ACTION);
KeymapManagerEx.getInstanceEx().bindShortcuts(EXISTENT_ACTION, ACTION_WITH_USE_SHORTCUT_OF_EXISTENT_ACTION_REDEFINED);
KeymapManagerEx.getInstanceEx().bindShortcuts(EXISTENT_ACTION, ACTION_WITH_USE_SHORTCUT_OF_EXISTENT_ACTION_REDEFINED_IN_PARENT);
KeymapManagerEx.getInstanceEx().bindShortcuts(NON_EXISTENT_ACTION, ACTION_WITH_USE_SHORTCUT_OF_NON_EXISTENT_ACTION);
mySavedRestrictions = ActionShortcutRestrictions.getInstance();
setRestrictions(new ActionShortcutRestrictions() {
@NotNull
@Override
public ShortcutRestrictions getForActionId(String actionId) {
return ACTION_WITH_FIXED_SHORTCUTS.equals(actionId) ? new ShortcutRestrictions(false, false, false, false, false, false) : ShortcutRestrictions.NO_RESTRICTIONS;
}
});
assertEquals("$Delete", KeymapManagerEx.getInstanceEx().getActionBinding(ACTION_EDITOR_DELETE_WITH_SHORTCUT));
assertEquals("$Cut", KeymapManagerEx.getInstanceEx().getActionBinding(ACTION_EDITOR_CUT_WITHOUT_SHORTCUT));
assertNotNull(actionManager.getAction(ACTION_EDITOR_DELETE_WITH_SHORTCUT));
assertNotNull(actionManager.getAction(ACTION_EDITOR_CUT_WITHOUT_SHORTCUT));
DefaultActionGroup group = (DefaultActionGroup) actionManager.getAction(IdeActions.GROUP_EDITOR);
group.addAll(myActionWithoutTextAndDescription, myActionWithTextOnly, myActionWithTextAndDescription, myActionExistent, myActionWithUseShortcutOfExistent, myActionWithUseShortcutOfExistentRedefined, myActionWithUseShortcutOfExistentRedefinedInParent, myActionWithUseShortcutOfNonExistent, myActionWithFixedShortcuts);
// populate action tree
myActionsTree = new ActionsTree();
KeyboardShortcut shortcut1 = new KeyboardShortcut(KeyStroke.getKeyStroke('1'), null);
KeyboardShortcut shortcut2 = new KeyboardShortcut(KeyStroke.getKeyStroke('2'), null);
KeymapImpl parent = new KeymapImpl();
parent.addShortcut(ACTION_WITH_USE_SHORTCUT_OF_EXISTENT_ACTION_REDEFINED_IN_PARENT, shortcut1);
parent.setName("parent");
parent.setCanModify(false);
KeymapImpl child = parent.deriveKeymap("child");
child.addShortcut(ACTION_WITH_USE_SHORTCUT_OF_EXISTENT_ACTION_REDEFINED, shortcut2);
child.addShortcut(ACTION_EDITOR_DELETE_WITH_SHORTCUT, shortcut2);
myActionsTree.reset(child, new QuickList[0]);
}
Aggregations