source: josm/trunk/src/org/openstreetmap/josm/Main.java@ 11988

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

improve unit test for Main.postConstructorProcessCmdLine

  • Property svn:eol-style set to native
File size: 50.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.BorderLayout;
7import java.awt.Component;
8import java.awt.GraphicsEnvironment;
9import java.awt.event.KeyEvent;
10import java.io.File;
11import java.io.IOException;
12import java.lang.ref.WeakReference;
13import java.net.URI;
14import java.net.URISyntaxException;
15import java.net.URL;
16import java.text.MessageFormat;
17import java.util.ArrayList;
18import java.util.Arrays;
19import java.util.Collection;
20import java.util.Collections;
21import java.util.EnumSet;
22import java.util.HashMap;
23import java.util.Iterator;
24import java.util.List;
25import java.util.Locale;
26import java.util.Map;
27import java.util.Objects;
28import java.util.Set;
29import java.util.StringTokenizer;
30import java.util.concurrent.Callable;
31import java.util.concurrent.ExecutionException;
32import java.util.concurrent.ExecutorService;
33import java.util.concurrent.Executors;
34import java.util.concurrent.Future;
35
36import javax.swing.Action;
37import javax.swing.InputMap;
38import javax.swing.JComponent;
39import javax.swing.JOptionPane;
40import javax.swing.JPanel;
41import javax.swing.KeyStroke;
42import javax.swing.LookAndFeel;
43import javax.swing.UIManager;
44import javax.swing.UnsupportedLookAndFeelException;
45
46import org.openstreetmap.gui.jmapviewer.FeatureAdapter;
47import org.openstreetmap.josm.actions.JosmAction;
48import org.openstreetmap.josm.actions.OpenFileAction;
49import org.openstreetmap.josm.actions.OpenLocationAction;
50import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask;
51import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask;
52import org.openstreetmap.josm.actions.downloadtasks.DownloadTask;
53import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler;
54import org.openstreetmap.josm.actions.mapmode.DrawAction;
55import org.openstreetmap.josm.actions.search.SearchAction;
56import org.openstreetmap.josm.data.Bounds;
57import org.openstreetmap.josm.data.Preferences;
58import org.openstreetmap.josm.data.ProjectionBounds;
59import org.openstreetmap.josm.data.UndoRedoHandler;
60import org.openstreetmap.josm.data.ViewportData;
61import org.openstreetmap.josm.data.cache.JCSCacheManager;
62import org.openstreetmap.josm.data.coor.CoordinateFormat;
63import org.openstreetmap.josm.data.coor.LatLon;
64import org.openstreetmap.josm.data.osm.DataSet;
65import org.openstreetmap.josm.data.osm.OsmPrimitive;
66import org.openstreetmap.josm.data.projection.Projection;
67import org.openstreetmap.josm.data.projection.ProjectionChangeListener;
68import org.openstreetmap.josm.data.validation.OsmValidator;
69import org.openstreetmap.josm.gui.MainFrame;
70import org.openstreetmap.josm.gui.MainMenu;
71import org.openstreetmap.josm.gui.MainPanel;
72import org.openstreetmap.josm.gui.MapFrame;
73import org.openstreetmap.josm.gui.MapFrameListener;
74import org.openstreetmap.josm.gui.ProgramArguments;
75import org.openstreetmap.josm.gui.ProgramArguments.Option;
76import org.openstreetmap.josm.gui.io.SaveLayersDialog;
77import org.openstreetmap.josm.gui.layer.Layer;
78import org.openstreetmap.josm.gui.layer.MainLayerManager;
79import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener;
80import org.openstreetmap.josm.gui.layer.TMSLayer;
81import org.openstreetmap.josm.gui.preferences.ToolbarPreferences;
82import org.openstreetmap.josm.gui.preferences.display.LafPreference;
83import org.openstreetmap.josm.gui.preferences.imagery.ImageryPreference;
84import org.openstreetmap.josm.gui.preferences.map.MapPaintPreference;
85import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference;
86import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor;
87import org.openstreetmap.josm.gui.progress.ProgressMonitorExecutor;
88import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
89import org.openstreetmap.josm.gui.util.GuiHelper;
90import org.openstreetmap.josm.gui.util.RedirectInputMap;
91import org.openstreetmap.josm.io.FileWatcher;
92import org.openstreetmap.josm.io.OnlineResource;
93import org.openstreetmap.josm.io.OsmApi;
94import org.openstreetmap.josm.io.OsmApiInitializationException;
95import org.openstreetmap.josm.io.OsmTransferCanceledException;
96import org.openstreetmap.josm.plugins.PluginHandler;
97import org.openstreetmap.josm.tools.CheckParameterUtil;
98import org.openstreetmap.josm.tools.I18n;
99import org.openstreetmap.josm.tools.ImageProvider;
100import org.openstreetmap.josm.tools.JosmRuntimeException;
101import org.openstreetmap.josm.tools.Logging;
102import org.openstreetmap.josm.tools.OpenBrowser;
103import org.openstreetmap.josm.tools.OsmUrlToBounds;
104import org.openstreetmap.josm.tools.OverpassTurboQueryWizard;
105import org.openstreetmap.josm.tools.PlatformHook;
106import org.openstreetmap.josm.tools.PlatformHookOsx;
107import org.openstreetmap.josm.tools.PlatformHookUnixoid;
108import org.openstreetmap.josm.tools.PlatformHookWindows;
109import org.openstreetmap.josm.tools.RightAndLefthandTraffic;
110import org.openstreetmap.josm.tools.Shortcut;
111import org.openstreetmap.josm.tools.Territories;
112import org.openstreetmap.josm.tools.Utils;
113import org.openstreetmap.josm.tools.bugreport.BugReport;
114
115/**
116 * Abstract class holding various static global variables and methods used in large parts of JOSM application.
117 * @since 98
118 */
119public abstract class Main {
120
121 /**
122 * The JOSM website URL.
123 * @since 6897 (was public from 6143 to 6896)
124 */
125 private static final String JOSM_WEBSITE = "https://josm.openstreetmap.de";
126
127 /**
128 * The OSM website URL.
129 * @since 6897 (was public from 6453 to 6896)
130 */
131 private static final String OSM_WEBSITE = "https://www.openstreetmap.org";
132
133 /**
134 * Replies true if JOSM currently displays a map view. False, if it doesn't, i.e. if
135 * it only shows the MOTD panel.
136 * <p>
137 * You do not need this when accessing the layer manager. The layer manager will be empty if no map view is shown.
138 *
139 * @return <code>true</code> if JOSM currently displays a map view
140 */
141 public static boolean isDisplayingMapView() {
142 return map != null && map.mapView != null;
143 }
144
145 /**
146 * Global parent component for all dialogs and message boxes
147 */
148 public static Component parent;
149
150 /**
151 * Global application.
152 */
153 public static volatile Main main;
154
155 /**
156 * The worker thread slave. This is for executing all long and intensive
157 * calculations. The executed runnables are guaranteed to be executed separately
158 * and sequential.
159 */
160 public static final ExecutorService worker = new ProgressMonitorExecutor("main-worker-%d", Thread.NORM_PRIORITY);
161
162 /**
163 * Global application preferences
164 */
165 public static final Preferences pref = new Preferences();
166
167 /**
168 * The MapFrame.
169 * <p>
170 * There should be no need to access this to access any map data. Use {@link #layerManager} instead.
171 *
172 * @see MainPanel
173 */
174 public static MapFrame map;
175
176 /**
177 * Provides access to the layers displayed in the main view.
178 * @since 10271
179 */
180 private static final MainLayerManager layerManager = new MainLayerManager();
181
182 /**
183 * The toolbar preference control to register new actions.
184 */
185 public static volatile ToolbarPreferences toolbar;
186
187 /**
188 * The commands undo/redo handler.
189 */
190 public final UndoRedoHandler undoRedo = new UndoRedoHandler();
191
192 /**
193 * The progress monitor being currently displayed.
194 */
195 public static PleaseWaitProgressMonitor currentProgressMonitor;
196
197 /**
198 * The main menu bar at top of screen.
199 */
200 public MainMenu menu;
201
202 /**
203 * The file watcher service.
204 */
205 public static final FileWatcher fileWatcher = new FileWatcher();
206
207 private static final Map<String, Throwable> NETWORK_ERRORS = new HashMap<>();
208
209 private static final Set<OnlineResource> OFFLINE_RESOURCES = EnumSet.noneOf(OnlineResource.class);
210
211 /**
212 * Logging level (5 = trace, 4 = debug, 3 = info, 2 = warn, 1 = error, 0 = none).
213 * @since 6248
214 * @deprecated Use {@link Logging} class.
215 */
216 @Deprecated
217 public static int logLevel = 3;
218
219 /**
220 * The real main panel. This field may be removed any time and made private to {@link MainFrame}
221 * @see #panel
222 */
223 protected static final MainPanel mainPanel = new MainPanel(getLayerManager());
224
225 /**
226 * Replies the first lines of last 5 error and warning messages, used for bug reports
227 * @return the first lines of last 5 error and warning messages
228 * @since 7420
229 */
230 public static final Collection<String> getLastErrorAndWarnings() {
231 return Logging.getLastErrorAndWarnings();
232 }
233
234 /**
235 * Clears the list of last error and warning messages.
236 * @since 8959
237 */
238 public static void clearLastErrorAndWarnings() {
239 Logging.clearLastErrorAndWarnings();
240 }
241
242 /**
243 * Prints an error message if logging is on.
244 * @param msg The message to print.
245 * @since 6248
246 */
247 public static void error(String msg) {
248 Logging.error(msg);
249 }
250
251 /**
252 * Prints a warning message if logging is on.
253 * @param msg The message to print.
254 */
255 public static void warn(String msg) {
256 Logging.warn(msg);
257 }
258
259 /**
260 * Prints an informational message if logging is on.
261 * @param msg The message to print.
262 */
263 public static void info(String msg) {
264 Logging.info(msg);
265 }
266
267 /**
268 * Prints a debug message if logging is on.
269 * @param msg The message to print.
270 */
271 public static void debug(String msg) {
272 Logging.debug(msg);
273 }
274
275 /**
276 * Prints a trace message if logging is on.
277 * @param msg The message to print.
278 */
279 public static void trace(String msg) {
280 Logging.trace(msg);
281 }
282
283 /**
284 * Determines if debug log level is enabled.
285 * Useful to avoid costly construction of debug messages when not enabled.
286 * @return {@code true} if log level is at least debug, {@code false} otherwise
287 * @since 6852
288 */
289 public static boolean isDebugEnabled() {
290 return Logging.isLoggingEnabled(Logging.LEVEL_DEBUG);
291 }
292
293 /**
294 * Determines if trace log level is enabled.
295 * Useful to avoid costly construction of trace messages when not enabled.
296 * @return {@code true} if log level is at least trace, {@code false} otherwise
297 * @since 6852
298 */
299 public static boolean isTraceEnabled() {
300 return Logging.isLoggingEnabled(Logging.LEVEL_TRACE);
301 }
302
303 /**
304 * Prints a formatted error message if logging is on. Calls {@link MessageFormat#format}
305 * function to format text.
306 * @param msg The formatted message to print.
307 * @param objects The objects to insert into format string.
308 * @since 6248
309 */
310 public static void error(String msg, Object... objects) {
311 Logging.error(msg, objects);
312 }
313
314 /**
315 * Prints a formatted warning message if logging is on. Calls {@link MessageFormat#format}
316 * function to format text.
317 * @param msg The formatted message to print.
318 * @param objects The objects to insert into format string.
319 */
320 public static void warn(String msg, Object... objects) {
321 Logging.warn(msg, objects);
322 }
323
324 /**
325 * Prints a formatted informational message if logging is on. Calls {@link MessageFormat#format}
326 * function to format text.
327 * @param msg The formatted message to print.
328 * @param objects The objects to insert into format string.
329 */
330 public static void info(String msg, Object... objects) {
331 Logging.info(msg, objects);
332 }
333
334 /**
335 * Prints a formatted debug message if logging is on. Calls {@link MessageFormat#format}
336 * function to format text.
337 * @param msg The formatted message to print.
338 * @param objects The objects to insert into format string.
339 */
340 public static void debug(String msg, Object... objects) {
341 Logging.debug(msg, objects);
342 }
343
344 /**
345 * Prints a formatted trace message if logging is on. Calls {@link MessageFormat#format}
346 * function to format text.
347 * @param msg The formatted message to print.
348 * @param objects The objects to insert into format string.
349 */
350 public static void trace(String msg, Object... objects) {
351 Logging.trace(msg, objects);
352 }
353
354 /**
355 * Prints an error message for the given Throwable.
356 * @param t The throwable object causing the error
357 * @since 6248
358 */
359 public static void error(Throwable t) {
360 Logging.logWithStackTrace(Logging.LEVEL_ERROR, t);
361 }
362
363 /**
364 * Prints a warning message for the given Throwable.
365 * @param t The throwable object causing the error
366 * @since 6248
367 */
368 public static void warn(Throwable t) {
369 Logging.logWithStackTrace(Logging.LEVEL_WARN, t);
370 }
371
372 /**
373 * Prints a debug message for the given Throwable. Useful for exceptions usually ignored
374 * @param t The throwable object causing the error
375 * @since 10420
376 */
377 public static void debug(Throwable t) {
378 Logging.log(Logging.LEVEL_DEBUG, t);
379 }
380
381 /**
382 * Prints a trace message for the given Throwable. Useful for exceptions usually ignored
383 * @param t The throwable object causing the error
384 * @since 10420
385 */
386 public static void trace(Throwable t) {
387 Logging.log(Logging.LEVEL_TRACE, t);
388 }
389
390 /**
391 * Prints an error message for the given Throwable.
392 * @param t The throwable object causing the error
393 * @param stackTrace {@code true}, if the stacktrace should be displayed
394 * @since 6642
395 */
396 public static void error(Throwable t, boolean stackTrace) {
397 if (stackTrace) {
398 Logging.log(Logging.LEVEL_ERROR, t);
399 } else {
400 Logging.logWithStackTrace(Logging.LEVEL_ERROR, t);
401 }
402 }
403
404 /**
405 * Prints an error message for the given Throwable.
406 * @param t The throwable object causing the error
407 * @param message additional error message
408 * @since 10420
409 */
410 public static void error(Throwable t, String message) {
411 Logging.log(Logging.LEVEL_ERROR, message, t);
412 }
413
414 /**
415 * Prints a warning message for the given Throwable.
416 * @param t The throwable object causing the error
417 * @param stackTrace {@code true}, if the stacktrace should be displayed
418 * @since 6642
419 */
420 public static void warn(Throwable t, boolean stackTrace) {
421 if (stackTrace) {
422 Logging.log(Logging.LEVEL_WARN, t);
423 } else {
424 Logging.logWithStackTrace(Logging.LEVEL_WARN, t);
425 }
426 }
427
428 /**
429 * Prints a warning message for the given Throwable.
430 * @param t The throwable object causing the error
431 * @param message additional error message
432 * @since 10420
433 */
434 public static void warn(Throwable t, String message) {
435 Logging.log(Logging.LEVEL_WARN, message, t);
436 }
437
438 /**
439 * Returns a human-readable message of error, also usable for developers.
440 * @param t The error
441 * @return The human-readable error message
442 * @since 6642
443 */
444 public static String getErrorMessage(Throwable t) {
445 if (t == null) {
446 return null;
447 } else {
448 return Logging.getErrorMessage(t);
449 }
450 }
451
452 /**
453 * Platform specific code goes in here.
454 * Plugins may replace it, however, some hooks will be called before any plugins have been loeaded.
455 * So if you need to hook into those early ones, split your class and send the one with the early hooks
456 * to the JOSM team for inclusion.
457 */
458 public static volatile PlatformHook platform;
459
460 private static volatile InitStatusListener initListener;
461
462 /**
463 * Initialization task listener.
464 */
465 public interface InitStatusListener {
466
467 /**
468 * Called when an initialization task updates its status.
469 * @param event task name
470 * @return new status
471 */
472 Object updateStatus(String event);
473
474 /**
475 * Called when an initialization task completes.
476 * @param status final status
477 */
478 void finish(Object status);
479 }
480
481 /**
482 * Sets initialization task listener.
483 * @param listener initialization task listener
484 */
485 public static void setInitStatusListener(InitStatusListener listener) {
486 CheckParameterUtil.ensureParameterNotNull(listener);
487 initListener = listener;
488 }
489
490 /**
491 * Constructs new {@code Main} object.
492 * @see #initialize()
493 */
494 protected Main() {
495 setInstance(this);
496 mainPanel.addMapFrameListener((o, n) -> redoUndoListener.commandChanged(0, 0));
497 }
498
499 private static void setInstance(Main instance) {
500 main = instance;
501 }
502
503 /**
504 * Initializes the main object. A lot of global variables are initialized here.
505 * @since 10340
506 */
507 public void initialize() {
508 fileWatcher.start();
509
510 new InitializationTask(tr("Executing platform startup hook"), platform::startupHook).call();
511
512 new InitializationTask(tr("Building main menu"), this::initializeMainWindow).call();
513
514 undoRedo.addCommandQueueListener(redoUndoListener);
515
516 // creating toolbar
517 GuiHelper.runInEDTAndWait(() -> contentPanePrivate.add(toolbar.control, BorderLayout.NORTH));
518
519 registerActionShortcut(menu.help, Shortcut.registerShortcut("system:help", tr("Help"),
520 KeyEvent.VK_F1, Shortcut.DIRECT));
521
522 // This needs to be done before RightAndLefthandTraffic::initialize is called
523 try {
524 new InitializationTask(tr("Initializing internal boundaries data"), Territories::initialize).call();
525 } catch (JosmRuntimeException e) {
526 // Can happen if the current projection needs NTV2 grid which is not available
527 // In this case we want the user be able to change his projection
528 BugReport.intercept(e).warn();
529 }
530
531 // contains several initialization tasks to be executed (in parallel) by a ExecutorService
532 List<Callable<Void>> tasks = new ArrayList<>();
533
534 tasks.add(new InitializationTask(tr("Initializing OSM API"), () -> {
535 // We try to establish an API connection early, so that any API
536 // capabilities are already known to the editor instance. However
537 // if it goes wrong that's not critical at this stage.
538 try {
539 OsmApi.getOsmApi().initialize(null, true);
540 } catch (OsmTransferCanceledException | OsmApiInitializationException e) {
541 Main.warn(getErrorMessage(Utils.getRootCause(e)));
542 }
543 }));
544
545 tasks.add(new InitializationTask(tr("Initializing internal traffic data"), RightAndLefthandTraffic::initialize));
546
547 tasks.add(new InitializationTask(tr("Initializing validator"), OsmValidator::initialize));
548
549 tasks.add(new InitializationTask(tr("Initializing presets"), TaggingPresets::initialize));
550
551 tasks.add(new InitializationTask(tr("Initializing map styles"), MapPaintPreference::initialize));
552
553 tasks.add(new InitializationTask(tr("Loading imagery preferences"), ImageryPreference::initialize));
554
555 try {
556 ExecutorService service = Executors.newFixedThreadPool(
557 Runtime.getRuntime().availableProcessors(), Utils.newThreadFactory("main-init-%d", Thread.NORM_PRIORITY));
558 for (Future<Void> i : service.invokeAll(tasks)) {
559 i.get();
560 }
561 // asynchronous initializations to be completed eventually
562 service.submit((Runnable) TMSLayer::getCache);
563 service.submit((Runnable) OsmValidator::initializeTests);
564 service.submit(OverpassTurboQueryWizard::getInstance);
565 service.shutdown();
566 } catch (InterruptedException | ExecutionException ex) {
567 throw new JosmRuntimeException(ex);
568 }
569
570 // hooks for the jmapviewer component
571 FeatureAdapter.registerBrowserAdapter(OpenBrowser::displayUrl);
572 FeatureAdapter.registerTranslationAdapter(I18n.getTranslationAdapter());
573 FeatureAdapter.registerLoggingAdapter(name -> Logging.getLogger());
574
575 new InitializationTask(tr("Updating user interface"), () -> GuiHelper.runInEDTAndWait(() -> {
576 toolbar.refreshToolbarControl();
577 toolbar.control.updateUI();
578 contentPanePrivate.updateUI();
579 })).call();
580 }
581
582 /**
583 * Called once at startup to initialize the main window content.
584 * Should set {@link #menu}
585 */
586 protected abstract void initializeMainWindow();
587
588 private static class InitializationTask implements Callable<Void> {
589
590 private final String name;
591 private final Runnable task;
592
593 protected InitializationTask(String name, Runnable task) {
594 this.name = name;
595 this.task = task;
596 }
597
598 @Override
599 public Void call() {
600 Object status = null;
601 if (initListener != null) {
602 status = initListener.updateStatus(name);
603 }
604 task.run();
605 if (initListener != null) {
606 initListener.finish(status);
607 }
608 return null;
609 }
610 }
611
612 /**
613 * Returns the main layer manager that is used by the map view.
614 * @return The layer manager. The value returned will never change.
615 * @since 10279
616 */
617 public static MainLayerManager getLayerManager() {
618 return layerManager;
619 }
620
621 /**
622 * Add a new layer to the map.
623 *
624 * If no map exists, create one.
625 *
626 * @param layer the layer
627 * @param bounds the bounds of the layer (target zoom area); can be null, then
628 * the viewport isn't changed
629 */
630 public final void addLayer(Layer layer, ProjectionBounds bounds) {
631 addLayer(layer, bounds == null ? null : new ViewportData(bounds));
632 }
633
634 /**
635 * Add a new layer to the map.
636 *
637 * If no map exists, create one.
638 *
639 * @param layer the layer
640 * @param viewport the viewport to zoom to; can be null, then the viewport isn't changed
641 */
642 public final void addLayer(Layer layer, ViewportData viewport) {
643 getLayerManager().addLayer(layer);
644 if (viewport != null && Main.map.mapView != null) {
645 // MapView may be null in headless mode here.
646 Main.map.mapView.scheduleZoomTo(viewport);
647 }
648 }
649
650 /**
651 * Replies the current selected primitives, from a end-user point of view.
652 * It is not always technically the same collection of primitives than {@link DataSet#getSelected()}.
653 * Indeed, if the user is currently in drawing mode, only the way currently being drawn is returned,
654 * see {@link DrawAction#getInProgressSelection()}.
655 *
656 * @return The current selected primitives, from a end-user point of view. Can be {@code null}.
657 * @since 6546
658 */
659 public Collection<OsmPrimitive> getInProgressSelection() {
660 if (map != null && map.mapMode instanceof DrawAction) {
661 return ((DrawAction) map.mapMode).getInProgressSelection();
662 } else {
663 DataSet ds = getLayerManager().getEditDataSet();
664 if (ds == null) return null;
665 return ds.getSelected();
666 }
667 }
668
669 protected static final JPanel contentPanePrivate = new JPanel(new BorderLayout());
670
671 public static void redirectToMainContentPane(JComponent source) {
672 RedirectInputMap.redirect(source, contentPanePrivate);
673 }
674
675 /**
676 * Registers a {@code JosmAction} and its shortcut.
677 * @param action action defining its own shortcut
678 */
679 public static void registerActionShortcut(JosmAction action) {
680 registerActionShortcut(action, action.getShortcut());
681 }
682
683 /**
684 * Registers an action and its shortcut.
685 * @param action action to register
686 * @param shortcut shortcut to associate to {@code action}
687 */
688 public static void registerActionShortcut(Action action, Shortcut shortcut) {
689 KeyStroke keyStroke = shortcut.getKeyStroke();
690 if (keyStroke == null)
691 return;
692
693 InputMap inputMap = contentPanePrivate.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
694 Object existing = inputMap.get(keyStroke);
695 if (existing != null && !existing.equals(action)) {
696 info(String.format("Keystroke %s is already assigned to %s, will be overridden by %s", keyStroke, existing, action));
697 }
698 inputMap.put(keyStroke, action);
699
700 contentPanePrivate.getActionMap().put(action, action);
701 }
702
703 /**
704 * Unregisters a shortcut.
705 * @param shortcut shortcut to unregister
706 */
707 public static void unregisterShortcut(Shortcut shortcut) {
708 contentPanePrivate.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).remove(shortcut.getKeyStroke());
709 }
710
711 /**
712 * Unregisters a {@code JosmAction} and its shortcut.
713 * @param action action to unregister
714 */
715 public static void unregisterActionShortcut(JosmAction action) {
716 unregisterActionShortcut(action, action.getShortcut());
717 }
718
719 /**
720 * Unregisters an action and its shortcut.
721 * @param action action to unregister
722 * @param shortcut shortcut to unregister
723 */
724 public static void unregisterActionShortcut(Action action, Shortcut shortcut) {
725 unregisterShortcut(shortcut);
726 contentPanePrivate.getActionMap().remove(action);
727 }
728
729 /**
730 * Replies the registered action for the given shortcut
731 * @param shortcut The shortcut to look for
732 * @return the registered action for the given shortcut
733 * @since 5696
734 */
735 public static Action getRegisteredActionShortcut(Shortcut shortcut) {
736 KeyStroke keyStroke = shortcut.getKeyStroke();
737 if (keyStroke == null)
738 return null;
739 Object action = contentPanePrivate.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).get(keyStroke);
740 if (action instanceof Action)
741 return (Action) action;
742 return null;
743 }
744
745 ///////////////////////////////////////////////////////////////////////////
746 // Implementation part
747 ///////////////////////////////////////////////////////////////////////////
748
749 /**
750 * Global panel.
751 */
752 public static final JPanel panel = mainPanel;
753
754 private final CommandQueueListener redoUndoListener = (queueSize, redoSize) -> {
755 menu.undo.setEnabled(queueSize > 0);
756 menu.redo.setEnabled(redoSize > 0);
757 };
758
759 /**
760 * Should be called before the main constructor to setup some parameter stuff
761 */
762 public static void preConstructorInit() {
763 ProjectionPreference.setProjection();
764
765 String defaultlaf = platform.getDefaultStyle();
766 String laf = LafPreference.LAF.get();
767 try {
768 UIManager.setLookAndFeel(laf);
769 } catch (final NoClassDefFoundError | ClassNotFoundException e) {
770 // Try to find look and feel in plugin classloaders
771 Main.trace(e);
772 Class<?> klass = null;
773 for (ClassLoader cl : PluginHandler.getResourceClassLoaders()) {
774 try {
775 klass = cl.loadClass(laf);
776 break;
777 } catch (ClassNotFoundException ex) {
778 Main.trace(ex);
779 }
780 }
781 if (klass != null && LookAndFeel.class.isAssignableFrom(klass)) {
782 try {
783 UIManager.setLookAndFeel((LookAndFeel) klass.getConstructor().newInstance());
784 } catch (ReflectiveOperationException ex) {
785 warn(ex, "Cannot set Look and Feel: " + laf + ": "+ex.getMessage());
786 } catch (UnsupportedLookAndFeelException ex) {
787 info("Look and Feel not supported: " + laf);
788 LafPreference.LAF.put(defaultlaf);
789 trace(ex);
790 }
791 } else {
792 info("Look and Feel not found: " + laf);
793 LafPreference.LAF.put(defaultlaf);
794 }
795 } catch (UnsupportedLookAndFeelException e) {
796 info("Look and Feel not supported: " + laf);
797 LafPreference.LAF.put(defaultlaf);
798 trace(e);
799 } catch (InstantiationException | IllegalAccessException e) {
800 error(e);
801 }
802 toolbar = new ToolbarPreferences();
803 contentPanePrivate.updateUI();
804 panel.updateUI();
805
806 UIManager.put("OptionPane.okIcon", ImageProvider.get("ok"));
807 UIManager.put("OptionPane.yesIcon", UIManager.get("OptionPane.okIcon"));
808 UIManager.put("OptionPane.cancelIcon", ImageProvider.get("cancel"));
809 UIManager.put("OptionPane.noIcon", UIManager.get("OptionPane.cancelIcon"));
810 // Ensures caret color is the same than text foreground color, see #12257
811 // See http://docs.oracle.com/javase/8/docs/api/javax/swing/plaf/synth/doc-files/componentProperties.html
812 for (String p : Arrays.asList(
813 "EditorPane", "FormattedTextField", "PasswordField", "TextArea", "TextField", "TextPane")) {
814 UIManager.put(p+".caretForeground", UIManager.getColor(p+".foreground"));
815 }
816
817 I18n.translateJavaInternalMessages();
818
819 // init default coordinate format
820 //
821 try {
822 CoordinateFormat.setCoordinateFormat(CoordinateFormat.valueOf(Main.pref.get("coordinates")));
823 } catch (IllegalArgumentException iae) {
824 Main.trace(iae);
825 CoordinateFormat.setCoordinateFormat(CoordinateFormat.DECIMAL_DEGREES);
826 }
827 }
828
829 /**
830 * Handle command line instructions after GUI has been initialized.
831 * @param args program arguments
832 */
833 protected static void postConstructorProcessCmdLine(ProgramArguments args) {
834 List<Future<?>> tasks = new ArrayList<>();
835 List<File> fileList = new ArrayList<>();
836 for (String s : args.get(Option.DOWNLOAD)) {
837 tasks.addAll(DownloadParamType.paramType(s).download(s, fileList));
838 }
839 if (!fileList.isEmpty()) {
840 tasks.add(OpenFileAction.openFiles(fileList, true));
841 }
842 for (String s : args.get(Option.DOWNLOADGPS)) {
843 tasks.addAll(DownloadParamType.paramType(s).downloadGps(s));
844 }
845 // Make sure all download tasks complete before handling selection arguments
846 for (Future<?> task : tasks) {
847 try {
848 task.get();
849 } catch (InterruptedException | ExecutionException e) {
850 error(e);
851 }
852 }
853 for (String s : args.get(Option.SELECTION)) {
854 SearchAction.search(s, SearchAction.SearchMode.add);
855 }
856 }
857
858 /**
859 * Closes JOSM and optionally terminates the Java Virtual Machine (JVM).
860 * If there are some unsaved data layers, asks first for user confirmation.
861 * @param exit If {@code true}, the JVM is terminated by running {@link System#exit} with a given return code.
862 * @param exitCode The return code
863 * @param reason the reason for exiting
864 * @return {@code true} if JOSM has been closed, {@code false} if the user has cancelled the operation.
865 * @since 11093 (3378 with a different function signature)
866 */
867 public static boolean exitJosm(boolean exit, int exitCode, SaveLayersDialog.Reason reason) {
868 final boolean proceed = Boolean.TRUE.equals(GuiHelper.runInEDTAndWaitAndReturn(() ->
869 SaveLayersDialog.saveUnsavedModifications(getLayerManager().getLayers(),
870 reason != null ? reason : SaveLayersDialog.Reason.EXIT)));
871 if (proceed) {
872 if (Main.main != null) {
873 Main.main.shutdown();
874 }
875
876 if (exit) {
877 System.exit(exitCode);
878 }
879 return true;
880 }
881 return false;
882 }
883
884 /**
885 * Shutdown JOSM.
886 */
887 protected void shutdown() {
888 if (!GraphicsEnvironment.isHeadless()) {
889 worker.shutdown();
890 ImageProvider.shutdown(false);
891 JCSCacheManager.shutdown();
892 }
893 if (map != null) {
894 map.rememberToggleDialogWidth();
895 }
896 // Remove all layers because somebody may rely on layerRemoved events (like AutosaveTask)
897 getLayerManager().resetState();
898 try {
899 pref.saveDefaults();
900 } catch (IOException ex) {
901 Main.warn(ex, tr("Failed to save default preferences."));
902 }
903 if (!GraphicsEnvironment.isHeadless()) {
904 worker.shutdownNow();
905 ImageProvider.shutdown(true);
906 }
907 }
908
909 /**
910 * The type of a command line parameter, to be used in switch statements.
911 * @see #paramType
912 */
913 enum DownloadParamType {
914 httpUrl {
915 @Override
916 List<Future<?>> download(String s, Collection<File> fileList) {
917 return new OpenLocationAction().openUrl(false, s);
918 }
919
920 @Override
921 List<Future<?>> downloadGps(String s) {
922 final Bounds b = OsmUrlToBounds.parse(s);
923 if (b == null) {
924 JOptionPane.showMessageDialog(
925 Main.parent,
926 tr("Ignoring malformed URL: \"{0}\"", s),
927 tr("Warning"),
928 JOptionPane.WARNING_MESSAGE
929 );
930 return Collections.emptyList();
931 }
932 return downloadFromParamBounds(true, b);
933 }
934 }, fileUrl {
935 @Override
936 List<Future<?>> download(String s, Collection<File> fileList) {
937 File f = null;
938 try {
939 f = new File(new URI(s));
940 } catch (URISyntaxException e) {
941 Main.warn(e);
942 JOptionPane.showMessageDialog(
943 Main.parent,
944 tr("Ignoring malformed file URL: \"{0}\"", s),
945 tr("Warning"),
946 JOptionPane.WARNING_MESSAGE
947 );
948 }
949 if (f != null) {
950 fileList.add(f);
951 }
952 return Collections.emptyList();
953 }
954 }, bounds {
955
956 /**
957 * Download area specified on the command line as bounds string.
958 * @param rawGps Flag to download raw GPS tracks
959 * @param s The bounds parameter
960 * @return the complete download task (including post-download handler), or {@code null}
961 */
962 private List<Future<?>> downloadFromParamBounds(final boolean rawGps, String s) {
963 final StringTokenizer st = new StringTokenizer(s, ",");
964 if (st.countTokens() == 4) {
965 return Main.downloadFromParamBounds(rawGps, new Bounds(
966 new LatLon(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken())),
967 new LatLon(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()))
968 ));
969 }
970 return Collections.emptyList();
971 }
972
973 @Override
974 List<Future<?>> download(String param, Collection<File> fileList) {
975 return downloadFromParamBounds(false, param);
976 }
977
978 @Override
979 List<Future<?>> downloadGps(String param) {
980 return downloadFromParamBounds(true, param);
981 }
982 }, fileName {
983 @Override
984 List<Future<?>> download(String s, Collection<File> fileList) {
985 fileList.add(new File(s));
986 return Collections.emptyList();
987 }
988 };
989
990 /**
991 * Performs the download
992 * @param param represents the object to be downloaded
993 * @param fileList files which shall be opened, should be added to this collection
994 * @return the download task, or {@code null}
995 */
996 abstract List<Future<?>> download(String param, Collection<File> fileList);
997
998 /**
999 * Performs the GPS download
1000 * @param param represents the object to be downloaded
1001 * @return the download task, or {@code null}
1002 */
1003 List<Future<?>> downloadGps(String param) {
1004 if (!GraphicsEnvironment.isHeadless()) {
1005 JOptionPane.showMessageDialog(
1006 Main.parent,
1007 tr("Parameter \"downloadgps\" does not accept file names or file URLs"),
1008 tr("Warning"),
1009 JOptionPane.WARNING_MESSAGE
1010 );
1011 }
1012 return Collections.emptyList();
1013 }
1014
1015 /**
1016 * Guess the type of a parameter string specified on the command line with --download= or --downloadgps.
1017 *
1018 * @param s A parameter string
1019 * @return The guessed parameter type
1020 */
1021 static DownloadParamType paramType(String s) {
1022 if (s.startsWith("http:") || s.startsWith("https:")) return DownloadParamType.httpUrl;
1023 if (s.startsWith("file:")) return DownloadParamType.fileUrl;
1024 String coorPattern = "\\s*[+-]?[0-9]+(\\.[0-9]+)?\\s*";
1025 if (s.matches(coorPattern + "(," + coorPattern + "){3}")) return DownloadParamType.bounds;
1026 // everything else must be a file name
1027 return DownloadParamType.fileName;
1028 }
1029 }
1030
1031 /**
1032 * Download area specified as Bounds value.
1033 * @param rawGps Flag to download raw GPS tracks
1034 * @param b The bounds value
1035 * @return the complete download task (including post-download handler)
1036 */
1037 private static List<Future<?>> downloadFromParamBounds(final boolean rawGps, Bounds b) {
1038 DownloadTask task = rawGps ? new DownloadGpsTask() : new DownloadOsmTask();
1039 // asynchronously launch the download task ...
1040 Future<?> future = task.download(true, b, null);
1041 // ... and the continuation when the download is finished (this will wait for the download to finish)
1042 return Collections.singletonList(Main.worker.submit(new PostDownloadHandler(task, future)));
1043 }
1044
1045 /**
1046 * Identifies the current operating system family and initializes the platform hook accordingly.
1047 * @since 1849
1048 */
1049 public static void determinePlatformHook() {
1050 String os = System.getProperty("os.name");
1051 if (os == null) {
1052 warn("Your operating system has no name, so I'm guessing its some kind of *nix.");
1053 platform = new PlatformHookUnixoid();
1054 } else if (os.toLowerCase(Locale.ENGLISH).startsWith("windows")) {
1055 platform = new PlatformHookWindows();
1056 } else if ("Linux".equals(os) || "Solaris".equals(os) ||
1057 "SunOS".equals(os) || "AIX".equals(os) ||
1058 "FreeBSD".equals(os) || "NetBSD".equals(os) || "OpenBSD".equals(os)) {
1059 platform = new PlatformHookUnixoid();
1060 } else if (os.toLowerCase(Locale.ENGLISH).startsWith("mac os x")) {
1061 platform = new PlatformHookOsx();
1062 } else {
1063 warn("I don't know your operating system '"+os+"', so I'm guessing its some kind of *nix.");
1064 platform = new PlatformHookUnixoid();
1065 }
1066 }
1067
1068 /* ----------------------------------------------------------------------------------------- */
1069 /* projection handling - Main is a registry for a single, global projection instance */
1070 /* */
1071 /* TODO: For historical reasons the registry is implemented by Main. An alternative approach */
1072 /* would be a singleton org.openstreetmap.josm.data.projection.ProjectionRegistry class. */
1073 /* ----------------------------------------------------------------------------------------- */
1074 /**
1075 * The projection method used.
1076 * use {@link #getProjection()} and {@link #setProjection(Projection)} for access.
1077 * Use {@link #setProjection(Projection)} in order to trigger a projection change event.
1078 */
1079 private static volatile Projection proj;
1080
1081 /**
1082 * Replies the current projection.
1083 *
1084 * @return the currently active projection
1085 */
1086 public static Projection getProjection() {
1087 return proj;
1088 }
1089
1090 /**
1091 * Sets the current projection
1092 *
1093 * @param p the projection
1094 */
1095 public static void setProjection(Projection p) {
1096 CheckParameterUtil.ensureParameterNotNull(p);
1097 Projection oldValue = proj;
1098 Bounds b = isDisplayingMapView() ? map.mapView.getRealBounds() : null;
1099 proj = p;
1100 fireProjectionChanged(oldValue, proj, b);
1101 }
1102
1103 /*
1104 * Keep WeakReferences to the listeners. This relieves clients from the burden of
1105 * explicitly removing the listeners and allows us to transparently register every
1106 * created dataset as projection change listener.
1107 */
1108 private static final List<WeakReference<ProjectionChangeListener>> listeners = new ArrayList<>();
1109
1110 private static void fireProjectionChanged(Projection oldValue, Projection newValue, Bounds oldBounds) {
1111 if ((newValue == null ^ oldValue == null)
1112 || (newValue != null && oldValue != null && !Objects.equals(newValue.toCode(), oldValue.toCode()))) {
1113 if (Main.map != null) {
1114 // This needs to be called first
1115 Main.map.mapView.fixProjection();
1116 }
1117 synchronized (Main.class) {
1118 Iterator<WeakReference<ProjectionChangeListener>> it = listeners.iterator();
1119 while (it.hasNext()) {
1120 WeakReference<ProjectionChangeListener> wr = it.next();
1121 ProjectionChangeListener listener = wr.get();
1122 if (listener == null) {
1123 it.remove();
1124 continue;
1125 }
1126 listener.projectionChanged(oldValue, newValue);
1127 }
1128 }
1129 if (newValue != null && oldBounds != null) {
1130 Main.map.mapView.zoomTo(oldBounds);
1131 }
1132 /* TODO - remove layers with fixed projection */
1133 }
1134 }
1135
1136 /**
1137 * Register a projection change listener.
1138 *
1139 * @param listener the listener. Ignored if <code>null</code>.
1140 */
1141 public static void addProjectionChangeListener(ProjectionChangeListener listener) {
1142 if (listener == null) return;
1143 synchronized (Main.class) {
1144 for (WeakReference<ProjectionChangeListener> wr : listeners) {
1145 // already registered ? => abort
1146 if (wr.get() == listener) return;
1147 }
1148 listeners.add(new WeakReference<>(listener));
1149 }
1150 }
1151
1152 /**
1153 * Removes a projection change listener.
1154 *
1155 * @param listener the listener. Ignored if <code>null</code>.
1156 */
1157 public static void removeProjectionChangeListener(ProjectionChangeListener listener) {
1158 if (listener == null) return;
1159 synchronized (Main.class) {
1160 // remove the listener - and any other listener which got garbage
1161 // collected in the meantime
1162 listeners.removeIf(wr -> wr.get() == null || wr.get() == listener);
1163 }
1164 }
1165
1166 /**
1167 * Listener for window switch events.
1168 *
1169 * These are events, when the user activates a window of another application
1170 * or comes back to JOSM. Window switches from one JOSM window to another
1171 * are not reported.
1172 */
1173 public interface WindowSwitchListener {
1174 /**
1175 * Called when the user activates a window of another application.
1176 */
1177 void toOtherApplication();
1178
1179 /**
1180 * Called when the user comes from a window of another application back to JOSM.
1181 */
1182 void fromOtherApplication();
1183 }
1184
1185 /**
1186 * Registers a new {@code MapFrameListener} that will be notified of MapFrame changes.
1187 * <p>
1188 * It will fire an initial mapFrameInitialized event when the MapFrame is present.
1189 * Otherwise will only fire when the MapFrame is created or destroyed.
1190 * @param listener The MapFrameListener
1191 * @return {@code true} if the listeners collection changed as a result of the call
1192 * @see #addMapFrameListener
1193 * @since 11904
1194 */
1195 public static boolean addAndFireMapFrameListener(MapFrameListener listener) {
1196 return mainPanel.addAndFireMapFrameListener(listener);
1197 }
1198
1199 /**
1200 * Registers a new {@code MapFrameListener} that will be notified of MapFrame changes
1201 * @param listener The MapFrameListener
1202 * @return {@code true} if the listeners collection changed as a result of the call
1203 * @see #addAndFireMapFrameListener
1204 * @since 5957
1205 */
1206 public static boolean addMapFrameListener(MapFrameListener listener) {
1207 return mainPanel.addMapFrameListener(listener);
1208 }
1209
1210 /**
1211 * Unregisters the given {@code MapFrameListener} from MapFrame changes
1212 * @param listener The MapFrameListener
1213 * @return {@code true} if the listeners collection changed as a result of the call
1214 * @since 5957
1215 */
1216 public static boolean removeMapFrameListener(MapFrameListener listener) {
1217 return mainPanel.removeMapFrameListener(listener);
1218 }
1219
1220 /**
1221 * Adds a new network error that occur to give a hint about broken Internet connection.
1222 * Do not use this method for errors known for sure thrown because of a bad proxy configuration.
1223 *
1224 * @param url The accessed URL that caused the error
1225 * @param t The network error
1226 * @return The previous error associated to the given resource, if any. Can be {@code null}
1227 * @since 6642
1228 */
1229 public static Throwable addNetworkError(URL url, Throwable t) {
1230 if (url != null && t != null) {
1231 Throwable old = addNetworkError(url.toExternalForm(), t);
1232 if (old != null) {
1233 Main.warn("Already here "+old);
1234 }
1235 return old;
1236 }
1237 return null;
1238 }
1239
1240 /**
1241 * Adds a new network error that occur to give a hint about broken Internet connection.
1242 * Do not use this method for errors known for sure thrown because of a bad proxy configuration.
1243 *
1244 * @param url The accessed URL that caused the error
1245 * @param t The network error
1246 * @return The previous error associated to the given resource, if any. Can be {@code null}
1247 * @since 6642
1248 */
1249 public static Throwable addNetworkError(String url, Throwable t) {
1250 if (url != null && t != null) {
1251 return NETWORK_ERRORS.put(url, t);
1252 }
1253 return null;
1254 }
1255
1256 /**
1257 * Returns the network errors that occured until now.
1258 * @return the network errors that occured until now, indexed by URL
1259 * @since 6639
1260 */
1261 public static Map<String, Throwable> getNetworkErrors() {
1262 return new HashMap<>(NETWORK_ERRORS);
1263 }
1264
1265 /**
1266 * Returns the JOSM website URL.
1267 * @return the josm website URL
1268 * @since 6897
1269 */
1270 public static String getJOSMWebsite() {
1271 if (Main.pref != null)
1272 return Main.pref.get("josm.url", JOSM_WEBSITE);
1273 return JOSM_WEBSITE;
1274 }
1275
1276 /**
1277 * Returns the JOSM XML URL.
1278 * @return the josm XML URL
1279 * @since 6897
1280 */
1281 public static String getXMLBase() {
1282 // Always return HTTP (issues reported with HTTPS)
1283 return "http://josm.openstreetmap.de";
1284 }
1285
1286 /**
1287 * Returns the OSM website URL.
1288 * @return the OSM website URL
1289 * @since 6897
1290 */
1291 public static String getOSMWebsite() {
1292 if (Main.pref != null)
1293 return Main.pref.get("osm.url", OSM_WEBSITE);
1294 return OSM_WEBSITE;
1295 }
1296
1297 /**
1298 * Returns the OSM website URL depending on the selected {@link OsmApi}.
1299 * @return the OSM website URL depending on the selected {@link OsmApi}
1300 */
1301 private static String getOSMWebsiteDependingOnSelectedApi() {
1302 final String api = OsmApi.getOsmApi().getServerUrl();
1303 if (OsmApi.DEFAULT_API_URL.equals(api)) {
1304 return getOSMWebsite();
1305 } else {
1306 return api.replaceAll("/api$", "");
1307 }
1308 }
1309
1310 /**
1311 * Replies the base URL for browsing information about a primitive.
1312 * @return the base URL, i.e. https://www.openstreetmap.org
1313 * @since 7678
1314 */
1315 public static String getBaseBrowseUrl() {
1316 if (Main.pref != null)
1317 return Main.pref.get("osm-browse.url", getOSMWebsiteDependingOnSelectedApi());
1318 return getOSMWebsiteDependingOnSelectedApi();
1319 }
1320
1321 /**
1322 * Replies the base URL for browsing information about a user.
1323 * @return the base URL, i.e. https://www.openstreetmap.org/user
1324 * @since 7678
1325 */
1326 public static String getBaseUserUrl() {
1327 if (Main.pref != null)
1328 return Main.pref.get("osm-user.url", getOSMWebsiteDependingOnSelectedApi() + "/user");
1329 return getOSMWebsiteDependingOnSelectedApi() + "/user";
1330 }
1331
1332 /**
1333 * Determines if we are currently running on OSX.
1334 * @return {@code true} if we are currently running on OSX
1335 * @since 6957
1336 */
1337 public static boolean isPlatformOsx() {
1338 return Main.platform instanceof PlatformHookOsx;
1339 }
1340
1341 /**
1342 * Determines if we are currently running on Windows.
1343 * @return {@code true} if we are currently running on Windows
1344 * @since 7335
1345 */
1346 public static boolean isPlatformWindows() {
1347 return Main.platform instanceof PlatformHookWindows;
1348 }
1349
1350 /**
1351 * Determines if the given online resource is currently offline.
1352 * @param r the online resource
1353 * @return {@code true} if {@code r} is offline and should not be accessed
1354 * @since 7434
1355 */
1356 public static boolean isOffline(OnlineResource r) {
1357 return OFFLINE_RESOURCES.contains(r) || OFFLINE_RESOURCES.contains(OnlineResource.ALL);
1358 }
1359
1360 /**
1361 * Sets the given online resource to offline state.
1362 * @param r the online resource
1363 * @return {@code true} if {@code r} was not already offline
1364 * @since 7434
1365 */
1366 public static boolean setOffline(OnlineResource r) {
1367 return OFFLINE_RESOURCES.add(r);
1368 }
1369
1370 /**
1371 * Sets the given online resource to online state.
1372 * @param r the online resource
1373 * @return {@code true} if {@code r} was offline
1374 * @since 8506
1375 */
1376 public static boolean setOnline(OnlineResource r) {
1377 return OFFLINE_RESOURCES.remove(r);
1378 }
1379
1380 /**
1381 * Replies the set of online resources currently offline.
1382 * @return the set of online resources currently offline
1383 * @since 7434
1384 */
1385 public static Set<OnlineResource> getOfflineResources() {
1386 return EnumSet.copyOf(OFFLINE_RESOURCES);
1387 }
1388}
Note: See TracBrowser for help on using the repository browser.