Changeset 3090 in josm for trunk/src/org/openstreetmap/josm/gui/preferences
- Timestamp:
- 2010-03-06T12:37:34+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/preferences
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/PluginPreference.java
r3088 r3090 17 17 import java.util.Collection; 18 18 import java.util.Collections; 19 import java.util.Iterator; 19 20 import java.util.LinkedList; 20 21 import java.util.List; … … 77 78 sb.append("<ul>"); 78 79 for(PluginInformation pi: downloaded) { 79 sb.append("<li>").append(pi.name).append(" </li>");80 sb.append("<li>").append(pi.name).append(" (").append(pi.version).append(")").append("</li>"); 80 81 } 81 82 sb.append("</ul>"); … … 283 284 SwingUtilities.invokeLater(new Runnable() { 284 285 public void run() { 285 model. setAvailablePlugins(task.getAvailabePlugins());286 model.updateAvailablePlugins(task.getAvailabePlugins()); 286 287 pnlPluginPreferences.refreshView(); 287 288 288 } 289 289 }); … … 320 320 sb.toString(), 321 321 tr("Update plugins"), 322 failed.isEmpty() ? JOptionPane.WARNING_MESSAGE : JOptionPane.INFORMATION_MESSAGE,322 !failed.isEmpty() ? JOptionPane.WARNING_MESSAGE : JOptionPane.INFORMATION_MESSAGE, 323 323 // FIXME: check help topic 324 324 HelpUtil.ht("/Preferences/Plugin") … … 326 326 } 327 327 328 protected void alertNothingToUpdate() { 329 HelpAwareOptionPane.showOptionDialog( 330 pnlPluginPreferences, 331 tr("All installed plugins are up to date. JOSM does not have to download newer versions."), 332 tr("Plugins up to date"), 333 JOptionPane.INFORMATION_MESSAGE, 334 null // FIXME: provide help context 335 ); 336 } 337 328 338 public void actionPerformed(ActionEvent e) { 329 List<PluginInformation> toUpdate = model.getSelectedPlugins();339 final List<PluginInformation> toUpdate = model.getSelectedPlugins(); 330 340 // the async task for downloading plugins 331 341 final PluginDownloadTask pluginDownloadTask = new PluginDownloadTask( … … 345 355 notifyDownloadResults(pluginDownloadTask); 346 356 model.refreshLocalPluginVersion(pluginDownloadTask.getDownloadedPlugins()); 357 model.clearPendingPlugins(pluginDownloadTask.getDownloadedPlugins()); 347 358 pnlPluginPreferences.refreshView(); 348 359 } … … 355 366 if (pluginInfoDownloadTask.isCanceled()) 356 367 return; 368 model.updateAvailablePlugins(pluginInfoDownloadTask.getAvailabePlugins()); 369 // select plugins which actually have to be updated 370 // 371 Iterator<PluginInformation> it = toUpdate.iterator(); 372 while(it.hasNext()) { 373 PluginInformation pi = it.next(); 374 if (!pi.isUpdateRequired()) { 375 it.remove(); 376 } 377 } 378 if (toUpdate.isEmpty()) { 379 alertNothingToUpdate(); 380 return; 381 } 382 pluginDownloadTask.setPluginsToDownload(toUpdate); 357 383 Main.worker.submit(pluginDownloadTask); 358 384 Main.worker.submit(pluginDownloadContinuation); -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferencesModel.java
r3083 r3090 74 74 } 75 75 76 protected void updateAvailablePlugin(PluginInformation other) { 77 if (other == null) return; 78 PluginInformation pi = getPluginInformation(other.name); 79 if (pi == null) { 80 availablePlugins.add(other); 81 return; 82 } 83 pi.updateFromPluginSite(other); 84 } 85 86 /** 87 * Updates the list of plugin information objects with new information from 88 * plugin update sites. 89 * 90 * @param fromPluginSite plugin information read from plugin update sites 91 */ 92 public void updateAvailablePlugins(Collection<PluginInformation> fromPluginSite) { 93 for (PluginInformation other: fromPluginSite) { 94 updateAvailablePlugin(other); 95 } 96 sort(); 97 filterDisplayedPlugins(filterExpression); 98 Set<String> activePlugins = new HashSet<String>(); 99 activePlugins.addAll(Main.pref.getCollection("plugins", activePlugins)); 100 for (PluginInformation pi: availablePlugins) { 101 if (selectedPluginsMap.get(pi) == null) { 102 if (activePlugins.contains(pi.name)) { 103 selectedPluginsMap.put(pi, true); 104 } 105 } 106 } 107 clearChanged(); 108 notifyObservers(); 109 } 110 76 111 /** 77 112 * Replies the list of selected plugin information objects … … 113 148 new Comparator<PluginInformation>() { 114 149 public int compare(PluginInformation o1, PluginInformation o2) { 115 String n1 = o1.getName() == null ? "" : o1.getName() ;116 String n2 = o2.getName() == null ? "" : o2.getName() ;150 String n1 = o1.getName() == null ? "" : o1.getName().toLowerCase(); 151 String n2 = o2.getName() == null ? "" : o2.getName().toLowerCase(); 117 152 return n1.compareTo(n2); 118 153 } … … 164 199 if (!selected) { 165 200 pendingDownloads.remove(name); 201 } 202 } 203 204 /** 205 * Removes all the plugin in {@code plugins} from the list of plugins 206 * with a pending download 207 * 208 * @param plugins the list of plugins to clear for a pending download 209 */ 210 public void clearPendingPlugins(Collection<PluginInformation> plugins){ 211 if (plugins == null || plugins.isEmpty()) return; 212 for(PluginInformation pi: plugins) { 213 pendingDownloads.remove(pi.name); 166 214 } 167 215 }
Note:
See TracChangeset
for help on using the changeset viewer.