public Component getTreeCellRendererComponent()

in src/main/java/org/jetbrains/plugins/spotbugs/gui/tree/view/TreeNodeCellRenderer.java [187:293]


	public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean selected, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) {
		if (_title.getFont().getStyle() == Font.BOLD) {
			_title.setFont(getFont());
		}

		if (selected && hasFocus) {
			_hits.setForeground(getTextNonSelectionColor());
			_hits.setBackground(getBackgroundSelectionColor());
			_title.setForeground(getTextSelectionColor());
			_title.setBackground(getBackgroundSelectionColor());
		} else {
			Color bColor = getBackgroundNonSelectionColor();
			if (bColor == null) {
				bColor = getBackground();
			}

			// Path highlighting
			final TreePath path = tree.getPathForRow(row);
			final TreePath selectionPath = tree.getSelectionPath();
			if (selectionPath != null && selectionPath.getPathCount() > 1) {
				final TreePath leadParentPath = new TreePath(new Object[] {selectionPath.getPathComponent(0), selectionPath.getPathComponent(1)});

				if (tree.getRowForPath(leadParentPath) > 0 && leadParentPath.isDescendant(path)) {
					setBackgroundNonSelectionColor(GuiResources.HIGHLIGHT_COLOR_LIGHTER);
				} else {
					setBackgroundNonSelectionColor(UIManager.getColor("Tree.textBackground"));
				}
			} else {
				setBackgroundNonSelectionColor(UIManager.getColor("Tree.textBackground"));
			}

			_hits.setForeground(getHitsForegroundColor());
			_hits.setBackground(bColor);
			_title.setForeground(getTextNonSelectionColor());
			_title.setBackground(bColor);
		}

		if (value != null) {
			setLinkHtml("");
			if (value instanceof BugInstanceNode) {
				final BugInstanceNode bugInstanceNode = (BugInstanceNode) value;

				if (expanded) {
					final Icon expandedIcon = bugInstanceNode.getExpandedIcon();
					((MaskIcon) expandedIcon).setColorPainted(selected);
					setIcon(expandedIcon);
				} else {
					final Icon collapsedIcon = bugInstanceNode.getCollapsedIcon();
					((MaskIcon) collapsedIcon).setColorPainted(selected);
					setIcon(collapsedIcon);
				}

				setToolTipText(bugInstanceNode.getTooltip());
				setTitle(bugInstanceNode.getSimpleName());
				setHits("");

			} else if (value instanceof RootNode) {
				final RootNode rootNode = (RootNode) value;

				if (expanded) {
					final Icon expandedIcon = rootNode.getExpandedIcon();
					((MaskIcon) expandedIcon).setColorPainted(selected);
					setIcon(expandedIcon);
				} else {
					final Icon collapsedIcon = rootNode.getCollapsedIcon();
					((MaskIcon) collapsedIcon).setColorPainted(selected);
					setIcon(collapsedIcon);
				}

				setToolTipText(rootNode.getTooltip());
				setTitle(rootNode.getSimpleName());
				final int bugCount = rootNode.getBugCount();
				final int classesCount = rootNode.getClassesCount();
				setHits(bugCount == -1 ? "" : "(found " + bugCount + " bug items in " + classesCount + (classesCount == 1 ? " class)" : " classes)"));
				setLinkHtml(rootNode.getLinkHtml());

			} else if (value instanceof BugInstanceGroupNode) {
				final BugInstanceGroupNode groupNode = (BugInstanceGroupNode) value;
				//final TreePath path = tree.getPathForRow(row);

				if (expanded) {
					final Icon expandedIcon = groupNode.getExpandedIcon();
					((MaskIcon) expandedIcon).setColorPainted(selected);
					setIcon(expandedIcon);
				} else {
					final Icon collapsedIcon = groupNode.getCollapsedIcon();
					((MaskIcon) collapsedIcon).setColorPainted(selected);
					setIcon(collapsedIcon);
				}

				setToolTipText(groupNode.getTooltip());
				setTitle(groupNode.getSimpleName());
				final int memberCount = groupNode.getMemberCount();
				setHits("(" + memberCount + (memberCount == 1 ? " item" : " items") + ')');

			} else {
				setIcon(null);
			}
		}

		_selected = selected;
		_hasFocus = hasFocus;

		updateBounds();

		return this;
	}