当前位置: 首页>>代码示例>>Java>>正文


Java KeyboardShortcut.getSecondKeyStroke方法代码示例

本文整理汇总了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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:KeyboardShortcutDialog.java

示例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());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:EditorFixture.java

示例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);
      }
    }
  }
}
 
开发者ID:andresdominguez,项目名称:ddescriber,代码行数:14,代码来源:DescriberDialog.java


注:本文中的com.intellij.openapi.actionSystem.KeyboardShortcut.getSecondKeyStroke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。