From 188f231739cf2a7e4b3648e60ca2e70de2c78187 Mon Sep 17 00:00:00 2001 From: Vadim Salavatov Date: Thu, 12 Feb 2026 16:10:03 +0100 Subject: [PATCH] IJPL-232707 refactor: move marketplaceSortByAction to MarketplaceSearchResultPanel, also pass sortGroup GitOrigin-RevId: 35ff86936d7424879e48f1baa50420df10321ee1 --- .../ide/plugins/MarketplacePluginsTab.java | 125 ++++++++++-------- 1 file changed, 67 insertions(+), 58 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/MarketplacePluginsTab.java b/platform/platform-impl/src/com/intellij/ide/plugins/MarketplacePluginsTab.java index 7a491768b03b..0a5c850f5f15 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/MarketplacePluginsTab.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/MarketplacePluginsTab.java @@ -113,7 +113,6 @@ class MarketplacePluginsTab extends PluginsTab { private Runnable myMarketplaceRunnable; private final DefaultActionGroup myMarketplaceSortByGroup; - private LinkComponent myMarketplaceSortByAction; private List myTagsSorted; private List myVendorsSorted; @@ -399,60 +398,6 @@ class MarketplacePluginsTab extends PluginsTab { } }; - myMarketplaceSortByAction = new LinkComponent() { - @Override - protected boolean isInClickableArea(Point pt) { - return true; - } - - @Override - public AccessibleContext getAccessibleContext() { - if (accessibleContext == null) { - accessibleContext = new AccessibleLinkComponent(); - } - return accessibleContext; - } - - protected class AccessibleLinkComponent extends AccessibleLinkLabel { - @Override - public AccessibleRole getAccessibleRole() { - return AccessibleRole.COMBO_BOX; - } - } - }; - myMarketplaceSortByAction.setIcon(new Icon() { - @Override - public void paintIcon(Component c, Graphics g, int x, int y) { - getIcon().paintIcon(c, g, x, y + 1); - } - - @Override - public int getIconWidth() { - return getIcon().getIconWidth(); - } - - @Override - public int getIconHeight() { - return getIcon().getIconHeight(); - } - - private static @NotNull Icon getIcon() { - return AllIcons.General.ButtonDropTriangle; - } - }); // TODO: icon - myMarketplaceSortByAction.setPaintUnderline(false); - myMarketplaceSortByAction.setIconTextGap(JBUIScale.scale(4)); - myMarketplaceSortByAction.setHorizontalTextPosition(SwingConstants.LEFT); - myMarketplaceSortByAction.setForeground(PluginsGroupComponent.SECTION_HEADER_FOREGROUND); - - //noinspection unchecked - myMarketplaceSortByAction.setListener( - (component, __) -> showRightBottomPopup(component.getParent().getParent(), IdeBundle.message("plugins.configurable.sort.by"), - myMarketplaceSortByGroup), null); - - DumbAwareAction.create(event -> myMarketplaceSortByAction.doClick()) - .registerCustomShortcutSet(KeyEvent.VK_DOWN, 0, myMarketplaceSortByAction); - MultiSelectionEventHandler eventHandler = new MultiSelectionEventHandler(); marketplaceController.setSearchResultEventHandler(eventHandler); @@ -476,7 +421,8 @@ class MarketplacePluginsTab extends PluginsTab { Project project = ProjectUtil.getActiveProject(); - myMarketplaceSearchPanel = new MarketplaceSearchResultPanel(myCoroutineScope, marketplaceController, panel, project, selectionListener); + myMarketplaceSearchPanel = new MarketplaceSearchResultPanel(myCoroutineScope, marketplaceController, panel, project, selectionListener, + myMarketplaceSortByGroup); return myMarketplaceSearchPanel; } @@ -759,15 +705,78 @@ class MarketplacePluginsTab extends PluginsTab { private class MarketplaceSearchResultPanel extends SearchResultPanel { private final Project myProject; private final @NotNull Consumer mySelectionListener; + private final @NotNull DefaultActionGroup myMarketplaceSortByGroup; + private final @NotNull LinkComponent myMarketplaceSortByAction; MarketplaceSearchResultPanel(CoroutineScope coroutineScope, SearchUpDownPopupController marketplaceController, PluginsGroupComponentWithProgress panel, Project project, - @NotNull Consumer selectionListener) { + @NotNull Consumer selectionListener, + @NotNull DefaultActionGroup marketplaceSortByGroup) { super(coroutineScope, marketplaceController, panel, true); myProject = project; mySelectionListener = selectionListener; + myMarketplaceSortByGroup = marketplaceSortByGroup; + myMarketplaceSortByAction = createSortByAction(); + } + + private @NotNull LinkComponent createSortByAction() { + LinkComponent sortByAction = new LinkComponent() { + @Override + protected boolean isInClickableArea(Point pt) { + return true; + } + + @Override + public AccessibleContext getAccessibleContext() { + if (accessibleContext == null) { + accessibleContext = new AccessibleLinkComponent(); + } + return accessibleContext; + } + + protected class AccessibleLinkComponent extends AccessibleLinkLabel { + @Override + public AccessibleRole getAccessibleRole() { + return AccessibleRole.COMBO_BOX; + } + } + }; + + sortByAction.setIcon(new Icon() { + @Override + public void paintIcon(Component c, Graphics g, int x, int y) { + getIcon().paintIcon(c, g, x, y + 1); + } + + @Override + public int getIconWidth() { + return getIcon().getIconWidth(); + } + + @Override + public int getIconHeight() { + return getIcon().getIconHeight(); + } + + private static @NotNull Icon getIcon() { + return AllIcons.General.ButtonDropTriangle; + } + }); // TODO: icon + sortByAction.setPaintUnderline(false); + sortByAction.setIconTextGap(JBUIScale.scale(4)); + sortByAction.setHorizontalTextPosition(SwingConstants.LEFT); + sortByAction.setForeground(PluginsGroupComponent.SECTION_HEADER_FOREGROUND); + + //noinspection unchecked + sortByAction.setListener( + (component, __) -> showRightBottomPopup(component.getParent().getParent(), IdeBundle.message("plugins.configurable.sort.by"), + myMarketplaceSortByGroup), null); + + DumbAwareAction.create(event -> sortByAction.doClick()) + .registerCustomShortcutSet(KeyEvent.VK_DOWN, 0, sortByAction); + return sortByAction; } @Override @@ -925,4 +934,4 @@ class MarketplacePluginsTab extends PluginsTab { searchIndex, pluginToScore); } } -} \ No newline at end of file +}