Changeset 1860 in josm for trunk/src/org/openstreetmap/josm/plugins/PluginDownloader.java
- Timestamp:
- 2009-07-27T18:36:17+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/PluginDownloader.java
r1811 r1860 28 28 import org.openstreetmap.josm.actions.AboutAction; 29 29 import org.openstreetmap.josm.gui.ExtendedDialog; 30 import org.openstreetmap.josm.gui.OptionPaneUtil; 30 31 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 31 32 import org.xml.sax.SAXException; … … 49 50 50 51 @Override protected void finish() { 51 if (errors.length() > 0) 52 JOptionPane.showMessageDialog(Main.parent, tr("There were problems with the following plugins:\n\n {0}",errors)); 53 else 54 JOptionPane.showMessageDialog(Main.parent, trn("{0} Plugin successfully downloaded. Please restart JOSM.", "{0} Plugins successfully downloaded. Please restart JOSM.", count, count)); 52 if (errors.length() > 0) { 53 OptionPaneUtil.showMessageDialog( 54 Main.parent, 55 tr("There were problems with the following plugins:\n\n {0}",errors), 56 tr("Error"), 57 JOptionPane.ERROR_MESSAGE 58 ); 59 } else { 60 OptionPaneUtil.showMessageDialog( 61 Main.parent, 62 trn("{0} Plugin successfully downloaded. Please restart JOSM.", "{0} Plugins successfully downloaded. Please restart JOSM.", count, count), 63 tr("Information"), 64 JOptionPane.INFORMATION_MESSAGE 65 ); 66 } 55 67 } 56 68 57 69 @Override protected void realRun() throws SAXException, IOException { 58 70 File pluginDir = Main.pref.getPluginsDirFile(); 59 if (!pluginDir.exists()) 71 if (!pluginDir.exists()) { 60 72 pluginDir.mkdirs(); 73 } 61 74 progressMonitor.setTicksCount(toUpdate.size()); 62 75 for (PluginInformation d : toUpdate) { … … 64 77 progressMonitor.worked(1); 65 78 File pluginFile = new File(pluginDir, d.name + ".jar.new"); 66 if(download(d, pluginFile)) 79 if(download(d, pluginFile)) { 67 80 count++; 68 else81 } else 69 82 { 70 83 errors += d.name + "\n"; … … 88 101 int count = 0; 89 102 for (String site : getSites()) { 90 /* TODO: remove old site files (everything except .jar) */103 /* TODO: remove old site files (everything except .jar) */ 91 104 try { 92 105 BufferedReader r = new BufferedReader(new InputStreamReader(new URL(site).openStream(), "utf-8")); 93 106 new File(Main.pref.getPreferencesDir()+"plugins").mkdir(); 94 107 BufferedWriter out = new BufferedWriter(new OutputStreamWriter( 95 new FileOutputStream(new File(Main.pref.getPluginsDirFile(),96 count + "-site-" + site.replaceAll("[/:\\\\ <>|]", "_") + ".txt")), "utf-8"));97 for (String line = r.readLine(); line != null; line = r.readLine()) 108 new FileOutputStream(new File(Main.pref.getPluginsDirFile(), 109 count + "-site-" + site.replaceAll("[/:\\\\ <>|]", "_") + ".txt")), "utf-8")); 110 for (String line = r.readLine(); line != null; line = r.readLine()) { 98 111 out.append(line+"\n"); 112 } 99 113 r.close(); 100 114 out.close(); … … 110 124 { 111 125 int answer = new ExtendedDialog(Main.parent, 112 113 114 115 126 tr("Skip download"), 127 tr("JOSM version {0} required for plugin {1}.", pd.mainversion, pd.name), 128 new String[] {tr("Download Plugin"), tr("Skip Download")}, 129 new String[] {"download.png", "cancel.png"}).getValue(); 116 130 if (answer != 1) 117 131 return false; … … 122 136 OutputStream out = new FileOutputStream(file); 123 137 byte[] buffer = new byte[8192]; 124 for (int read = in.read(buffer); read != -1; read = in.read(buffer)) 138 for (int read = in.read(buffer); read != -1; read = in.read(buffer)) { 125 139 out.write(buffer, 0, read); 140 } 126 141 out.close(); 127 142 in.close();
Note:
See TracChangeset
for help on using the changeset viewer.