source: josm/trunk/src/org/openstreetmap/josm/io/OnlineResource.java@ 14397

Last change on this file since 14397 was 14121, checked in by Don-vip, 6 years ago

see #15229 - deprecate all Main methods related to network features. New NetworkManager class

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6/**
7 * Online resources directly used by JOSM.
8 * This does not include websites where user can sometimes be redirected through its web browser,
9 * but only those to we establish a connection.
10 *
11 * @since 7434
12 */
13public enum OnlineResource {
14
15 /** The OSM API, used for download, upload, history, etc. */
16 OSM_API(tr("OSM API")),
17 /** The JOSM website, used for startup page, imagery/presets/styles/rules entries, help, etc. */
18 JOSM_WEBSITE(tr("JOSM website")),
19 /** Value used to represent all online resources */
20 ALL(tr("All"));
21
22 private final String locName;
23
24 OnlineResource(String locName) {
25 this.locName = locName;
26 }
27
28 /**
29 * Replies the localized name.
30 * @return the localized name
31 */
32 public final String getLocName() {
33 return locName;
34 }
35
36 /**
37 * Ensures resource is not accessed in offline mode.
38 * @param downloadString The attempted download string
39 * @param resourceString The resource download string that should not be accessed
40 * @throws OfflineAccessException if resource is accessed in offline mode, in any protocol
41 */
42 public final void checkOfflineAccess(String downloadString, String resourceString) {
43 if (NetworkManager.isOffline(this) && downloadString.substring(downloadString.indexOf("://"))
44 .startsWith(resourceString.substring(resourceString.indexOf("://")))) {
45 throw new OfflineAccessException(tr("Unable to access ''{0}'': {1} not available (offline mode)", downloadString, getLocName()));
46 }
47 }
48}
Note: See TracBrowser for help on using the repository browser.