- Timestamp:
- 2018-05-21T00:57:38+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/preferences/plugin
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginListPanel.java
r13111 r13799 100 100 hint.setText( 101 101 "<html>" 102 + tr("Please click on <strong>Download list</strong> to download and display a list of available plugins.") 102 + (model.getAvailablePlugins().isEmpty() ? 103 tr("Please click on <strong>Download list</strong> to download and display a list of available plugins.") : 104 tr("The filter returned no results.")) 103 105 + "</html>" 104 106 ); … … 107 109 108 110 /** 109 * Refreshes the list. 111 * Displays a list of plugins. 112 * @param displayedPlugins list of plugins 113 * @since 13799 110 114 */ 111 public void refreshView() { 112 final Rectangle visibleRect = getVisibleRect(); 113 List<PluginInformation> displayedPlugins = model.getDisplayedPlugins(); 114 removeAll(); 115 115 public void displayPluginList(List<PluginInformation> displayedPlugins) { 116 116 GridBagConstraints gbc = new GridBagConstraints(); 117 117 gbc.gridx = 0; … … 119 119 gbc.fill = GridBagConstraints.HORIZONTAL; 120 120 gbc.weightx = 1.0; 121 122 if (displayedPlugins.isEmpty()) {123 displayEmptyPluginListInformation();124 return;125 }126 121 127 122 int row = -1; … … 164 159 add(description, gbc); 165 160 } 161 } 162 163 /** 164 * Refreshes the list. 165 */ 166 public void refreshView() { 167 final Rectangle visibleRect = getVisibleRect(); 168 List<PluginInformation> displayedPlugins = model.getDisplayedPlugins(); 169 removeAll(); 170 171 if (displayedPlugins.isEmpty()) { 172 displayEmptyPluginListInformation(); 173 } else { 174 displayPluginList(displayedPlugins); 175 } 166 176 revalidate(); 167 177 repaint(); -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java
r13431 r13799 27 27 import javax.swing.AbstractAction; 28 28 import javax.swing.BorderFactory; 29 import javax.swing.ButtonGroup; 29 30 import javax.swing.DefaultListModel; 30 31 import javax.swing.JButton; … … 34 35 import javax.swing.JOptionPane; 35 36 import javax.swing.JPanel; 37 import javax.swing.JRadioButton; 36 38 import javax.swing.JScrollPane; 37 39 import javax.swing.JTabbedPane; … … 177 179 gc.weightx = 0.0; 178 180 gc.insets = new Insets(0, 0, 0, 3); 181 pnl.add(GBC.glue(0, 0)); 182 183 gc.weightx = 1.0; 184 ButtonGroup bg = new ButtonGroup(); 185 JPanel radios = new JPanel(); 186 addRadioButton(bg, radios, new JRadioButton(tr("All"), true), gc, PluginInstallation.ALL); 187 addRadioButton(bg, radios, new JRadioButton(tr("Installed")), gc, PluginInstallation.INSTALLED); 188 addRadioButton(bg, radios, new JRadioButton(tr("Available")), gc, PluginInstallation.AVAILABLE); 189 pnl.add(radios, gc); 190 191 gc.gridx = 0; 192 gc.weightx = 0.0; 179 193 pnl.add(new JLabel(tr("Search:")), gc); 180 194 … … 187 201 tfFilter.getDocument().addDocumentListener(new SearchFieldAdapter()); 188 202 return pnl; 203 } 204 205 private void addRadioButton(ButtonGroup bg, JPanel pnl, JRadioButton rb, GridBagConstraints gc, PluginInstallation value) { 206 bg.add(rb); 207 pnl.add(rb, gc); 208 rb.addActionListener(e -> { 209 model.filterDisplayedPlugins(value); 210 pnlPluginPreferences.refreshView(); 211 }); 189 212 } 190 213 -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferencesModel.java
r12846 r13799 29 29 private final Set<String> currentActivePlugins; 30 30 private final List<PluginInformation> availablePlugins = new ArrayList<>(); 31 private PluginInstallation filterStatus; 31 32 private String filterExpression; 32 33 private final List<PluginInformation> displayedPlugins = new ArrayList<>(); … … 44 45 45 46 /** 46 * Filters the list of displayed plugins. 47 * Filters the list of displayed plugins by installation status. 48 * @param status The filter used against installation status 49 * @since 13799 50 */ 51 public void filterDisplayedPlugins(PluginInstallation status) { 52 if (status == null) { 53 displayedPlugins.clear(); 54 displayedPlugins.addAll(availablePlugins); 55 this.filterStatus = null; 56 return; 57 } 58 displayedPlugins.clear(); 59 for (PluginInformation pi: availablePlugins) { 60 boolean installed = currentActivePlugins.contains(pi.getName()); 61 if (PluginInstallation.ALL == status 62 || (PluginInstallation.INSTALLED == status && installed) 63 || (PluginInstallation.AVAILABLE == status && !installed)) { 64 displayedPlugins.add(pi); 65 } 66 } 67 filterStatus = status; 68 fireStateChanged(); 69 } 70 71 /** 72 * Filters the list of displayed plugins by text. 47 73 * @param filter The filter used against plugin name, description or version 48 74 */ … … 78 104 protected final void availablePluginsModified() { 79 105 sort(); 106 filterDisplayedPlugins(filterStatus); 80 107 filterDisplayedPlugins(filterExpression); 81 108 Set<String> activePlugins = new HashSet<>();
Note:
See TracChangeset
for help on using the changeset viewer.