@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();
         }
       });
 }
  protected JLabel createActionLabel(
      final AnAction anAction,
      final String anActionName,
      final Color fg,
      final Color bg,
      final Icon icon) {
    final 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);
    }

    final Shortcut[] shortcutSet =
        KeymapManager.getInstance().getActiveKeymap().getShortcuts(getActionId(anAction));
    final String actionName =
        anActionName
            + (shortcutSet != null && shortcutSet.length > 0
                ? " (" + KeymapUtil.getShortcutText(shortcutSet[0]) + ")"
                : "");
    final JLabel actionLabel = new JLabel(actionName, layeredIcon, SwingConstants.LEFT);
    actionLabel.setBackground(bg);
    actionLabel.setForeground(fg);
    return actionLabel;
  }
 @Nullable
 private static String getShortcutText(String actionId, Keymap keymap) {
   for (final Shortcut shortcut : keymap.getShortcuts(actionId)) {
     if (shortcut instanceof KeyboardShortcut) {
       return KeymapUtil.getShortcutText(shortcut);
     }
   }
   return null;
 }
  @Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);

    if (myCurrentWindow == null || myCurrentWindow.getFiles().length == 0) {
      g.setColor(UIUtil.isUnderDarcula() ? UIUtil.getBorderColor() : new Color(0, 0, 0, 50));
      g.drawLine(0, 0, getWidth(), 0);
    }

    if (showEmptyText()) {
      UIUtil.applyRenderingHints(g);
      g.setColor(new JBColor(Gray._100, Gray._160));
      g.setFont(UIUtil.getLabelFont().deriveFont(UIUtil.isUnderDarcula() ? 24f : 18f));

      final UIUtil.TextPainter painter =
          new UIUtil.TextPainter().withShadow(true).withLineSpacing(1.4f);
      painter.appendLine("No files are open").underlined(new JBColor(Gray._150, Gray._100));

      if (!isProjectViewVisible()) {
        painter
            .appendLine(
                "Open Project View with "
                    + KeymapUtil.getShortcutText(
                        new KeyboardShortcut(
                            KeyStroke.getKeyStroke((SystemInfo.isMac ? "meta" : "alt") + " 1"),
                            null)))
            .smaller()
            .withBullet();
      }

      painter
          .appendLine("Open a file by name with " + getActionShortcutText("GotoFile"))
          .smaller()
          .withBullet()
          .appendLine(
              "Open Recent files with " + getActionShortcutText(IdeActions.ACTION_RECENT_FILES))
          .smaller()
          .withBullet()
          .appendLine("Open Navigation Bar with " + getActionShortcutText("ShowNavBar"))
          .smaller()
          .withBullet()
          .appendLine("Drag'n'Drop file(s) here from " + ShowFilePathAction.getFileManagerName())
          .smaller()
          .withBullet()
          .draw(
              g,
              new PairFunction<Integer, Integer, Pair<Integer, Integer>>() {
                @Override
                public Pair<Integer, Integer> fun(Integer width, Integer height) {
                  final Dimension s = getSize();
                  return Pair.create((s.width - width) / 2, (s.height - height) / 2);
                }
              });
    }
  }
  private static String getActionShortcutText(final String actionId) {
    final Shortcut[] shortcuts =
        KeymapManager.getInstance().getActiveKeymap().getShortcuts(actionId);
    String shortcutText = "";
    for (final Shortcut shortcut : shortcuts) {
      if (shortcut instanceof KeyboardShortcut) {
        shortcutText = KeymapUtil.getShortcutText(shortcut);
        break;
      }
    }

    return shortcutText;
  }
 @Nullable
 private static String getSecondInvocationTitle(
     @NotNull FindUsagesOptions options, @NotNull FindUsagesHandler handler) {
   if (getShowUsagesShortcut() != null) {
     GlobalSearchScope maximalScope = FindUsagesManager.getMaximalScope(handler);
     if (!notNullizeScope(options, handler.getProject()).equals(maximalScope)) {
       return "Press "
           + KeymapUtil.getShortcutText(getShowUsagesShortcut())
           + " again to search in "
           + maximalScope.getDisplayName();
     }
   }
   return null;
 }
 @Override
 protected void customizeCellRenderer(
     final JList list,
     final Object value,
     final int index,
     final boolean selected,
     final boolean hasFocus) {
   if (value == null) return;
   if (value instanceof Pair) {
     final Pair<AnAction, KeyStroke> pair = (Pair<AnAction, KeyStroke>) value;
     append(
         KeymapUtil.getShortcutText(new KeyboardShortcut(pair.getSecond(), null)),
         SimpleTextAttributes.GRAY_ATTRIBUTES);
     appendAlign(30);
     final String text = pair.getFirst().getTemplatePresentation().getText();
     append(text, SimpleTextAttributes.REGULAR_ATTRIBUTES);
   }
 }
  private void addCheckbox(final JPanel panel, final TreeAction action) {
    String text =
        action instanceof FileStructureFilter
            ? ((FileStructureFilter) action).getCheckBoxText()
            : action instanceof FileStructureNodeProvider
                ? ((FileStructureNodeProvider) action).getCheckBoxText()
                : null;

    if (text == null) return;

    Shortcut[] shortcuts =
        action instanceof FileStructureFilter
            ? ((FileStructureFilter) action).getShortcut()
            : ((FileStructureNodeProvider) action).getShortcut();

    final JCheckBox chkFilter = new JCheckBox();
    UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, chkFilter);

    final boolean selected = getDefaultValue(action);
    chkFilter.setSelected(selected);
    myTreeActionsOwner.setActionIncluded(
        action, action instanceof FileStructureFilter ? !selected : selected);
    chkFilter.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            final boolean state = chkFilter.isSelected();
            if (!myAutoClicked.contains(chkFilter)) {
              saveState(action, state);
            }
            myTreeActionsOwner.setActionIncluded(
                action, action instanceof FileStructureFilter ? !state : state);
            // final String filter = mySpeedSearch.isPopupActive() ?
            // mySpeedSearch.getEnteredPrefix() : null;
            // mySpeedSearch.hidePopup();
            Object selection =
                ContainerUtil.getFirstItem(myAbstractTreeBuilder.getSelectedElements());
            if (selection instanceof FilteringTreeStructure.FilteringNode) {
              selection = ((FilteringTreeStructure.FilteringNode) selection).getDelegate();
            }
            myTreeStructure.rebuildTree();
            myFilteringStructure.rebuild();

            final Object sel = selection;
            final Runnable runnable =
                new Runnable() {
                  public void run() {
                    ApplicationManager.getApplication()
                        .runReadAction(
                            new Runnable() {
                              @Override
                              public void run() {
                                myAbstractTreeBuilder
                                    .refilter(sel, true, false)
                                    .doWhenProcessed(
                                        new Runnable() {
                                          @Override
                                          public void run() {
                                            if (mySpeedSearch.isPopupActive()) {
                                              mySpeedSearch.refreshSelection();
                                            }
                                          }
                                        });
                              }
                            });
                  }
                };
            if (ApplicationManager.getApplication().isUnitTestMode()) {
              runnable.run();
            } else {
              ApplicationManager.getApplication().invokeLater(runnable);
            }
          }
        });
    chkFilter.setFocusable(false);

    if (shortcuts.length > 0) {
      text += " (" + KeymapUtil.getShortcutText(shortcuts[0]) + ")";
      new AnAction() {
        public void actionPerformed(final AnActionEvent e) {
          chkFilter.doClick();
        }
      }.registerCustomShortcutSet(new CustomShortcutSet(shortcuts), myTree);
    }
    chkFilter.setText(text);
    panel.add(chkFilter);
    myCheckBoxes.put(action.getClass(), chkFilter);
  }
  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();
  }