本文整理汇总了Java中com.intellij.openapi.actionSystem.KeyboardShortcut.getSecondKeyStroke方法的典型用法代码示例。如果您正苦于以下问题:Java KeyboardShortcut.getSecondKeyStroke方法的具体用法?Java KeyboardShortcut.getSecondKeyStroke怎么用?Java KeyboardShortcut.getSecondKeyStroke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.actionSystem.KeyboardShortcut
的用法示例。
在下文中一共展示了KeyboardShortcut.getSecondKeyStroke方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setData
import com.intellij.openapi.actionSystem.KeyboardShortcut; //导入方法依赖的package包/类
public void setData(Keymap keymap, KeyboardShortcut shortcut) {
myKeymap = keymap;
myEnableSecondKeystroke.setSelected(false);
if (shortcut != null) {
myFirstStrokePanel.getShortcutTextField().setKeyStroke(shortcut.getFirstKeyStroke());
if (shortcut.getSecondKeyStroke() != null) {
myEnableSecondKeystroke.setSelected(true);
mySecondStrokePanel.getShortcutTextField().setKeyStroke(shortcut.getSecondKeyStroke());
}
}
handleSecondKey();
updateCurrentKeyStrokeInfo();
}
示例2: invokeActionViaKeystroke
import com.intellij.openapi.actionSystem.KeyboardShortcut; //导入方法依赖的package包/类
private void invokeActionViaKeystroke(@NotNull String actionId) {
AnAction action = ActionManager.getInstance().getAction(actionId);
assertNotNull(actionId, action);
assertTrue(actionId + " is not enabled", action.getTemplatePresentation().isEnabled());
Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
Shortcut[] shortcuts = keymap.getShortcuts(actionId);
assertNotNull(shortcuts);
assertThat(shortcuts).isNotEmpty();
Shortcut shortcut = shortcuts[0];
if (shortcut instanceof KeyboardShortcut) {
KeyboardShortcut cs = (KeyboardShortcut)shortcut;
KeyStroke firstKeyStroke = cs.getFirstKeyStroke();
Component component = getFocusedEditor();
if (component != null) {
ComponentDriver driver = new ComponentDriver(robot);
System.out.println("Invoking editor action " + actionId + " via shortcut "
+ KeyEvent.getKeyModifiersText(firstKeyStroke.getModifiers())
+ KeyEvent.getKeyText(firstKeyStroke.getKeyCode()));
driver.pressAndReleaseKey(component, firstKeyStroke.getKeyCode(), new int[]{firstKeyStroke.getModifiers()});
KeyStroke secondKeyStroke = cs.getSecondKeyStroke();
if (secondKeyStroke != null) {
System.out.println(" and "
+ KeyEvent.getKeyModifiersText(secondKeyStroke.getModifiers())
+ KeyEvent.getKeyText(secondKeyStroke.getKeyCode()));
driver.pressAndReleaseKey(component, secondKeyStroke.getKeyCode(), new int[]{secondKeyStroke.getModifiers()});
}
} else {
fail("Editor not focused for action");
}
}
else {
fail("Unsupported shortcut type " + shortcut.getClass().getName());
}
}
示例3: registerForEveryKeyboardShortcut
import com.intellij.openapi.actionSystem.KeyboardShortcut; //导入方法依赖的package包/类
private void registerForEveryKeyboardShortcut(ActionListener action,
@NotNull ShortcutSet shortcuts) {
for (Shortcut shortcut : shortcuts.getShortcuts()) {
if (shortcut instanceof KeyboardShortcut) {
KeyboardShortcut ks = (KeyboardShortcut) shortcut;
KeyStroke first = ks.getFirstKeyStroke();
KeyStroke second = ks.getSecondKeyStroke();
if (second == null) {
getRootPane().registerKeyboardAction(action, first, JComponent.WHEN_IN_FOCUSED_WINDOW);
}
}
}
}