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


Java KeymapUtil类代码示例

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


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

示例1: getKeyboardShortcutsText

import com.intellij.openapi.keymap.KeymapUtil; //导入依赖的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: testLambdaMarker

import com.intellij.openapi.keymap.KeymapUtil; //导入依赖的package包/类
public void testLambdaMarker() throws Exception {
  configureByFile(getBasePath() + getTestName(false) + ".java");
  int offset = myEditor.getCaretModel().getOffset();

  doHighlighting();
  Document document = getEditor().getDocument();
  List<LineMarkerInfo> markers = DaemonCodeAnalyzerImpl.getLineMarkers(document, getProject());
  for (LineMarkerInfo info : markers) {
    if (info.endOffset >= offset && info.startOffset <= offset) {
      Shortcut shortcut = ActionManager.getInstance().getAction(IdeActions.ACTION_GOTO_SUPER).getShortcutSet().getShortcuts()[0];
      assertEquals(
        "<html><body>Overrides method in <a href=\"#javaClass/I\">I</a><br><div style='margin-top: 5px'><font size='2'>Click or press " +
        KeymapUtil.getShortcutText(shortcut) +
        " to navigate</font></div></body></html>",
        info.getLineMarkerTooltip());
      return;
    }
  }
  fail("Gutter expected");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:JavaGotoSuperTest.java

示例3: update

import com.intellij.openapi.keymap.KeymapUtil; //导入依赖的package包/类
public boolean update() {
  AnActionEvent event = createAnEvent(null, 0);

  if (event == null) return false;

  myAction.update(event);
  Presentation p = event.getPresentation();
  boolean changed = !areEqual(p, myPrevPresentation);

  setIcons(p.getIcon(), p.getDisabledIcon(), p.getHoveredIcon());

  if (changed) {
    myButton.setIcons(this);
    String tooltipText = KeymapUtil.createTooltipText(p.getText(), myAction);
    myButton.setToolTipText(tooltipText.length() > 0 ? tooltipText : null);
    myButton.setVisible(p.isEnabled() && p.isVisible());
  }

  myPrevPresentation = p;

  return changed;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ActionButton.java

示例4: createPopup

import com.intellij.openapi.keymap.KeymapUtil; //导入依赖的package包/类
@NotNull
JBPopup createPopup() {
  JPanel panel = new JPanel(new BorderLayout());
  panel.add(myTextField, BorderLayout.CENTER);
  ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, myTextField)
    .setCancelOnClickOutside(true)
    .setAdText(KeymapUtil.getShortcutsText(CommonShortcuts.CTRL_ENTER.getShortcuts()) + " to finish")
    .setRequestFocus(true)
    .setResizable(true)
    .setMayBeParent(true);

  final JBPopup popup = builder.createPopup();
  popup.setMinimumSize(new Dimension(200, 90));
  AnAction okAction = new DumbAwareAction() {
    @Override
    public void actionPerformed(@NotNull AnActionEvent e) {
      unregisterCustomShortcutSet(popup.getContent());
      popup.closeOk(e.getInputEvent());
    }
  };
  okAction.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, popup.getContent());
  return popup;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:MultilinePopupBuilder.java

示例5: getValueAt

import com.intellij.openapi.keymap.KeymapUtil; //导入依赖的package包/类
public Object getValueAt(Object value, int column) {
  if (!(value instanceof DefaultMutableTreeNode)) {
    return "???";
  }

  if (column == 0) {
    return value;
  }
  else if (column == 1) {
    Object userObject = ((DefaultMutableTreeNode)value).getUserObject();
    if (userObject instanceof QuickList) {
      userObject = ((QuickList)userObject).getActionId();
    }
    return userObject instanceof String ? KeymapUtil.getShortcutsText(myKeymap.getShortcuts((String)userObject)) : "";
  }
  else {
    return "???";
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ActionsTree.java

示例6: ActionButton

import com.intellij.openapi.keymap.KeymapUtil; //导入依赖的package包/类
public ActionButton(AnAction action) {
  myAction = action;

  Presentation presentation = action.getTemplatePresentation();
  InplaceButton button = new InplaceButton(KeymapUtil.createTooltipText(presentation.getText(), action), EmptyIcon.ICON_16, this) {
    @Override
    public boolean isActive() {
      return LightToolWindow.this.isActive();
    }
  };
  button.setHoveringEnabled(!SystemInfo.isMac);
  setContent(button);

  Icon icon = presentation.getIcon();
  Icon hoveredIcon = presentation.getHoveredIcon();
  button.setIcons(icon, icon, hoveredIcon == null ? icon : hoveredIcon);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:LightToolWindow.java

示例7: getAdText

import com.intellij.openapi.keymap.KeymapUtil; //导入依赖的package包/类
@Nullable
protected String getAdText(final Executor alternateExecutor) {
  final PropertiesComponent properties = PropertiesComponent.getInstance();
  if (alternateExecutor != null && !properties.isTrueValue(myAddKey)) {
    return String
      .format("Hold %s to %s", KeymapUtil.getKeystrokeText(KeyStroke.getKeyStroke("SHIFT")), alternateExecutor.getActionName());
  }

  if (!properties.isTrueValue("run.configuration.edit.ad")) {
    return String.format("Press %s to Edit", KeymapUtil.getKeystrokeText(KeyStroke.getKeyStroke("F4")));
  }

  if (!properties.isTrueValue("run.configuration.delete.ad")) {
    return String.format("Press %s to Delete configuration", KeymapUtil.getKeystrokeText(KeyStroke.getKeyStroke("DELETE")));
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ChooseRunConfigurationPopup.java

示例8: createSettingsButton

import com.intellij.openapi.keymap.KeymapUtil; //导入依赖的package包/类
@NotNull
private InplaceButton createSettingsButton(@NotNull final FindUsagesHandler handler,
                                           @NotNull final RelativePoint popupPosition,
                                           final Editor editor,
                                           final int maxUsages,
                                           @NotNull final Runnable cancelAction) {
  String shortcutText = "";
  KeyboardShortcut shortcut = UsageViewImpl.getShowUsagesWithSettingsShortcut();
  if (shortcut != null) {
    shortcutText = "(" + KeymapUtil.getShortcutText(shortcut) + ")";
  }
  return new InplaceButton("Settings..." + shortcutText, AllIcons.General.Settings, new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          showDialogAndFindUsages(handler, popupPosition, editor, maxUsages);
        }
      });
      cancelAction.run();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ShowUsagesAction.java

示例9: TitleIndex

import com.intellij.openapi.keymap.KeymapUtil; //导入依赖的package包/类
TitleIndex() {
  String gotoClass = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction("GotoClass"));
  gotoClassTitle = StringUtil.isEmpty(gotoClass) ? "Classes" : "Classes (" + gotoClass + ")";
  String gotoFile = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction("GotoFile"));
  gotoFileTitle = StringUtil.isEmpty(gotoFile) ? "Files" : "Files (" + gotoFile + ")";
  String gotoAction = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction("GotoAction"));
  gotoActionTitle = StringUtil.isEmpty(gotoAction) ? "Actions" : "Actions (" + gotoAction + ")";
  String gotoSettings = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction("ShowSettings"));
  gotoSettingsTitle = StringUtil.isEmpty(gotoAction) ? ShowSettingsUtil.getSettingsMenuName() : ShowSettingsUtil.getSettingsMenuName() + " (" + gotoSettings + ")";
  String gotoRecentFiles = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction("RecentFiles"));
  gotoRecentFilesTitle = StringUtil.isEmpty(gotoRecentFiles) ? "Recent Files" : "Recent Files (" + gotoRecentFiles + ")";
  String gotoSymbol = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction("GotoSymbol"));
  gotoSymbolTitle = StringUtil.isEmpty(gotoSymbol) ? "Symbols" : "Symbols (" + gotoSymbol + ")";
  String gotoRunConfiguration = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction("ChooseDebugConfiguration"));
  if (StringUtil.isEmpty(gotoRunConfiguration)) {
    gotoRunConfiguration = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction("ChooseRunConfiguration"));
  }
  gotoRunConfigurationsTitle = StringUtil.isEmpty(gotoRunConfiguration) ? "Run Configurations" : "Run Configurations (" + gotoRunConfiguration + ")";
  String gotoStructure = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction("FileStructurePopup"));
  gotoStructureTitle = StringUtil.isEmpty(gotoStructure) ? "File Structure" : "File Structure (" + gotoStructure + ")";
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:SearchEverywhereAction.java

示例10: createActionLabel

import com.intellij.openapi.keymap.KeymapUtil; //导入依赖的package包/类
protected JLabel createActionLabel(AnAction anAction, String anActionName,
                                   Color fg, Color bg,
                                   Icon icon) {
  LayeredIcon layeredIcon = new LayeredIcon(2);
  layeredIcon.setIcon(EMPTY_ICON, 0);
  if (icon != null && icon.getIconWidth() <= EMPTY_ICON.getIconWidth() && icon.getIconHeight() <= EMPTY_ICON.getIconHeight()) {
    layeredIcon
      .setIcon(icon, 1, (-icon.getIconWidth() + EMPTY_ICON.getIconWidth()) / 2, (EMPTY_ICON.getIconHeight() - icon.getIconHeight()) / 2);
  }

  Shortcut shortcut = preferKeyboardShortcut(KeymapManager.getInstance().getActiveKeymap().getShortcuts(getActionId(anAction)));
  String actionName = anActionName + (shortcut != null ? " (" + KeymapUtil.getShortcutText(shortcut) + ")" : "");
  JLabel actionLabel = new JLabel(actionName, layeredIcon, SwingConstants.LEFT);
  actionLabel.setBackground(bg);
  actionLabel.setForeground(fg);
  return actionLabel;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GotoActionModel.java

示例11: ChooseByNamePopup

import com.intellij.openapi.keymap.KeymapUtil; //导入依赖的package包/类
protected ChooseByNamePopup(@Nullable final Project project,
                            @NotNull ChooseByNameModel model,
                            @NotNull ChooseByNameItemProvider provider,
                            @Nullable ChooseByNamePopup oldPopup,
                            @Nullable final String predefinedText,
                            boolean mayRequestOpenInCurrentWindow,
                            int initialIndex) {
  super(project, model, provider, oldPopup != null ? oldPopup.getEnteredText() : predefinedText, initialIndex);
  myOldPopup = oldPopup;
  if (oldPopup != null) { //inherit old focus owner
    myOldFocusOwner = oldPopup.myPreviouslyFocusedComponent;
  }
  myMayRequestCurrentWindow = mayRequestOpenInCurrentWindow;
  myAdText = myMayRequestCurrentWindow ? "Press " +
                                         KeymapUtil.getKeystrokeText(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_MASK)) +
                                         " to open in current window" : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ChooseByNamePopup.java

示例12: ActionButton

import com.intellij.openapi.keymap.KeymapUtil; //导入依赖的package包/类
ActionButton(@NotNull AnAction action) {
  myAction = action;
  Icon icon = action.getTemplatePresentation().getIcon();
  Icon hoveredIcon = action.getTemplatePresentation().getHoveredIcon();
  if (hoveredIcon == null) {
    hoveredIcon = icon;
  }

  String toolTip = KeymapUtil.createTooltipText(action.getTemplatePresentation().getText(), action);
  myButton = new InplaceButton(toolTip, icon, this);

  myButton.setIcons(icon, icon, hoveredIcon);

  myButton.setHoveringEnabled(!SystemInfo.isMac);
  setContent(myButton);
  setOpaque(false);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ToolWindowAlikePanel.java

示例13: LightBulbComponentImpl

import com.intellij.openapi.keymap.KeymapUtil; //导入依赖的package包/类
public LightBulbComponentImpl(@NotNull final QuickFixManager manager, @NotNull final Icon icon) {
  myManager = manager;
  myIcon = icon;

  setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
  final String acceleratorsText = KeymapUtil.getFirstKeyboardShortcutText(
    ActionManager.getInstance().getAction(IdeActions.ACTION_SHOW_INTENTION_ACTIONS));
  if (acceleratorsText.length() > 0) {
    setToolTipText(UIDesignerBundle.message("tooltip.press.accelerator", acceleratorsText));
  }

  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent e, int clickCount) {
      myManager.showIntentionPopup();
      return true;
    }
  }.installOn(this);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:LightBulbComponentImpl.java

示例14: getValueAt

import com.intellij.openapi.keymap.KeymapUtil; //导入依赖的package包/类
public Object getValueAt(Object value, int column) {
  if (!(value instanceof DefaultMutableTreeNode)) {
    return "???";
  }

  if (column == 0) {
    return value;
  }
  else if (column == 1) {
    Object userObject = ((DefaultMutableTreeNode)value).getUserObject();
    if (userObject instanceof QuickList) {
      userObject = ((QuickList)userObject).getActionId();
    }

    if (userObject instanceof String) {
      Shortcut[] shortcuts = myKeymap.getShortcuts((String)userObject);
      return KeymapUtil.getShortcutsText(shortcuts);
    }
    else {
      return "";
    }
  }
  else {
    return "???";
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:ActionsTree.java

示例15: CloseOnESCAction

import com.intellij.openapi.keymap.KeymapUtil; //导入依赖的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


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