source: josm/trunk/src/org/openstreetmap/josm/gui/MainApplication.java@ 11610

Last change on this file since 11610 was 11509, checked in by Don-vip, 7 years ago

fix #14305 - allow file:// URL for command-line argument --load-preferences

  • Property svn:eol-style set to native
File size: 26.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5import static org.openstreetmap.josm.tools.I18n.trn;
6
7import java.awt.Dimension;
8import java.io.File;
9import java.io.IOException;
10import java.io.InputStream;
11import java.net.Authenticator;
12import java.net.Inet6Address;
13import java.net.InetAddress;
14import java.net.ProxySelector;
15import java.net.URL;
16import java.security.AllPermission;
17import java.security.CodeSource;
18import java.security.GeneralSecurityException;
19import java.security.KeyStoreException;
20import java.security.NoSuchAlgorithmException;
21import java.security.PermissionCollection;
22import java.security.Permissions;
23import java.security.Policy;
24import java.security.cert.CertificateException;
25import java.util.Arrays;
26import java.util.Collection;
27import java.util.List;
28import java.util.Locale;
29import java.util.Optional;
30import java.util.Set;
31import java.util.TreeSet;
32import java.util.logging.Level;
33import java.util.stream.Collectors;
34import java.util.stream.Stream;
35
36import javax.net.ssl.SSLSocketFactory;
37import javax.swing.JOptionPane;
38import javax.swing.RepaintManager;
39import javax.swing.SwingUtilities;
40
41import org.jdesktop.swinghelper.debug.CheckThreadViolationRepaintManager;
42import org.openstreetmap.josm.Main;
43import org.openstreetmap.josm.actions.PreferencesAction;
44import org.openstreetmap.josm.actions.RestartAction;
45import org.openstreetmap.josm.data.AutosaveTask;
46import org.openstreetmap.josm.data.CustomConfigurator;
47import org.openstreetmap.josm.data.Version;
48import org.openstreetmap.josm.gui.ProgramArguments.Option;
49import org.openstreetmap.josm.gui.SplashScreen.SplashProgressMonitor;
50import org.openstreetmap.josm.gui.download.DownloadDialog;
51import org.openstreetmap.josm.gui.preferences.server.OAuthAccessTokenHolder;
52import org.openstreetmap.josm.gui.preferences.server.ProxyPreference;
53import org.openstreetmap.josm.gui.util.GuiHelper;
54import org.openstreetmap.josm.io.CertificateAmendment;
55import org.openstreetmap.josm.io.DefaultProxySelector;
56import org.openstreetmap.josm.io.MessageNotifier;
57import org.openstreetmap.josm.io.OnlineResource;
58import org.openstreetmap.josm.io.auth.CredentialsManager;
59import org.openstreetmap.josm.io.auth.DefaultAuthenticator;
60import org.openstreetmap.josm.io.protocols.data.Handler;
61import org.openstreetmap.josm.io.remotecontrol.RemoteControl;
62import org.openstreetmap.josm.plugins.PluginHandler;
63import org.openstreetmap.josm.plugins.PluginInformation;
64import org.openstreetmap.josm.tools.FontsManager;
65import org.openstreetmap.josm.tools.HttpClient;
66import org.openstreetmap.josm.tools.I18n;
67import org.openstreetmap.josm.tools.Logging;
68import org.openstreetmap.josm.tools.OsmUrlToBounds;
69import org.openstreetmap.josm.tools.PlatformHookWindows;
70import org.openstreetmap.josm.tools.Utils;
71import org.openstreetmap.josm.tools.WindowGeometry;
72import org.openstreetmap.josm.tools.bugreport.BugReport;
73import org.openstreetmap.josm.tools.bugreport.BugReportExceptionHandler;
74
75/**
76 * Main window class application.
77 *
78 * @author imi
79 */
80public class MainApplication extends Main {
81
82 private MainFrame mainFrame;
83
84 /**
85 * Constructs a new {@code MainApplication} without a window.
86 */
87 public MainApplication() {
88 // Allow subclassing (see JOSM.java)
89 this(null);
90 }
91
92 /**
93 * Constructs a main frame, ready sized and operating. Does not display the frame.
94 * @param mainFrame The main JFrame of the application
95 * @since 10340
96 */
97 public MainApplication(MainFrame mainFrame) {
98 this.mainFrame = mainFrame;
99 }
100
101 @Override
102 protected void initializeMainWindow() {
103 mainPanel.reAddListeners();
104 if (mainFrame != null) {
105 mainFrame.initialize();
106
107 menu = mainFrame.getMenu();
108 } else {
109 // required for running some tests.
110 menu = new MainMenu();
111 }
112 }
113
114 @Override
115 protected void shutdown() {
116 if (mainFrame != null) {
117 mainFrame.storeState();
118 }
119 super.shutdown();
120 }
121
122 /**
123 * Displays help on the console
124 * @since 2748
125 */
126 public static void showHelp() {
127 // TODO: put in a platformHook for system that have no console by default
128 System.out.println(getHelp());
129 }
130
131 static String getHelp() {
132 return tr("Java OpenStreetMap Editor")+" ["
133 +Version.getInstance().getAgentString()+"]\n\n"+
134 tr("usage")+":\n"+
135 "\tjava -jar josm.jar <options>...\n\n"+
136 tr("options")+":\n"+
137 "\t--help|-h "+tr("Show this help")+'\n'+
138 "\t--geometry=widthxheight(+|-)x(+|-)y "+tr("Standard unix geometry argument")+'\n'+
139 "\t[--download=]minlat,minlon,maxlat,maxlon "+tr("Download the bounding box")+'\n'+
140 "\t[--download=]<URL> "+tr("Download the location at the URL (with lat=x&lon=y&zoom=z)")+'\n'+
141 "\t[--download=]<filename> "+tr("Open a file (any file type that can be opened with File/Open)")+'\n'+
142 "\t--downloadgps=minlat,minlon,maxlat,maxlon "+tr("Download the bounding box as raw GPS")+'\n'+
143 "\t--downloadgps=<URL> "+tr("Download the location at the URL (with lat=x&lon=y&zoom=z) as raw GPS")+'\n'+
144 "\t--selection=<searchstring> "+tr("Select with the given search")+'\n'+
145 "\t--[no-]maximize "+tr("Launch in maximized mode")+'\n'+
146 "\t--reset-preferences "+tr("Reset the preferences to default")+"\n\n"+
147 "\t--load-preferences=<url-to-xml> "+tr("Changes preferences according to the XML file")+"\n\n"+
148 "\t--set=<key>=<value> "+tr("Set preference key to value")+"\n\n"+
149 "\t--language=<language> "+tr("Set the language")+"\n\n"+
150 "\t--version "+tr("Displays the JOSM version and exits")+"\n\n"+
151 "\t--debug "+tr("Print debugging messages to console")+"\n\n"+
152 "\t--skip-plugins "+tr("Skip loading plugins")+"\n\n"+
153 "\t--offline=<osm_api|josm_website|all> "+tr("Disable access to the given resource(s), separated by comma")+"\n\n"+
154 tr("options provided as Java system properties")+":\n"+
155 align("\t-Djosm.dir.name=JOSM") + tr("Change the JOSM directory name") + "\n\n" +
156 align("\t-Djosm.pref=" + tr("/PATH/TO/JOSM/PREF ")) + tr("Set the preferences directory") + "\n" +
157 align("\t") + tr("Default: {0}", platform.getDefaultPrefDirectory()) + "\n\n" +
158 align("\t-Djosm.userdata=" + tr("/PATH/TO/JOSM/USERDATA")) + tr("Set the user data directory") + "\n" +
159 align("\t") + tr("Default: {0}", platform.getDefaultUserDataDirectory()) + "\n\n" +
160 align("\t-Djosm.cache=" + tr("/PATH/TO/JOSM/CACHE ")) + tr("Set the cache directory") + "\n" +
161 align("\t") + tr("Default: {0}", platform.getDefaultCacheDirectory()) + "\n\n" +
162 align("\t-Djosm.home=" + tr("/PATH/TO/JOSM/HOMEDIR ")) +
163 tr("Set the preferences+data+cache directory (cache directory will be josm.home/cache)")+"\n\n"+
164 tr("-Djosm.home has lower precedence, i.e. the specific setting overrides the general one")+"\n\n"+
165 tr("note: For some tasks, JOSM needs a lot of memory. It can be necessary to add the following\n" +
166 " Java option to specify the maximum size of allocated memory in megabytes")+":\n"+
167 "\t-Xmx...m\n\n"+
168 tr("examples")+":\n"+
169 "\tjava -jar josm.jar track1.gpx track2.gpx london.osm\n"+
170 "\tjava -jar josm.jar "+OsmUrlToBounds.getURL(43.2, 11.1, 13)+'\n'+
171 "\tjava -jar josm.jar london.osm --selection=http://www.ostertag.name/osm/OSM_errors_node-duplicate.xml\n"+
172 "\tjava -jar josm.jar 43.2,11.1,43.4,11.4\n"+
173 "\tjava -Djosm.pref=$XDG_CONFIG_HOME -Djosm.userdata=$XDG_DATA_HOME -Djosm.cache=$XDG_CACHE_HOME -jar josm.jar\n"+
174 "\tjava -Djosm.dir.name=josm_dev -jar josm.jar\n"+
175 "\tjava -Djosm.home=/home/user/.josm_dev -jar josm.jar\n"+
176 "\tjava -Xmx1024m -jar josm.jar\n\n"+
177 tr("Parameters --download, --downloadgps, and --selection are processed in this order.")+'\n'+
178 tr("Make sure you load some data if you use --selection.")+'\n';
179 }
180
181 private static String align(String str) {
182 return str + Stream.generate(() -> " ").limit(Math.max(0, 43 - str.length())).collect(Collectors.joining(""));
183 }
184
185 /**
186 * Main application Startup
187 * @param argArray Command-line arguments
188 */
189 public static void main(final String[] argArray) {
190 I18n.init();
191
192 // construct argument table
193 ProgramArguments args = null;
194 try {
195 args = new ProgramArguments(argArray);
196 } catch (IllegalArgumentException e) {
197 System.err.println(e.getMessage());
198 System.exit(1);
199 return;
200 }
201
202 Level logLevel = args.getLogLevel();
203 Logging.setLogLevel(logLevel);
204 if (!args.showVersion() && !args.showHelp()) {
205 Main.info(tr("Log level is at {0} ({1}, {2})", logLevel.getLocalizedName(), logLevel.getName(), logLevel.intValue()));
206 }
207
208 Optional<String> language = args.getSingle(Option.LANGUAGE);
209 I18n.set(language.orElse(null));
210
211 Policy.setPolicy(new Policy() {
212 // Permissions for plug-ins loaded when josm is started via webstart
213 private PermissionCollection pc;
214
215 {
216 pc = new Permissions();
217 pc.add(new AllPermission());
218 }
219
220 @Override
221 public PermissionCollection getPermissions(CodeSource codesource) {
222 return pc;
223 }
224 });
225
226 Thread.setDefaultUncaughtExceptionHandler(new BugReportExceptionHandler());
227
228 // initialize the platform hook, and
229 Main.determinePlatformHook();
230 // call the really early hook before we do anything else
231 Main.platform.preStartupHook();
232
233 if (args.showVersion()) {
234 System.out.println(Version.getInstance().getAgentString());
235 return;
236 } else if (args.showHelp()) {
237 showHelp();
238 return;
239 }
240
241 Main.COMMAND_LINE_ARGS.addAll(Arrays.asList(argArray));
242
243 boolean skipLoadingPlugins = args.hasOption(Option.SKIP_PLUGINS);
244 if (skipLoadingPlugins) {
245 Main.info(tr("Plugin loading skipped"));
246 }
247
248 if (Logging.isLoggingEnabled(Logging.LEVEL_TRACE)) {
249 // Enable debug in OAuth signpost via system preference, but only at trace level
250 Utils.updateSystemProperty("debug", "true");
251 Main.info(tr("Enabled detailed debug level (trace)"));
252 }
253
254 Main.pref.init(args.hasOption(Option.RESET_PREFERENCES));
255
256 args.getPreferencesToSet().forEach(Main.pref::put);
257
258 if (!language.isPresent()) {
259 I18n.set(Main.pref.get("language", null));
260 }
261 Main.pref.updateSystemProperties();
262
263 checkIPv6();
264
265 processOffline(args);
266
267 Main.platform.afterPrefStartupHook();
268
269 FontsManager.initialize();
270
271 I18n.setupLanguageFonts();
272
273 Handler.install();
274
275 WindowGeometry geometry = WindowGeometry.mainWindow("gui.geometry",
276 args.getSingle(Option.GEOMETRY).orElse(null),
277 !args.hasOption(Option.NO_MAXIMIZE) && Main.pref.getBoolean("gui.maximized", false));
278 final MainFrame mainFrame = new MainFrame(contentPanePrivate, mainPanel, geometry);
279 Main.parent = mainFrame;
280
281 if (args.hasOption(Option.LOAD_PREFERENCES)) {
282 CustomConfigurator.XMLCommandProcessor config = new CustomConfigurator.XMLCommandProcessor(Main.pref);
283 for (String i : args.get(Option.LOAD_PREFERENCES)) {
284 info("Reading preferences from " + i);
285 try (InputStream is = openStream(new URL(i))) {
286 config.openAndReadXML(is);
287 } catch (IOException ex) {
288 throw BugReport.intercept(ex).put("file", i);
289 }
290 }
291 }
292
293 try {
294 CertificateAmendment.addMissingCertificates();
295 } catch (IOException | GeneralSecurityException ex) {
296 Main.warn(ex);
297 Main.warn(getErrorMessage(Utils.getRootCause(ex)));
298 }
299 Authenticator.setDefault(DefaultAuthenticator.getInstance());
300 DefaultProxySelector proxySelector = new DefaultProxySelector(ProxySelector.getDefault());
301 ProxySelector.setDefault(proxySelector);
302 OAuthAccessTokenHolder.getInstance().init(Main.pref, CredentialsManager.getInstance());
303
304 final SplashScreen splash = GuiHelper.runInEDTAndWaitAndReturn(SplashScreen::new);
305 final SplashScreen.SplashProgressMonitor monitor = splash.getProgressMonitor();
306 monitor.beginTask(tr("Initializing"));
307 GuiHelper.runInEDT(() -> splash.setVisible(Main.pref.getBoolean("draw.splashscreen", true)));
308 Main.setInitStatusListener(new InitStatusListener() {
309
310 @Override
311 public Object updateStatus(String event) {
312 monitor.beginTask(event);
313 return event;
314 }
315
316 @Override
317 public void finish(Object status) {
318 if (status instanceof String) {
319 monitor.finishTask((String) status);
320 }
321 }
322 });
323
324 Collection<PluginInformation> pluginsToLoad = null;
325
326 if (!skipLoadingPlugins) {
327 pluginsToLoad = updateAndLoadEarlyPlugins(splash, monitor);
328 }
329
330 monitor.indeterminateSubTask(tr("Setting defaults"));
331 preConstructorInit();
332
333 monitor.indeterminateSubTask(tr("Creating main GUI"));
334 final Main main = new MainApplication(mainFrame);
335 main.initialize();
336
337 if (!skipLoadingPlugins) {
338 loadLatePlugins(splash, monitor, pluginsToLoad);
339 }
340
341 // Wait for splash disappearance (fix #9714)
342 GuiHelper.runInEDTAndWait(() -> {
343 splash.setVisible(false);
344 splash.dispose();
345 mainFrame.setVisible(true);
346 });
347
348 Main.MasterWindowListener.setup();
349
350 boolean maximized = Main.pref.getBoolean("gui.maximized", false);
351 if ((!args.hasOption(Option.NO_MAXIMIZE) && maximized) || args.hasOption(Option.MAXIMIZE)) {
352 mainFrame.setMaximized(true);
353 }
354 if (main.menu.fullscreenToggleAction != null) {
355 main.menu.fullscreenToggleAction.initial();
356 }
357
358 SwingUtilities.invokeLater(new GuiFinalizationWorker(args, proxySelector));
359
360 if (Main.isPlatformWindows()) {
361 try {
362 // Check for insecure certificates to remove.
363 // This is Windows-dependant code but it can't go to preStartupHook (need i18n)
364 // neither startupHook (need to be called before remote control)
365 PlatformHookWindows.removeInsecureCertificates();
366 } catch (NoSuchAlgorithmException | CertificateException | KeyStoreException | IOException e) {
367 error(e);
368 }
369 }
370
371 if (RemoteControl.PROP_REMOTECONTROL_ENABLED.get()) {
372 RemoteControl.start();
373 }
374
375 if (MessageNotifier.PROP_NOTIFIER_ENABLED.get()) {
376 MessageNotifier.start();
377 }
378
379 if (Main.pref.getBoolean("debug.edt-checker.enable", Version.getInstance().isLocalBuild())) {
380 // Repaint manager is registered so late for a reason - there is lots of violation during startup process
381 // but they don't seem to break anything and are difficult to fix
382 info("Enabled EDT checker, wrongful access to gui from non EDT thread will be printed to console");
383 RepaintManager.setCurrentManager(new CheckThreadViolationRepaintManager());
384 }
385 }
386
387 private static InputStream openStream(URL url) throws IOException {
388 if ("file".equals(url.getProtocol())) {
389 return url.openStream();
390 } else {
391 return HttpClient.create(url).connect().getContent();
392 }
393 }
394
395 static Collection<PluginInformation> updateAndLoadEarlyPlugins(SplashScreen splash, SplashProgressMonitor monitor) {
396 Collection<PluginInformation> pluginsToLoad;
397 pluginsToLoad = PluginHandler.buildListOfPluginsToLoad(splash, monitor.createSubTaskMonitor(1, false));
398 if (!pluginsToLoad.isEmpty() && PluginHandler.checkAndConfirmPluginUpdate(splash)) {
399 monitor.subTask(tr("Updating plugins"));
400 pluginsToLoad = PluginHandler.updatePlugins(splash, null, monitor.createSubTaskMonitor(1, false), false);
401 }
402
403 monitor.indeterminateSubTask(tr("Installing updated plugins"));
404 PluginHandler.installDownloadedPlugins(true);
405
406 monitor.indeterminateSubTask(tr("Loading early plugins"));
407 PluginHandler.loadEarlyPlugins(splash, pluginsToLoad, monitor.createSubTaskMonitor(1, false));
408 return pluginsToLoad;
409 }
410
411 static void loadLatePlugins(SplashScreen splash, SplashProgressMonitor monitor, Collection<PluginInformation> pluginsToLoad) {
412 monitor.indeterminateSubTask(tr("Loading plugins"));
413 PluginHandler.loadLatePlugins(splash, pluginsToLoad, monitor.createSubTaskMonitor(1, false));
414 toolbar.refreshToolbarControl();
415 }
416
417 private static void processOffline(ProgramArguments args) {
418 for (String offlineNames : args.get(Option.OFFLINE)) {
419 for (String s : offlineNames.split(",")) {
420 try {
421 Main.setOffline(OnlineResource.valueOf(s.toUpperCase(Locale.ENGLISH)));
422 } catch (IllegalArgumentException e) {
423 Main.error(e, tr("''{0}'' is not a valid value for argument ''{1}''. Possible values are {2}, possibly delimited by commas.",
424 s.toUpperCase(Locale.ENGLISH), Option.OFFLINE.getName(), Arrays.toString(OnlineResource.values())));
425 System.exit(1);
426 return;
427 }
428 }
429 }
430 Set<OnlineResource> offline = Main.getOfflineResources();
431 if (!offline.isEmpty()) {
432 Main.warn(trn("JOSM is running in offline mode. This resource will not be available: {0}",
433 "JOSM is running in offline mode. These resources will not be available: {0}",
434 offline.size(), offline.size() == 1 ? offline.iterator().next() : Arrays.toString(offline.toArray())));
435 }
436 }
437
438 /**
439 * Check if IPv6 can be safely enabled and do so. Because this cannot be done after network activation,
440 * disabling or enabling IPV6 may only be done with next start.
441 */
442 private static void checkIPv6() {
443 if ("auto".equals(Main.pref.get("prefer.ipv6", "auto"))) {
444 new Thread((Runnable) () -> { /* this may take some time (DNS, Connect) */
445 boolean hasv6 = false;
446 boolean wasv6 = Main.pref.getBoolean("validated.ipv6", false);
447 try {
448 /* Use the check result from last run of the software, as after the test, value
449 changes have no effect anymore */
450 if (wasv6) {
451 Utils.updateSystemProperty("java.net.preferIPv6Addresses", "true");
452 }
453 for (InetAddress a : InetAddress.getAllByName("josm.openstreetmap.de")) {
454 if (a instanceof Inet6Address) {
455 if (a.isReachable(1000)) {
456 /* be sure it REALLY works */
457 SSLSocketFactory.getDefault().createSocket(a, 443).close();
458 Utils.updateSystemProperty("java.net.preferIPv6Addresses", "true");
459 if (!wasv6) {
460 Main.info(tr("Detected useable IPv6 network, prefering IPv6 over IPv4 after next restart."));
461 } else {
462 Main.info(tr("Detected useable IPv6 network, prefering IPv6 over IPv4."));
463 }
464 hasv6 = true;
465 }
466 break; /* we're done */
467 }
468 }
469 } catch (IOException | SecurityException e) {
470 if (Main.isDebugEnabled()) {
471 Main.debug("Exception while checking IPv6 connectivity: "+e);
472 }
473 Main.trace(e);
474 }
475 if (wasv6 && !hasv6) {
476 Main.info(tr("Detected no useable IPv6 network, prefering IPv4 over IPv6 after next restart."));
477 Main.pref.put("validated.ipv6", hasv6); // be sure it is stored before the restart!
478 new RestartAction().actionPerformed(null);
479 }
480 Main.pref.put("validated.ipv6", hasv6);
481 }, "IPv6-checker").start();
482 }
483 }
484
485 private static class GuiFinalizationWorker implements Runnable {
486
487 private final ProgramArguments args;
488 private final DefaultProxySelector proxySelector;
489
490 GuiFinalizationWorker(ProgramArguments args, DefaultProxySelector proxySelector) {
491 this.args = args;
492 this.proxySelector = proxySelector;
493 }
494
495 @Override
496 public void run() {
497
498 // Handle proxy/network errors early to inform user he should change settings to be able to use JOSM correctly
499 if (!handleProxyErrors()) {
500 handleNetworkErrors();
501 }
502
503 // Restore autosave layers after crash and start autosave thread
504 handleAutosave();
505
506 // Handle command line instructions
507 postConstructorProcessCmdLine(args);
508
509 // Show download dialog if autostart is enabled
510 DownloadDialog.autostartIfNeeded();
511 }
512
513 private static void handleAutosave() {
514 if (AutosaveTask.PROP_AUTOSAVE_ENABLED.get()) {
515 AutosaveTask autosaveTask = new AutosaveTask();
516 List<File> unsavedLayerFiles = autosaveTask.getUnsavedLayersFiles();
517 if (!unsavedLayerFiles.isEmpty()) {
518 ExtendedDialog dialog = new ExtendedDialog(
519 Main.parent,
520 tr("Unsaved osm data"),
521 new String[] {tr("Restore"), tr("Cancel"), tr("Discard")}
522 );
523 dialog.setContent(
524 trn("JOSM found {0} unsaved osm data layer. ",
525 "JOSM found {0} unsaved osm data layers. ", unsavedLayerFiles.size(), unsavedLayerFiles.size()) +
526 tr("It looks like JOSM crashed last time. Would you like to restore the data?"));
527 dialog.setButtonIcons(new String[] {"ok", "cancel", "dialogs/delete"});
528 int selection = dialog.showDialog().getValue();
529 if (selection == 1) {
530 autosaveTask.recoverUnsavedLayers();
531 } else if (selection == 3) {
532 autosaveTask.discardUnsavedLayers();
533 }
534 }
535 autosaveTask.schedule();
536 }
537 }
538
539 private static boolean handleNetworkOrProxyErrors(boolean hasErrors, String title, String message) {
540 if (hasErrors) {
541 ExtendedDialog ed = new ExtendedDialog(
542 Main.parent, title,
543 new String[]{tr("Change proxy settings"), tr("Cancel")});
544 ed.setButtonIcons(new String[]{"dialogs/settings", "cancel"}).setCancelButton(2);
545 ed.setMinimumSize(new Dimension(460, 260));
546 ed.setIcon(JOptionPane.WARNING_MESSAGE);
547 ed.setContent(message);
548
549 if (ed.showDialog().getValue() == 1) {
550 PreferencesAction.forPreferenceSubTab(null, null, ProxyPreference.class).run();
551 }
552 }
553 return hasErrors;
554 }
555
556 private boolean handleProxyErrors() {
557 return handleNetworkOrProxyErrors(proxySelector.hasErrors(), tr("Proxy errors occurred"),
558 tr("JOSM tried to access the following resources:<br>" +
559 "{0}" +
560 "but <b>failed</b> to do so, because of the following proxy errors:<br>" +
561 "{1}" +
562 "Would you like to change your proxy settings now?",
563 Utils.joinAsHtmlUnorderedList(proxySelector.getErrorResources()),
564 Utils.joinAsHtmlUnorderedList(proxySelector.getErrorMessages())
565 ));
566 }
567
568 private static boolean handleNetworkErrors() {
569 boolean condition = !NETWORK_ERRORS.isEmpty();
570 if (condition) {
571 Set<String> errors = new TreeSet<>();
572 for (Throwable t : NETWORK_ERRORS.values()) {
573 errors.add(t.toString());
574 }
575 return handleNetworkOrProxyErrors(condition, tr("Network errors occurred"),
576 tr("JOSM tried to access the following resources:<br>" +
577 "{0}" +
578 "but <b>failed</b> to do so, because of the following network errors:<br>" +
579 "{1}" +
580 "It may be due to a missing proxy configuration.<br>" +
581 "Would you like to change your proxy settings now?",
582 Utils.joinAsHtmlUnorderedList(NETWORK_ERRORS.keySet()),
583 Utils.joinAsHtmlUnorderedList(errors)
584 ));
585 }
586 return false;
587 }
588 }
589}
Note: See TracBrowser for help on using the repository browser.