本文整理汇总了Java中com.intellij.openapi.keymap.impl.KeymapImpl.addShortcut方法的典型用法代码示例。如果您正苦于以下问题:Java KeymapImpl.addShortcut方法的具体用法?Java KeymapImpl.addShortcut怎么用?Java KeymapImpl.addShortcut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.keymap.impl.KeymapImpl
的用法示例。
在下文中一共展示了KeymapImpl.addShortcut方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: quickListRenamed
import com.intellij.openapi.keymap.impl.KeymapImpl; //导入方法依赖的package包/类
@Override
public void quickListRenamed(final QuickList oldQuickList, final QuickList newQuickList){
for (Keymap keymap : getAllKeymaps()) {
KeymapImpl impl = (KeymapImpl)keymap;
String actionId = oldQuickList.getActionId();
String newActionId = newQuickList.getActionId();
Shortcut[] shortcuts = impl.getShortcuts(actionId);
if (shortcuts != null) {
for (Shortcut shortcut : shortcuts) {
impl.removeShortcut(actionId, shortcut);
impl.addShortcut(newActionId, shortcut);
}
}
}
myQuickListsModified = true;
}
示例2: quickListRenamed
import com.intellij.openapi.keymap.impl.KeymapImpl; //导入方法依赖的package包/类
@Override
public void quickListRenamed(final QuickList oldQuickList, final QuickList newQuickList) {
for (Keymap keymap : getAllKeymaps()) {
KeymapImpl impl = (KeymapImpl)keymap;
String actionId = oldQuickList.getActionId();
String newActionId = newQuickList.getActionId();
Shortcut[] shortcuts = impl.getShortcuts(actionId);
if (shortcuts != null) {
for (Shortcut shortcut : shortcuts) {
impl.removeShortcut(actionId, shortcut);
impl.addShortcut(newActionId, shortcut);
}
}
}
myQuickListsModified = true;
}
示例3: setUp
import com.intellij.openapi.keymap.impl.KeymapImpl; //导入方法依赖的package包/类
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) : 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.setName("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]);
}