Changeset 17785 in josm
- Timestamp:
- 2021-04-14T21:21:33+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginListPanel.java
r17784 r17785 10 10 import java.awt.event.MouseAdapter; 11 11 import java.awt.event.MouseEvent; 12 import java.util. ArrayList;12 import java.util.Collections; 13 13 import java.util.HashSet; 14 14 import java.util.List; … … 113 113 ); 114 114 hint.putClientProperty("plugin", "empty"); 115 hint.setVisible(false); 115 116 add(hint, gbc); 116 117 } … … 170 171 add(description, gbc); 171 172 } 172 173 173 pluginListInitialized = true; 174 174 } … … 182 182 public void refreshView() { 183 183 final Rectangle visibleRect = getVisibleRect(); 184 List<PluginInformation> displayedPlugins = model.getDisplayedPlugins(); 185 186 if (displayedPlugins.isEmpty()) { 187 hidePluginsNotInList(new ArrayList<>()); 184 if (!pluginListInitialized) { 185 removeAll(); 188 186 displayEmptyPluginListInformation(); 189 } else if (!pluginListInitialized) { 190 removeAll(); 191 displayPluginList(displayedPlugins); 187 displayPluginList(model.getAvailablePlugins()); 192 188 } else { 193 hidePluginsNotInList( displayedPlugins);189 hidePluginsNotInList(new HashSet<>(model.getDisplayedPlugins())); 194 190 } 195 191 revalidate(); … … 205 201 * those that shouldn't be visible. 206 202 * 207 * @param displayedPlugins A collection of plugins that are currently visible. 208 */ 209 private void hidePluginsNotInList(List<PluginInformation> displayedPlugins) { 210 // Remove the empty plugin list warning if it's there 211 synchronized (getTreeLock()) { 212 for (int i = 0; i < getComponentCount(); i++) { 213 JComponent component = (JComponent) getComponent(i); 214 if ("empty".equals(component.getClientProperty("plugin"))) { 215 remove(component); 216 } 217 } 218 } 219 220 Set<PluginInformation> displayedPluginsSet = new HashSet<>(displayedPlugins); 203 * @param displayedPlugins A set of plugins that are currently visible. 204 */ 205 private void hidePluginsNotInList(Set<PluginInformation> displayedPlugins) { 221 206 synchronized (getTreeLock()) { 222 207 for (int i = 0; i < getComponentCount(); i++) { 223 208 JComponent component = (JComponent) getComponent(i); 224 209 Object plugin = component.getClientProperty("plugin"); 225 component.setVisible(displayedPluginsSet.contains(plugin)); 210 if ("empty".equals(plugin)) { 211 // Hide the empty plugin list warning if it's there 212 component.setVisible(displayedPlugins.isEmpty()); 213 } else { 214 component.setVisible(displayedPlugins.contains(plugin)); 215 } 226 216 } 227 217 }
Note:
See TracChangeset
for help on using the changeset viewer.