Ignore:
Timestamp:
2009-11-01T14:14:52+01:00 (16 years ago)
Author:
stoecker
Message:

fix #3391 - update plugins after josm update

File:
1 edited

Legend:

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

    r2360 r2372  
    9191        }
    9292
    93 
    9493        if (plugins.isEmpty())
    9594            return;
     95
     96        if(early)
     97        {
     98            String doUpdate = null;
     99            String check = null;
     100            int v = Version.getInstance().getVersion();
     101            if(Main.pref.getInteger("pluginmanager.version", 0) < v)
     102            {
     103                doUpdate = tr("You updated your JOSM software\nTo prevent problems the plugins should be updated as well.\n"
     104                        + "Update plugins now?");
     105                check = "pluginmanger.version";
     106            }
     107            else
     108            {
     109                long tim = System.currentTimeMillis();
     110                long last = Main.pref.getLong("pluginmanager.lastupdate", 0);
     111                Integer maxTime = Main.pref.getInteger("pluginmanager.warntime", 60);
     112                long d = (tim - last)/(24*60*60*1000l);
     113                if ((last <= 0) || (maxTime <= 0)) {
     114                    Main.pref.put("pluginmanager.lastupdate",Long.toString(tim));
     115                } else if (d > maxTime) {
     116                    doUpdate = tr("Last plugin update more than {0} days ago.", d);
     117                    check = "pluginmanager.time";
     118                }
     119            }
     120            if(doUpdate != null)
     121            {
     122                ExtendedDialog dialog = new ExtendedDialog(
     123                        Main.parent,
     124                        tr("Update plugins"),
     125                        new String[] {tr("Update plugins"), tr("Skip update")}
     126                );
     127                dialog.setContent(doUpdate);
     128                dialog.toggleEnable(check);
     129                dialog.setButtonIcons( new String[] {"dialogs/refresh.png", "cancel.png"});
     130                dialog.showDialog();
     131                if(dialog.getValue() == 1)
     132                    new PluginSelection().update();
     133            }
     134        }
    96135
    97136        SortedMap<Integer, Collection<PluginInformation>> p = new TreeMap<Integer, Collection<PluginInformation>>();
     
    143182                        tr("Error"),
    144183                        JOptionPane.ERROR_MESSAGE
    145                 );
    146             }
    147         }
    148 
    149         if (!early) {
    150             long tim = System.currentTimeMillis();
    151             long last = Main.pref.getLong("pluginmanager.lastupdate", 0);
    152             Integer maxTime = Main.pref.getInteger("pluginmanager.warntime", 30);
    153             long d = (tim - last)/(24*60*60*1000l);
    154             if ((last <= 0) || (maxTime <= 0)) {
    155                 Main.pref.put("pluginmanager.lastupdate",Long.toString(tim));
    156             } else if (d > maxTime) {
    157                 JOptionPane.showMessageDialog(Main.parent,
    158                         "<html>" +
    159                         tr("Last plugin update more than {0} days ago.", d) +
    160                         "<br><em>" +
    161                         tr("(You can change the number of days after which this warning appears<br>by setting the config option 'pluginmanager.warntime'.)") +
    162                         "</html>",
    163                         tr("Warning"),
    164                         JOptionPane.WARNING_MESSAGE
    165184                );
    166185            }
Note: See TracChangeset for help on using the changeset viewer.