Changeset 2372 in josm


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

fix #3391 - update plugins after josm update

Location:
trunk/src/org/openstreetmap/josm
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r2371 r2372  
    323323    public void save() throws IOException {
    324324        /* currently unused, but may help to fix configuration issues in future */
    325         properties.put("josm.version", Version.getInstance().getVersionString());
     325        putInteger("josm.version", Version.getInstance().getVersion());
    326326
    327327        updateSystemProperties();
  • trunk/src/org/openstreetmap/josm/gui/MainMenu.java

    r2323 r2372  
    33package org.openstreetmap.josm.gui;
    44
    5 import static org.openstreetmap.josm.tools.I18n.marktr;
    65import static org.openstreetmap.josm.tools.I18n.tr;
    76
     
    159158    public final JosmAction statusreport = new ShowStatusReportAction();
    160159
    161     public final JMenu fileMenu = addMenu(marktr("File"), KeyEvent.VK_F, 0, ht("/Menu/File"));
    162     public final JMenu editMenu = addMenu(marktr("Edit"), KeyEvent.VK_E, 1, ht("/Menu/Edit"));
    163     public final JMenu viewMenu = addMenu(marktr("View"), KeyEvent.VK_V, 2, ht("/Menu/View"));
    164     public final JMenu toolsMenu = addMenu(marktr("Tools"), KeyEvent.VK_T, 3, ht("/Menu/Tools"));
    165     public final JMenu presetsMenu = addMenu(marktr("Presets"), KeyEvent.VK_P, 4, ht("/Menu/Presets"));
     160    public final JMenu fileMenu = addMenu(tr("File"), KeyEvent.VK_F, 0, ht("/Menu/File"));
     161    public final JMenu editMenu = addMenu(tr("Edit"), KeyEvent.VK_E, 1, ht("/Menu/Edit"));
     162    public final JMenu viewMenu = addMenu(tr("View"), KeyEvent.VK_V, 2, ht("/Menu/View"));
     163    public final JMenu toolsMenu = addMenu(tr("Tools"), KeyEvent.VK_T, 3, ht("/Menu/Tools"));
     164    public final JMenu presetsMenu = addMenu(tr("Presets"), KeyEvent.VK_P, 4, ht("/Menu/Presets"));
    166165    public JMenu audioMenu = null;
    167     public final JMenu helpMenu = addMenu(marktr("Help"), KeyEvent.VK_H, 5, ht("/Menu/Help"));
     166    public final JMenu helpMenu = addMenu(tr("Help"), KeyEvent.VK_H, 5, ht("/Menu/Help"));
    168167    public final int defaultMenuPos = 5;
    169168
     
    185184        return menuitem;
    186185    }
    187    
    188     @Deprecated
    189     public JMenu addMenu(String name, int mnemonicKey, int position) {
    190         return addMenu(name, mnemonicKey, position, "/Menu/" + name);
    191     }
    192    
     186
    193187    public JMenu addMenu(String name, int mnemonicKey, int position, String relativeHelpTopic) {
    194         JMenu menu = new JMenu(tr(name));
     188        JMenu menu = new JMenu(name);
    195189        Shortcut.registerShortcut("menu:" + name, tr("Menu: {0}", tr(name)), mnemonicKey,
    196190                Shortcut.GROUP_MNEMONIC).setMnemonic(menu);
     
    314308
    315309        if (!Main.pref.getBoolean("audio.menuinvisible", false)) {
    316             audioMenu = addMenu(marktr("Audio"), KeyEvent.VK_A, 5, ht("/Menu/Audio"));
     310            audioMenu = addMenu(tr("Audio"), KeyEvent.VK_A, 5, ht("/Menu/Audio"));
    317311            add(audioMenu, audioPlayPause);
    318312            add(audioMenu, audioNext);
  • trunk/src/org/openstreetmap/josm/plugins/PluginDownloader.java

    r2358 r2372  
    3939        private String errors = "";
    4040        private int count = 0;
     41        private boolean restart;
    4142
    42         private UpdateTask(Collection<PluginInformation> toUpdate, boolean up) {
     43        private UpdateTask(Collection<PluginInformation> toUpdate, boolean up, boolean restart) {
    4344            super(up ? tr("Update Plugins") : tr("Download Plugins"));
    4445            this.toUpdate = toUpdate;
     46            this.restart = restart;
    4547        }
    4648
     
    5860                );
    5961            } else {
     62                String txt = trn("{0} Plugin successfully downloaded.", "{0} Plugins successfully downloaded.", count, count);
     63                if(restart)
     64                    txt += "\n"+tr("Please restart JOSM.");
     65
    6066                JOptionPane.showMessageDialog(
    6167                        Main.parent,
    62                         trn("{0} Plugin successfully downloaded. Please restart JOSM.", "{0} Plugins successfully downloaded. Please restart JOSM.", count, count),
     68                        txt,
    6369                        tr("Information"),
    6470                        JOptionPane.INFORMATION_MESSAGE
     
    154160    }
    155161
    156     public static void update(Collection<PluginInformation> update) {
    157         Main.worker.execute(new UpdateTask(update, true));
     162    public static void update(Collection<PluginInformation> update, boolean restart) {
     163        Main.worker.execute(new UpdateTask(update, true, restart));
    158164    }
    159165
     
    162168        // Waiting for result is not a good idea because the waiting thread will probably be either EDT
    163169        // or worker thread. Blocking one of these threads will cause deadlock
    164         UpdateTask t = new UpdateTask(download, false);
     170        UpdateTask t = new UpdateTask(download, false, true);
    165171        t.run();
    166172        return t.failed;
  • 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            }
  • trunk/src/org/openstreetmap/josm/plugins/PluginSelection.java

    r2152 r2372  
    3838
    3939import org.openstreetmap.josm.Main;
     40import org.openstreetmap.josm.data.Version;
    4041import org.openstreetmap.josm.gui.ExtendedDialog;
    4142import org.openstreetmap.josm.tools.OpenBrowser;
     
    7576    }
    7677
     78    public void update() {
     79        update(null);
     80    }
     81
    7782    public void update(JPanel pluginPanel) {
    7883        // refresh description
     
    8085        Boolean done = false;
    8186        loadPlugins();
    82         drawPanel(pluginPanel);
     87        if(pluginPanel != null)
     88            drawPanel(pluginPanel);
    8389
    8490        Set<PluginInformation> toUpdate = new HashSet<PluginInformation>();
     
    115121
    116122            if (ed.getValue() == 1) {
    117                 PluginDownloader.update(toUpdate);
     123                PluginDownloader.update(toUpdate, pluginPanel != null);
    118124                done = true;
    119125            }
     
    121127        if (done && num >= 1) {
    122128            Main.pref.put("pluginmanager.lastupdate", Long.toString(System.currentTimeMillis()));
     129            Main.pref.putInteger("pluginmanager.version", Version.getInstance().getVersion());
    123130        }
    124131        loadPlugins();
    125         drawPanel(pluginPanel);
     132        if(pluginPanel != null)
     133            drawPanel(pluginPanel);
    126134    }
    127135
Note: See TracChangeset for help on using the changeset viewer.