use of org.archicontribs.modelrepository.dialogs.UserNamePasswordDialog in project archi-modelrepository-plugin by archi-contribs.
the class AbstractModelAction method getUserNameAndPasswordFromCredentialsFileOrDialog.
/**
* Get user name and password from credentials file if prefs set or from dialog
* @param storageFileName
* @param shell
* @return the username and password, or null
*/
protected UsernamePassword getUserNameAndPasswordFromCredentialsFileOrDialog(Shell shell) {
boolean doStoreInCredentialsFile = ModelRepositoryPlugin.INSTANCE.getPreferenceStore().getBoolean(IPreferenceConstants.PREFS_STORE_REPO_CREDENTIALS);
SimpleCredentialsStorage scs = new SimpleCredentialsStorage(new File(getRepository().getLocalGitFolder(), IGraficoConstants.REPO_CREDENTIALS_FILE));
// Is it stored?
if (doStoreInCredentialsFile && scs.hasCredentialsFile()) {
try {
return new UsernamePassword(scs.getUsername(), scs.getPassword());
} catch (IOException ex) {
displayErrorDialog(Messages.AbstractModelAction_9, ex);
}
}
// Else ask the user
UserNamePasswordDialog dialog = new UserNamePasswordDialog(shell, scs);
if (dialog.open() == Window.OK) {
return new UsernamePassword(dialog.getUsername(), dialog.getPassword());
}
return null;
}
Aggregations