use of com.google.gerrit.client.rpc.GerritCallback in project gerrit by GerritCodeReview.
the class AccountGroupInfoScreen method initGroupOptions.
private void initGroupOptions() {
final VerticalPanel groupOptionsPanel = new VerticalPanel();
final VerticalPanel vp = new VerticalPanel();
vp.setStyleName(Gerrit.RESOURCES.css().groupOptionsPanel());
vp.add(new SmallHeading(AdminConstants.I.headingGroupOptions()));
visibleToAllCheckBox = new CheckBox(AdminConstants.I.isVisibleToAll());
vp.add(visibleToAllCheckBox);
groupOptionsPanel.add(vp);
saveGroupOptions = new Button(AdminConstants.I.buttonSaveGroupOptions());
saveGroupOptions.setEnabled(false);
saveGroupOptions.addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
GroupApi.setGroupOptions(getGroupUUID(), visibleToAllCheckBox.getValue(), new GerritCallback<VoidResult>() {
@Override
public void onSuccess(final VoidResult result) {
saveGroupOptions.setEnabled(false);
}
});
}
});
groupOptionsPanel.add(saveGroupOptions);
add(groupOptionsPanel);
final OnEditEnabler enabler = new OnEditEnabler(saveGroupOptions);
enabler.listenTo(visibleToAllCheckBox);
}
use of com.google.gerrit.client.rpc.GerritCallback in project gerrit by GerritCodeReview.
the class CherryPickAction method call.
static void call(final Button b, final ChangeInfo info, final String revision, String project, final String commitMessage) {
// TODO Replace CherryPickDialog with a nicer looking display.
b.setEnabled(false);
new CherryPickDialog(new Project.NameKey(project)) {
{
sendButton.setText(Util.C.buttonCherryPickChangeSend());
if (info.status() == Change.Status.MERGED) {
message.setText(Util.M.cherryPickedChangeDefaultMessage(commitMessage.trim(), revision));
} else {
message.setText(commitMessage.trim());
}
}
@Override
public void onSend() {
ChangeApi.cherrypick(info.legacyId().get(), revision, getDestinationBranch(), getMessageText(), new GerritCallback<ChangeInfo>() {
@Override
public void onSuccess(ChangeInfo result) {
sent = true;
hide();
Gerrit.display(PageLinks.toChange(result.legacyId()));
}
@Override
public void onFailure(Throwable caught) {
enableButtons(true);
super.onFailure(caught);
}
});
}
@Override
public void onClose(CloseEvent<PopupPanel> event) {
super.onClose(event);
b.setEnabled(true);
}
}.center();
}
use of com.google.gerrit.client.rpc.GerritCallback in project gerrit by GerritCodeReview.
the class QueryScreen method loadCallback.
@Override
protected AsyncCallback<ChangeList> loadCallback() {
return new GerritCallback<ChangeList>() {
@Override
public void onSuccess(ChangeList result) {
if (isAttached()) {
if (result.length() == 1 && isSingleQuery(query)) {
ChangeInfo c = result.get(0);
Change.Id id = c.legacyId();
Gerrit.display(PageLinks.toChange(id));
} else {
display(result);
QueryScreen.this.display();
}
}
}
};
}
use of com.google.gerrit.client.rpc.GerritCallback in project gerrit by GerritCodeReview.
the class DraftBox method save.
void save(CallbackGroup group) {
if (pendingGroup != null) {
pendingGroup.addListener(group);
return;
}
String message = editArea.getValue().trim();
if (message.length() == 0) {
return;
}
CommentInfo input = CommentInfo.copy(comment);
input.message(message);
enableEdit(false);
pendingGroup = group;
final LocalComments lc = new LocalComments(psId);
GerritCallback<CommentInfo> cb = new GerritCallback<CommentInfo>() {
@Override
public void onSuccess(CommentInfo result) {
enableEdit(true);
pendingGroup = null;
set(result);
setEdit(false);
if (autoClosed) {
setOpen(false);
}
getCommentManager().setUnsaved(DraftBox.this, false);
}
@Override
public void onFailure(Throwable e) {
enableEdit(true);
pendingGroup = null;
if (RestApi.isNotSignedIn(e)) {
CommentInfo saved = CommentInfo.copy(comment);
saved.message(editArea.getValue().trim());
lc.setInlineComment(saved);
}
super.onFailure(e);
}
};
if (input.id() == null) {
CommentApi.createDraft(psId, input, group.add(cb));
} else {
CommentApi.updateDraft(psId, input.id(), input, group.add(cb));
}
CodeMirror cm = getCm();
cm.vim().handleKey("<Esc>");
cm.focus();
}
use of com.google.gerrit.client.rpc.GerritCallback 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);
}
});
}
Aggregations