Changeset 2372 in josm for trunk/src/org/openstreetmap/josm/plugins
- Timestamp:
- 2009-11-01T14:14:52+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/plugins
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/PluginDownloader.java
r2358 r2372 39 39 private String errors = ""; 40 40 private int count = 0; 41 private boolean restart; 41 42 42 private UpdateTask(Collection<PluginInformation> toUpdate, boolean up ) {43 private UpdateTask(Collection<PluginInformation> toUpdate, boolean up, boolean restart) { 43 44 super(up ? tr("Update Plugins") : tr("Download Plugins")); 44 45 this.toUpdate = toUpdate; 46 this.restart = restart; 45 47 } 46 48 … … 58 60 ); 59 61 } 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 60 66 JOptionPane.showMessageDialog( 61 67 Main.parent, 62 t rn("{0} Plugin successfully downloaded. Please restart JOSM.", "{0} Plugins successfully downloaded. Please restart JOSM.", count, count),68 txt, 63 69 tr("Information"), 64 70 JOptionPane.INFORMATION_MESSAGE … … 154 160 } 155 161 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)); 158 164 } 159 165 … … 162 168 // Waiting for result is not a good idea because the waiting thread will probably be either EDT 163 169 // 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); 165 171 t.run(); 166 172 return t.failed; -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r2360 r2372 91 91 } 92 92 93 94 93 if (plugins.isEmpty()) 95 94 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 } 96 135 97 136 SortedMap<Integer, Collection<PluginInformation>> p = new TreeMap<Integer, Collection<PluginInformation>>(); … … 143 182 tr("Error"), 144 183 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_MESSAGE165 184 ); 166 185 } -
trunk/src/org/openstreetmap/josm/plugins/PluginSelection.java
r2152 r2372 38 38 39 39 import org.openstreetmap.josm.Main; 40 import org.openstreetmap.josm.data.Version; 40 41 import org.openstreetmap.josm.gui.ExtendedDialog; 41 42 import org.openstreetmap.josm.tools.OpenBrowser; … … 75 76 } 76 77 78 public void update() { 79 update(null); 80 } 81 77 82 public void update(JPanel pluginPanel) { 78 83 // refresh description … … 80 85 Boolean done = false; 81 86 loadPlugins(); 82 drawPanel(pluginPanel); 87 if(pluginPanel != null) 88 drawPanel(pluginPanel); 83 89 84 90 Set<PluginInformation> toUpdate = new HashSet<PluginInformation>(); … … 115 121 116 122 if (ed.getValue() == 1) { 117 PluginDownloader.update(toUpdate );123 PluginDownloader.update(toUpdate, pluginPanel != null); 118 124 done = true; 119 125 } … … 121 127 if (done && num >= 1) { 122 128 Main.pref.put("pluginmanager.lastupdate", Long.toString(System.currentTimeMillis())); 129 Main.pref.putInteger("pluginmanager.version", Version.getInstance().getVersion()); 123 130 } 124 131 loadPlugins(); 125 drawPanel(pluginPanel); 132 if(pluginPanel != null) 133 drawPanel(pluginPanel); 126 134 } 127 135
Note:
See TracChangeset
for help on using the changeset viewer.