Changeset 1645 in josm for trunk/src/org/openstreetmap/josm/plugins
- Timestamp:
- 2009-06-06T21:38:10+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/plugins
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/PluginDownloader.java
r1619 r1645 29 29 import javax.swing.JOptionPane; 30 30 31 import org.openstreetmap.josm.actions.AboutAction; 31 32 import org.openstreetmap.josm.Main; 33 import org.openstreetmap.josm.gui.ExtendedDialog; 32 34 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 33 35 import org.xml.sax.SAXException; … … 62 64 for (PluginInformation d : toUpdate) { 63 65 File pluginFile = new File(pluginDir, d.name + ".jar.new"); 64 if (download(d .downloadlink, pluginFile))66 if (download(d, pluginFile)) 65 67 count++; 66 68 else … … 101 103 } 102 104 103 private static String escape(String s) {104 return s.replaceAll("<", "<").replaceAll(">", ">");105 }106 107 105 public static boolean downloadPlugin(PluginInformation pd) { 108 106 File file = new File(Main.pref.getPluginsDirFile(), pd.name + ".jar"); 109 if (!download(pd .downloadlink, file)) {107 if (!download(pd, file)) { 110 108 JOptionPane.showMessageDialog(Main.parent, tr("Could not download plugin: {0} from {1}", pd.name, pd.downloadlink)); 111 109 } else { … … 123 121 } 124 122 125 private static boolean download(String url, File file) { 123 private static boolean download(PluginInformation pd, File file) { 124 if(pd.mainversion > AboutAction.getVersionNumber()) 125 { 126 int answer = new ExtendedDialog(Main.parent, 127 tr("Skip download"), 128 tr("JOSM version {0} required for plugin {1}.", pd.mainversion, pd.name), 129 new String[] {tr("Download Plugin"), tr("Skip Download")}, 130 new String[] {"download.png", "cancel.png"}).getValue(); 131 if (answer != 1) 132 return false; 133 } 134 126 135 try { 127 InputStream in = new URL( url).openStream();136 InputStream in = new URL(pd.downloadlink).openStream(); 128 137 OutputStream out = new FileOutputStream(file); 129 138 byte[] buffer = new byte[8192]; -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r1506 r1645 76 76 if (info.early != early) 77 77 continue; 78 if (info.mainversion != null) { 79 int requiredJOSMVersion = 0; 80 try { 81 requiredJOSMVersion = Integer.parseInt(info.mainversion); 82 } catch(NumberFormatException e) { 83 e.printStackTrace(); 84 } 85 if (requiredJOSMVersion > AboutAction.getVersionNumber()) { 86 JOptionPane.showMessageDialog(Main.parent, tr("Plugin requires JOSM update: {0}.", pluginName)); 87 continue; 88 } 78 if (info.mainversion > AboutAction.getVersionNumber()) { 79 JOptionPane.showMessageDialog(Main.parent, tr("Plugin {0} requires JOSM update to version {1}.", pluginName, 80 info.mainversion)); 81 continue; 89 82 } 90 83 if(info.requires != null) -
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r1623 r1645 31 31 public File file = null; 32 32 public String name = null; 33 public String mainversion = null;33 public int mainversion = 0; 34 34 public String className = null; 35 35 public String requires = null; … … 110 110 stage = stageStr == null ? 50 : Integer.parseInt(stageStr); 111 111 version = attr.getValue("Plugin-Version"); 112 mainversion = attr.getValue("Plugin-Mainversion"); 112 try { 113 mainversion = Integer.parseInt(attr.getValue("Plugin-Mainversion")); 114 } catch(NumberFormatException e) { 115 e.printStackTrace(); 116 } 113 117 author = attr.getValue("Author"); 114 118
Note:
See TracChangeset
for help on using the changeset viewer.