Changeset 1645 in josm


Ignore:
Timestamp:
Jun 6, 2009 9:38:10 PM (4 years ago)
Author:
stoecker
Message:

fix #1903 - don't download plugins for newer JOSM versions

Location:
trunk/src/org/openstreetmap/josm/plugins
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/plugins/PluginDownloader.java

    r1619 r1645  
    2929import javax.swing.JOptionPane; 
    3030 
     31import org.openstreetmap.josm.actions.AboutAction; 
    3132import org.openstreetmap.josm.Main; 
     33import org.openstreetmap.josm.gui.ExtendedDialog; 
    3234import org.openstreetmap.josm.gui.PleaseWaitRunnable; 
    3335import org.xml.sax.SAXException; 
     
    6264            for (PluginInformation d : toUpdate) { 
    6365                File pluginFile = new File(pluginDir, d.name + ".jar.new"); 
    64                 if (download(d.downloadlink, pluginFile)) 
     66                if (download(d, pluginFile)) 
    6567                    count++; 
    6668                else 
     
    101103    } 
    102104 
    103     private static String escape(String s) { 
    104         return s.replaceAll("<", "&lt;").replaceAll(">", "&gt;"); 
    105     } 
    106  
    107105    public static boolean downloadPlugin(PluginInformation pd) { 
    108106        File file = new File(Main.pref.getPluginsDirFile(), pd.name + ".jar"); 
    109         if (!download(pd.downloadlink, file)) { 
     107        if (!download(pd, file)) { 
    110108            JOptionPane.showMessageDialog(Main.parent, tr("Could not download plugin: {0} from {1}", pd.name, pd.downloadlink)); 
    111109        } else { 
     
    123121    } 
    124122 
    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 
    126135        try { 
    127             InputStream in = new URL(url).openStream(); 
     136            InputStream in = new URL(pd.downloadlink).openStream(); 
    128137            OutputStream out = new FileOutputStream(file); 
    129138            byte[] buffer = new byte[8192]; 
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r1506 r1645  
    7676                if (info.early != early) 
    7777                    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; 
    8982                } 
    9083                if(info.requires != null) 
  • trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java

    r1623 r1645  
    3131    public File file = null; 
    3232    public String name = null; 
    33     public String mainversion = null; 
     33    public int mainversion = 0; 
    3434    public String className = null; 
    3535    public String requires = null; 
     
    110110        stage = stageStr == null ? 50 : Integer.parseInt(stageStr); 
    111111        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        } 
    113117        author = attr.getValue("Author"); 
    114118 
Note: See TracChangeset for help on using the changeset viewer.