Component ( JTable list, Object value, boolean isSelected, boolean hasFocus, int row, @UsageTableColumn int column ) { UsageNode usageNode = (UsageNode)value; Usage usage = usageNode == null ? null : usageNode.getUsage(); Color selectionBg = UIUtil.getListSelectionBackground(true); Color selectionFg = NamedColorUtil.getListSelectionForeground(true); Color rowSelectionBackground = isSelected ? selectionBg : null; Color rowForeground = isSelected ? selectionFg : list.getForeground(); if (usageNode == null || usageNode instanceof ShowUsagesAction.StringNode) { SimpleColoredComponent textChunks = new SimpleColoredComponent(); if (usageNode == null) { textChunks.append("", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES); } else { textChunks.append(((ShowUsagesAction.StringNode)value).getString(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES); } return textComponentSpanningWholeRow(textChunks, list.getBackground(), rowSelectionBackground, rowForeground, column, list); } if (usage == ((ShowUsagesTable)list).MORE_USAGES_SEPARATOR) { SimpleColoredComponent textChunks = new SimpleColoredComponent(); textChunks.append("...<"); textChunks.append(FindBundle.message("show.usages.more.usages.label"), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES); textChunks.append(">..."); return textComponentSpanningWholeRow(textChunks, list.getBackground(), rowSelectionBackground, rowForeground, column, list); } if (usage == ((ShowUsagesTable)list).USAGES_OUTSIDE_SCOPE_SEPARATOR) { String message = UsageViewManagerImpl.outOfScopeMessage(myOutOfScopeUsages.get(), mySearchScope); SimpleColoredComponent textChunks = new SimpleColoredComponent(); textChunks.append("...<"); textChunks.append(message, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES); textChunks.append(">..."); return textComponentSpanningWholeRow(textChunks, list.getBackground(), rowSelectionBackground, rowForeground, column, list); } if (usage == ((ShowUsagesTable)list).USAGES_FILTERED_OUT_SEPARATOR) { ShowUsagesAction.FilteredOutUsagesNode filtered = (ShowUsagesAction.FilteredOutUsagesNode)usageNode; SimpleColoredComponent textChunks = new SimpleColoredComponent(); textChunks.append(filtered.getString(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES); JComponent component = textComponentSpanningWholeRow(textChunks, list.getBackground(), rowSelectionBackground, rowForeground, column, list); component.setToolTipText(filtered.getTooltip()); return component; } UsagePresentation presentation = usage.getPresentation(); UsageNodePresentation cachedPresentation = presentation.getCachedPresentation(); Color fileBgColor = cachedPresentation == null ? presentation.getBackgroundColor() : cachedPresentation.getBackgroundColor(); Color rowBackground = fileBgColor == null ? list.getBackground() : fileBgColor; // greying the current usage the "find usages" was originated from boolean isOriginUsage = myOriginUsageCheck.test(usage); SelectablePanel panel = new SelectablePanel() { @Override public @NotNull AccessibleContext getAccessibleContext() { AccessibleContext acc = super.getAccessibleContext(); if (column == CURRENT_ASTERISK_COL) { acc.setAccessibleName(getAccessibleNameForRow(list, row, isOriginUsage)); } return acc; } }; LayoutManager layout = switch (column) { case USAGE_TEXT_COL -> new BorderLayout(); default -> new MyLayout(panel); }; panel.setLayout(layout); panel.setFont(null); if (isOriginUsage && !ExperimentalUI.isNewUI()) { rowBackground = slightlyDifferentColor(rowBackground); rowSelectionBackground = slightlyDifferentColor(rowSelectionBackground); fileBgColor = slightlyDifferentColor(fileBgColor); selectionBg = slightlyDifferentColor(selectionBg); } panel.setForeground(rowForeground); applyBackground(panel, column, rowBackground, rowSelectionBackground); TextChunk[] text = cachedPresentation == null ? presentation.getText() : cachedPresentation.getText(); switch (column) { case CURRENT_ASTERISK_COL -> { if (!ExperimentalUI.isNewUI() && isOriginUsage) { panel.add(new JLabel(isSelected ? AllIcons.General.ModifiedSelected : AllIcons.General.Modified)); } } case FILE_GROUP_COL -> { appendGroupText(list, (GroupNode)usageNode.getParent(), panel, fileBgColor, isSelected); } case LINE_NUMBER_COL -> { SimpleColoredComponent textChunks = new SimpleColoredComponent(); textChunks.setOpaque(false); if (text.length != 0) { TextChunk chunk = text[0]; textChunks.append(chunk.getText(), getAttributes(isSelected, fileBgColor, selectionBg, selectionFg, chunk)); } SpeedSearchUtil.applySpeedSearchHighlighting(list, textChunks, false, isSelected); panel.add(textChunks); panel.getAccessibleContext().setAccessibleName(IdeBundle.message("ShowUsagesTableCellRenderer.accessible.LINE_NUMBER_COL", textChunks.getAccessibleContext().getAccessibleName())); } case USAGE_TEXT_COL -> { SimpleColoredComponent textChunks = new SimpleColoredComponent(); textChunks.setOpaque(false); Icon icon = cachedPresentation == null ? presentation.getIcon() : cachedPresentation.getIcon(); textChunks.setIcon(icon == null ? EmptyIcon.ICON_16 : icon); textChunks.append("").appendTextPadding(JBUIScale.scale(16 + 5)); for (int i = 1; i < text.length; i++) { TextChunk chunk = text[i]; textChunks.append(chunk.getText(), getAttributes(isSelected, fileBgColor, selectionBg, selectionFg, chunk)); } SpeedSearchUtil.applySpeedSearchHighlighting(list, textChunks, false, isSelected); panel.add(textChunks); panel.getAccessibleContext().setAccessibleName(IdeBundle.message("ShowUsagesTableCellRenderer.accessible.USAGE_TEXT_COL", textChunks.getAccessibleContext().getAccessibleName())); if (isOriginUsage) { SimpleColoredComponent origin; if (ExperimentalUI.isNewUI()) { RoundedColoredComponent roundedOrigin = new RoundedColoredComponent(isSelected); roundedOrigin.append(FindBundle.message("show.usages.current.usage.label")); origin = roundedOrigin; } else { origin = new SimpleColoredComponent(); origin.setOpaque(false); origin.setIconTextGap(JBUIScale.scale(5)); // for this particular icon it looks better // use attributes of "line number" to show "Current" word SimpleTextAttributes attributes = text.length == 0 ? SimpleTextAttributes.REGULAR_ATTRIBUTES.derive(-1, new Color(0x808080), null, null) : getAttributes(isSelected, fileBgColor, selectionBg, selectionFg, text[0]); origin.append("| " + FindBundle.message("show.usages.current.usage.label"), attributes); origin.appendTextPadding(JBUIScale.scale(45)); } panel.add(origin, BorderLayout.EAST); panel.getAccessibleContext() .setAccessibleName(panel.getAccessibleContext().getAccessibleName() + ", " + origin.getAccessibleContext().getAccessibleName()); } } default -> throw new IllegalStateException("unknown column: " + column); } return panel; }