Changeset 16427 in josm


Ignore:
Timestamp:
2020-05-16T21:25:54+02:00 (3 weeks ago)
Author:
simon04
Message:

see #18712 - Add OfflineAccessException.forResource(String)

Location:
trunk/src/org/openstreetmap/josm
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/MessageNotifier.java

    r15251 r16427  
    105105        int interval = PROP_INTERVAL.get();
    106106        if (NetworkManager.isOffline(OnlineResource.OSM_API)) {
    107             Logging.info(tr("{0} not available (offline mode)", tr("Message notifier")));
     107            Logging.info(OfflineAccessException.forResource(tr("Message notifier")).getMessage());
    108108        } else if (!isRunning() && interval > 0 && isUserEnoughIdentified()) {
    109109            task = EXECUTOR.scheduleAtFixedRate(WORKER, 0, interval, TimeUnit.MINUTES);
  • trunk/src/org/openstreetmap/josm/io/OfflineAccessException.java

    r7937 r16427  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.io;
     3
     4import static org.openstreetmap.josm.tools.I18n.tr;
    35
    46/**
     
    1517        super(s);
    1618    }
     19
     20    /**
     21     * Returns a new OfflineAccessException with a translated message for the given resource
     22     * @param name the translated name/description of the resource
     23     * @return a new OfflineAccessException
     24     */
     25    public static OfflineAccessException forResource(String name) {
     26        return new OfflineAccessException(tr("{0} not available (offline mode)", name));
     27    }
    1728}
  • trunk/src/org/openstreetmap/josm/io/OnlineResource.java

    r16426 r16427  
    6969    public final void checkOfflineAccess(String downloadString, String ignore) {
    7070        if (NetworkManager.isOffline(downloadString)) {
    71             throw new OfflineAccessException(tr("Unable to access ''{0}'': {1} not available (offline mode)", downloadString, getLocName()));
     71            throw OfflineAccessException.forResource(downloadString);
    7272        }
    7373    }
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r16426 r16427  
    256256            if (capabilities == null) {
    257257                if (NetworkManager.isOffline(OnlineResource.OSM_API)) {
    258                     Logging.warn(tr("{0} not available (offline mode)", tr("OSM API")));
     258                    Logging.warn(OfflineAccessException.forResource(tr("")).getMessage());
    259259                } else {
    260260                    Logging.error(tr("Unable to initialize OSM API."));
  • trunk/src/org/openstreetmap/josm/io/OsmServerReader.java

    r16426 r16427  
    158158        try {
    159159            if (NetworkManager.isOffline(urlStr)) {
    160                 throw new OsmApiException(new OfflineAccessException(tr("{0} not available (offline mode)", urlStr)));
     160                throw new OsmApiException(OfflineAccessException.forResource(urlStr));
    161161            }
    162162
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r16426 r16427  
    6767import org.openstreetmap.josm.gui.widgets.JosmTextArea;
    6868import org.openstreetmap.josm.io.NetworkManager;
     69import org.openstreetmap.josm.io.OfflineAccessException;
    6970import org.openstreetmap.josm.spi.preferences.Config;
    7071import org.openstreetmap.josm.tools.Destroyable;
     
    435436    public static boolean checkAndConfirmPluginUpdate(Component parent) {
    436437        if (Preferences.main().getPluginSites().stream().anyMatch(NetworkManager::isOffline)) {
    437             Logging.info(tr("{0} not available (offline mode)", tr("Plugin update")));
     438            Logging.info(OfflineAccessException.forResource(tr("Plugin update")).getMessage());
    438439            return false;
    439440        }
Note: See TracChangeset for help on using the changeset viewer.