From a9bce1a28973b2d56bcd3aab471765db3a0d7421 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Thu, 11 Aug 2022 13:31:00 +0200 Subject: [PATCH] ui: fix "Copy" action for 'Settings | File Types' list * support SimpleListCellRenderer * support expanded renderers GitOrigin-RevId: 7e9978883620bdf7b01b74512387cc9bcb395eeb --- .../src/com/intellij/ui/components/JBList.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/components/JBList.java b/platform/platform-api/src/com/intellij/ui/components/JBList.java index 6b7f176800b9..b60d7c3560b8 100644 --- a/platform/platform-api/src/com/intellij/ui/components/JBList.java +++ b/platform/platform-api/src/com/intellij/ui/components/JBList.java @@ -35,7 +35,7 @@ import java.util.Collection; * @author Anton Makeev * @author Konstantin Bulenkov */ -public class JBList extends JList implements ComponentWithEmptyText, ComponentWithExpandableItems{ +public class JBList extends JList implements ComponentWithEmptyText, ComponentWithExpandableItems { private StatusText myEmptyText; private ExpandableItemsHandler myExpandableItemsHandler; @@ -76,8 +76,9 @@ public class JBList extends JList implements ComponentWithEmptyText, Compo public void removeNotify() { super.removeNotify(); - if (!ScreenUtil.isStandardAddRemoveNotify(this)) + if (!ScreenUtil.isStandardAddRemoveNotify(this)) { return; + } if (myBusyIcon != null) { remove(myBusyIcon); @@ -243,12 +244,17 @@ public class JBList extends JList implements ComponentWithEmptyText, Compo private @Nullable String itemToText(int index, E value) { ListCellRenderer renderer = getCellRenderer(); Component c = renderer == null ? null : renderer.getListCellRendererComponent(this, value, index, true, true); + if (c != null) { + c = ExpandedItemRendererComponentWrapper.unwrap(c); + } + SimpleColoredComponent coloredComponent = null; if (c instanceof JComponent) { coloredComponent = UIUtil.findComponentOfType((JComponent)c, SimpleColoredComponent.class); } return coloredComponent != null ? coloredComponent.getCharSequence(true).toString() : c instanceof JTextComponent ? ((JTextComponent)c).getText() : + c instanceof JLabel ? ((JLabel)c).getText() : value != null ? value.toString() : null; }