private void setFixedColumnWidth(final int columnIndex, String sampleText) {
   final TableColumn column =
       myEntryTable.getTableHeader().getColumnModel().getColumn(columnIndex);
   final FontMetrics fontMetrics = myEntryTable.getFontMetrics(myEntryTable.getFont());
   final int width = fontMetrics.stringWidth(" " + sampleText + " ") + JBUI.scale(4);
   column.setPreferredWidth(width);
   column.setMinWidth(width);
   column.setResizable(false);
 }
  private int setTypeTextLabel(
      LookupElement item,
      final Color background,
      Color foreground,
      final LookupElementPresentation presentation,
      int allowedWidth,
      boolean selected,
      boolean nonFocusedSelection,
      FontMetrics normalMetrics) {
    final String givenText = presentation.getTypeText();
    final String labelText =
        trimLabelText(
            StringUtil.isEmpty(givenText) ? "" : " " + givenText, allowedWidth, normalMetrics);

    int used = RealLookupElementPresentation.getStringWidth(labelText, normalMetrics);

    final Icon icon = presentation.getTypeIcon();
    if (icon != null) {
      myTypeLabel.setIcon(icon);
      used += icon.getIconWidth();
    }

    Color sampleBackground = background;

    Object o = item.isValid() ? item.getObject() : null;
    //noinspection deprecation
    if (o instanceof LookupValueWithUIHint && StringUtil.isEmpty(labelText)) {
      //noinspection deprecation
      Color proposedBackground = ((LookupValueWithUIHint) o).getColorHint();
      if (proposedBackground != null) {
        sampleBackground = proposedBackground;
      }
      myTypeLabel.append("  ");
      used += normalMetrics.stringWidth("WW");
    } else {
      myTypeLabel.append(labelText);
    }

    myTypeLabel.setBackground(sampleBackground);
    myTypeLabel.setForeground(
        getTypeTextColor(item, foreground, presentation, selected, nonFocusedSelection));
    return used;
  }
  private void paintRowData(Tree tree, Object data, Rectangle bounds, Graphics2D g) {
    Shortcut[] shortcuts = null;
    Set<String> abbreviations = null;
    if (data instanceof String) {
      final String actionId = (String) data;
      shortcuts = myKeymap.getShortcuts(actionId);
      abbreviations = AbbreviationManager.getInstance().getAbbreviations(actionId);
    } else if (data instanceof QuickList) {
      shortcuts = myKeymap.getShortcuts(((QuickList) data).getActionId());
    }

    final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);

    int totalWidth = 0;
    final FontMetrics metrics = tree.getFontMetrics(tree.getFont());
    if (shortcuts != null && shortcuts.length > 0) {
      for (Shortcut shortcut : shortcuts) {
        totalWidth += metrics.stringWidth(KeymapUtil.getShortcutText(shortcut));
        totalWidth += 10;
      }
      totalWidth -= 5;

      int x = bounds.x + bounds.width - totalWidth;
      int fontHeight = (int) metrics.getMaxCharBounds(g).getHeight();

      Color c1 = new Color(234, 200, 162);
      Color c2 = new Color(208, 200, 66);

      g.translate(0, bounds.y - 1);

      for (Shortcut shortcut : shortcuts) {
        int width = metrics.stringWidth(KeymapUtil.getShortcutText(shortcut));
        UIUtil.drawSearchMatch(g, x, x + width, bounds.height, c1, c2);
        g.setColor(Gray._50);
        g.drawString(KeymapUtil.getShortcutText(shortcut), x, fontHeight);

        x += width;
        x += 10;
      }
      g.translate(0, -bounds.y + 1);
    }
    if (Registry.is("actionSystem.enableAbbreviations")
        && abbreviations != null
        && abbreviations.size() > 0) {
      for (String abbreviation : abbreviations) {
        totalWidth += metrics.stringWidth(abbreviation);
        totalWidth += 10;
      }
      totalWidth -= 5;

      int x = bounds.x + bounds.width - totalWidth;
      int fontHeight = (int) metrics.getMaxCharBounds(g).getHeight();

      Color c1 = new Color(206, 234, 176);
      Color c2 = new Color(126, 208, 82);

      g.translate(0, bounds.y - 1);

      for (String abbreviation : abbreviations) {
        int width = metrics.stringWidth(abbreviation);
        UIUtil.drawSearchMatch(g, x, x + width, bounds.height, c1, c2);
        g.setColor(Gray._50);
        g.drawString(abbreviation, x, fontHeight);

        x += width;
        x += 10;
      }
      g.translate(0, -bounds.y + 1);
    }

    config.restore();
  }