Changeset 6248 in josm for trunk/src/org/openstreetmap/josm/plugins
- Timestamp:
- 2013-09-23T16:47:50+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/plugins
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/PluginDownloadTask.java
r6073 r6248 114 114 try { 115 115 if (pi.downloadlink == null) { 116 String msg = tr(" Warning:Cannot download plugin ''{0}''. Its download link is not known. Skipping download.", pi.name);117 System.err.println(msg);116 String msg = tr("Cannot download plugin ''{0}''. Its download link is not known. Skipping download.", pi.name); 117 Main.warn(msg); 118 118 throw new PluginDownloadException(msg); 119 119 } … … 128 128 out.write(buffer, 0, read); 129 129 } 130 } catch(MalformedURLException e) { 131 String msg = tr(" Warning:Cannot download plugin ''{0}''. Its download link ''{1}'' is not a valid URL. Skipping download.", pi.name, pi.downloadlink);132 System.err.println(msg);130 } catch (MalformedURLException e) { 131 String msg = tr("Cannot download plugin ''{0}''. Its download link ''{1}'' is not a valid URL. Skipping download.", pi.name, pi.downloadlink); 132 Main.warn(msg); 133 133 throw new PluginDownloadException(msg); 134 134 } catch (IOException e) { -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r6090 r6248 66 66 * PluginHandler is basically a collection of static utility functions used to bootstrap 67 67 * and manage the loaded plugins. 68 * 68 * @since 1326 69 69 */ 70 70 public class PluginHandler { 71 71 72 72 /** 73 * deprecated plugins that are removed on start73 * Deprecated plugins that are removed on start 74 74 */ 75 75 public final static Collection<DeprecatedPlugin> DEPRECATED_PLUGINS; … … 117 117 } 118 118 119 /** 120 * Description of a deprecated plugin 121 */ 119 122 public static class DeprecatedPlugin implements Comparable<DeprecatedPlugin> { 120 public String name; 121 // short explanation, can be null 122 public String reason; 123 // migration, can be null 124 private Runnable migration; 125 123 /** Plugin name */ 124 public final String name; 125 /** Short explanation about deprecation, can be {@code null} */ 126 public final String reason; 127 /** Code to run to perform migration, can be {@code null} */ 128 private final Runnable migration; 129 130 /** 131 * Constructs a new {@code DeprecatedPlugin}. 132 * @param name The plugin name 133 */ 126 134 public DeprecatedPlugin(String name) { 127 this.name = name; 128 } 129 135 this(name, null, null); 136 } 137 138 /** 139 * Constructs a new {@code DeprecatedPlugin} with a given reason. 140 * @param name The plugin name 141 * @param reason The reason about deprecation 142 */ 130 143 public DeprecatedPlugin(String name, String reason) { 131 this.name = name; 132 this.reason = reason; 133 } 134 144 this(name, reason, null); 145 } 146 147 /** 148 * Constructs a new {@code DeprecatedPlugin}. 149 * @param name The plugin name 150 * @param reason The reason about deprecation 151 * @param migration The code to run to perform migration 152 */ 135 153 public DeprecatedPlugin(String name, String reason, Runnable migration) { 136 154 this.name = name; … … 139 157 } 140 158 159 /** 160 * Performs migration. 161 */ 141 162 public void migrate() { 142 163 if (migration != null) { … … 151 172 } 152 173 174 /** 175 * List of unmaintained plugins. Not really up-to-date as the vast majority of plugins are not really maintained after a few months, sadly... 176 */ 153 177 final public static String [] UNMAINTAINED_PLUGINS = new String[] {"gpsbabelgui", "Intersect_way"}; 154 178 … … 319 343 if (policy.equals("never")) { 320 344 if ("pluginmanager.version-based-update.policy".equals(togglePreferenceKey)) { 321 System.out.println(tr("Skipping plugin update after JOSM upgrade. Automatic update at startup is disabled."));345 Main.info(tr("Skipping plugin update after JOSM upgrade. Automatic update at startup is disabled.")); 322 346 } else if ("pluginmanager.time-based-update.policy".equals(togglePreferenceKey)) { 323 System.out.println(tr("Skipping plugin update after elapsed update interval. Automatic update at startup is disabled."));347 Main.info(tr("Skipping plugin update after elapsed update interval. Automatic update at startup is disabled.")); 324 348 } 325 349 return false; … … 328 352 if (policy.equals("always")) { 329 353 if ("pluginmanager.version-based-update.policy".equals(togglePreferenceKey)) { 330 System.out.println(tr("Running plugin update after JOSM upgrade. Automatic update at startup is enabled."));354 Main.info(tr("Running plugin update after JOSM upgrade. Automatic update at startup is enabled.")); 331 355 } else if ("pluginmanager.time-based-update.policy".equals(togglePreferenceKey)) { 332 System.out.println(tr("Running plugin update after elapsed update interval. Automatic update at startup is disabled."));356 Main.info(tr("Running plugin update after elapsed update interval. Automatic update at startup is disabled.")); 333 357 } 334 358 return true; … … 336 360 337 361 if (!policy.equals("ask")) { 338 System.err.println(tr("Unexpected value ''{0}'' for preference ''{1}''. Assuming value ''ask''.", policy, togglePreferenceKey));362 Main.warn(tr("Unexpected value ''{0}'' for preference ''{1}''. Assuming value ''ask''.", policy, togglePreferenceKey)); 339 363 } 340 364 int ret = HelpAwareOptionPane.showOptionDialog( … … 513 537 * the class loader <code>pluginClassLoader</code>. 514 538 * 539 * @param parent The parent component to be used for the displayed dialog 515 540 * @param plugin the plugin 516 541 * @param pluginClassLoader the plugin class loader … … 521 546 Class<?> klass = plugin.loadClass(pluginClassLoader); 522 547 if (klass != null) { 523 System.out.println(tr("loading plugin ''{0}'' (version {1})", plugin.name, plugin.localversion));548 Main.info(tr("loading plugin ''{0}'' (version {1})", plugin.name, plugin.localversion)); 524 549 PluginProxy pluginProxy = plugin.load(klass); 525 550 pluginList.add(pluginProxy); … … 528 553 msg = null; 529 554 } catch (PluginException e) { 530 System.err.println(e.getMessage());555 Main.error(e.getMessage()); 531 556 Throwable cause = e.getCause(); 532 557 if (cause != null) { 533 558 msg = cause.getLocalizedMessage(); 534 559 if (msg != null) { 535 System.err.println("Cause: " + cause.getClass().getName()+": " + msg);560 Main.error("Cause: " + cause.getClass().getName()+": " + msg); 536 561 } else { 537 562 cause.printStackTrace(); … … 545 570 e.printStackTrace(); 546 571 } 547 if(msg != null && confirmDisablePlugin(parent, msg, plugin.name)) { 572 if (msg != null && confirmDisablePlugin(parent, msg, plugin.name)) { 548 573 Main.pref.removeFromCollection("plugins", plugin.name); 549 574 } … … 554 579 * memory. 555 580 * 581 * @param parent The parent component to be used for the displayed dialog 556 582 * @param plugins the list of plugins 557 583 * @param monitor the progress monitor. Defaults to {@link NullProgressMonitor#INSTANCE} if null. … … 621 647 * set to false. 622 648 * 649 * @param parent The parent component to be used for the displayed dialog 623 650 * @param plugins the collection of plugins 624 651 * @param monitor the progress monitor. Defaults to {@link NullProgressMonitor#INSTANCE} if null. … … 698 725 * messages. 699 726 * 727 * @param parent The parent component to be used for the displayed dialog 700 728 * @param monitor the progress monitor. Defaults to {@link NullProgressMonitor#INSTANCE} if null. 701 729 * @return the set of plugins to load (as set of plugin names) … … 785 813 } 786 814 } catch (PluginException e) { 787 System.out.println(tr("Warning: failed to find plugin {0}", name));815 Main.warn(tr("Failed to find plugin {0}", name)); 788 816 e.printStackTrace(); 789 817 } … … 801 829 * @throws IllegalArgumentException thrown if plugins is null 802 830 */ 803 public static List<PluginInformation> 831 public static List<PluginInformation> updatePlugins(Component parent, 804 832 List<PluginInformation> plugins, ProgressMonitor monitor) 805 833 throws IllegalArgumentException{ … … 825 853 allPlugins = task1.getAvailablePlugins(); 826 854 plugins = buildListOfPluginsToLoad(parent,monitor.createSubTaskMonitor(1, false)); 827 } catch(ExecutionException e) { 828 System.out.println(tr("Warning: failed to download plugin information list"));855 } catch (ExecutionException e) { 856 Main.warn(tr("Failed to download plugin information list")); 829 857 e.printStackTrace(); 830 858 // don't abort in case of error, continue with downloading plugins below 831 } catch(InterruptedException e) { 832 System.out.println(tr("Warning: failed to download plugin information list"));859 } catch (InterruptedException e) { 860 Main.warn(tr("Failed to download plugin information list")); 833 861 e.printStackTrace(); 834 862 // don't abort in case of error, continue with downloading plugins below … … 838 866 // 839 867 Collection<PluginInformation> pluginsToUpdate = new ArrayList<PluginInformation>(); 840 for(PluginInformation pi: plugins) { 868 for (PluginInformation pi: plugins) { 841 869 if (pi.isUpdateRequired()) { 842 870 pluginsToUpdate.add(pi); … … 907 935 /** 908 936 * Ask the user for confirmation that a plugin shall be disabled. 909 * 937 * 938 * @param parent The parent component to be used for the displayed dialog 910 939 * @param reason the reason for disabling the plugin 911 940 * @param name the plugin name … … 940 969 } 941 970 971 /** 972 * Returns the plugin of the specified name. 973 * @param name The plugin name 974 * @return The plugin of the specified name, if installed and loaded, or {@code null} otherwise. 975 */ 942 976 public static Object getPlugin(String name) { 943 977 for (PluginProxy plugin : pluginList) 944 if(plugin.getPluginInformation().name.equals(name)) 978 if (plugin.getPluginInformation().name.equals(name)) 945 979 return plugin.plugin; 946 980 return null; … … 986 1020 if (plugin.exists()) { 987 1021 if (!plugin.delete() && dowarn) { 988 System.err.println(tr("Warning: failed to delete outdated plugin ''{0}''.", plugin.toString()));989 System.err.println(tr("Warning: failed to install already downloaded plugin ''{0}''. Skipping installation. JOSM is still going to load the old plugin version.", pluginName));1022 Main.warn(tr("Failed to delete outdated plugin ''{0}''.", plugin.toString())); 1023 Main.warn(tr("Failed to install already downloaded plugin ''{0}''. Skipping installation. JOSM is still going to load the old plugin version.", pluginName)); 990 1024 continue; 991 1025 } … … 996 1030 } catch (Exception e) { 997 1031 if (dowarn) { 998 System.err.println(tr("Warning: failed to install plugin ''{0}'' from temporary download file ''{1}''. {2}", plugin.toString(), updatedPlugin.toString(), e.getLocalizedMessage()));1032 Main.warn(tr("Failed to install plugin ''{0}'' from temporary download file ''{1}''. {2}", plugin.toString(), updatedPlugin.toString(), e.getLocalizedMessage())); 999 1033 } 1000 1034 continue; … … 1002 1036 // Install plugin 1003 1037 if (!updatedPlugin.renameTo(plugin) && dowarn) { 1004 System.err.println(tr("Warning: failed to install plugin ''{0}'' from temporary download file ''{1}''. Renaming failed.", plugin.toString(), updatedPlugin.toString()));1005 System.err.println(tr("Warning: failed to install already downloaded plugin ''{0}''. Skipping installation. JOSM is still going to load the old plugin version.", pluginName));1038 Main.warn(tr("Failed to install plugin ''{0}'' from temporary download file ''{1}''. Renaming failed.", plugin.toString(), updatedPlugin.toString())); 1039 Main.warn(tr("Failed to install already downloaded plugin ''{0}''. Skipping installation. JOSM is still going to load the old plugin version.", pluginName)); 1006 1040 } 1007 1041 } … … 1177 1211 } 1178 1212 1213 /** 1214 * Returns the list of loaded plugins as a {@code String} to be displayed in status report. Useful for bug reports. 1215 * @return The list of loaded plugins (one plugin per line) 1216 */ 1179 1217 public static String getBugReportText() { 1180 String text = "";1218 StringBuilder text = new StringBuilder(); 1181 1219 LinkedList <String> pl = new LinkedList<String>(Main.pref.getCollection("plugins", new LinkedList<String>())); 1182 1220 for (final PluginProxy pp : pluginList) { … … 1188 1226 Collections.sort(pl); 1189 1227 for (String s : pl) { 1190 text += "Plugin: " + s + "\n"; 1191 } 1192 return text; 1193 } 1194 1228 text.append("Plugin: ").append(s).append("\n"); 1229 } 1230 return text.toString(); 1231 } 1232 1233 /** 1234 * Returns the list of loaded plugins as a {@code JPanel} to be displayed in About dialog. 1235 * @return The list of loaded plugins (one "line" of Swing components per plugin) 1236 */ 1195 1237 public static JPanel getInfoPanel() { 1196 1238 JPanel pluginTab = new JPanel(new GridBagLayout()); -
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r6232 r6248 23 23 import java.util.jar.JarInputStream; 24 24 import java.util.jar.Manifest; 25 25 26 import javax.swing.ImageIcon; 26 27 … … 186 187 new URL(s); 187 188 } catch (MalformedURLException e) { 188 System.out.println(tr("Invalid URL ''{0}'' in plugin {1}", s, name));189 Main.info(tr("Invalid URL ''{0}'' in plugin {1}", s, name)); 189 190 s = null; 190 191 } … … 200 201 s = tr(s); 201 202 } catch (IllegalArgumentException e) { 202 System.out.println(tr("Invalid plugin description ''{0}'' in plugin {1}", s, name));203 Main.info(tr("Invalid plugin description ''{0}'' in plugin {1}", s, name)); 203 204 } 204 205 } -
trunk/src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java
r6084 r6248 14 14 import java.util.Map; 15 15 16 import org.openstreetmap.josm.Main; 16 17 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 17 18 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 90 91 processLocalPluginInformationFile(f); 91 92 } catch(PluginListParseException e) { 92 System.err.println(tr("Warning:Failed to scan file ''{0}'' for plugin information. Skipping.", fname));93 Main.warn(tr("Failed to scan file ''{0}'' for plugin information. Skipping.", fname)); 93 94 e.printStackTrace(); 94 95 } … … 151 152 } 152 153 } catch (PluginException e){ 153 System.err.println(e.getMessage());154 System.err.println(tr("Warning:Failed to scan file ''{0}'' for plugin information. Skipping.", fname));154 Main.warn("PluginException: "+e.getMessage()); 155 Main.warn(tr("Failed to scan file ''{0}'' for plugin information. Skipping.", fname)); 155 156 } 156 157 monitor.worked(1); -
trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java
r6084 r6248 259 259 if (!pluginDir.exists()) { 260 260 if (! pluginDir.mkdirs()) { 261 System.err.println(tr("Warning: failed to create plugin directory ''{0}''. Cannot cache plugin list from plugin site ''{1}''.", pluginDir.toString(), site));261 Main.warn(tr("Failed to create plugin directory ''{0}''. Cannot cache plugin list from plugin site ''{1}''.", pluginDir.toString(), site)); 262 262 } 263 263 } … … 311 311 List<PluginInformation> pis = new PluginListParser().parse(in); 312 312 availablePlugins.addAll(filterDeprecatedPlugins(pis)); 313 } catch(UnsupportedEncodingException e) { 314 System.err.println(tr("Failed to parse plugin list document from site ''{0}''. Skipping site. Exception was: {1}", site, e.toString()));315 e.printStackTrace(); 316 } catch(PluginListParseException e) { 317 System.err.println(tr("Failed to parse plugin list document from site ''{0}''. Skipping site. Exception was: {1}", site, e.toString()));313 } catch (UnsupportedEncodingException e) { 314 Main.error(tr("Failed to parse plugin list document from site ''{0}''. Skipping site. Exception was: {1}", site, e.toString())); 315 e.printStackTrace(); 316 } catch (PluginListParseException e) { 317 Main.error(tr("Failed to parse plugin list document from site ''{0}''. Skipping site. Exception was: {1}", site, e.toString())); 318 318 e.printStackTrace(); 319 319 }
Note:
See TracChangeset
for help on using the changeset viewer.