Changeset 12803 in josm for trunk/src/org/openstreetmap/josm/gui/oauth
- Timestamp:
- 2017-09-09T16:45:41+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java
r12686 r12803 21 21 import java.beans.PropertyChangeEvent; 22 22 import java.beans.PropertyChangeListener; 23 import java.lang.reflect.InvocationTargetException; 24 import java.net.URL; 23 25 import java.util.concurrent.Executor; 26 import java.util.concurrent.FutureTask; 24 27 25 28 import javax.swing.AbstractAction; … … 30 33 import javax.swing.JPanel; 31 34 import javax.swing.JScrollPane; 35 import javax.swing.SwingUtilities; 32 36 import javax.swing.UIManager; 33 37 import javax.swing.event.HyperlinkEvent; … … 51 55 import org.openstreetmap.josm.tools.OpenBrowser; 52 56 import org.openstreetmap.josm.tools.UserCancelException; 57 import org.openstreetmap.josm.tools.Utils; 53 58 54 59 /** … … 333 338 } 334 339 340 /** 341 * Obtains an OAuth access token for the connection. Afterwards, the token is accessible via {@link OAuthAccessTokenHolder}. 342 * @param serverUrl the URL to OSM server 343 * @throws InterruptedException if we're interrupted while waiting for the event dispatching thread to finish OAuth authorization task 344 * @throws InvocationTargetException if an exception is thrown while running OAuth authorization task 345 * @since 12803 346 */ 347 public static void obtainAccessToken(final URL serverUrl) throws InvocationTargetException, InterruptedException { 348 final Runnable authTask = new FutureTask<>(() -> { 349 // Concerning Utils.newDirectExecutor: Main worker cannot be used since this connection is already 350 // executed via main worker. The OAuth connections would block otherwise. 351 final OAuthAuthorizationWizard wizard = new OAuthAuthorizationWizard( 352 Main.parent, serverUrl.toExternalForm(), Utils.newDirectExecutor()); 353 wizard.showDialog(); 354 return wizard; 355 }); 356 // exception handling differs from implementation at GuiHelper.runInEDTAndWait() 357 if (SwingUtilities.isEventDispatchThread()) { 358 authTask.run(); 359 } else { 360 SwingUtilities.invokeAndWait(authTask); 361 } 362 } 363 335 364 class AuthorisationProcedureChangeListener implements ItemListener { 336 365 @Override
Note:
See TracChangeset
for help on using the changeset viewer.