Ignore:
Timestamp:
2017-09-11T01:54:52+02:00 (4 years ago)
Author:
Don-vip
Message:

see #15229 - see #15182 - remove GUI references from I/O subsystem

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r12808 r12821  
    9797import org.openstreetmap.josm.gui.bugreport.BugReportDialog;
    9898import org.openstreetmap.josm.gui.download.DownloadDialog;
     99import org.openstreetmap.josm.gui.io.CredentialDialog;
    99100import org.openstreetmap.josm.gui.io.CustomConfigurator.XMLCommandProcessor;
    100101import org.openstreetmap.josm.gui.io.SaveLayersDialog;
     
    132133import org.openstreetmap.josm.io.OsmTransferCanceledException;
    133134import org.openstreetmap.josm.io.OsmTransferException;
     135import org.openstreetmap.josm.io.auth.AbstractCredentialsAgent;
    134136import org.openstreetmap.josm.io.auth.CredentialsManager;
    135137import org.openstreetmap.josm.io.auth.DefaultAuthenticator;
     
    10891091    static void setupCallbacks() {
    10901092        OsmConnection.setOAuthAccessTokenFetcher(OAuthAuthorizationWizard::obtainAccessToken);
     1093        AbstractCredentialsAgent.setCredentialsProvider(CredentialDialog::promptCredentials);
    10911094        MessageNotifier.setNotifierCallback(MainApplication::notifyNewMessages);
    10921095        DeleteCommand.setDeletionCallback(DeleteAction.defaultDeletionCallback);
  • trunk/src/org/openstreetmap/josm/gui/io/CredentialDialog.java

    r12805 r12821  
    1818import java.awt.event.WindowAdapter;
    1919import java.awt.event.WindowEvent;
     20import java.net.Authenticator.RequestorType;
    2021import java.util.Objects;
    2122
     
    3233import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction;
    3334import org.openstreetmap.josm.gui.help.HelpUtil;
     35import org.openstreetmap.josm.gui.util.GuiHelper;
    3436import org.openstreetmap.josm.gui.util.WindowGeometry;
    3537import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
     
    3840import org.openstreetmap.josm.io.DefaultProxySelector;
    3941import org.openstreetmap.josm.io.OsmApi;
     42import org.openstreetmap.josm.io.auth.AbstractCredentialsAgent;
     43import org.openstreetmap.josm.io.auth.CredentialsAgentResponse;
    4044import org.openstreetmap.josm.tools.ImageProvider;
    4145import org.openstreetmap.josm.tools.InputMapUtils;
     
    6872        dialog.pack();
    6973        return dialog;
     74    }
     75
     76    /**
     77     * Prompts the user (in the EDT) for credentials and fills the given response with what has been entered.
     78     * @param requestorType type of the entity requesting authentication
     79     * @param agent the credentials agent requesting credentials
     80     * @param response authentication response to fill
     81     * @param username the known username, if any. Likely to be empty
     82     * @param password the known password, if any. Likely to be empty
     83     * @param host the host against authentication will be performed
     84     * @since 12821
     85     */
     86    public static void promptCredentials(RequestorType requestorType, AbstractCredentialsAgent agent, CredentialsAgentResponse response,
     87            String username, String password, String host) {
     88        GuiHelper.runInEDTAndWait(() -> {
     89            CredentialDialog dialog;
     90            if (requestorType.equals(RequestorType.PROXY))
     91                dialog = getHttpProxyCredentialDialog(
     92                        username, password, host, agent.getSaveUsernameAndPasswordCheckboxText());
     93            else
     94                dialog = getOsmApiCredentialDialog(
     95                        username, password, host, agent.getSaveUsernameAndPasswordCheckboxText());
     96            dialog.setVisible(true);
     97            response.setCanceled(dialog.isCanceled());
     98            if (dialog.isCanceled())
     99                return;
     100            response.setUsername(dialog.getUsername());
     101            response.setPassword(dialog.getPassword());
     102            response.setSaveCredentials(dialog.isSaveCredentials());
     103        });
    70104    }
    71105
Note: See TracChangeset for help on using the changeset viewer.