Changeset 6582 in josm for trunk/src/org


Ignore:
Timestamp:
2014-01-01T11:57:38+01:00 (11 years ago)
Author:
bastiK
Message:

fixed #9505 - Defaults for osm-server.url differ = !null

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/oauth/OAuthParameters.java

    r6453 r6582  
    9191     */
    9292    static public OAuthParameters createFromPreferences(Preferences pref) {
    93         OAuthParameters parameters = createDefault(pref.get("osm-server.url"));
     93        OAuthParameters parameters = createDefault(pref.get("osm-server.url", OsmApi.DEFAULT_API_URL));
    9494        parameters.setConsumerKey(pref.get("oauth.settings.consumer-key", parameters.getConsumerKey()));
    9595        parameters.setConsumerSecret(pref.get("oauth.settings.consumer-secret", parameters.getConsumerSecret()));
  • trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java

    r6268 r6582  
    3535import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    3636import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     37import org.openstreetmap.josm.io.OsmApi;
    3738import org.openstreetmap.josm.io.OsmTransferCanceledException;
    3839import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    6162     */
    6263    public OsmOAuthAuthorizationClient() {
    63         oauthProviderParameters = OAuthParameters.createDefault(Main.pref.get("osm-server.url"));
     64        oauthProviderParameters = OAuthParameters.createDefault(Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL));
    6465        consumer = oauthProviderParameters.buildConsumer();
    6566        provider = oauthProviderParameters.buildProvider(consumer);
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/OsmApiUrlInputPanel.java

    r6529 r6582  
    128128     */
    129129    public void initFromPreferences() {
    130         String url =  Main.pref.get("osm-server.url", null);
    131         if (url == null) {
    132             cbUseDefaultServerUrl.setSelected(true);
    133             firePropertyChange(API_URL_PROP, null, OsmApi.DEFAULT_API_URL);
    134         } else if (url.trim().equals(OsmApi.DEFAULT_API_URL)) {
     130        String url =  Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL);
     131        if (url.trim().equals(OsmApi.DEFAULT_API_URL)) {
    135132            cbUseDefaultServerUrl.setSelected(true);
    136133            firePropertyChange(API_URL_PROP, null, OsmApi.DEFAULT_API_URL);
     
    146143     */
    147144    public void saveToPreferences() {
    148         String old_url = Main.pref.get("osm-server.url", null);
     145        String old_url = Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL);
    149146        if (cbUseDefaultServerUrl.isSelected()) {
    150147            Main.pref.put("osm-server.url", null);
     
    154151            Main.pref.put("osm-server.url", tfOsmServerUrl.getText().trim());
    155152        }
    156         String new_url = Main.pref.get("osm-server.url", null);
     153        String new_url = Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL);
    157154
    158155        // When API URL changes, re-initialize API connection so we may adjust
    159156        // server-dependent settings.
    160         if ((old_url == null && new_url != null) || (old_url != null && !old_url.equals(new_url))) {
     157        if (!old_url.equals(new_url)) {
    161158            try {
    162159                OsmApi.getOsmApi().initialize(null);
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r6552 r6582  
    9999     *
    100100     * @return the OsmApi
    101      * @throws IllegalStateException thrown, if the preference <code>osm-server.url</code> is not set
    102      *
    103101     */
    104102    static public OsmApi getOsmApi() {
    105103        String serverUrl = Main.pref.get("osm-server.url", DEFAULT_API_URL);
    106         if (serverUrl == null)
    107             throw new IllegalStateException(tr("Preference ''{0}'' missing. Cannot initialize OsmApi.", "osm-server.url"));
    108104        return getOsmApi(serverUrl);
    109105    }
  • trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java

    r6362 r6582  
    5252        String msg = tr(
    5353                "<html>Failed to initialize communication with the OSM server {0}.<br>"
    54                 + "Check the server URL in your preferences and your internet connection.", Main.pref.get(
    55                         "osm-server.url", OsmApi.DEFAULT_API_URL));
     54                + "Check the server URL in your preferences and your internet connection.",
     55                Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL));
    5656        return msg;
    5757    }
Note: See TracChangeset for help on using the changeset viewer.