Changeset 9353 in josm for trunk/src


Ignore:
Timestamp:
2016-01-09T16:37:20+01:00 (9 years ago)
Author:
simon04
Message:

Refactoring: introduce OsmApi#getServerUrl

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java

    r9352 r9353  
    162162     */
    163163    public void initFromPreferences() {
    164         setApiUrl(Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL).trim());
     164        setApiUrl(OsmApi.getOsmApi().getServerUrl().trim());
    165165        refreshView();
    166166    }
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/OsmApiUrlInputPanel.java

    r8840 r9353  
    119119     */
    120120    public void initFromPreferences() {
    121         String url =  Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL);
     121        String url =  OsmApi.getOsmApi().getServerUrl();
    122122        if (OsmApi.DEFAULT_API_URL.equals(url.trim())) {
    123123            cbUseDefaultServerUrl.setSelected(true);
     
    134134     */
    135135    public void saveToPreferences() {
    136         String oldUrl = Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL);
     136        String oldUrl = OsmApi.getOsmApi().getServerUrl();
    137137        String hmiUrl = getStrippedApiUrl();
    138138        if (cbUseDefaultServerUrl.isSelected()) {
     
    143143            Main.pref.put("osm-server.url", hmiUrl);
    144144        }
    145         String newUrl = Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL);
     145        String newUrl = OsmApi.getOsmApi().getServerUrl();
    146146
    147147        // When API URL changes, re-initialize API connection so we may adjust
  • trunk/src/org/openstreetmap/josm/io/CachedFile.java

    r9296 r9353  
    453453    private static void checkOfflineAccess(String urlString) {
    454454        OnlineResource.JOSM_WEBSITE.checkOfflineAccess(urlString, Main.getJOSMWebsite());
    455         OnlineResource.OSM_API.checkOfflineAccess(urlString, Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL));
     455        OnlineResource.OSM_API.checkOfflineAccess(urlString, OsmApi.getOsmApi().getServerUrl());
    456456    }
    457457
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r9352 r9353  
    340340
    341341    /**
     342     * Returns the server URL
     343     * @return the server URL
     344     * @since 9353
     345     */
     346    public String getServerUrl() {
     347        return serverUrl;
     348    }
     349
     350    /**
    342351     * Creates an OSM primitive on the server. The OsmPrimitive object passed in
    343352     * is modified by giving it the server-assigned id.
  • trunk/src/org/openstreetmap/josm/io/OsmConnection.java

    r9352 r9353  
    127127    protected void obtainAccessToken(final HttpClient connection) throws MissingOAuthAccessTokenException {
    128128        try {
    129             final URL apiUrl = new URL(Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL));
     129            final URL apiUrl = new URL(OsmApi.getOsmApi().getServerUrl());
    130130            if (!Objects.equals(apiUrl.getHost(), connection.getURL().getHost())) {
    131131                throw new MissingOAuthAccessTokenException();
  • trunk/src/org/openstreetmap/josm/io/OsmServerReader.java

    r9309 r9353  
    113113        try {
    114114            OnlineResource.JOSM_WEBSITE.checkOfflineAccess(urlStr, Main.getJOSMWebsite());
    115             OnlineResource.OSM_API.checkOfflineAccess(urlStr, Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL));
     115            OnlineResource.OSM_API.checkOfflineAccess(urlStr, OsmApi.getOsmApi().getServerUrl());
    116116
    117117            URL url = null;
  • trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java

    r8846 r9353  
    5353                "<html>Failed to initialize communication with the OSM server {0}.<br>"
    5454                + "Check the server URL in your preferences and your internet connection.",
    55                 Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL));
     55                OsmApi.getOsmApi().getServerUrl());
    5656    }
    5757
     
    6464                + "Please open the Preferences Dialog and generate or enter an Access Token."
    6565                + "</html>",
    66                 Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL)
     66                OsmApi.getOsmApi().getServerUrl()
    6767        );
    6868    }
Note: See TracChangeset for help on using the changeset viewer.