use of com.google.gerrit.client.rpc.RestApi in project gerrit by GerritCodeReview.
the class DiffApi method list.
public static void list(int id, String revision, RevisionInfo base, AsyncCallback<NativeMap<FileInfo>> cb) {
RestApi api = ChangeApi.revision(id, revision).view("files");
if (base != null) {
if (base._number() < 0) {
api.addParameter("parent", -base._number());
} else {
api.addParameter("base", base.name());
}
}
api.get(NativeMap.copyKeysIntoChildren("path", cb));
}
use of com.google.gerrit.client.rpc.RestApi in project gerrit by GerritCodeReview.
the class DownloadBox method insertPatch.
private void insertPatch() {
String id = revision.substring(0, 7);
Anchor patchBase64 = new Anchor(id + ".diff.base64");
patchBase64.setHref(new RestApi("/changes/").id(psId.getParentKey().get()).view("revisions").id(revision).view("patch").addParameterTrue("download").url());
Anchor patchZip = new Anchor(id + ".diff.zip");
patchZip.setHref(new RestApi("/changes/").id(psId.getParentKey().get()).view("revisions").id(revision).view("patch").addParameterTrue("zip").url());
HorizontalPanel p = new HorizontalPanel();
p.add(patchBase64);
InlineLabel spacer = new InlineLabel("|");
spacer.setStyleName(Gerrit.RESOURCES.css().downloadBoxSpacer());
p.add(spacer);
p.add(patchZip);
insertCommand("Patch-File", p);
}
use of com.google.gerrit.client.rpc.RestApi 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.rpc.RestApi in project gerrit by GerritCodeReview.
the class DownloadBox method insertArchive.
private void insertArchive() {
List<String> activated = Gerrit.info().download().archives();
if (activated.isEmpty()) {
return;
}
List<Anchor> anchors = new ArrayList<>(activated.size());
for (String f : activated) {
Anchor archive = new Anchor(f);
archive.setHref(new RestApi("/changes/").id(psId.getParentKey().get()).view("revisions").id(revision).view("archive").addParameter("format", f).url());
anchors.add(archive);
}
HorizontalPanel p = new HorizontalPanel();
Iterator<Anchor> it = anchors.iterator();
while (it.hasNext()) {
Anchor a = it.next();
p.add(a);
if (it.hasNext()) {
InlineLabel spacer = new InlineLabel("|");
spacer.setStyleName(Gerrit.RESOURCES.css().downloadBoxSpacer());
p.add(spacer);
}
}
insertCommand("Archive", p);
}
use of com.google.gerrit.client.rpc.RestApi 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());
}
Aggregations