use of com.google.gerrit.client.rpc.GerritCallback in project gerrit by GerritCodeReview.
the class ContactPanelShort method doRegisterNewEmail.
private void doRegisterNewEmail() {
if (!canRegisterNewEmail()) {
return;
}
final AutoCenterDialogBox box = new AutoCenterDialogBox(true, true);
final VerticalPanel body = new VerticalPanel();
final NpTextBox inEmail = new NpTextBox();
inEmail.setVisibleLength(60);
final Button register = new Button(Util.C.buttonSendRegisterNewEmail());
final Button cancel = new Button(Util.C.buttonCancel());
final FormPanel form = new FormPanel();
form.addSubmitHandler(new FormPanel.SubmitHandler() {
@Override
public void onSubmit(final SubmitEvent event) {
event.cancel();
final String addr = inEmail.getText().trim();
if (!addr.contains("@")) {
new ErrorDialog(Util.C.invalidUserEmail()).center();
return;
}
inEmail.setEnabled(false);
register.setEnabled(false);
AccountApi.registerEmail("self", addr, new GerritCallback<EmailInfo>() {
@Override
public void onSuccess(EmailInfo result) {
box.hide();
if (Gerrit.info().auth().isDev()) {
currentEmail = addr;
if (emailPick.getItemCount() == 0) {
AccountInfo me = Gerrit.getUserAccount();
me.email(addr);
onSaveSuccess(me);
} else {
save.setEnabled(true);
}
updateEmailList();
}
}
@Override
public void onFailure(final Throwable caught) {
inEmail.setEnabled(true);
register.setEnabled(true);
if (caught.getMessage().startsWith(EmailException.MESSAGE)) {
final ErrorDialog d = new ErrorDialog(caught.getMessage().substring(EmailException.MESSAGE.length()));
d.setText(Util.C.errorDialogTitleRegisterNewEmail());
d.center();
} else {
super.onFailure(caught);
}
}
});
}
});
form.setWidget(body);
register.addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
form.submit();
}
});
cancel.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
box.hide();
}
});
final FlowPanel buttons = new FlowPanel();
buttons.setStyleName(Gerrit.RESOURCES.css().patchSetActions());
buttons.add(register);
buttons.add(cancel);
if (!Gerrit.info().auth().isDev()) {
body.add(new HTML(Util.C.descRegisterNewEmail()));
}
body.add(inEmail);
body.add(buttons);
box.setText(Util.C.titleRegisterNewEmail());
box.setWidget(form);
box.center();
inEmail.setFocus(true);
}
use of com.google.gerrit.client.rpc.GerritCallback in project gerrit by GerritCodeReview.
the class MyGpgKeysScreen method refreshKeys.
private void refreshKeys() {
AccountApi.self().view("gpgkeys").get(NativeMap.copyKeysIntoChildren("id", new GerritCallback<NativeMap<GpgKeyInfo>>() {
@Override
public void onSuccess(NativeMap<GpgKeyInfo> result) {
List<GpgKeyInfo> list = Natives.asList(result.values());
// TODO(dborowitz): Sort on something more meaningful, like
// created date?
Collections.sort(list, new Comparator<GpgKeyInfo>() {
@Override
public int compare(GpgKeyInfo a, GpgKeyInfo b) {
return a.id().compareTo(b.id());
}
});
keys.clear();
keyText.setText("");
errorPanel.setVisible(false);
addButton.setEnabled(true);
if (!list.isEmpty()) {
keys.setVisible(true);
for (GpgKeyInfo k : list) {
keys.addOneKey(k);
}
showKeyTable(true);
showAddKeyBlock(false);
} else {
keys.setVisible(false);
showAddKeyBlock(true);
showKeyTable(false);
}
display();
}
}));
}
use of com.google.gerrit.client.rpc.GerritCallback in project gerrit by GerritCodeReview.
the class MyWatchesTable method addNotifyButton.
protected void addNotifyButton(final ProjectWatchInfo.Type type, final ProjectWatchInfo info, final int row, final int col) {
final CheckBox cbox = new CheckBox();
cbox.addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
final Boolean oldVal = info.notify(type);
info.notify(type, cbox.getValue());
cbox.setEnabled(false);
AccountApi.updateWatchedProject("self", info, new GerritCallback<JsArray<ProjectWatchInfo>>() {
@Override
public void onSuccess(JsArray<ProjectWatchInfo> watchedProjects) {
cbox.setEnabled(true);
}
@Override
public void onFailure(Throwable caught) {
cbox.setEnabled(true);
info.notify(type, oldVal);
cbox.setValue(oldVal);
super.onFailure(caught);
}
});
}
});
cbox.setValue(info.notify(type));
table.setWidget(row, col, cbox);
}
use of com.google.gerrit.client.rpc.GerritCallback in project gerrit by GerritCodeReview.
the class ChangeScreen method onLoad.
@Override
protected void onLoad() {
super.onLoad();
CallbackGroup group = new CallbackGroup();
if (Gerrit.isSignedIn()) {
ChangeList.query("change:" + changeId.get() + " has:draft", Collections.<ListChangesOption>emptySet(), group.add(new AsyncCallback<ChangeList>() {
@Override
public void onSuccess(ChangeList result) {
hasDraftComments = result.length() > 0;
}
@Override
public void onFailure(Throwable caught) {
}
}));
ChangeApi.editWithFiles(changeId.get(), group.add(new AsyncCallback<EditInfo>() {
@Override
public void onSuccess(EditInfo result) {
edit = result;
}
@Override
public void onFailure(Throwable caught) {
}
}));
}
loadChangeInfo(true, group.addFinal(new GerritCallback<ChangeInfo>() {
@Override
public void onSuccess(final ChangeInfo info) {
info.init();
initCurrentRevision(info);
final RevisionInfo rev = info.revision(revision);
CallbackGroup group = new CallbackGroup();
loadCommit(rev, group);
group.addListener(new GerritCallback<Void>() {
@Override
public void onSuccess(Void result) {
if (base.isBase() && rev.isMerge()) {
base = DiffObject.parse(info.legacyId(), Gerrit.getUserPreferences().defaultBaseForMerges().getBase());
}
loadConfigInfo(info, base);
JsArray<MessageInfo> mAr = info.messages();
for (int i = 0; i < mAr.length(); i++) {
if (mAr.get(i).tag() != null) {
hideTaggedComments.setVisible(true);
break;
}
}
}
});
group.done();
}
}));
}
use of com.google.gerrit.client.rpc.GerritCallback in project gerrit by GerritCodeReview.
the class ProjectInfoScreen method onLoad.
@Override
protected void onLoad() {
super.onLoad();
Project.NameKey project = getProjectKey();
CallbackGroup cbg = new CallbackGroup();
AccessMap.get(project, cbg.add(new GerritCallback<ProjectAccessInfo>() {
@Override
public void onSuccess(ProjectAccessInfo result) {
isOwner = result.isOwner();
configVisible = result.configVisible();
enableForm();
saveProject.setVisible(isOwner);
}
}));
ProjectApi.getConfig(project, cbg.addFinal(new ScreenLoadCallback<ConfigInfo>(this) {
@Override
public void preDisplay(ConfigInfo result) {
display(result);
}
}));
savedPanel = INFO;
}
Aggregations