Changeset 2147 in josm for trunk/src/org/openstreetmap/josm/plugins
- Timestamp:
- 2009-09-16T17:55:01+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/PluginSelection.java
r2056 r2147 31 31 import javax.swing.JOptionPane; 32 32 import javax.swing.JPanel; 33 import javax.swing.JTextField; 33 34 import javax.swing.UIManager; 34 35 import javax.swing.event.HyperlinkEvent; … … 45 46 private Map<String, PluginInformation> availablePlugins; 46 47 private Map<String, PluginInformation> localPlugins; 48 49 private JTextField txtFilter = null; 50 51 /* Get a copy of PluginPreference's txtField so we can use it for searching */ 52 public void passTxtFilter(JTextField filter) { 53 txtFilter = filter; 54 } 47 55 48 56 public void updateDescription(JPanel pluginPanel) { … … 213 221 } 214 222 223 /* If this plugin doesn't match our search parameters we don't want to display it */ 224 if (txtFilter.getText() != null) { 225 boolean matches = filterNameAndDescription(txtFilter.getText(),plugin.name, 226 plugin.getLinkDescription(), 227 remoteversion, localversion); 228 if (!matches) { 229 /* This is not the plugin you're looking for */ 230 continue; 231 } 232 } 233 215 234 final JCheckBox pluginCheck = new JCheckBox( 216 235 tr("{0}: Version {1}{2}", plugin.name, remoteversion, localversion), … … 253 272 } 254 273 pluginPanel.updateUI(); 274 } 275 276 private static boolean filterNameAndDescription(String filter, final String name, final String description, 277 final String remoteversion, final String localversion) { 278 final String input[] = filter.split("\\s+"); 279 /* We're doing case-insensitive matching */ 280 final String name_lc = name.toLowerCase(); 281 final String description_lc = description.toLowerCase(); 282 final String remoteversion_lc = remoteversion.toLowerCase(); 283 final String localversion_lc = localversion.toLowerCase(); 284 285 boolean canHas = true; 286 287 /* Make 'foo bar' search for 'bar' or 'foo' in both name and description */ 288 for (String bit : input) { 289 final String lc_bit = bit.toLowerCase(); 290 if (!name_lc.contains(lc_bit) && 291 !description_lc.contains(lc_bit) && 292 !remoteversion_lc.contains(lc_bit) && 293 !localversion_lc.contains(lc_bit)) { 294 canHas = false; 295 } 296 } 297 298 return canHas; 255 299 } 256 300
Note:
See TracChangeset
for help on using the changeset viewer.