Index: trunk/src/org/openstreetmap/josm/Main.java
===================================================================
--- trunk/src/org/openstreetmap/josm/Main.java (revision 1095)
+++ trunk/src/org/openstreetmap/josm/Main.java (revision 1096)
@@ -181,5 +181,6 @@
/**
- * Remove the specified layer from the map. If it is the last layer, remove the map as well.
+ * Remove the specified layer from the map. If it is the last layer,
+ * remove the map as well.
*/
public final void removeLayer(final Layer layer) {
@@ -217,6 +218,6 @@
/**
- * Load all plugins specified in preferences. If the parameter is true
, all
- * early plugins are loaded (before constructor).
+ * Load all plugins specified in preferences. If the parameter is
+ * true
, all early plugins are loaded (before constructor).
*/
public static void loadPlugins(boolean early) {
@@ -229,8 +230,6 @@
String [] oldplugins = new String[] {"mappaint", "unglueplugin", "lang-de","lang-en_GB","lang-fr","lang-it","lang-pl","lang-ro","lang-ru"};
- for(String p : oldplugins)
- {
- if(plugins.contains(p))
- {
+ for (String p : oldplugins) {
+ if (plugins.contains(p)) {
plugins.remove(p);
Main.pref.removeFromCollection("plugins", p);
@@ -248,6 +247,5 @@
if (info.early != early)
continue;
- if (info.mainversion != null && info.mainversion.compareTo(AboutAction.version) > 0)
- {
+ if (info.mainversion != null && info.mainversion.compareTo(AboutAction.version) > 0) {
JOptionPane.showMessageDialog(Main.parent, tr("Plugin requires JOSM update: {0}.", pluginName));
continue;
@@ -264,17 +262,14 @@
}
- if(!early)
- {
+ if (!early) {
long tim = System.currentTimeMillis();
long last = Main.pref.getLong("pluginmanager.lastupdate", 0);
Integer maxTime = Main.pref.getInteger("pluginmanager.warntime", 30);
- if(last <= 0)
- {
+ if (last <= 0) {
Main.pref.put("pluginmanager.lastupdate",Long.toString(tim));
- }
- else if(tim - last >= maxTime*1000*24*60*60)
- {
- long d = (tim - last)/(24*60*60*1000);
- JOptionPane.showMessageDialog(Main.parent, tr("Last plugin update more than {0} days ago.", d));
+ } else if (tim - last >= maxTime*1000l*24*60*60) {
+ long d = (tim - last)/(24*60*60*1000l);
+ JOptionPane.showMessageDialog(Main.parent,
+ tr("Last plugin update more than {0} days ago.", d));
}
}
@@ -348,7 +343,4 @@
}
-
-
-
/**
* Use this to register shortcuts to
@@ -357,7 +349,7 @@
- ////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////
// Implementation part
- ////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////
public static JPanel panel = new JPanel(new BorderLayout());
Index: trunk/src/org/openstreetmap/josm/gui/preferences/PluginPreference.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/PluginPreference.java (revision 1095)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/PluginPreference.java (revision 1096)
@@ -12,4 +12,5 @@
import java.io.File;
import java.io.FileReader;
+import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
@@ -113,13 +114,13 @@
JButton morePlugins = new JButton(tr("Download List"));
morePlugins.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent e) {
- int count = PluginDownloader.downloadDescription();
- if (count > 0)
- JOptionPane.showMessageDialog(Main.parent,
- trn("Downloaded plugin information from {0} site",
- "Downloaded plugin information from {0} sites", count, count));
- else
- JOptionPane.showMessageDialog(Main.parent, tr("No plugin information found."));
- refreshPluginPanel(gui);
+ public void actionPerformed(ActionEvent e) {
+ int count = PluginDownloader.downloadDescription();
+ if (count > 0)
+ JOptionPane.showMessageDialog(Main.parent,
+ trn("Downloaded plugin information from {0} site",
+ "Downloaded plugin information from {0} sites", count, count));
+ else
+ JOptionPane.showMessageDialog(Main.parent, tr("No plugin information found."));
+ refreshPluginPanel(gui);
}
});
@@ -132,5 +133,4 @@
refreshPluginPanel(gui);
}
-
});
plugin.add(update, GBC.std().insets(0,0,10,0));
@@ -141,5 +141,4 @@
configureSites();
}
-
});
plugin.add(configureSites, GBC.std());
@@ -286,4 +285,23 @@
pluginCheck.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
+ // if user enabled a plugin, it is not loaded but found somewhere on disk: offer to delete jar
+ if (pluginCheck.isSelected()) {
+ PluginInformation plinfo = PluginInformation.findPlugin(plugin.name);
+ if ((PluginInformation.getLoaded(plugin.name) == null) && (plinfo != null)) {
+ try {
+ int answer = JOptionPane.showConfirmDialog(Main.parent,
+ tr("Plugin archive already available. Do you want to download current version by deleting existing archive?\n\n{0}",
+ plinfo.file.getCanonicalPath()), tr("Plugin already exists"), JOptionPane.OK_CANCEL_OPTION);
+ if (answer == JOptionPane.OK_OPTION) {
+ if (!plinfo.file.delete()) {
+ JOptionPane.showMessageDialog(Main.parent, tr("Error deleting plugin file: {0}", plinfo.file.getCanonicalPath()));
+ }
+ }
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ JOptionPane.showMessageDialog(Main.parent, tr("Error deleting plugin file: {0}", e1.getMessage()));
+ }
+ }
+ }
pluginMap.put(plugin, pluginCheck.isSelected());
}