use of com.google.gerrit.client.rpc.CallbackGroup in project gerrit by GerritCodeReview.
the class DraftBox method onDiscard.
@UiHandler({ "discard1", "discard2" })
void onDiscard(ClickEvent e) {
e.stopPropagation();
if (isNew()) {
removeUI();
restoreSelection();
} else {
setEdit(false);
pendingGroup = new CallbackGroup();
CommentApi.deleteDraft(psId, comment.id(), pendingGroup.addFinal(new GerritCallback<JavaScriptObject>() {
@Override
public void onSuccess(JavaScriptObject result) {
pendingGroup = null;
removeUI();
}
}));
}
}
use of com.google.gerrit.client.rpc.CallbackGroup in project gerrit by GerritCodeReview.
the class DiffScreen method onLoad.
@Override
protected void onLoad() {
super.onLoad();
CallbackGroup group1 = new CallbackGroup();
final CallbackGroup group2 = new CallbackGroup();
CodeMirror.initLibrary(group1.add(new AsyncCallback<Void>() {
final AsyncCallback<Void> themeCallback = group2.addEmpty();
@Override
public void onSuccess(Void result) {
// Load theme after CM library to ensure theme can override CSS.
ThemeLoader.loadTheme(prefs.theme(), themeCallback);
}
@Override
public void onFailure(Throwable caught) {
}
}));
DiffApi.diff(revision, path).base(base.asPatchSetId()).wholeFile().intraline(prefs.intralineDifference()).ignoreWhitespace(prefs.ignoreWhitespace()).get(group1.addFinal(new GerritCallback<DiffInfo>() {
final AsyncCallback<Void> modeInjectorCb = group2.addEmpty();
@Override
public void onSuccess(DiffInfo diffInfo) {
diff = diffInfo;
fileSize = bucketFileSize(diffInfo);
if (prefs.syntaxHighlighting()) {
if (fileSize.compareTo(FileSize.SMALL) > 0) {
modeInjectorCb.onSuccess(null);
} else {
injectMode(diffInfo, modeInjectorCb);
}
} else {
modeInjectorCb.onSuccess(null);
}
}
}));
if (Gerrit.isSignedIn()) {
ChangeApi.edit(changeId.get(), group2.add(new AsyncCallback<EditInfo>() {
@Override
public void onSuccess(EditInfo result) {
edit = result;
}
@Override
public void onFailure(Throwable caught) {
}
}));
}
final CommentsCollections comments = new CommentsCollections(base, revision, path);
comments.load(group2);
countParents(group2);
RestApi call = ChangeApi.detail(changeId.get());
ChangeList.addOptions(call, EnumSet.of(ListChangesOption.ALL_REVISIONS));
call.get(group2.add(new AsyncCallback<ChangeInfo>() {
@Override
public void onSuccess(ChangeInfo info) {
changeStatus = info.status();
info.revisions().copyKeysIntoChildren("name");
if (edit != null) {
edit.setName(edit.commit().commit());
info.setEdit(edit);
info.revisions().put(edit.name(), RevisionInfo.fromEdit(edit));
}
String currentRevision = info.currentRevision();
boolean current = currentRevision != null && revision.get() == info.revision(currentRevision)._number();
JsArray<RevisionInfo> list = info.revisions().values();
RevisionInfo.sortRevisionInfoByNumber(list);
getDiffTable().set(prefs, list, parents, diff, edit != null, current, changeStatus.isOpen(), diff.binary());
header.setChangeInfo(info);
}
@Override
public void onFailure(Throwable caught) {
}
}));
ConfigInfoCache.get(changeId, group2.addFinal(getScreenLoadCallback(comments)));
}
use of com.google.gerrit.client.rpc.CallbackGroup in project gerrit by GerritCodeReview.
the class DiffScreen method onUnload.
@Override
protected void onUnload() {
super.onUnload();
removeKeyHandlerRegistrations();
if (getCommentManager() != null) {
CallbackGroup group = new CallbackGroup();
getCommentManager().saveAllDrafts(group);
group.done();
}
if (resizeHandler != null) {
resizeHandler.removeHandler();
resizeHandler = null;
}
for (CodeMirror cm : getCms()) {
if (cm != null) {
cm.getWrapperElement().removeFromParent();
}
}
if (prefsAction != null) {
prefsAction.hide();
}
Window.enableScrolling(true);
Gerrit.setHeaderVisible(true);
}
use of com.google.gerrit.client.rpc.CallbackGroup in project gerrit by GerritCodeReview.
the class DiffScreen method upToChange.
private Runnable upToChange(boolean openReplyBox) {
return () -> {
CallbackGroup group = new CallbackGroup();
getCommentManager().saveAllDrafts(group);
group.done();
group.addListener(new GerritCallback<Void>() {
@Override
public void onSuccess(Void result) {
String rev = String.valueOf(revision.get());
Gerrit.display(PageLinks.toChange(changeId, base.asString(), rev), new ChangeScreen(changeId, base, rev, openReplyBox, FileTable.Mode.REVIEW));
}
});
};
}
use of com.google.gerrit.client.rpc.CallbackGroup in project gerrit by GerritCodeReview.
the class DraftBox method onKeyDown.
@UiHandler("editArea")
void onKeyDown(KeyDownEvent e) {
resizeTimer.cancel();
if ((e.isControlKeyDown() || e.isMetaKeyDown()) && !e.isAltKeyDown() && !e.isShiftKeyDown()) {
switch(e.getNativeKeyCode()) {
case 's':
case 'S':
e.preventDefault();
CallbackGroup group = new CallbackGroup();
save(group);
group.done();
return;
}
} else if (e.getNativeKeyCode() == KeyCodes.KEY_ESCAPE && !isDirty()) {
if (isNew()) {
removeUI();
restoreSelection();
return;
}
setEdit(false);
if (autoClosed) {
setOpen(false);
}
getCm().focus();
return;
}
expandTimer.schedule(250);
}
Aggregations