use of com.google.gerrit.client.info.ChangeInfo in project gerrit by GerritCodeReview.
the class EditScreen method onLoad.
@Override
protected void onLoad() {
super.onLoad();
prefs = EditPreferences.create(Gerrit.getEditPreferences());
CallbackGroup group1 = new CallbackGroup();
final CallbackGroup group2 = new CallbackGroup();
final CallbackGroup group3 = new CallbackGroup();
CodeMirror.initLibrary(group1.add(new AsyncCallback<Void>() {
final AsyncCallback<Void> themeCallback = group3.addEmpty();
@Override
public void onSuccess(Void result) {
// Load theme after CM library to ensure theme can override CSS.
ThemeLoader.loadTheme(prefs.theme(), themeCallback);
group2.done();
new AddonInjector().add(Addons.I.merge_bundled().getName()).inject(new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(Void result) {
if (!prefs.showBase() || revision.get() > 0) {
group3.done();
}
}
});
}
@Override
public void onFailure(Throwable caught) {
}
}));
ChangeApi.detail(revision.getParentKey().get(), group1.add(new AsyncCallback<ChangeInfo>() {
@Override
public void onSuccess(ChangeInfo c) {
project.setInnerText(c.project());
SafeHtml.setInnerHTML(filePath, Header.formatPath(path));
}
@Override
public void onFailure(Throwable caught) {
}
}));
if (revision.get() == 0) {
ChangeEditApi.getMeta(revision, path, group1.add(new AsyncCallback<EditFileInfo>() {
@Override
public void onSuccess(EditFileInfo editInfo) {
editFileInfo = editInfo;
}
@Override
public void onFailure(Throwable e) {
}
}));
if (prefs.showBase()) {
ChangeEditApi.get(revision, path, true, /* base */
group1.addFinal(new HttpCallback<NativeString>() {
@Override
public void onSuccess(HttpResponse<NativeString> fc) {
baseContent = fc;
group3.done();
}
@Override
public void onFailure(Throwable e) {
}
}));
} else {
group1.done();
}
} else {
// TODO(davido): We probably want to create dedicated GET EditScreenMeta
// REST endpoint. Abuse GET diff for now, as it retrieves links we need.
DiffApi.diff(revision, path).webLinksOnly().get(group1.addFinal(new AsyncCallback<DiffInfo>() {
@Override
public void onSuccess(DiffInfo diffInfo) {
diffLinks = diffInfo.webLinks();
}
@Override
public void onFailure(Throwable e) {
}
}));
}
ChangeEditApi.get(revision, path, group2.add(new HttpCallback<NativeString>() {
final AsyncCallback<Void> modeCallback = group3.addEmpty();
@Override
public void onSuccess(HttpResponse<NativeString> fc) {
content = fc;
if (revision.get() > 0) {
baseContent = fc;
}
if (prefs.syntaxHighlighting()) {
injectMode(fc.getContentType(), modeCallback);
} else {
modeCallback.onSuccess(null);
}
}
@Override
public void onFailure(Throwable e) {
// "Not Found" means it's a new file.
if (RestApi.isNotFound(e)) {
content = null;
modeCallback.onSuccess(null);
} else {
GerritCallback.showFailure(e);
}
}
}));
group3.addListener(new ScreenLoadCallback<Void>(this) {
@Override
protected void preDisplay(Void result) {
initEditor();
renderLinks(editFileInfo, diffLinks);
editFileInfo = null;
diffLinks = null;
showBase.setValue(prefs.showBase(), true);
cmBase.refresh();
}
});
}
use of com.google.gerrit.client.info.ChangeInfo 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.info.ChangeInfo in project gerrit by GerritCodeReview.
the class DownloadBox method onLoad.
@Override
protected void onLoad() {
if (fetch == null) {
if (psId.get() == 0) {
ChangeApi.editWithCommands(change.legacyId().get()).get(new AsyncCallback<EditInfo>() {
@Override
public void onSuccess(EditInfo result) {
fetch = result.fetch();
renderScheme();
}
@Override
public void onFailure(Throwable caught) {
}
});
} else {
RestApi call = ChangeApi.detail(change.legacyId().get());
ChangeList.addOptions(call, EnumSet.of(revision.equals(change.currentRevision()) ? ListChangesOption.CURRENT_REVISION : ListChangesOption.ALL_REVISIONS, ListChangesOption.DOWNLOAD_COMMANDS));
call.get(new AsyncCallback<ChangeInfo>() {
@Override
public void onSuccess(ChangeInfo result) {
fetch = result.revision(revision).fetch();
renderScheme();
}
@Override
public void onFailure(Throwable caught) {
}
});
}
}
}
use of com.google.gerrit.client.info.ChangeInfo in project gerrit by GerritCodeReview.
the class CreateChangeAction method call.
static void call(final Button b, final String project) {
// TODO Replace CreateChangeDialog with a nicer looking display.
b.setEnabled(false);
new CreateChangeDialog(new Project.NameKey(project)) {
{
sendButton.setText(AdminConstants.I.buttonCreate());
message.setText(AdminConstants.I.buttonCreateDescription());
}
@Override
public void onSend() {
ChangeApi.createChange(project, getDestinationBranch(), getDestinationTopic(), message.getText(), null, 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.info.ChangeInfo in project gerrit by GerritCodeReview.
the class ChangeTable method onOpenRow.
@Override
protected void onOpenRow(final int row) {
final ChangeInfo c = getRowItem(row);
final Change.Id id = c.legacyId();
Gerrit.display(PageLinks.toChange(id));
}
Aggregations