Java Code Examples for com.intellij.openapi.keymap.KeymapUtil#getShortcutsText()

The following examples show how to use com.intellij.openapi.keymap.KeymapUtil#getShortcutsText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActionsTree.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 "???";
  }
}
 
Example 2
Source File: RecentLocationsAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static JBCheckBox createCheckbox(@Nonnull ShortcutSet checkboxShortcutSet, boolean showChanged) {
  String text = "<html>" +
                IdeBundle.message("recent.locations.title.text") +
                " <font color=\"" +
                SHORTCUT_HEX_COLOR +
                "\">" +
                KeymapUtil.getShortcutsText(checkboxShortcutSet.getShortcuts()) +
                "</font>" +
                "</html>";
  JBCheckBox checkBox = new JBCheckBox(text);
  checkBox.setBorder(JBUI.Borders.empty());
  checkBox.setOpaque(false);
  checkBox.setSelected(showChanged);

  return checkBox;
}
 
Example 3
Source File: Switcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static String layoutText(@Nonnull String actionId) {
  ShortcutSet shortcuts = getActiveKeymapShortcuts(actionId);
  return "<html>" +
         IdeBundle.message("recent.files.checkbox.label") +
         " <font color=\"" +
         SHORTCUT_HEX_COLOR +
         "\">" +
         KeymapUtil.getShortcutsText(shortcuts.getShortcuts()) +
         "</font>" +
         "</html>";
}
 
Example 4
Source File: DaemonTooltipWithActionRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
private String getKeymap(String key) {
  KeymapManager keymapManager = KeymapManager.getInstance();
  if (keymapManager != null) {
    Keymap keymap = keymapManager.getActiveKeymap();

    return KeymapUtil.getShortcutsText(keymap.getShortcuts(key));
  }

  return "";
}
 
Example 5
Source File: SearchEverywhereAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static String getShortcut() {
  String shortcutText;
  final Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_SEARCH_EVERYWHERE);
  if (shortcuts.length == 0) {
    shortcutText = "Double " + (SystemInfo.isMac ? MacKeymapUtil.SHIFT : "Shift");
  }
  else {
    shortcutText = KeymapUtil.getShortcutsText(shortcuts);
  }
  return shortcutText;
}
 
Example 6
Source File: ContentTabLabel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public String getTooltip() {
  String text = KeymapUtil.getShortcutsText(KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_CLOSE_ACTIVE_TAB));

  return text.isEmpty() || !isSelected() ? ACTION_NAME : ACTION_NAME + " (" + text + ")";
}