[6380] | 1 | // License: GPL. For details, see LICENSE file.
|
---|
[626] | 2 | package org.openstreetmap.josm;
|
---|
[5670] | 3 |
|
---|
[301] | 4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
| 5 |
|
---|
| 6 | import java.awt.Component;
|
---|
[9821] | 7 | import java.io.IOException;
|
---|
[6471] | 8 | import java.net.URL;
|
---|
[13838] | 9 | import java.nio.file.InvalidPathException;
|
---|
[301] | 10 | import java.util.Collection;
|
---|
[11986] | 11 | import java.util.Collections;
|
---|
[2025] | 12 | import java.util.List;
|
---|
[301] | 13 | import java.util.Map;
|
---|
[7434] | 14 | import java.util.Set;
|
---|
[5134] | 15 | import java.util.concurrent.Callable;
|
---|
[10212] | 16 | import java.util.concurrent.ExecutionException;
|
---|
[1465] | 17 | import java.util.concurrent.ExecutorService;
|
---|
[5134] | 18 | import java.util.concurrent.Executors;
|
---|
[2322] | 19 | import java.util.concurrent.Future;
|
---|
[301] | 20 |
|
---|
| 21 | import org.openstreetmap.josm.data.Preferences;
|
---|
| 22 | import org.openstreetmap.josm.data.UndoRedoHandler;
|
---|
[12735] | 23 | import org.openstreetmap.josm.data.coor.conversion.CoordinateFormatManager;
|
---|
| 24 | import org.openstreetmap.josm.data.coor.conversion.DecimalDegreesCoordinateFormat;
|
---|
| 25 | import org.openstreetmap.josm.data.coor.conversion.ICoordinateFormat;
|
---|
[301] | 26 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
[13926] | 27 | import org.openstreetmap.josm.data.osm.IPrimitive;
|
---|
| 28 | import org.openstreetmap.josm.data.osm.OsmData;
|
---|
[6546] | 29 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
[13023] | 30 | import org.openstreetmap.josm.data.preferences.JosmBaseDirectories;
|
---|
[301] | 31 | import org.openstreetmap.josm.data.projection.Projection;
|
---|
[4126] | 32 | import org.openstreetmap.josm.data.projection.ProjectionChangeListener;
|
---|
[14120] | 33 | import org.openstreetmap.josm.data.projection.ProjectionRegistry;
|
---|
[7185] | 34 | import org.openstreetmap.josm.io.FileWatcher;
|
---|
[14121] | 35 | import org.openstreetmap.josm.io.NetworkManager;
|
---|
[7434] | 36 | import org.openstreetmap.josm.io.OnlineResource;
|
---|
[14125] | 37 | import org.openstreetmap.josm.spi.lifecycle.InitializationTask;
|
---|
[12846] | 38 | import org.openstreetmap.josm.spi.preferences.Config;
|
---|
[14119] | 39 | import org.openstreetmap.josm.spi.preferences.IUrls;
|
---|
[301] | 40 | import org.openstreetmap.josm.tools.ImageProvider;
|
---|
[11374] | 41 | import org.openstreetmap.josm.tools.JosmRuntimeException;
|
---|
[10899] | 42 | import org.openstreetmap.josm.tools.Logging;
|
---|
[12776] | 43 | import org.openstreetmap.josm.tools.Platform;
|
---|
[1023] | 44 | import org.openstreetmap.josm.tools.PlatformHook;
|
---|
[1465] | 45 | import org.openstreetmap.josm.tools.PlatformHookOsx;
|
---|
[1023] | 46 | import org.openstreetmap.josm.tools.PlatformHookWindows;
|
---|
[4288] | 47 | import org.openstreetmap.josm.tools.Utils;
|
---|
[11642] | 48 | import org.openstreetmap.josm.tools.bugreport.BugReport;
|
---|
[626] | 49 |
|
---|
[5829] | 50 | /**
|
---|
| 51 | * Abstract class holding various static global variables and methods used in large parts of JOSM application.
|
---|
| 52 | * @since 98
|
---|
| 53 | */
|
---|
[6883] | 54 | public abstract class Main {
|
---|
[2485] | 55 |
|
---|
[1104] | 56 | /**
|
---|
| 57 | * Global parent component for all dialogs and message boxes
|
---|
| 58 | */
|
---|
| 59 | public static Component parent;
|
---|
[6070] | 60 |
|
---|
[1104] | 61 | /**
|
---|
| 62 | * Global application.
|
---|
| 63 | */
|
---|
[8126] | 64 | public static volatile Main main;
|
---|
[6070] | 65 |
|
---|
[1104] | 66 | /**
|
---|
| 67 | * Global application preferences
|
---|
| 68 | */
|
---|
[13023] | 69 | public static final Preferences pref = new Preferences(JosmBaseDirectories.getInstance());
|
---|
[1814] | 70 |
|
---|
[1104] | 71 | /**
|
---|
[5829] | 72 | * The commands undo/redo handler.
|
---|
[14134] | 73 | * @deprecated Use {@link UndoRedoHandler#getInstance}
|
---|
[5829] | 74 | */
|
---|
[14134] | 75 | @Deprecated
|
---|
| 76 | public final UndoRedoHandler undoRedo = UndoRedoHandler.getInstance();
|
---|
[626] | 77 |
|
---|
[5831] | 78 | /**
|
---|
[7185] | 79 | * The file watcher service.
|
---|
[14128] | 80 | * @deprecated Use {@link FileWatcher#getDefaultInstance}
|
---|
[7185] | 81 | */
|
---|
[14128] | 82 | @Deprecated
|
---|
| 83 | public static final FileWatcher fileWatcher = FileWatcher.getDefaultInstance();
|
---|
[7185] | 84 |
|
---|
[1356] | 85 | /**
|
---|
[1104] | 86 | * Platform specific code goes in here.
|
---|
[12641] | 87 | * Plugins may replace it, however, some hooks will be called before any plugins have been loaded.
|
---|
[1104] | 88 | * So if you need to hook into those early ones, split your class and send the one with the early hooks
|
---|
| 89 | * to the JOSM team for inclusion.
|
---|
| 90 | */
|
---|
[8126] | 91 | public static volatile PlatformHook platform;
|
---|
[1023] | 92 |
|
---|
[11352] | 93 | /**
|
---|
[10340] | 94 | * Constructs new {@code Main} object.
|
---|
| 95 | * @see #initialize()
|
---|
[6523] | 96 | */
|
---|
[11656] | 97 | protected Main() {
|
---|
| 98 | setInstance(this);
|
---|
[10340] | 99 | }
|
---|
| 100 |
|
---|
[11656] | 101 | private static void setInstance(Main instance) {
|
---|
| 102 | main = instance;
|
---|
| 103 | }
|
---|
| 104 |
|
---|
[10340] | 105 | /**
|
---|
| 106 | * Initializes the main object. A lot of global variables are initialized here.
|
---|
| 107 | * @since 10340
|
---|
| 108 | */
|
---|
| 109 | public void initialize() {
|
---|
[12629] | 110 | // Initializes tasks that must be run before parallel tasks
|
---|
| 111 | runInitializationTasks(beforeInitializationTasks());
|
---|
[4681] | 112 |
|
---|
[12629] | 113 | // Initializes tasks to be executed (in parallel) by a ExecutorService
|
---|
[11642] | 114 | try {
|
---|
[10899] | 115 | ExecutorService service = Executors.newFixedThreadPool(
|
---|
[8734] | 116 | Runtime.getRuntime().availableProcessors(), Utils.newThreadFactory("main-init-%d", Thread.NORM_PRIORITY));
|
---|
[12629] | 117 | for (Future<Void> i : service.invokeAll(parallelInitializationTasks())) {
|
---|
[5195] | 118 | i.get();
|
---|
| 119 | }
|
---|
[11092] | 120 | // asynchronous initializations to be completed eventually
|
---|
[12629] | 121 | asynchronousRunnableTasks().forEach(service::submit);
|
---|
| 122 | asynchronousCallableTasks().forEach(service::submit);
|
---|
[13647] | 123 | try {
|
---|
| 124 | service.shutdown();
|
---|
| 125 | } catch (SecurityException e) {
|
---|
| 126 | Logging.log(Logging.LEVEL_ERROR, "Unable to shutdown executor service", e);
|
---|
| 127 | }
|
---|
[10212] | 128 | } catch (InterruptedException | ExecutionException ex) {
|
---|
[11374] | 129 | throw new JosmRuntimeException(ex);
|
---|
[4718] | 130 | }
|
---|
[3669] | 131 |
|
---|
[12629] | 132 | // Initializes tasks that must be run after parallel tasks
|
---|
| 133 | runInitializationTasks(afterInitializationTasks());
|
---|
| 134 | }
|
---|
[4489] | 135 |
|
---|
[12629] | 136 | private static void runInitializationTasks(List<InitializationTask> tasks) {
|
---|
| 137 | for (InitializationTask task : tasks) {
|
---|
| 138 | try {
|
---|
| 139 | task.call();
|
---|
| 140 | } catch (JosmRuntimeException e) {
|
---|
| 141 | // Can happen if the current projection needs NTV2 grid which is not available
|
---|
| 142 | // In this case we want the user be able to change his projection
|
---|
| 143 | BugReport.intercept(e).warn();
|
---|
| 144 | }
|
---|
| 145 | }
|
---|
[1104] | 146 | }
|
---|
[626] | 147 |
|
---|
[10340] | 148 | /**
|
---|
[12629] | 149 | * Returns tasks that must be run before parallel tasks.
|
---|
| 150 | * @return tasks that must be run before parallel tasks
|
---|
| 151 | * @see #afterInitializationTasks
|
---|
| 152 | * @see #parallelInitializationTasks
|
---|
| 153 | */
|
---|
| 154 | protected List<InitializationTask> beforeInitializationTasks() {
|
---|
| 155 | return Collections.emptyList();
|
---|
| 156 | }
|
---|
| 157 |
|
---|
| 158 | /**
|
---|
| 159 | * Returns tasks to be executed (in parallel) by a ExecutorService.
|
---|
| 160 | * @return tasks to be executed (in parallel) by a ExecutorService
|
---|
| 161 | */
|
---|
| 162 | protected Collection<InitializationTask> parallelInitializationTasks() {
|
---|
| 163 | return Collections.emptyList();
|
---|
| 164 | }
|
---|
| 165 |
|
---|
| 166 | /**
|
---|
| 167 | * Returns asynchronous callable initializations to be completed eventually
|
---|
| 168 | * @return asynchronous callable initializations to be completed eventually
|
---|
| 169 | */
|
---|
| 170 | protected List<Callable<?>> asynchronousCallableTasks() {
|
---|
| 171 | return Collections.emptyList();
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 | /**
|
---|
| 175 | * Returns asynchronous runnable initializations to be completed eventually
|
---|
| 176 | * @return asynchronous runnable initializations to be completed eventually
|
---|
| 177 | */
|
---|
| 178 | protected List<Runnable> asynchronousRunnableTasks() {
|
---|
| 179 | return Collections.emptyList();
|
---|
| 180 | }
|
---|
| 181 |
|
---|
| 182 | /**
|
---|
| 183 | * Returns tasks that must be run after parallel tasks.
|
---|
| 184 | * @return tasks that must be run after parallel tasks
|
---|
| 185 | * @see #beforeInitializationTasks
|
---|
| 186 | * @see #parallelInitializationTasks
|
---|
| 187 | */
|
---|
| 188 | protected List<InitializationTask> afterInitializationTasks() {
|
---|
| 189 | return Collections.emptyList();
|
---|
| 190 | }
|
---|
| 191 |
|
---|
[1104] | 192 | /**
|
---|
[13926] | 193 | * Replies the current selected OSM primitives, from a end-user point of view.
|
---|
[6546] | 194 | * It is not always technically the same collection of primitives than {@link DataSet#getSelected()}.
|
---|
[13926] | 195 | * @return The current selected OSM primitives, from a end-user point of view. Can be {@code null}.
|
---|
[6546] | 196 | * @since 6546
|
---|
| 197 | */
|
---|
| 198 | public Collection<OsmPrimitive> getInProgressSelection() {
|
---|
[12636] | 199 | return Collections.emptyList();
|
---|
[6546] | 200 | }
|
---|
[1750] | 201 |
|
---|
[11352] | 202 | /**
|
---|
[13926] | 203 | * Replies the current selected primitives, from a end-user point of view.
|
---|
| 204 | * It is not always technically the same collection of primitives than {@link OsmData#getSelected()}.
|
---|
| 205 | * @return The current selected primitives, from a end-user point of view. Can be {@code null}.
|
---|
| 206 | * @since 13926
|
---|
| 207 | */
|
---|
| 208 | public Collection<? extends IPrimitive> getInProgressISelection() {
|
---|
| 209 | return Collections.emptyList();
|
---|
| 210 | }
|
---|
| 211 |
|
---|
| 212 | /**
|
---|
[13434] | 213 | * Gets the active edit data set (not read-only).
|
---|
[12718] | 214 | * @return That data set, <code>null</code>.
|
---|
[13434] | 215 | * @see #getActiveDataSet
|
---|
[12691] | 216 | * @since 12691
|
---|
| 217 | */
|
---|
[12718] | 218 | public abstract DataSet getEditDataSet();
|
---|
[12691] | 219 |
|
---|
| 220 | /**
|
---|
[13434] | 221 | * Gets the active data set (can be read-only).
|
---|
| 222 | * @return That data set, <code>null</code>.
|
---|
| 223 | * @see #getEditDataSet
|
---|
| 224 | * @since 13434
|
---|
[12718] | 225 | */
|
---|
[13434] | 226 | public abstract DataSet getActiveDataSet();
|
---|
[12718] | 227 |
|
---|
| 228 | /**
|
---|
[13434] | 229 | * Sets the active data set (and also edit data set if not read-only).
|
---|
| 230 | * @param ds New data set, or <code>null</code>
|
---|
| 231 | * @since 13434
|
---|
| 232 | */
|
---|
| 233 | public abstract void setActiveDataSet(DataSet ds);
|
---|
| 234 |
|
---|
| 235 | /**
|
---|
[12718] | 236 | * Determines if the list of data sets managed by JOSM contains {@code ds}.
|
---|
| 237 | * @param ds the data set to look for
|
---|
| 238 | * @return {@code true} if the list of data sets managed by JOSM contains {@code ds}
|
---|
| 239 | * @since 12718
|
---|
| 240 | */
|
---|
| 241 | public abstract boolean containsDataSet(DataSet ds);
|
---|
| 242 |
|
---|
[1104] | 243 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 244 | // Implementation part
|
---|
| 245 | ///////////////////////////////////////////////////////////////////////////
|
---|
[626] | 246 |
|
---|
[5829] | 247 | /**
|
---|
[1104] | 248 | * Should be called before the main constructor to setup some parameter stuff
|
---|
| 249 | */
|
---|
[10962] | 250 | public static void preConstructorInit() {
|
---|
[1990] | 251 | // init default coordinate format
|
---|
[12846] | 252 | ICoordinateFormat fmt = CoordinateFormatManager.getCoordinateFormat(Config.getPref().get("coordinates"));
|
---|
[12735] | 253 | if (fmt == null) {
|
---|
| 254 | fmt = DecimalDegreesCoordinateFormat.INSTANCE;
|
---|
[1990] | 255 | }
|
---|
[12735] | 256 | CoordinateFormatManager.setCoordinateFormat(fmt);
|
---|
[1104] | 257 | }
|
---|
[626] | 258 |
|
---|
[11986] | 259 | /**
|
---|
[8412] | 260 | * Closes JOSM and optionally terminates the Java Virtual Machine (JVM).
|
---|
[6342] | 261 | * @param exit If {@code true}, the JVM is terminated by running {@link System#exit} with a given return code.
|
---|
| 262 | * @param exitCode The return code
|
---|
[12636] | 263 | * @return {@code true}
|
---|
| 264 | * @since 12636
|
---|
[5829] | 265 | */
|
---|
[12636] | 266 | public static boolean exitJosm(boolean exit, int exitCode) {
|
---|
| 267 | if (Main.main != null) {
|
---|
| 268 | Main.main.shutdown();
|
---|
| 269 | }
|
---|
[8412] | 270 |
|
---|
[12636] | 271 | if (exit) {
|
---|
| 272 | System.exit(exitCode);
|
---|
[5829] | 273 | }
|
---|
[12636] | 274 | return true;
|
---|
[3378] | 275 | }
|
---|
| 276 |
|
---|
[11986] | 277 | /**
|
---|
| 278 | * Shutdown JOSM.
|
---|
| 279 | */
|
---|
[10340] | 280 | protected void shutdown() {
|
---|
[14131] | 281 | ImageProvider.shutdown(false);
|
---|
[10340] | 282 | try {
|
---|
| 283 | pref.saveDefaults();
|
---|
[13838] | 284 | } catch (IOException | InvalidPathException ex) {
|
---|
[12620] | 285 | Logging.log(Logging.LEVEL_WARN, tr("Failed to save default preferences."), ex);
|
---|
[10340] | 286 | }
|
---|
[14131] | 287 | ImageProvider.shutdown(true);
|
---|
[10340] | 288 | }
|
---|
| 289 |
|
---|
[2798] | 290 | /**
|
---|
[5829] | 291 | * Identifies the current operating system family and initializes the platform hook accordingly.
|
---|
| 292 | * @since 1849
|
---|
| 293 | */
|
---|
[1849] | 294 | public static void determinePlatformHook() {
|
---|
[12776] | 295 | platform = Platform.determinePlatform().accept(PlatformHook.CONSTRUCT_FROM_PLATFORM);
|
---|
[1104] | 296 | }
|
---|
[1023] | 297 |
|
---|
[4126] | 298 | /**
|
---|
| 299 | * Replies the current projection.
|
---|
[4489] | 300 | *
|
---|
[5357] | 301 | * @return the currently active projection
|
---|
[14120] | 302 | * @deprecated Use {@link ProjectionRegistry#getProjection}
|
---|
[4126] | 303 | */
|
---|
[14120] | 304 | @Deprecated
|
---|
[4126] | 305 | public static Projection getProjection() {
|
---|
[14120] | 306 | return ProjectionRegistry.getProjection();
|
---|
[4126] | 307 | }
|
---|
| 308 |
|
---|
| 309 | /**
|
---|
| 310 | * Sets the current projection
|
---|
[4489] | 311 | *
|
---|
[4126] | 312 | * @param p the projection
|
---|
[14120] | 313 | * @deprecated Use {@link ProjectionRegistry#setProjection}
|
---|
[4126] | 314 | */
|
---|
[14120] | 315 | @Deprecated
|
---|
[4126] | 316 | public static void setProjection(Projection p) {
|
---|
[14120] | 317 | ProjectionRegistry.setProjection(p);
|
---|
[4126] | 318 | }
|
---|
| 319 |
|
---|
[12631] | 320 | /**
|
---|
[5538] | 321 | * Register a projection change listener.
|
---|
[12119] | 322 | * The listener is registered to be weak, so keep a reference of it if you want it to be preserved.
|
---|
[4489] | 323 | *
|
---|
[5357] | 324 | * @param listener the listener. Ignored if <code>null</code>.
|
---|
[14120] | 325 | * @deprecated Use {@link ProjectionRegistry#addProjectionChangeListener}
|
---|
[4126] | 326 | */
|
---|
[14120] | 327 | @Deprecated
|
---|
[4126] | 328 | public static void addProjectionChangeListener(ProjectionChangeListener listener) {
|
---|
[14120] | 329 | ProjectionRegistry.addProjectionChangeListener(listener);
|
---|
[4126] | 330 | }
|
---|
| 331 |
|
---|
| 332 | /**
|
---|
[5538] | 333 | * Removes a projection change listener.
|
---|
[4489] | 334 | *
|
---|
[5357] | 335 | * @param listener the listener. Ignored if <code>null</code>.
|
---|
[14120] | 336 | * @deprecated Use {@link ProjectionRegistry#removeProjectionChangeListener}
|
---|
[4126] | 337 | */
|
---|
[14120] | 338 | @Deprecated
|
---|
[4126] | 339 | public static void removeProjectionChangeListener(ProjectionChangeListener listener) {
|
---|
[14120] | 340 | ProjectionRegistry.removeProjectionChangeListener(listener);
|
---|
[4126] | 341 | }
|
---|
[5538] | 342 |
|
---|
| 343 | /**
|
---|
[13322] | 344 | * Remove all projection change listeners. For testing purposes only.
|
---|
| 345 | * @since 13322
|
---|
[14120] | 346 | * @deprecated Use {@link ProjectionRegistry#clearProjectionChangeListeners}
|
---|
[13322] | 347 | */
|
---|
[14120] | 348 | @Deprecated
|
---|
[13322] | 349 | public static void clearProjectionChangeListeners() {
|
---|
[14120] | 350 | ProjectionRegistry.clearProjectionChangeListeners();
|
---|
[13322] | 351 | }
|
---|
| 352 |
|
---|
| 353 | /**
|
---|
[6642] | 354 | * Adds a new network error that occur to give a hint about broken Internet connection.
|
---|
| 355 | * Do not use this method for errors known for sure thrown because of a bad proxy configuration.
|
---|
[6852] | 356 | *
|
---|
[6642] | 357 | * @param url The accessed URL that caused the error
|
---|
| 358 | * @param t The network error
|
---|
| 359 | * @return The previous error associated to the given resource, if any. Can be {@code null}
|
---|
[14121] | 360 | * @deprecated Use {@link NetworkManager#addNetworkError(URL, Throwable)}
|
---|
[6643] | 361 | * @since 6642
|
---|
[6642] | 362 | */
|
---|
[14121] | 363 | @Deprecated
|
---|
[6642] | 364 | public static Throwable addNetworkError(URL url, Throwable t) {
|
---|
[14121] | 365 | return NetworkManager.addNetworkError(url, t);
|
---|
[6642] | 366 | }
|
---|
| 367 |
|
---|
| 368 | /**
|
---|
| 369 | * Adds a new network error that occur to give a hint about broken Internet connection.
|
---|
| 370 | * Do not use this method for errors known for sure thrown because of a bad proxy configuration.
|
---|
[6852] | 371 | *
|
---|
[6642] | 372 | * @param url The accessed URL that caused the error
|
---|
| 373 | * @param t The network error
|
---|
| 374 | * @return The previous error associated to the given resource, if any. Can be {@code null}
|
---|
[14121] | 375 | * @deprecated Use {@link NetworkManager#addNetworkError(String, Throwable)}
|
---|
[6643] | 376 | * @since 6642
|
---|
[6642] | 377 | */
|
---|
[14121] | 378 | @Deprecated
|
---|
[6642] | 379 | public static Throwable addNetworkError(String url, Throwable t) {
|
---|
[14121] | 380 | return NetworkManager.addNetworkError(url, t);
|
---|
[6642] | 381 | }
|
---|
| 382 |
|
---|
| 383 | /**
|
---|
| 384 | * Returns the network errors that occured until now.
|
---|
| 385 | * @return the network errors that occured until now, indexed by URL
|
---|
[14121] | 386 | * @deprecated Use {@link NetworkManager#getNetworkErrors}
|
---|
[6642] | 387 | * @since 6639
|
---|
| 388 | */
|
---|
[14121] | 389 | @Deprecated
|
---|
[6642] | 390 | public static Map<String, Throwable> getNetworkErrors() {
|
---|
[14121] | 391 | return NetworkManager.getNetworkErrors();
|
---|
[6642] | 392 | }
|
---|
[6897] | 393 |
|
---|
| 394 | /**
|
---|
[12011] | 395 | * Clears the network errors cache.
|
---|
[14121] | 396 | * @deprecated Use {@link NetworkManager#clearNetworkErrors}
|
---|
[12011] | 397 | * @since 12011
|
---|
| 398 | */
|
---|
[14121] | 399 | @Deprecated
|
---|
[12011] | 400 | public static void clearNetworkErrors() {
|
---|
[14121] | 401 | NetworkManager.clearNetworkErrors();
|
---|
[12011] | 402 | }
|
---|
| 403 |
|
---|
| 404 | /**
|
---|
[6897] | 405 | * Returns the JOSM website URL.
|
---|
| 406 | * @return the josm website URL
|
---|
[14119] | 407 | * @deprecated Use {@link IUrls#getJOSMWebsite}
|
---|
[6897] | 408 | * @since 6897
|
---|
| 409 | */
|
---|
[14119] | 410 | @Deprecated
|
---|
[6897] | 411 | public static String getJOSMWebsite() {
|
---|
[14119] | 412 | return Config.getUrls().getJOSMWebsite();
|
---|
[6897] | 413 | }
|
---|
| 414 |
|
---|
| 415 | /**
|
---|
| 416 | * Returns the JOSM XML URL.
|
---|
| 417 | * @return the josm XML URL
|
---|
[14119] | 418 | * @deprecated Use {@link IUrls#getXMLBase}
|
---|
[6897] | 419 | * @since 6897
|
---|
| 420 | */
|
---|
[14119] | 421 | @Deprecated
|
---|
[6897] | 422 | public static String getXMLBase() {
|
---|
[14119] | 423 | return Config.getUrls().getXMLBase();
|
---|
[6897] | 424 | }
|
---|
| 425 |
|
---|
| 426 | /**
|
---|
| 427 | * Returns the OSM website URL.
|
---|
| 428 | * @return the OSM website URL
|
---|
[14119] | 429 | * @deprecated Use {@link IUrls#getOSMWebsite}
|
---|
[6897] | 430 | * @since 6897
|
---|
| 431 | */
|
---|
[14119] | 432 | @Deprecated
|
---|
[6897] | 433 | public static String getOSMWebsite() {
|
---|
[14119] | 434 | return Config.getUrls().getOSMWebsite();
|
---|
[6897] | 435 | }
|
---|
[6957] | 436 |
|
---|
| 437 | /**
|
---|
[7678] | 438 | * Replies the base URL for browsing information about a primitive.
|
---|
| 439 | * @return the base URL, i.e. https://www.openstreetmap.org
|
---|
[14119] | 440 | * @deprecated Use {@link IUrls#getBaseBrowseUrl}
|
---|
[7678] | 441 | * @since 7678
|
---|
| 442 | */
|
---|
[14119] | 443 | @Deprecated
|
---|
[7678] | 444 | public static String getBaseBrowseUrl() {
|
---|
[14119] | 445 | return Config.getUrls().getBaseBrowseUrl();
|
---|
[7678] | 446 | }
|
---|
| 447 |
|
---|
| 448 | /**
|
---|
| 449 | * Replies the base URL for browsing information about a user.
|
---|
| 450 | * @return the base URL, i.e. https://www.openstreetmap.org/user
|
---|
[14119] | 451 | * @deprecated Use {@link IUrls#getBaseUserUrl}
|
---|
[7678] | 452 | * @since 7678
|
---|
| 453 | */
|
---|
[14119] | 454 | @Deprecated
|
---|
[7678] | 455 | public static String getBaseUserUrl() {
|
---|
[14119] | 456 | return Config.getUrls().getBaseUserUrl();
|
---|
[7678] | 457 | }
|
---|
| 458 |
|
---|
| 459 | /**
|
---|
[6957] | 460 | * Determines if we are currently running on OSX.
|
---|
| 461 | * @return {@code true} if we are currently running on OSX
|
---|
| 462 | * @since 6957
|
---|
| 463 | */
|
---|
| 464 | public static boolean isPlatformOsx() {
|
---|
| 465 | return Main.platform instanceof PlatformHookOsx;
|
---|
| 466 | }
|
---|
[7335] | 467 |
|
---|
| 468 | /**
|
---|
| 469 | * Determines if we are currently running on Windows.
|
---|
| 470 | * @return {@code true} if we are currently running on Windows
|
---|
| 471 | * @since 7335
|
---|
| 472 | */
|
---|
| 473 | public static boolean isPlatformWindows() {
|
---|
| 474 | return Main.platform instanceof PlatformHookWindows;
|
---|
| 475 | }
|
---|
[7434] | 476 |
|
---|
| 477 | /**
|
---|
| 478 | * Determines if the given online resource is currently offline.
|
---|
| 479 | * @param r the online resource
|
---|
| 480 | * @return {@code true} if {@code r} is offline and should not be accessed
|
---|
[14121] | 481 | * @deprecated Use {@link NetworkManager#isOffline}
|
---|
[7434] | 482 | * @since 7434
|
---|
| 483 | */
|
---|
[14121] | 484 | @Deprecated
|
---|
[7434] | 485 | public static boolean isOffline(OnlineResource r) {
|
---|
[14121] | 486 | return NetworkManager.isOffline(r);
|
---|
[7434] | 487 | }
|
---|
| 488 |
|
---|
| 489 | /**
|
---|
| 490 | * Sets the given online resource to offline state.
|
---|
| 491 | * @param r the online resource
|
---|
| 492 | * @return {@code true} if {@code r} was not already offline
|
---|
[14121] | 493 | * @deprecated Use {@link NetworkManager#setOffline}
|
---|
[7434] | 494 | * @since 7434
|
---|
| 495 | */
|
---|
[14121] | 496 | @Deprecated
|
---|
[7434] | 497 | public static boolean setOffline(OnlineResource r) {
|
---|
[14121] | 498 | return NetworkManager.setOffline(r);
|
---|
[7434] | 499 | }
|
---|
| 500 |
|
---|
| 501 | /**
|
---|
[8506] | 502 | * Sets the given online resource to online state.
|
---|
| 503 | * @param r the online resource
|
---|
| 504 | * @return {@code true} if {@code r} was offline
|
---|
[14121] | 505 | * @deprecated Use {@link NetworkManager#setOnline}
|
---|
[8506] | 506 | * @since 8506
|
---|
| 507 | */
|
---|
[14121] | 508 | @Deprecated
|
---|
[8506] | 509 | public static boolean setOnline(OnlineResource r) {
|
---|
[14121] | 510 | return NetworkManager.setOnline(r);
|
---|
[8506] | 511 | }
|
---|
| 512 |
|
---|
| 513 | /**
|
---|
[7434] | 514 | * Replies the set of online resources currently offline.
|
---|
| 515 | * @return the set of online resources currently offline
|
---|
[14121] | 516 | * @deprecated Use {@link NetworkManager#getOfflineResources}
|
---|
[7434] | 517 | * @since 7434
|
---|
| 518 | */
|
---|
[14121] | 519 | @Deprecated
|
---|
[7434] | 520 | public static Set<OnlineResource> getOfflineResources() {
|
---|
[14121] | 521 | return NetworkManager.getOfflineResources();
|
---|
[7434] | 522 | }
|
---|
[626] | 523 | }
|
---|