Changeset 3287 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2010-05-30T17:07:19+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r3252 r3287 195 195 if (!pluginsToLoad.isEmpty() && PluginHandler.checkAndConfirmPluginUpdate(splash)) { 196 196 monitor.subTask(tr("Updating plugins...")); 197 PluginHandler.updatePlugins(splash,pluginsToLoad, monitor.createSubTaskMonitor(1, false));197 pluginsToLoad = PluginHandler.updatePlugins(splash,pluginsToLoad, monitor.createSubTaskMonitor(1, false)); 198 198 } 199 199 monitor.worked(1); -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r3232 r3287 620 620 * @throws IllegalArgumentException thrown if plugins is null 621 621 */ 622 public static void updatePlugins(Window parent, Collection<PluginInformation> plugins, ProgressMonitor monitor) throws IllegalArgumentException{ 622 public static List<PluginInformation> updatePlugins(Window parent, 623 List<PluginInformation> plugins, ProgressMonitor monitor) 624 throws IllegalArgumentException{ 623 625 CheckParameterUtil.ensureParameterNotNull(plugins, "plugins"); 624 626 if (monitor == null) { … … 638 640 try { 639 641 future.get(); 642 plugins = buildListOfPluginsToLoad(parent,monitor.createSubTaskMonitor(1, false)); 640 643 } catch(ExecutionException e) { 641 644 System.out.println(tr("Warning: failed to download plugin information list")); … … 672 675 e.printStackTrace(); 673 676 alertFailedPluginUpdate(parent, pluginsToUpdate); 674 return ;677 return plugins; 675 678 } catch(InterruptedException e) { 676 679 e.printStackTrace(); 677 680 alertFailedPluginUpdate(parent, pluginsToUpdate); 678 return ;681 return plugins; 679 682 } 680 683 // notify user if downloading a locally installed plugin failed … … 682 685 if (! task2.getFailedPlugins().isEmpty()) { 683 686 alertFailedPluginUpdate(parent, task2.getFailedPlugins()); 684 return ;687 return plugins; 685 688 } 686 689 } … … 692 695 Main.pref.putInteger("pluginmanager.version", Version.getInstance().getVersion()); 693 696 Main.pref.put("pluginmanager.lastupdate", Long.toString(System.currentTimeMillis())); 697 return plugins; 694 698 } 695 699 -
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r3090 r3287 351 351 */ 352 352 public boolean isUpdateRequired(String referenceVersion) { 353 if (this.downloadlink == null) return false; 353 354 if (this.version == null && referenceVersion!= null) 354 355 return true; … … 366 367 */ 367 368 public boolean isUpdateRequired() { 369 if (this.downloadlink == null) return false; 368 370 if (this.localversion == null) return true; 369 371 return isUpdateRequired(this.localversion); -
trunk/src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java
r3130 r3287 62 62 ); 63 63 if (!availablePlugins.containsKey(info.getName())) { 64 info.localversion = info.version; 64 65 availablePlugins.put(info.getName(), info); 65 66 } else { … … 184 185 Collection<String> pluginLocations = PluginInformation.getPluginLocations(); 185 186 getProgressMonitor().setTicksCount(pluginLocations.size() + 2); 186 if (canceled) return;187 if (canceled) return; 187 188 for (String location : pluginLocations) { 188 189 scanLocalPluginRepository( -
trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java
r3231 r3287 7 7 import java.io.ByteArrayInputStream; 8 8 import java.io.File; 9 import java.io.FilenameFilter; 9 10 import java.io.FileOutputStream; 10 11 import java.io.IOException; … … 43 44 private boolean canceled; 44 45 private HttpURLConnection connection; 45 private List<PluginInformation> availab ePlugins;46 private List<PluginInformation> availablePlugins; 46 47 47 48 protected void init(Collection<String> sites){ … … 50 51 this.sites = Collections.emptySet(); 51 52 } 52 availab ePlugins = new LinkedList<PluginInformation>();53 availablePlugins = new LinkedList<PluginInformation>(); 53 54 54 55 } … … 94 95 * @return the file name for the cache file 95 96 */ 96 protected String createSiteCacheFileName(String site) { 97 protected File createSiteCacheFile(File pluginDir, String site) { 98 String name; 97 99 try { 98 100 URL url = new URL(site); … … 113 115 } 114 116 sb.append(".txt"); 115 returnsb.toString();117 name = sb.toString(); 116 118 } catch(MalformedURLException e) { 117 return "site-unknown.txt"; 118 } 119 name = "site-unknown.txt"; 120 } 121 return new File(pluginDir, name); 119 122 } 120 123 … … 186 189 } 187 190 } 188 File cacheFile = new File(pluginDir, createSiteCacheFileName(site));191 File cacheFile = createSiteCacheFile(pluginDir, site); 189 192 getProgressMonitor().subTask(tr("Writing plugin list to local cache ''{0}''", cacheFile.toString())); 190 193 writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(cacheFile), "utf-8")); … … 231 234 InputStream in = new ByteArrayInputStream(doc.getBytes("UTF-8")); 232 235 List<PluginInformation> pis = new PluginListParser().parse(in); 233 availab ePlugins.addAll(filterDeprecatedPlugins(pis));236 availablePlugins.addAll(filterDeprecatedPlugins(pis)); 234 237 } catch(UnsupportedEncodingException e) { 235 238 System.err.println(tr("Failed to parse plugin list document from site ''{0}''. Skipping site. Exception was: {1}", site, e.toString())); … … 245 248 if (sites == null) return; 246 249 getProgressMonitor().setTicksCount(sites.size() * 3); 250 File pluginDir = Main.pref.getPluginsDirectory(); 251 List<File> siteCacheFiles = new LinkedList<File>(); 252 for (String location : PluginInformation.getPluginLocations()) { 253 File [] f = new File(location).listFiles( 254 new FilenameFilter() { 255 public boolean accept(File dir, String name) { 256 return name.matches("^([0-9]+-)?site.*\\.txt$"); 257 } 258 } 259 ); 260 if(f != null && f.length > 0) 261 siteCacheFiles.addAll(Arrays.asList(f)); 262 } 263 247 264 for (String site: sites) { 248 265 getProgressMonitor().subTask(tr("Processing plugin list from site ''{0}''", site)); 249 266 String list = downloadPluginList(site, getProgressMonitor().createSubTaskMonitor(0, false)); 250 if (canceled || list == null) return;251 getProgressMonitor().worked(1);252 cachePluginList(site, list);253 267 if (canceled) return; 254 getProgressMonitor().worked(1); 255 parsePluginListDocument(site, list); 256 if (canceled) return; 257 getProgressMonitor().worked(1); 268 if(list != null) 269 { 270 siteCacheFiles.remove(createSiteCacheFile(pluginDir, site)); 271 getProgressMonitor().worked(1); 272 cachePluginList(site, list); 273 if (canceled) return; 274 getProgressMonitor().worked(1); 275 parsePluginListDocument(site, list); 276 if (canceled) return; 277 getProgressMonitor().worked(1); 278 if (canceled) return; 279 } 280 } 281 for (File file: siteCacheFiles) /* remove old stuff or whole update process is broken */ 282 { 283 file.delete(); 258 284 } 259 285 } … … 273 299 */ 274 300 public List<PluginInformation> getAvailabePlugins() { 275 return availab ePlugins;301 return availablePlugins; 276 302 } 277 303 }
Note:
See TracChangeset
for help on using the changeset viewer.