/**
* Inits contents from preferences.
*/
public void initFromPreferences() {
CredentialsAgent cm = CredentialsManager.getInstance();
try {
decorationPanel.removeAll();
decorationPanel.add(cm.getPreferencesDecorationPanel(), BorderLayout.CENTER);
PasswordAuthentication pa = cm.lookup(RequestorType.SERVER, OsmApi.getOsmApi().getHost());
if (pa == null) {
tfOsmUserName.setText("");
tfOsmPassword.setText("");
} else {
tfOsmUserName.setText(pa.getUserName() == null? "" : pa.getUserName());
tfOsmPassword.setText(pa.getPassword() == null ? "" : String.valueOf(pa.getPassword()));
}
} catch(CredentialsAgentException e) {
Main.error(e);
Main.warn(tr("Failed to retrieve OSM credentials from credential manager."));
Main.warn(tr("Current credential manager is of type ''{0}''", cm.getClass().getName()));
tfOsmUserName.setText("");
tfOsmPassword.setText("");
}
}