public void customizeCellRenderer(
        JTree tree,
        Object value,
        boolean selected,
        boolean expanded,
        boolean leaf,
        int row,
        boolean hasFocus) {
      if (value instanceof PackageDependenciesNode) {
        PackageDependenciesNode node = (PackageDependenciesNode) value;
        setIcon(node.getIcon());

        setForeground(
            selected && hasFocus
                ? UIUtil.getTreeSelectionForeground()
                : UIUtil.getTreeForeground());
        if (!(selected && hasFocus)
            && node.hasMarked()
            && !DependencyUISettings.getInstance().UI_FILTER_LEGALS) {
          setForeground(node.hasUnmarked() ? PARTIAL_INCLUDED : WHOLE_INCLUDED);
        }
        append(node.toString(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
        final String locationString = node.getComment();
        if (!StringUtil.isEmpty(locationString)) {
          append(" (" + locationString + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
        }
      }
    }
  public Component getTreeCellRendererComponent(
      JTree tree,
      Object value,
      boolean selected,
      boolean expanded,
      boolean leaf,
      int row,
      boolean hasFocus) {
    setText(tree.convertValueToText(value, selected, expanded, leaf, row, hasFocus));
    setFont(UIUtil.getTreeFont());
    setIcon(null);

    if (WideSelectionTreeUI.isWideSelection(tree)) {
      setOpaque(false);
      myIsSelected = false;
      myHasFocus = false;
      setDoNotHighlight(selected && hasFocus);
      setForeground(
          selected && hasFocus ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeForeground());
    } else {
      setOpaque(true);
      myIsSelected = selected;
      myHasFocus = hasFocus;
      setDoNotHighlight(false);
    }

    myHasFocus = hasFocus;
    return this;
  }
    public Component getTreeCellRendererComponent(
        JTree tree,
        Object value,
        boolean sel,
        boolean expanded,
        boolean leaf,
        int row,
        boolean hasFocus) {
      super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
      if (value instanceof DefaultMutableTreeNode) {
        Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
        Icon icon = null;
        if (userObject instanceof Group) {
          Group group = (Group) userObject;
          String name = group.getName();
          setText(name != null ? name : group.getId());
          icon = group.getIcon();
          if (icon == null) {
            icon = getClosedIcon();
          }
        } else if (userObject instanceof String) {
          String actionId = (String) userObject;
          AnAction action = ActionManager.getInstance().getAction(actionId);
          String name = action != null ? action.getTemplatePresentation().getText() : null;
          setText(!StringUtil.isEmptyOrSpaces(name) ? name : actionId);
          if (action != null) {
            Icon actionIcon = action.getTemplatePresentation().getIcon();
            if (actionIcon != null) {
              icon = actionIcon;
            }
          }
        } else if (userObject instanceof Pair) {
          String actionId = (String) ((Pair) userObject).first;
          AnAction action = ActionManager.getInstance().getAction(actionId);
          setText(action != null ? action.getTemplatePresentation().getText() : actionId);
          icon = (Icon) ((Pair) userObject).second;
        } else if (userObject instanceof Separator) {
          setText("-------------");
        } else if (userObject instanceof QuickList) {
          setText(((QuickList) userObject).getDisplayName());
          icon = AllIcons.Actions.QuickList;
        } else {
          throw new IllegalArgumentException("unknown userObject: " + userObject);
        }

        setIcon(ActionsTree.getEvenIcon(icon));

        if (sel) {
          setForeground(UIUtil.getTreeSelectionForeground());
        } else {
          setForeground(UIUtil.getTreeForeground());
        }
      }
      return this;
    }
 /**
  * When the item is selected then we use default tree's selection foreground. It guaranties
  * readability of selected text in any LAF.
  */
 @Override
 public void append(
     @NotNull @Nls String fragment, @NotNull SimpleTextAttributes attributes, boolean isMainText) {
   if (mySelected && isFocused()) {
     super.append(
         fragment,
         new SimpleTextAttributes(attributes.getStyle(), UIUtil.getTreeSelectionForeground()),
         isMainText);
   } else if (mySelected && UIUtil.isUnderAquaBasedLookAndFeel()) {
     super.append(
         fragment,
         new SimpleTextAttributes(attributes.getStyle(), UIUtil.getTreeForeground()),
         isMainText);
   } else {
     super.append(fragment, attributes, isMainText);
   }
 }
    // Make sure that the text rendered by this method is 'searchable' via
    // com.intellij.openapi.keymap.impl.ui.ActionsTree.filter method.
    public void customizeCellRenderer(
        JTree tree,
        Object value,
        boolean selected,
        boolean expanded,
        boolean leaf,
        int row,
        boolean hasFocus) {
      final boolean showIcons = UISettings.getInstance().SHOW_ICONS_IN_MENUS;
      Keymap originalKeymap = myKeymap != null ? myKeymap.getParent() : null;
      Icon icon = null;
      String text;
      boolean bound = false;
      setToolTipText(null);

      if (value instanceof DefaultMutableTreeNode) {
        Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
        boolean changed;
        if (userObject instanceof Group) {
          Group group = (Group) userObject;
          text = group.getName();

          changed = originalKeymap != null && isGroupChanged(group, originalKeymap, myKeymap);
          icon = group.getIcon();
          if (icon == null) {
            icon = CLOSE_ICON;
          }
        } else if (userObject instanceof String) {
          String actionId = (String) userObject;
          bound = myShowBoundActions && ((KeymapImpl) myKeymap).isActionBound(actionId);
          AnAction action = ActionManager.getInstance().getAction(actionId);
          if (action != null) {
            text = action.getTemplatePresentation().getText();
            if (text == null || text.length() == 0) { // fill dynamic presentation gaps
              text = actionId;
            }
            Icon actionIcon = action.getTemplatePresentation().getIcon();
            if (actionIcon != null) {
              icon = actionIcon;
            }
            setToolTipText(action.getTemplatePresentation().getDescription());
          } else {
            text = actionId;
          }
          changed = originalKeymap != null && isActionChanged(actionId, originalKeymap, myKeymap);
        } else if (userObject instanceof QuickList) {
          QuickList list = (QuickList) userObject;
          icon = AllIcons.Actions.QuickList;
          text = list.getDisplayName();

          changed =
              originalKeymap != null
                  && isActionChanged(list.getActionId(), originalKeymap, myKeymap);
        } else if (userObject instanceof Separator) {
          // TODO[vova,anton]: beautify
          changed = false;
          text = "-------------";
        } else {
          throw new IllegalArgumentException("unknown userObject: " + userObject);
        }

        if (showIcons) {
          setIcon(ActionsTree.getEvenIcon(icon));
        }

        Color foreground;
        if (selected) {
          foreground = UIUtil.getTreeSelectionForeground();
        } else {
          if (changed) {
            foreground = PlatformColors.BLUE;
          } else {
            foreground = UIUtil.getTreeForeground();
          }

          if (bound) {
            foreground = JBColor.MAGENTA;
          }
        }
        SearchUtil.appendFragments(
            myFilter,
            text,
            Font.PLAIN,
            foreground,
            selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(),
            this);
      }
    }