use of com.google.gerrit.client.rpc.NativeString in project gerrit by GerritCodeReview.
the class MyProfileScreen method display.
void display(AccountInfo account) {
if (Gerrit.info().plugin().hasAvatars()) {
avatar.setAccount(account, 93, false);
new RestApi("/accounts/").id("self").view("avatar.change.url").get(new AsyncCallback<NativeString>() {
@Override
public void onSuccess(NativeString changeUrl) {
changeAvatar.setHref(changeUrl.asString());
changeAvatar.setVisible(true);
}
@Override
public void onFailure(Throwable caught) {
}
});
}
int row = 0;
if (Gerrit.info().auth().siteHasUsernames()) {
info.setWidget(row++, fieldIdx, new UsernameField());
}
info.setText(row++, fieldIdx, account.name());
info.setText(row++, fieldIdx, account.email());
info.setText(row++, fieldIdx, mediumFormat(account.registeredOn()));
info.setText(row, fieldIdx, account.getId().toString());
}
use of com.google.gerrit.client.rpc.NativeString in project gerrit by GerritCodeReview.
the class MyPasswordScreen method onLoad.
@Override
protected void onLoad() {
super.onLoad();
ExtensionPanel extensionPanel = createExtensionPoint(GerritUiExtensionPoint.PASSWORD_SCREEN_BOTTOM);
extensionPanel.addStyleName(Gerrit.RESOURCES.css().extensionPanel());
add(extensionPanel);
if (password == null) {
display();
return;
}
enableUI(false);
AccountApi.getUsername("self", new GerritCallback<NativeString>() {
@Override
public void onSuccess(NativeString user) {
Gerrit.getUserAccount().username(user.asString());
enableUI(true);
display();
}
@Override
public void onFailure(final Throwable caught) {
if (RestApi.isNotFound(caught)) {
Gerrit.getUserAccount().username(null);
display();
} else {
super.onFailure(caught);
}
}
});
}
use of com.google.gerrit.client.rpc.NativeString in project gerrit by GerritCodeReview.
the class ContactPanelShort method onLoad.
@Override
protected void onLoad() {
super.onLoad();
onInitUI();
body.add(save);
display(Gerrit.getUserAccount());
emailPick.clear();
emailPick.setEnabled(false);
registerNewEmail.setEnabled(false);
haveAccount = false;
haveEmails = false;
CallbackGroup group = new CallbackGroup();
AccountApi.getName("self", group.add(new GerritCallback<NativeString>() {
@Override
public void onSuccess(NativeString result) {
nameTxt.setText(result.asString());
haveAccount = true;
}
@Override
public void onFailure(Throwable caught) {
}
}));
AccountApi.getEmails("self", group.addFinal(new GerritCallback<JsArray<EmailInfo>>() {
@Override
public void onSuccess(JsArray<EmailInfo> result) {
for (EmailInfo i : Natives.asList(result)) {
emailPick.addItem(i.email());
if (i.isPreferred()) {
currentEmail = i.email();
}
}
haveEmails = true;
postLoad();
}
}));
}
use of com.google.gerrit.client.rpc.NativeString in project gerrit by GerritCodeReview.
the class ContactPanelShort method doSave.
void doSave() {
final String newName;
String name = canEditFullName() ? nameTxt.getText() : null;
if (name != null && name.trim().isEmpty()) {
newName = null;
} else {
newName = name;
}
final String newEmail;
if (emailPick.isEnabled() && emailPick.getSelectedIndex() >= 0) {
final String v = emailPick.getValue(emailPick.getSelectedIndex());
if (Util.C.buttonOpenRegisterNewEmail().equals(v)) {
newEmail = currentEmail;
} else {
newEmail = v;
}
} else {
newEmail = currentEmail;
}
save.setEnabled(false);
registerNewEmail.setEnabled(false);
CallbackGroup group = new CallbackGroup();
if (currentEmail != null && !newEmail.equals(currentEmail)) {
AccountApi.setPreferredEmail("self", newEmail, group.add(new GerritCallback<NativeString>() {
@Override
public void onSuccess(NativeString result) {
}
}));
}
AccountApi.setName("self", newName, group.add(new GerritCallback<NativeString>() {
@Override
public void onSuccess(NativeString result) {
}
@Override
public void onFailure(Throwable caught) {
save.setEnabled(true);
registerNewEmail.setEnabled(true);
super.onFailure(caught);
}
}));
group.done();
group.addListener(new GerritCallback<Void>() {
@Override
public void onSuccess(Void result) {
currentEmail = newEmail;
AccountInfo me = Gerrit.getUserAccount();
me.email(currentEmail);
me.name(newName);
onSaveSuccess(me);
registerNewEmail.setEnabled(true);
}
});
}
use of com.google.gerrit.client.rpc.NativeString in project gerrit by GerritCodeReview.
the class UsernameField method doSetUserName.
private void doSetUserName() {
if (!canEditUserName()) {
return;
}
enableUI(false);
String newName = userNameTxt.getText();
if ("".equals(newName)) {
newName = null;
}
final String newUserName = newName;
AccountApi.setUsername("self", newUserName, new GerritCallback<NativeString>() {
@Override
public void onSuccess(NativeString result) {
Gerrit.getUserAccount().username(newUserName);
userNameLbl.setText(newUserName);
userNameLbl.setVisible(true);
userNameTxt.setVisible(false);
setUserName.setVisible(false);
}
@Override
public void onFailure(Throwable caught) {
enableUI(true);
if (RestApi.isExpected(422)) {
new ErrorDialog(Util.C.invalidUserName()).center();
} else {
super.onFailure(caught);
}
}
});
}
Aggregations