Changeset 12928 in josm for trunk/src/org/openstreetmap/josm/gui/oauth
- Timestamp:
- 2017-10-06T15:17:51+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/oauth
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/oauth/AbstractAuthorizationUI.java
r10378 r12928 130 130 131 131 /** 132 * Initializes the authorisation UI. 133 * 134 * @param paramApiUrl the API URL. Must not be null. 135 * @throws IllegalArgumentException if paramApiUrl is null 136 */ 137 public void initialize(String paramApiUrl) { 138 CheckParameterUtil.ensureParameterNotNull(paramApiUrl, "paramApiUrl"); 139 pnlAdvancedProperties.initialize(paramApiUrl); 140 } 141 142 /** 132 143 * Initializes the authorisation UI with preference values in <code>pref</code>. 133 144 * 134 145 * @param pref the preferences. Must not be null. 135 146 * @throws IllegalArgumentException if pref is null 147 * @deprecated (since 12928) replaced by {@link #initialize(java.lang.String)} 136 148 */ 149 @Deprecated 137 150 public void initFromPreferences(Preferences pref) { 138 151 CheckParameterUtil.ensureParameterNotNull(pref, "pref"); -
trunk/src/org/openstreetmap/josm/gui/oauth/AdvancedOAuthPropertiesPanel.java
r12841 r12928 24 24 import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator; 25 25 import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel; 26 import org.openstreetmap.josm.spi.preferences.Config; 26 27 import org.openstreetmap.josm.tools.CheckParameterUtil; 27 28 import org.openstreetmap.josm.tools.ImageProvider; … … 257 258 * Initializes the panel from the values in the preferences <code>preferences</code>. 258 259 * 260 * @param paramApiUrl the API URL. Must not be null. 261 * @throws IllegalArgumentException if paramApiUrl is null 262 */ 263 public void initialize(String paramApiUrl) { 264 CheckParameterUtil.ensureParameterNotNull(paramApiUrl, "paramApiUrl"); 265 setApiUrl(paramApiUrl); 266 boolean useDefault = Config.getPref().getBoolean("oauth.settings.use-default", true); 267 ilUseDefault.setEnabled(false); 268 if (useDefault) { 269 resetToDefaultSettings(); 270 } else { 271 setAdvancedParameters(OAuthParameters.createFromApiUrl(paramApiUrl)); 272 } 273 ilUseDefault.setEnabled(true); 274 } 275 276 /** 277 * Initializes the panel from the values in the preferences <code>preferences</code>. 278 * 259 279 * @param pref the preferences. Must not be null. 260 280 * @throws IllegalArgumentException if pref is null 261 */ 281 * @deprecated (since 12928) replaced by {@link #initialize(java.lang.String)} 282 */ 283 @Deprecated 262 284 public void initFromPreferences(Preferences pref) { 263 285 CheckParameterUtil.ensureParameterNotNull(pref, "pref"); … … 275 297 /** 276 298 * Remembers the current values in the preferences <code>pref</code>. 299 */ 300 public void rememberPreferences() { 301 Config.getPref().putBoolean("oauth.settings.use-default", cbUseDefaults.isSelected()); 302 if (cbUseDefaults.isSelected()) { 303 new OAuthParameters(null, null, null, null, null, null, null).rememberPreferences(); 304 } else { 305 getAdvancedParameters().rememberPreferences(); 306 } 307 } 308 309 /** 310 * Remembers the current values in the preferences <code>pref</code>. 277 311 * 278 312 * @param pref the preferences. Must not be null. 279 313 * @throws IllegalArgumentException if pref is null. 280 */ 314 * @deprecated (since 12928) replaced by {@link #rememberPreferences()} 315 */ 316 @Deprecated 281 317 public void rememberPreferences(Preferences pref) { 282 318 CheckParameterUtil.ensureParameterNotNull(pref, "pref"); -
trunk/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUI.java
r12620 r12928 169 169 /** 170 170 * Initializes the panel with values from the preferences 171 * @param paramApiUrl the API URL 172 */ 173 @Override 174 public void initialize(String paramApiUrl) { 175 super.initialize(paramApiUrl); 176 CredentialsAgent cm = CredentialsManager.getInstance(); 177 try { 178 PasswordAuthentication pa = cm.lookup(RequestorType.SERVER, OsmApi.getOsmApi().getHost()); 179 if (pa == null) { 180 tfUserName.setText(""); 181 tfPassword.setText(""); 182 } else { 183 tfUserName.setText(pa.getUserName() == null ? "" : pa.getUserName()); 184 tfPassword.setText(pa.getPassword() == null ? "" : String.valueOf(pa.getPassword())); 185 } 186 } catch (CredentialsAgentException e) { 187 Logging.error(e); 188 tfUserName.setText(""); 189 tfPassword.setText(""); 190 } 191 } 192 193 /** 194 * Initializes the panel with values from the preferences 171 195 * @param pref Preferences structure 172 */ 196 * @deprecated (since 12928) replaced by {@link #initialize(java.lang.String)} 197 */ 198 @Deprecated 173 199 @Override 174 200 public void initFromPreferences(Preferences pref) { -
trunk/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java
r12803 r12928 40 40 41 41 import org.openstreetmap.josm.Main; 42 import org.openstreetmap.josm.data.Preferences;43 42 import org.openstreetmap.josm.data.oauth.OAuthAccessTokenHolder; 44 43 import org.openstreetmap.josm.data.oauth.OAuthParameters; … … 309 308 */ 310 309 public void initFromPreferences() { 311 // Copy current JOSM preferences to update API url with the one used in this wizard 312 Preferences copyPref = new Preferences(Main.pref); 313 copyPref.put("osm-server.url", apiUrl); 314 pnlFullyAutomaticAuthorisationUI.initFromPreferences(copyPref); 315 pnlSemiAutomaticAuthorisationUI.initFromPreferences(copyPref); 316 pnlManualAuthorisationUI.initFromPreferences(copyPref); 310 pnlFullyAutomaticAuthorisationUI.initialize(apiUrl); 311 pnlSemiAutomaticAuthorisationUI.initialize(apiUrl); 312 pnlManualAuthorisationUI.initialize(apiUrl); 317 313 } 318 314
Note:
See TracChangeset
for help on using the changeset viewer.