Ignore:
Timestamp:
2013-01-30T02:25:13+01:00 (12 years ago)
Author:
Don-vip
Message:

fix EDT violation, javadoc

File:
1 edited

Legend:

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

    r4826 r5692  
    88
    99import org.openstreetmap.josm.gui.io.CredentialDialog;
     10import org.openstreetmap.josm.gui.util.GuiHelper;
    1011
    1112abstract public class AbstractCredentialsAgent implements CredentialsAgent {
     
    1415
    1516    /**
    16      * @see CredentialsAgent#getCredentials(RequestorType, boolean)
     17     * @see CredentialsAgent#getCredentials(RequestorType, String, boolean)
    1718     */
    1819    @Override
    19     public CredentialsAgentResponse getCredentials(RequestorType requestorType, String host, boolean noSuccessWithLastResponse) throws CredentialsAgentException{
     20    public CredentialsAgentResponse getCredentials(final RequestorType requestorType, final String host, boolean noSuccessWithLastResponse) throws CredentialsAgentException{
    2021        if (requestorType == null)
    2122            return null;
    2223        PasswordAuthentication credentials =  lookup(requestorType, host);
    23         String username = (credentials == null || credentials.getUserName() == null) ? "" : credentials.getUserName();
    24         String password = (credentials == null || credentials.getPassword() == null) ? "" : String.valueOf(credentials.getPassword());
     24        final String username = (credentials == null || credentials.getUserName() == null) ? "" : credentials.getUserName();
     25        final String password = (credentials == null || credentials.getPassword() == null) ? "" : String.valueOf(credentials.getPassword());
    2526
    26         CredentialsAgentResponse response = new CredentialsAgentResponse();
     27        final CredentialsAgentResponse response = new CredentialsAgentResponse();
    2728
    2829        /*
     
    4546         */
    4647        } else if (noSuccessWithLastResponse || username.equals("") || password.equals("")) {
    47             CredentialDialog dialog = null;
    48             switch(requestorType) {
    49             case SERVER: dialog = CredentialDialog.getOsmApiCredentialDialog(username, password, host, getSaveUsernameAndPasswordCheckboxText()); break;
    50             case PROXY: dialog = CredentialDialog.getHttpProxyCredentialDialog(username, password, host, getSaveUsernameAndPasswordCheckboxText()); break;
     48            GuiHelper.runInEDTAndWait(new Runnable() {
     49                @Override
     50                public void run() {
     51                    CredentialDialog dialog = null;
     52                    switch(requestorType) {
     53                    case SERVER: dialog = CredentialDialog.getOsmApiCredentialDialog(username, password, host, getSaveUsernameAndPasswordCheckboxText()); break;
     54                    case PROXY: dialog = CredentialDialog.getHttpProxyCredentialDialog(username, password, host, getSaveUsernameAndPasswordCheckboxText()); break;
     55                    }
     56                    dialog.setVisible(true);
     57                    response.setCanceled(dialog.isCanceled());
     58                    if (dialog.isCanceled())
     59                        return;
     60                    response.setUsername(dialog.getUsername());
     61                    response.setPassword(dialog.getPassword());
     62                    response.setSaveCredentials(dialog.isSaveCredentials());
     63                }
     64            });
     65            if (response.isCanceled()) {
     66                return response;
    5167            }
    52             dialog.setVisible(true);
    53             response.setCanceled(dialog.isCanceled());
    54             if (dialog.isCanceled())
    55                 return response;
    56             response.setUsername(dialog.getUsername());
    57             response.setPassword(dialog.getPassword());
    58             if (dialog.isSaveCredentials()) {
     68            if (response.isSaveCredentials()) {
    5969                store(requestorType, host, new PasswordAuthentication(
    6070                        response.getUsername(),
     
    6676             */
    6777            } else {
    68                 PasswordAuthentication pa = new PasswordAuthentication(dialog.getUsername(), dialog.getPassword());
     78                PasswordAuthentication pa = new PasswordAuthentication(response.getUsername(), response.getPassword());
    6979                memoryCredentialsCache.put(requestorType, pa);
    7080            }
Note: See TracChangeset for help on using the changeset viewer.