public void customizeCellRenderer()

in idea-plugin/src/main/java/com/jetbrains/ide/streamdeck/keymap/ActionsTree.java [533:642]


    public void customizeCellRenderer(@NotNull JTree tree,
                                      Object value,
                                      boolean selected,
                                      boolean expanded,
                                      boolean leaf,
                                      int row,
                                      boolean hasFocus) {
      myRow = row;
      myHaveLink = false;
      myIsSeparator = false;

      @Nullable @Nls String text;
      boolean changed;

      Icon icon = null;
      @NonNls String actionId = null;
      @NonNls String boundId = null;
      @Nls String tooltipText = null;

      DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
      Object userObject = node.getUserObject();
      if (userObject instanceof Group group) {
        actionId = group.getId();
        text = group.getName();
        changed = myKeymap != null && areGroupShortcutsCustomized(group, myKeymap);
        icon = ObjectUtils.chooseNotNull(group.getIcon(), AllIcons.Nodes.Folder);
      }
      else if (userObject instanceof String) {
        actionId = (String)userObject;
        boundId = ((KeymapImpl)myKeymap).hasShortcutDefined(actionId) ? null : ActionManagerEx.getInstanceEx().getActionBinding(actionId);
        AnAction action = ActionManager.getInstance().getAction(actionId);
        text = getActionText(action, actionId, null);
        if (action != null) {
          icon = action.getTemplatePresentation().getIcon();
          tooltipText = action.getTemplatePresentation().getDescription();
        }
        changed = myKeymap != null && isShortcutCustomized(actionId, myKeymap);
      }
      else if (userObject instanceof QuickList list) {
        text = list.getName();
        changed = myKeymap != null && isShortcutCustomized(list.getActionId(), myKeymap);
      }
      else if (userObject instanceof Separator) {
        myIsSeparator = true;
        text = null;
        changed = false;
      }
      else if (userObject instanceof Hyperlink link) {
        // see also XDebuggerTreeRenderer
        myHaveLink = true;
        text = null;
        changed = false;
        icon = link.getIcon();

        myLink.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
        myLink.append(link.getLinkText(), link.getTextAttributes(), link);

        getIpad().right = 0;
        myLink.getIpad().left = 0;

        Rectangle treeVisibleRect = tree.getVisibleRect();
        int rowX = TreeUtil.getNodeRowX(tree, row);
        setupLinkDimensions(treeVisibleRect, rowX);
      }
      else {
        throw new IllegalArgumentException("unknown userObject: " + userObject);
      }

      if (UISettings.getInstance().getShowIconsInMenus()) {
        setIcon(getEvenIcon(icon));
      }

      Color foreground;
      if (selected) {
        foreground = UIUtil.getTreeForeground(true, hasFocus);
      }
      else {
        if (changed) {
          foreground = JBColor.namedColor("Tree.modifiedItemForeground", PlatformColors.BLUE);
        }
        else {
          foreground = UIUtil.getTreeForeground();
        }
      }
      Color background = UIUtil.getTreeBackground(selected, true);

      SearchUtil.appendFragments(myFilter, text, SimpleTextAttributes.STYLE_PLAIN, foreground, background, this);

      if (boundId != null) {
        append(" ");
        append(IdeBundle.message("uses.shortcut.of"), SimpleTextAttributes.GRAY_ATTRIBUTES);
        append(" ");

        String boundText = getActionText(ActionManager.getInstance().getAction(boundId), boundId, actionId);
        append(boundText, GRAY_LINK, new SelectActionRunnable(boundId));
      }

      if (actionId != null && !(userObject instanceof Group group) ) {// && UISettings.getInstance().getShowInplaceCommentsInternal()
        @NlsSafe String pluginName = myPluginNames.get(actionId);
        if (pluginName != null) {
          Group parentGroup = (Group)((DefaultMutableTreeNode)node.getParent()).getUserObject();
          if (pluginName.equals(parentGroup.getName())) pluginName = null;
        }
        append("   ");
        append(pluginName != null ? actionId + " (" + pluginName + ")" : actionId, SimpleTextAttributes.GRAYED_SMALL_ATTRIBUTES);
      }

      setToolTipText(tooltipText);
      putClientProperty(ExpandableItemsHandler.RENDERER_DISABLED, myHaveLink);
    }