Changeset 12620 in josm for trunk/src/org/openstreetmap/josm/plugins
- Timestamp:
- 2017-08-22T22:26:32+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/plugins
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/PluginDownloadTask.java
r12279 r12620 23 23 import org.openstreetmap.josm.tools.CheckParameterUtil; 24 24 import org.openstreetmap.josm.tools.HttpClient; 25 import org.openstreetmap.josm.tools.Logging; 25 26 import org.xml.sax.SAXException; 26 27 … … 117 118 if (pi.downloadlink == null) { 118 119 String msg = tr("Cannot download plugin ''{0}''. Its download link is not known. Skipping download.", pi.name); 119 Main.warn(msg);120 Logging.warn(msg); 120 121 throw new PluginDownloadException(msg); 121 122 } … … 131 132 String msg = tr("Cannot download plugin ''{0}''. Its download link ''{1}'' is not a valid URL. Skipping download.", 132 133 pi.name, pi.downloadlink); 133 Main.warn(msg);134 Logging.warn(msg); 134 135 throw new PluginDownloadException(msg, e); 135 136 } catch (IOException e) { … … 150 151 String message = tr("Failed to create plugin directory ''{0}''", pluginDir.toString()); 151 152 lastException = new PluginDownloadException(message); 152 Main.error(message);153 Logging.error(message); 153 154 failed.addAll(toUpdate); 154 155 return; … … 159 160 return; 160 161 String message = tr("Downloading Plugin {0}...", d.name); 161 Main.info(message);162 Logging.info(message); 162 163 progressMonitor.subTask(message); 163 164 progressMonitor.worked(1); … … 167 168 } catch (PluginDownloadException e) { 168 169 lastException = e; 169 Main.error(e);170 Logging.error(e); 170 171 failed.add(d); 171 172 continue; -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r12599 r12620 69 69 import org.openstreetmap.josm.tools.I18n; 70 70 import org.openstreetmap.josm.tools.ImageProvider; 71 import org.openstreetmap.josm.tools.Logging; 71 72 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 72 73 import org.openstreetmap.josm.tools.Utils; … … 304 305 sources.add(org.openstreetmap.josm.gui.MainApplication.class.getClassLoader()); 305 306 } catch (SecurityException ex) { 306 Main.debug(ex);307 Logging.debug(ex); 307 308 sources.add(ImageProvider.class.getClassLoader()); 308 309 } … … 414 415 public static boolean checkAndConfirmPluginUpdate(Component parent) { 415 416 if (!checkOfflineAccess()) { 416 Main.info(tr("{0} not available (offline mode)", tr("Plugin update")));417 Logging.info(tr("{0} not available (offline mode)", tr("Plugin update"))); 417 418 return false; 418 419 } … … 456 457 case "never": 457 458 if ("pluginmanager.version-based-update.policy".equals(togglePreferenceKey)) { 458 Main.info(tr("Skipping plugin update after JOSM upgrade. Automatic update at startup is disabled."));459 Logging.info(tr("Skipping plugin update after JOSM upgrade. Automatic update at startup is disabled.")); 459 460 } else if ("pluginmanager.time-based-update.policy".equals(togglePreferenceKey)) { 460 Main.info(tr("Skipping plugin update after elapsed update interval. Automatic update at startup is disabled."));461 Logging.info(tr("Skipping plugin update after elapsed update interval. Automatic update at startup is disabled.")); 461 462 } 462 463 return false; … … 464 465 case "always": 465 466 if ("pluginmanager.version-based-update.policy".equals(togglePreferenceKey)) { 466 Main.info(tr("Running plugin update after JOSM upgrade. Automatic update at startup is enabled."));467 Logging.info(tr("Running plugin update after JOSM upgrade. Automatic update at startup is enabled.")); 467 468 } else if ("pluginmanager.time-based-update.policy".equals(togglePreferenceKey)) { 468 Main.info(tr("Running plugin update after elapsed update interval. Automatic update at startup is disabled."));469 Logging.info(tr("Running plugin update after elapsed update interval. Automatic update at startup is disabled.")); 469 470 } 470 471 return true; … … 474 475 475 476 default: 476 Main.warn(tr("Unexpected value ''{0}'' for preference ''{1}''. Assuming value ''ask''.", policy, togglePreferenceKey));477 Logging.warn(tr("Unexpected value ''{0}'' for preference ''{1}''. Assuming value ''ask''.", policy, togglePreferenceKey)); 477 478 } 478 479 … … 529 530 OnlineResource.JOSM_WEBSITE.checkOfflineAccess(updateSite, Main.getJOSMWebsite()); 530 531 } catch (OfflineAccessException e) { 531 Main.trace(e);532 Logging.trace(e); 532 533 return false; 533 534 } … … 614 615 RestartAction.restartJOSM(); 615 616 } catch (IOException e) { 616 Main.error(e);617 Logging.error(e); 617 618 } 618 619 } else { 619 Main.warn("No plugin downloaded, restart canceled");620 Logging.warn("No plugin downloaded, restart canceled"); 620 621 } 621 622 }); 622 623 } else { 623 Main.warn("No plugin to download, operation canceled");624 Logging.warn("No plugin to download, operation canceled"); 624 625 } 625 626 }); … … 776 777 Class<?> klass = plugin.loadClass(pluginClassLoader); 777 778 if (klass != null) { 778 Main.info(tr("loading plugin ''{0}'' (version {1})", plugin.name, plugin.localversion));779 Logging.info(tr("loading plugin ''{0}'' (version {1})", plugin.name, plugin.localversion)); 779 780 PluginProxy pluginProxy = plugin.load(klass, pluginClassLoader); 780 781 pluginList.add(pluginProxy); … … 784 785 } catch (PluginException e) { 785 786 pluginLoadingExceptions.put(plugin.name, e); 786 Main.error(e);787 Logging.error(e); 787 788 if (e.getCause() instanceof ClassNotFoundException) { 788 789 msg = tr("<html>Could not load plugin {0} because the plugin<br>main class ''{1}'' was not found.<br>" … … 791 792 } catch (RuntimeException e) { // NOPMD 792 793 pluginLoadingExceptions.put(plugin.name, e); 793 Main.error(e);794 Logging.error(e); 794 795 } 795 796 if (msg != null && confirmDisablePlugin(parent, msg, plugin.name)) { … … 919 920 task.run(); 920 921 } catch (RuntimeException e) { // NOPMD 921 Main.error(e);922 Logging.error(e); 922 923 return null; 923 924 } … … 968 969 monitor.beginTask(tr("Determining plugins to load...")); 969 970 Set<String> plugins = new HashSet<>(Main.pref.getCollection("plugins", new LinkedList<String>())); 970 if (Main.isDebugEnabled()) { 971 Main.debug("Plugins list initialized to " + plugins); 972 } 971 Logging.debug("Plugins list initialized to {0}", plugins); 973 972 String systemProp = System.getProperty("josm.plugins"); 974 973 if (systemProp != null) { 975 974 plugins.addAll(Arrays.asList(systemProp.split(","))); 976 if (Main.isDebugEnabled()) { 977 Main.debug("josm.plugins system property set to '" + systemProp+"'. Plugins list is now " + plugins); 978 } 975 Logging.debug("josm.plugins system property set to '{0}'. Plugins list is now {1}", systemProp, plugins); 979 976 } 980 977 monitor.subTask(tr("Removing deprecated plugins...")); … … 982 979 monitor.subTask(tr("Removing unmaintained plugins...")); 983 980 filterUnmaintainedPlugins(parent, plugins); 984 if (Main.isDebugEnabled()) { 985 Main.debug("Plugins list is finally set to " + plugins); 986 } 981 Logging.debug("Plugins list is finally set to {0}", plugins); 987 982 Map<String, PluginInformation> infos = loadLocallyAvailablePluginInformation(monitor.createSubTaskMonitor(1, false)); 988 983 List<PluginInformation> ret = new LinkedList<>(); … … 1053 1048 } 1054 1049 } catch (PluginException e) { 1055 Main.warn(tr("Failed to find plugin {0}", name));1056 Main.error(e);1050 Logging.warn(tr("Failed to find plugin {0}", name)); 1051 Logging.error(e); 1057 1052 } 1058 1053 } … … 1097 1092 } 1098 1093 } catch (RuntimeException e) { // NOPMD 1099 Main.warn(tr("Failed to download plugin information list"));1100 Main.error(e);1094 Logging.warn(tr("Failed to download plugin information list")); 1095 Logging.error(e); 1101 1096 // don't abort in case of error, continue with downloading plugins below 1102 1097 } … … 1142 1137 pluginDownloadTask.run(); 1143 1138 } catch (RuntimeException e) { // NOPMD 1144 Main.error(e);1139 Logging.error(e); 1145 1140 alertFailedPluginUpdate(parent, pluginsToUpdate); 1146 1141 return plugins; … … 1268 1263 String pluginName = updatedPlugin.getName().substring(0, updatedPlugin.getName().length() - 8); 1269 1264 if (plugin.exists() && !plugin.delete() && dowarn) { 1270 Main.warn(tr("Failed to delete outdated plugin ''{0}''.", plugin.toString()));1271 Main.warn(tr("Failed to install already downloaded plugin ''{0}''. " +1265 Logging.warn(tr("Failed to delete outdated plugin ''{0}''.", plugin.toString())); 1266 Logging.warn(tr("Failed to install already downloaded plugin ''{0}''. " + 1272 1267 "Skipping installation. JOSM is still going to load the old plugin version.", 1273 1268 pluginName)); … … 1279 1274 } catch (IOException e) { 1280 1275 if (dowarn) { 1281 Main.warn(e, tr("Failed to install plugin ''{0}'' from temporary download file ''{1}''. {2}",1282 plugin.toString(), updatedPlugin.toString(), e.getLocalizedMessage()) );1276 Logging.log(Logging.LEVEL_WARN, tr("Failed to install plugin ''{0}'' from temporary download file ''{1}''. {2}", 1277 plugin.toString(), updatedPlugin.toString(), e.getLocalizedMessage()), e); 1283 1278 } 1284 1279 continue; … … 1286 1281 // Install plugin 1287 1282 if (!updatedPlugin.renameTo(plugin) && dowarn) { 1288 Main.warn(tr("Failed to install plugin ''{0}'' from temporary download file ''{1}''. Renaming failed.",1283 Logging.warn(tr("Failed to install plugin ''{0}'' from temporary download file ''{1}''. Renaming failed.", 1289 1284 plugin.toString(), updatedPlugin.toString())); 1290 Main.warn(tr("Failed to install already downloaded plugin ''{0}''. " +1285 Logging.warn(tr("Failed to install already downloaded plugin ''{0}''. " + 1291 1286 "Skipping installation. JOSM is still going to load the old plugin version.", 1292 1287 pluginName)); … … 1306 1301 new JarFile(jar).close(); 1307 1302 } catch (IOException e) { 1308 Main.warn(e);1303 Logging.warn(e); 1309 1304 return false; 1310 1305 } 1311 1306 return true; 1312 1307 } else if (jar != null) { 1313 Main.warn("Invalid jar file ''"+jar+"'' (exists: "+jar.exists()+", canRead: "+jar.canRead()+')');1308 Logging.warn("Invalid jar file ''"+jar+"'' (exists: "+jar.exists()+", canRead: "+jar.canRead()+')'); 1314 1309 } 1315 1310 return false; … … 1351 1346 pi.updateFromJar(new PluginInformation(downloadedPluginFile, pi.name)); 1352 1347 } catch (PluginException e) { 1353 Main.error(e);1348 Logging.error(e); 1354 1349 } 1355 1350 } … … 1405 1400 return task.get(); 1406 1401 } catch (InterruptedException | ExecutionException e) { 1407 Main.warn(e);1402 Logging.warn(e); 1408 1403 } 1409 1404 return -1; -
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r12322 r12620 29 29 import org.openstreetmap.josm.tools.ImageProvider; 30 30 import org.openstreetmap.josm.tools.LanguageInfo; 31 import org.openstreetmap.josm.tools.Logging; 31 32 import org.openstreetmap.josm.tools.Utils; 32 33 … … 201 202 String s = Optional.ofNullable(attr.getValue(lang+"Plugin-Link")).orElseGet(() -> attr.getValue("Plugin-Link")); 202 203 if (s != null && !Utils.isValidUrl(s)) { 203 Main.info(tr("Invalid URL ''{0}'' in plugin {1}", s, name));204 Logging.info(tr("Invalid URL ''{0}'' in plugin {1}", s, name)); 204 205 s = null; 205 206 } … … 213 214 s = tr(s); 214 215 } catch (IllegalArgumentException e) { 215 Main.debug(e);216 Main.info(tr("Invalid plugin description ''{0}'' in plugin {1}", s, name));216 Logging.debug(e); 217 Logging.info(tr("Invalid plugin description ''{0}'' in plugin {1}", s, name)); 217 218 } 218 219 } … … 230 231 mainversion = Integer.parseInt(s); 231 232 } catch (NumberFormatException e) { 232 Main.warn(tr("Invalid plugin main version ''{0}'' in plugin {1}", s, name));233 Logging.warn(tr("Invalid plugin main version ''{0}'' in plugin {1}", s, name)); 233 234 } 234 235 } else { 235 Main.warn(tr("Missing plugin main version in plugin {0}", name));236 Logging.warn(tr("Missing plugin main version in plugin {0}", name)); 236 237 } 237 238 author = attr.getValue("Author"); … … 265 266 } 266 267 } catch (NumberFormatException e) { 267 Main.error(e);268 Logging.error(e); 268 269 } 269 270 } … … 391 392 } 392 393 } catch (IOException e) { 393 Main.warn(e);394 Logging.warn(e); 394 395 } 395 396 -
trunk/src/org/openstreetmap/josm/plugins/PluginListParser.java
r11381 r12620 13 13 import java.util.List; 14 14 15 import org.openstreetmap.josm. Main;15 import org.openstreetmap.josm.tools.Logging; 16 16 17 17 /** … … 103 103 } 104 104 } catch (PluginListParseException ex) { 105 Main.error(ex);105 Logging.error(ex); 106 106 } 107 107 } -
trunk/src/org/openstreetmap/josm/plugins/PluginProxy.java
r12599 r12620 4 4 import java.util.List; 5 5 6 import org.openstreetmap.josm.Main;7 6 import org.openstreetmap.josm.gui.MapFrame; 8 7 import org.openstreetmap.josm.gui.download.DownloadSelection; 9 8 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 9 import org.openstreetmap.josm.tools.Logging; 10 10 import org.openstreetmap.josm.tools.bugreport.BugReportExceptionHandler; 11 11 … … 66 66 plugin.getClass().getMethod("mapFrameInitialized", MapFrame.class, MapFrame.class).invoke(plugin, oldFrame, newFrame); 67 67 } catch (NoSuchMethodException e) { 68 Main.trace(e);69 Main.debug("Plugin "+plugin+" does not define mapFrameInitialized");68 Logging.trace(e); 69 Logging.debug("Plugin "+plugin+" does not define mapFrameInitialized"); 70 70 } catch (ReflectiveOperationException | IllegalArgumentException | NoClassDefFoundError e) { 71 71 handlePluginException(e); … … 78 78 return (PreferenceSetting) plugin.getClass().getMethod("getPreferenceSetting").invoke(plugin); 79 79 } catch (NoSuchMethodException e) { 80 Main.trace(e);81 Main.debug("Plugin "+plugin+" does not define getPreferenceSetting");80 Logging.trace(e); 81 Logging.debug("Plugin "+plugin+" does not define getPreferenceSetting"); 82 82 return null; 83 83 } catch (ReflectiveOperationException | IllegalArgumentException | NoClassDefFoundError e) { … … 92 92 plugin.getClass().getMethod("addDownloadSelection", List.class).invoke(plugin, list); 93 93 } catch (NoSuchMethodException e) { 94 Main.trace(e);95 Main.debug("Plugin "+plugin+" does not define addDownloadSelection");94 Logging.trace(e); 95 Logging.debug("Plugin "+plugin+" does not define addDownloadSelection"); 96 96 } catch (ReflectiveOperationException | IllegalArgumentException | NoClassDefFoundError e) { 97 97 handlePluginException(e); -
trunk/src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java
r10965 r12620 14 14 import java.util.Map; 15 15 16 import org.openstreetmap.josm.Main;17 16 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 18 17 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 19 18 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 20 19 import org.openstreetmap.josm.io.OsmTransferException; 20 import org.openstreetmap.josm.tools.Logging; 21 21 import org.xml.sax.SAXException; 22 22 … … 96 96 processLocalPluginInformationFile(f); 97 97 } catch (PluginListParseException e) { 98 Main.warn(tr("Failed to scan file ''{0}'' for plugin information. Skipping.", fname));99 Main.error(e);98 Logging.warn(tr("Failed to scan file ''{0}'' for plugin information. Skipping.", fname)); 99 Logging.error(e); 100 100 } 101 101 monitor.worked(1); … … 123 123 } 124 124 } catch (PluginException e) { 125 Main.warn(e, "PluginException: ");126 Main.warn(tr("Failed to scan file ''{0}'' for plugin information. Skipping.", fname));125 Logging.log(Logging.LEVEL_WARN, "PluginException: ", e); 126 Logging.warn(tr("Failed to scan file ''{0}'' for plugin information. Skipping.", fname)); 127 127 } 128 128 monitor.worked(1); -
trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java
r11553 r12620 39 39 import org.openstreetmap.josm.tools.GBC; 40 40 import org.openstreetmap.josm.tools.HttpClient; 41 import org.openstreetmap.josm.tools.Logging; 41 42 import org.openstreetmap.josm.tools.Utils; 42 43 import org.xml.sax.SAXException; … … 164 165 } catch (MalformedURLException e) { 165 166 if (canceled) return null; 166 Main.error(e);167 Logging.error(e); 167 168 return null; 168 169 } catch (IOException e) { … … 184 185 final String msg = e.getMessage(); 185 186 if (details == null || details.isEmpty()) { 186 Main.error(e.getClass().getSimpleName()+": " + msg);187 Logging.error(e.getClass().getSimpleName()+": " + msg); 187 188 } else { 188 Main.error(msg + " - Details:\n" + details);189 Logging.error(msg + " - Details:\n" + details); 189 190 } 190 191 … … 227 228 File pluginDir = Main.pref.getPluginsDirectory(); 228 229 if (!pluginDir.exists() && !pluginDir.mkdirs()) { 229 Main.warn(tr("Failed to create plugin directory ''{0}''. Cannot cache plugin list from plugin site ''{1}''.",230 Logging.warn(tr("Failed to create plugin directory ''{0}''. Cannot cache plugin list from plugin site ''{1}''.", 230 231 pluginDir.toString(), site)); 231 232 } … … 237 238 } catch (IOException e) { 238 239 // just failed to write the cache file. No big deal, but log the exception anyway 239 Main.error(e);240 Logging.error(e); 240 241 } 241 242 } … … 276 277 availablePlugins.addAll(filterDeprecatedPlugins(pis)); 277 278 } catch (PluginListParseException e) { 278 Main.error(tr("Failed to parse plugin list document from site ''{0}''. Skipping site. Exception was: {1}", site, e.toString()));279 Main.error(e);279 Logging.error(tr("Failed to parse plugin list document from site ''{0}''. Skipping site. Exception was: {1}", site, e.toString())); 280 Logging.error(e); 280 281 } 281 282 }
Note:
See TracChangeset
for help on using the changeset viewer.