use of com.google.gerrit.client.rpc.CallbackGroup in project gerrit by GerritCodeReview.
the class Gerrit method onModuleLoad.
@Override
public void onModuleLoad() {
if (!canLoadInIFrame()) {
UserAgent.assertNotInIFrame();
}
setXsrfToken();
KeyUtil.setEncoderImpl(new KeyUtil.Encoder() {
@Override
public String encode(String e) {
e = URL.encodeQueryString(e);
e = fixPathImpl(e);
e = fixColonImpl(e);
e = fixDoubleQuote(e);
return e;
}
@Override
public String decode(final String e) {
return URL.decodeQueryString(e);
}
private native String fixPathImpl(String path);
private native String fixColonImpl(String path);
private native String fixDoubleQuote(String path);
});
initHostname();
Window.setTitle(M.windowTitle1(myHost));
RpcStatus.INSTANCE = new RpcStatus();
CallbackGroup cbg = new CallbackGroup();
getDocIndex(cbg.add(new GerritCallback<DocInfo>() {
@Override
public void onSuccess(DocInfo indexInfo) {
hasDocumentation = indexInfo != null;
docUrl = selfRedirect("/Documentation/");
}
}));
ConfigServerApi.serverInfo(cbg.add(new GerritCallback<ServerInfo>() {
@Override
public void onSuccess(ServerInfo info) {
myServerInfo = info;
urlAliasMatcher = new UrlAliasMatcher(info.urlAliases());
String du = info.gerrit().docUrl();
if (du != null && !du.isEmpty()) {
hasDocumentation = true;
docUrl = du;
}
docSearch = info.gerrit().docSearch();
}
}));
HostPageDataService hpd = GWT.create(HostPageDataService.class);
hpd.load(cbg.addFinal(new GerritCallback<HostPageData>() {
@Override
public void onSuccess(final HostPageData result) {
Document.get().getElementById("gerrit_hostpagedata").removeFromParent();
myTheme = result.theme;
isNoteDbEnabled = result.isNoteDbEnabled;
if (result.accountDiffPref != null) {
myAccountDiffPref = result.accountDiffPref;
}
if (result.accountDiffPref != null) {
// TODO: Support options on the GetDetail REST endpoint so that it can
// also return the preferences. Then we can fetch everything with a
// single request and we don't need the callback group anymore.
CallbackGroup cbg = new CallbackGroup();
AccountApi.self().view("detail").get(cbg.add(new GerritCallback<AccountInfo>() {
@Override
public void onSuccess(AccountInfo result) {
myAccount = result;
}
}));
AccountApi.self().view("preferences").get(cbg.add(new GerritCallback<GeneralPreferences>() {
@Override
public void onSuccess(GeneralPreferences prefs) {
myPrefs = prefs;
onModuleLoad2(result);
}
}));
AccountApi.getEditPreferences(cbg.addFinal(new GerritCallback<EditPreferences>() {
@Override
public void onSuccess(EditPreferences prefs) {
EditPreferencesInfo prefsInfo = new EditPreferencesInfo();
prefs.copyTo(prefsInfo);
editPrefs = prefsInfo;
}
}));
} else {
myAccount = AccountInfo.create(0, null, null, null);
myPrefs = GeneralPreferences.createDefault();
editPrefs = null;
onModuleLoad2(result);
}
}
}));
}
use of com.google.gerrit.client.rpc.CallbackGroup in project gerrit by GerritCodeReview.
the class ContactPanelShort method onLoad.
@Override
protected void onLoad() {
super.onLoad();
onInitUI();
body.add(save);
display(Gerrit.getUserAccount());
emailPick.clear();
emailPick.setEnabled(false);
registerNewEmail.setEnabled(false);
haveAccount = false;
haveEmails = false;
CallbackGroup group = new CallbackGroup();
AccountApi.getName("self", group.add(new GerritCallback<NativeString>() {
@Override
public void onSuccess(NativeString result) {
nameTxt.setText(result.asString());
haveAccount = true;
}
@Override
public void onFailure(Throwable caught) {
}
}));
AccountApi.getEmails("self", group.addFinal(new GerritCallback<JsArray<EmailInfo>>() {
@Override
public void onSuccess(JsArray<EmailInfo> result) {
for (EmailInfo i : Natives.asList(result)) {
emailPick.addItem(i.email());
if (i.isPreferred()) {
currentEmail = i.email();
}
}
haveEmails = true;
postLoad();
}
}));
}
use of com.google.gerrit.client.rpc.CallbackGroup in project gerrit by GerritCodeReview.
the class Loader method initLibrary.
static void initLibrary(final AsyncCallback<Void> cb) {
if (isLibLoaded()) {
cb.onSuccess(null);
return;
}
CallbackGroup group = new CallbackGroup();
injectCss(Lib.I.css(), group.<Void>addEmpty());
injectScript(Lib.I.js().getSafeUri(), group.add(new AsyncCallback<Void>() {
@Override
public void onSuccess(Void result) {
Vim.initKeyMap();
}
@Override
public void onFailure(Throwable caught) {
}
}));
group.addListener(cb);
group.done();
}
use of com.google.gerrit.client.rpc.CallbackGroup in project gerrit by GerritCodeReview.
the class ProjectAccessScreen method onLoad.
@Override
protected void onLoad() {
super.onLoad();
CallbackGroup cbs = new CallbackGroup();
ConfigServerApi.capabilities(cbs.add(new AsyncCallback<NativeMap<CapabilityInfo>>() {
@Override
public void onSuccess(NativeMap<CapabilityInfo> result) {
capabilityMap = result;
}
@Override
public void onFailure(Throwable caught) {
// Handled by ScreenLoadCallback.onFailure().
}
}));
Util.PROJECT_SVC.projectAccess(getProjectKey(), cbs.addFinal(new ScreenLoadCallback<ProjectAccess>(this) {
@Override
public void preDisplay(ProjectAccess access) {
displayReadOnly(access);
}
}));
savedPanel = ACCESS;
}
use of com.google.gerrit.client.rpc.CallbackGroup 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();
}
});
}
Aggregations