From cd2ea306761d99094c3ff28ffbd3e3d3738f4d0c Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 2 Oct 2018 13:25:26 +0300 Subject: [PATCH] | current is back --- .../actions/ShowUsagesTableCellRenderer.java | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesTableCellRenderer.java b/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesTableCellRenderer.java index 2e6c044f9b9f..b2eec176c5d5 100644 --- a/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesTableCellRenderer.java +++ b/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesTableCellRenderer.java @@ -96,17 +96,20 @@ class ShowUsagesTableCellRenderer implements TableCellRenderer { return textComponentSpanningWholeRow(textChunks, rowBackground, rowForeground, column, list); } - JPanel panel = new JPanel(new FlowLayout(column == LINE_NUMBER_COL ? FlowLayout.RIGHT : FlowLayout.LEFT, 0, 0) { + // want to be able to right-align the "current" word + LayoutManager layout = column == USAGE_TEXT_COL + ? new BorderLayout() : new FlowLayout(column == LINE_NUMBER_COL ? FlowLayout.RIGHT : FlowLayout.LEFT, 0, 0) { @Override public void layoutContainer(Container container) { super.layoutContainer(container); - for (Component component: container.getComponents()) { // align inner components + for (Component component : container.getComponents()) { // align inner components Rectangle b = component.getBounds(); Insets insets = container.getInsets(); component.setBounds(b.x, b.y, b.width, container.getSize().height - insets.top - insets.bottom); } } - }); + }; + JPanel panel = new JPanel(layout); panel.setFont(null); // greying the current usage the "find usages" was originated from @@ -132,7 +135,7 @@ class ShowUsagesTableCellRenderer implements TableCellRenderer { case FILE_GROUP_COL: appendGroupText(list, (GroupNode)usageNode.getParent(), panel, fileBgColor, isSelected); break; - case LINE_NUMBER_COL: { + case LINE_NUMBER_COL: if (text.length != 0) { TextChunk chunk = text[0]; textChunks.append(chunk.getText(), getAttributes(isSelected, fileBgColor, selectionBg, selectionFg, chunk)); @@ -141,9 +144,8 @@ class ShowUsagesTableCellRenderer implements TableCellRenderer { panel.add(textChunks); break; - } - case USAGE_TEXT_COL: { + case USAGE_TEXT_COL: Icon icon = presentation.getIcon(); textChunks.setIcon(icon == null ? EmptyIcon.ICON_16 : icon); textChunks.append("").appendTextPadding(JBUI.scale(16 + 5)); @@ -154,8 +156,20 @@ class ShowUsagesTableCellRenderer implements TableCellRenderer { SpeedSearchUtil.applySpeedSearchHighlighting(list, textChunks, false, isSelected); panel.add(textChunks); + + if (isOriginUsage) { + SimpleColoredComponent origin = new SimpleColoredComponent(); + origin.setIconTextGap(JBUI.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("| Current", attributes); + origin.appendTextPadding(JBUI.scale(45)); + panel.add(origin, BorderLayout.EAST); + } break; - } default: throw new IllegalStateException("unknown column: " + column); @@ -171,11 +185,6 @@ class ShowUsagesTableCellRenderer implements TableCellRenderer { ColorUtil.hackBrightness(back, 1, 1/1.05f); // Olga insisted on very-pale almost invisible gray. oh well } - //@NotNull - //private static Icon slightlyDifferentColor(@NotNull Icon icon) { - // return EditorColorsManager.getInstance().isDarkEditor() ? IconUtil.brighter(icon, 3) : IconUtil.darker(icon, 8); - //} - @NotNull private static SimpleTextAttributes getAttributes(boolean isSelected, Color fileBgColor, Color selectionBg, Color selectionFg, @NotNull TextChunk chunk) { SimpleTextAttributes background = chunk.getSimpleAttributesIgnoreBackground();