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


Java Shortcut类代码示例

本文整理汇总了Java中com.intellij.openapi.actionSystem.Shortcut的典型用法代码示例。如果您正苦于以下问题:Java Shortcut类的具体用法?Java Shortcut怎么用?Java Shortcut使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Shortcut类属于com.intellij.openapi.actionSystem包,在下文中一共展示了Shortcut类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getKeyboardShortcutsText

import com.intellij.openapi.actionSystem.Shortcut; //导入依赖的package包/类
/**
 * Uses an actionID to access the key-map of IDEA and find possible short-cuts
 * @param myIdeaActionID ActionID to look the shortcut up
 * @return a string combining one or more shortcuts
 */
static String getKeyboardShortcutsText(String myIdeaActionID) {
    final Keymap activeKeymap = keyMapManager.getActiveKeymap();
    Shortcut[] shortcuts = activeKeymap.getShortcuts(myIdeaActionID);
    if (shortcuts.length == 0) {
        return "";
    }
    StringBuilder buffer = new StringBuilder();
    for (int i = 0; i < shortcuts.length; i++) {
        Shortcut shortcut = shortcuts[i];
        if (i > 0) {
            buffer.append(" or ");
        }
        buffer.append("'").append(KeymapUtil.getShortcutText(shortcut)).append("'");
    }
    return buffer.toString();
}
 
开发者ID:halirutan,项目名称:IntelliJ-Key-Promoter-X,代码行数:22,代码来源:KeyPromoterUtils.java

示例2: CloseOnESCAction

import com.intellij.openapi.actionSystem.Shortcut; //导入依赖的package包/类
public CloseOnESCAction(EditorSearchComponent editorSearchComponent, JComponent textField) {
  super(editorSearchComponent);

  ArrayList<Shortcut> shortcuts = new ArrayList<Shortcut>();
  if (KeymapUtil.isEmacsKeymap()) {
    shortcuts.add(new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_MASK), null));
    textField.registerKeyboardAction(new ActionListener() {
                                       @Override
                                       public void actionPerformed(final ActionEvent e) {
                                         CloseOnESCAction.this.actionPerformed(null);
                                       }
                                     }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_FOCUSED);
  } else {
    shortcuts.add(new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), null));
  }

  registerCustomShortcutSet(new CustomShortcutSet(shortcuts.toArray(new Shortcut[shortcuts.size()])), textField);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:CloseOnESCAction.java

示例3: skipAction

import com.intellij.openapi.actionSystem.Shortcut; //导入依赖的package包/类
private static boolean skipAction(KeyEvent e, List<AnAction> actionsToSkip)
{
	if(actionsToSkip != null)
	{
		final KeyboardShortcut eventShortcut = new KeyboardShortcut(KeyStroke.getKeyStrokeForEvent(e), null);
		for(AnAction action : actionsToSkip)
		{
			for(Shortcut sc : action.getShortcutSet().getShortcuts())
			{
				if(sc.isKeyboard() && sc.startsWith(eventShortcut))
				{
					return true;
				}
			}
		}
	}
	return false;
}
 
开发者ID:consulo,项目名称:consulo-terminal,代码行数:19,代码来源:JBTerminalPanel.java

示例4: getActivateToolWindowVKs

import com.intellij.openapi.actionSystem.Shortcut; //导入依赖的package包/类
public static Set<Integer> getActivateToolWindowVKs() {
  if (ApplicationManager.getApplication() == null) return new HashSet<>();

  Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
  Shortcut[] baseShortcut = keymap.getShortcuts("ActivateProjectToolWindow");
  int baseModifiers = 0;
  for (Shortcut each : baseShortcut) {
    if (each instanceof KeyboardShortcut) {
      KeyStroke keyStroke = ((KeyboardShortcut)each).getFirstKeyStroke();
      baseModifiers = keyStroke.getModifiers();
      if (baseModifiers > 0) {
        break;
      }
    }
  }
  return getModifiersVKs(baseModifiers);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:DesktopToolWindowManagerImpl.java

示例5: subInit

import com.intellij.openapi.actionSystem.Shortcut; //导入依赖的package包/类
@Override
protected void subInit() {
    super.subInit();

    this.myMessageTextField = new EditorTextField("");
    this.myKindUpDownHint      = new JLabel();
    this.myKindUpDownHint.setIcon(PlatformIcons.UP_DOWN_ARROWS);
    this.myKindUpDownHint.setToolTipText(PhpBundle.message("actions.new.php.base.arrows.kind.tooltip"));


    this.myKindComboBox = new ComboBox<String>();
    this.myKindComboBox.setMinimumAndPreferredWidth(400);
    this.myKindComboBox.setRenderer(new ListCellRendererWrapper<Trinity>() {
        public void customize(JList list, Trinity value, int index, boolean selected, boolean hasFocus) {
            this.setText((String)value.first);
            this.setIcon((Icon)value.second);
        }
    });
    ComboboxSpeedSearch var10001 = new ComboboxSpeedSearch(this.myKindComboBox) {
        protected String getElementText(Object element) {
            return (String)((Trinity)element).first;
        }
    };
    KeyboardShortcut up = new KeyboardShortcut(KeyStroke.getKeyStroke(38, 0), (KeyStroke)null);
    KeyboardShortcut down = new KeyboardShortcut(KeyStroke.getKeyStroke(40, 0), (KeyStroke)null);
    AnAction kindArrow = PhpNewFileDialog.getCbArrowAction(this.myKindComboBox);
    kindArrow.registerCustomShortcutSet(new CustomShortcutSet(new Shortcut[]{up, down}), this.myNameTextField);
    List<Trinity> exceptionTypes = this.getExceptionTypes();

    for(Trinity type : exceptionTypes) {
        this.myKindComboBox.addItem(type);
    }
}
 
开发者ID:aurimasniekis,项目名称:idea-php-class-templates,代码行数:34,代码来源:PhpNewExceptionClassDialog.java

示例6: registerHandlerForComplementaryAction

import com.intellij.openapi.actionSystem.Shortcut; //导入依赖的package包/类
private static void registerHandlerForComplementaryAction(final Project project,
                                                          final Editor editor,
                                                          final PsiElement aClass,
                                                          final boolean toImplement,
                                                          final MemberChooser<PsiMethodMember> chooser) {
  final JComponent preferredFocusedComponent = chooser.getPreferredFocusedComponent();
  final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();

  @NonNls final String s = toImplement ? "OverrideMethods" : "ImplementMethods";
  final Shortcut[] shortcuts = keymap.getShortcuts(s);

  if (shortcuts.length > 0 && shortcuts[0] instanceof KeyboardShortcut) {
    preferredFocusedComponent.getInputMap().put(
      ((KeyboardShortcut)shortcuts[0]).getFirstKeyStroke(), s
    );

    preferredFocusedComponent.getActionMap().put(
        s,
        new AbstractAction() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            chooser.close(DialogWrapper.CANCEL_EXIT_CODE);

            // invoke later in order to close previous modal dialog
            ApplicationManager.getApplication().invokeLater(new Runnable() {
              @Override
              public void run() {
                final CodeInsightActionHandler handler = toImplement ? new OverrideMethodsHandler(): new ImplementMethodsHandler();
                handler.invoke(project, editor, aClass.getContainingFile());
              }
            });
          }
        }
    );
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:OverrideImplementUtil.java

示例7: composeText

import com.intellij.openapi.actionSystem.Shortcut; //导入依赖的package包/类
@NotNull
private static String composeText(@NotNull PsiElement[] methods, @NotNull String start, @NotNull String pattern, @NotNull String actionId) {
  Shortcut[] shortcuts = ActionManager.getInstance().getAction(actionId).getShortcutSet().getShortcuts();
  Shortcut shortcut = ArrayUtil.getFirstElement(shortcuts);
  String postfix = "<br><div style='margin-top: 5px'><font size='2'>Click";
  if (shortcut != null) postfix += " or press " + KeymapUtil.getShortcutText(shortcut);
  postfix += " to navigate</font></div>";
  return GutterIconTooltipHelper.composeText(Arrays.asList(methods), start, pattern, postfix);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:MarkerType.java

示例8: removeShortcuts

import com.intellij.openapi.actionSystem.Shortcut; //导入依赖的package包/类
private void removeShortcuts(String actionId) {
  Shortcut[] shortcuts = getKeymap().getShortcuts(actionId);
  for (Shortcut each : shortcuts) {
    if (each instanceof KeyboardShortcut) {
      getKeymap().removeShortcut(actionId, each);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:QuickAccessSettings.java

示例9: getShortcuts

import com.intellij.openapi.actionSystem.Shortcut; //导入依赖的package包/类
@NotNull
private Shortcut[] getShortcuts(@Nullable String projectPath, @Nullable String taskName) {
  String actionId = getActionId(projectPath, taskName);
  if (actionId == null) return Shortcut.EMPTY_ARRAY;
  Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap();
  return activeKeymap.getShortcuts(actionId);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:ExternalSystemShortcutsManager.java

示例10: parse

import com.intellij.openapi.actionSystem.Shortcut; //导入依赖的package包/类
private static Shortcut parse(String s) {
  String[] sc = s.split(",");
  KeyStroke fst = ActionManagerEx.getKeyStroke(sc[0]);
  assert fst != null : s;
  KeyStroke snd = null;
  if (sc.length == 2) {
    snd = ActionManagerEx.getKeyStroke(sc[1]);
  }
  return new KeyboardShortcut(fst, snd);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:KeymapsTestCase.java

示例11: getText

import com.intellij.openapi.actionSystem.Shortcut; //导入依赖的package包/类
private static String getText(Shortcut shortcut) {
  if (shortcut instanceof KeyboardShortcut) {
    KeyStroke fst = ((KeyboardShortcut)shortcut).getFirstKeyStroke();
    String s = KeymapImpl.getKeyShortcutString(fst);

    KeyStroke snd = ((KeyboardShortcut)shortcut).getSecondKeyStroke();
    if (snd != null) {
      s += "," + KeymapImpl.getKeyShortcutString(snd);
    }
    return s;
  }
  return KeymapUtil.getShortcutText(shortcut);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:KeymapsTestCase.java

示例12: checkLinuxKeymap

import com.intellij.openapi.actionSystem.Shortcut; //导入依赖的package包/类
private static void checkLinuxKeymap(final Keymap keymap) {
  for (String actionId : keymap.getActionIds()) {
    for (Shortcut shortcut : keymap.getShortcuts(actionId)) {
      if (shortcut instanceof KeyboardShortcut) {
        checkCtrlAltFn(keymap, shortcut, ((KeyboardShortcut)shortcut).getFirstKeyStroke());
        checkCtrlAltFn(keymap, shortcut, ((KeyboardShortcut)shortcut).getSecondKeyStroke());
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:KeymapsTestCase.java

示例13: checkCtrlAltFn

import com.intellij.openapi.actionSystem.Shortcut; //导入依赖的package包/类
private static void checkCtrlAltFn(final Keymap keymap, final Shortcut shortcut, final KeyStroke stroke) {
  if (stroke != null) {
    final int modifiers = stroke.getModifiers();
    final int keyCode = stroke.getKeyCode();
    if (KeyEvent.VK_F1 <= keyCode && keyCode <= KeyEvent.VK_F12 &&
        (modifiers & InputEvent.CTRL_MASK) != 0 && (modifiers & InputEvent.ALT_MASK) != 0 && (modifiers & InputEvent.SHIFT_MASK) == 0) {
      final String message = "Invalid shortcut '" + shortcut + "' for action(s) " + Arrays.asList(keymap.getActionIds(shortcut)) +
                             " in keymap '" + keymap.getName() + "' " +
                             "(Ctrl-Alt-Fn shortcuts switch Linux virtual terminals (causes newbie panic), " +
                             "so either assign another shortcut, or remove it; see Keymap_XWin.xml for reference).";
      TestCase.fail(message);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:KeymapsTestCase.java

示例14: getParentShortcuts

import com.intellij.openapi.actionSystem.Shortcut; //导入依赖的package包/类
protected Shortcut[] getParentShortcuts(String actionId) {
  Shortcut[] parentShortcuts = super.getParentShortcuts(actionId);
  Shortcut[] macShortcuts = new Shortcut[parentShortcuts.length];
  for (int i = 0; i < parentShortcuts.length; i++) {
    macShortcuts[i] = convertShortcutFromParent(parentShortcuts[i]);
  }
  return macShortcuts;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:MacOSDefaultKeymap.java

示例15: convertShortcutFromParent

import com.intellij.openapi.actionSystem.Shortcut; //导入依赖的package包/类
public static Shortcut convertShortcutFromParent(Shortcut parentShortcut) {
  if (parentShortcut instanceof MouseShortcut) {
    return convertMouseShortcut((MouseShortcut)parentShortcut);
  }

  KeyboardShortcut key = (KeyboardShortcut)parentShortcut;
  return new KeyboardShortcut(convertKeyStroke(key.getFirstKeyStroke()),
                              convertKeyStroke(key.getSecondKeyStroke()));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:MacOSDefaultKeymap.java


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