diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListItem.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListItem.java index 4add0a8a05..428e19fd0b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListItem.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListItem.java @@ -40,7 +40,6 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JToggleButton; import lombok.Getter; -import lombok.extern.slf4j.Slf4j; import net.runelite.client.plugins.PluginType; import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.PluginPanel; @@ -48,7 +47,6 @@ import net.runelite.client.util.ImageUtil; import net.runelite.client.util.SwingUtil; import org.apache.commons.text.similarity.JaroWinklerDistance; -@Slf4j public class PluginListItem extends JPanel { private static final JaroWinklerDistance DISTANCE = new JaroWinklerDistance(); @@ -195,7 +193,6 @@ public class PluginListItem extends JPanel } this.color = color; - log.info("{}, updated to {}", nameLabel.getText(), color); this.nameLabel.setForeground(color); } @@ -254,4 +251,4 @@ public class PluginListItem extends JPanel } }); } -} \ No newline at end of file +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListPanel.java index ba2e335393..2e0bf4d49c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListPanel.java @@ -28,6 +28,7 @@ import com.google.common.collect.ImmutableList; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; +import java.awt.Container; import java.awt.Dimension; import java.awt.Insets; import java.awt.event.MouseAdapter; @@ -337,8 +338,22 @@ public class PluginListPanel extends PluginPanel } sections.get(sectionName).add(pluginListItem); - } + + sections.forEach((key, value) -> + { + Container parent = value.getParent(); + JToggleButton collapseButton = (JToggleButton) ((JPanel) parent.getComponent(0)).getComponent(0); + + if (searchBar.getText().equals("")) + { + resetSection(key, collapseButton, value); + } + else + { + forceExpandSection(collapseButton, value); + } + }); } private void showMatchingPlugins(boolean pinned, String text) @@ -527,10 +542,10 @@ public class PluginListPanel extends PluginPanel @Override public void mouseClicked(MouseEvent e) { - toggleSection("pluginlist", name, collapse, sectionContents); + toggleSection(name, collapse, sectionContents); } }; - collapse.addActionListener(e -> toggleSection("pluginlist", name, collapse, sectionContents)); + collapse.addActionListener(e -> toggleSection(name, collapse, sectionContents)); headerLabel.addMouseListener(adapter); // Allow for sub-sections @@ -540,13 +555,45 @@ public class PluginListPanel extends PluginPanel return sectionContents; } - private void toggleSection(String group, String key, JToggleButton button, JPanel contents) + private void toggleSection(String key, JToggleButton button, JPanel contents) { + if (!button.isEnabled()) + { + return; + } + boolean newState = !contents.isVisible(); button.setSelected(newState); - contents.setVisible(newState); - configManager.setConfiguration(group, key, newState); button.setToolTipText(newState ? "Retract" : "Expand"); + contents.setVisible(newState); + configManager.setConfiguration("pluginlist", key, newState); + SwingUtilities.invokeLater(() -> + { + contents.revalidate(); + contents.repaint(); + }); + } + + private void forceExpandSection(JToggleButton button, JPanel contents) + { + button.setSelected(true); + button.setToolTipText(null); + button.setEnabled(false); + contents.setVisible(true); + + SwingUtilities.invokeLater(() -> + { + contents.revalidate(); + contents.repaint(); + }); + } + + private void resetSection(String key, JToggleButton button, JPanel contents) + { + boolean newState = Boolean.parseBoolean(configManager.getConfiguration("pluginlist", key)); + button.setSelected(newState); + button.setToolTipText(newState ? "Retract" : "Expand"); + contents.setVisible(newState); SwingUtilities.invokeLater(() -> { contents.revalidate();