use of com.google.gwt.user.client.rpc.AsyncCallback 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.gwt.user.client.rpc.AsyncCallback in project gerrit by GerritCodeReview.
the class StarredChanges method startRequest.
private static void startRequest() {
busy = true;
final Change.Id id = pending.keySet().iterator().next();
final boolean starred = pending.remove(id);
RestApi call = AccountApi.self().view("starred.changes").id(id.get());
AsyncCallback<JavaScriptObject> cb = new AsyncCallback<JavaScriptObject>() {
@Override
public void onSuccess(JavaScriptObject none) {
if (pending.isEmpty()) {
busy = false;
} else {
startRequest();
}
}
@Override
public void onFailure(Throwable caught) {
if (!starred && RestApi.isStatus(caught, 404)) {
onSuccess(null);
return;
}
fireChangeStarEvent(id, !starred);
for (Map.Entry<Change.Id, Boolean> e : pending.entrySet()) {
fireChangeStarEvent(e.getKey(), !e.getValue());
}
pending.clear();
busy = false;
}
};
if (starred) {
call.put(cb);
} else {
call.delete(cb);
}
}
use of com.google.gwt.user.client.rpc.AsyncCallback 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.gwt.user.client.rpc.AsyncCallback in project gwt-test-utils by gwt-test-utils.
the class MyBeautifulApp method onModuleLoad.
public void onModuleLoad() {
FlowPanel panel = new FlowPanel();
b1 = new Button("Button1's HTML");
b1.getElement().setId("button-1");
panel.add(b1);
b2 = new Button("Button2's HTML");
b2.getElement().setId("button-2");
panel.add(b2);
l = new Label();
l.setText("init");
panel.add(l);
t = new TextBox();
panel.add(t);
historyLabel = new Label();
panel.add(historyLabel);
invisibleTB = new TextBox();
invisibleTB.setVisible(false);
panel.add(invisibleTB);
lb = new ListBox();
lb.addItem("lbText0");
lb.addItem("lbText1");
lb.addItem("lbText2");
panel.add(lb);
RootPanel.get().add(panel);
b1.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent arg0) {
l.setText("click on b1");
}
});
b2.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent arg0) {
l.setText("click on b2");
}
});
b3 = new Button("Button3's HTML");
panel.add(b3);
b3.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent arg0) {
MyRemoteServiceAsync remoteServiceAsync = GWT.create(MyRemoteService.class);
remoteServiceAsync.myMethod(l.getText(), new AsyncCallback<String>() {
public void onFailure(Throwable arg0) {
l.setText("error");
}
public void onSuccess(String arg0) {
l.setText(arg0);
}
});
}
});
b4 = new Button("Button4's HTML");
panel.add(b4);
b4.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent arg0) {
MyRemoteServiceAsync remoteServiceAsync = GWT.create(MyRemoteService.class);
remoteServiceAsync.myMethod2(new MyCustomObject("toto"), new AsyncCallback<MyCustomObject>() {
public void onFailure(Throwable t) {
throw new RuntimeException(t);
}
public void onSuccess(MyCustomObject object) {
l.setText(object.myField + " " + object.myTransientField);
}
});
}
});
b5 = new Button("Button5's HTML");
panel.add(b5);
b5.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent arg0) {
MyRemoteServiceAsync remoteServiceAsync = GWT.create(MyRemoteService.class);
remoteServiceAsync.myMethod3(new AsyncCallback<Void>() {
public void onFailure(Throwable arg0) {
l.setText("error");
}
public void onSuccess(Void arg0) {
l.setText("success");
}
});
}
});
t.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
historyLabel.setText("t was filled with value \"" + t.getText() + "\"");
}
});
invisibleTB.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
historyLabel.setText("invisibleTB was filled with value \"" + invisibleTB.getText() + "\"");
}
});
myComposite = new MyComposite("myComposite Label", "MyComposite Button");
panel.add(myComposite);
}
use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.
the class GeneratedDownloadController method fetchGeneratedDownloads.
private void fetchGeneratedDownloads() {
final GetGeneratedDownloadsRequest input = ApiHelper.setAccessCode(new GetGeneratedDownloadsRequest()).pager(pager);
input.session(SessionController.get().sessionForApiCall());
if (getGeneratedDownloadsRequest != null) {
getGeneratedDownloadsRequest.cancel();
}
getGeneratedDownloadsRequest = ApiHelper.createDownloadClient().getGeneratedDownloads(input, new AsyncCallback<GetGeneratedDownloadsResponse>() {
@Override
public void onSuccess(GetGeneratedDownloadsResponse output) {
getGeneratedDownloadsRequest = null;
if (output.status == StatusType.StatusTypeSuccess) {
if (output.downloads != null && output.downloads.size() > 0) {
pager = output.pager;
updateRowCount(input.pager.count == null ? 0 : input.pager.count.intValue(), input.pager.count == null || input.pager.count.intValue() == 0);
updateRowData(input.pager.start.intValue(), output.downloads);
} else {
updateRowCount(input.pager.start.intValue(), true);
updateRowData(input.pager.start.intValue(), Collections.<GeneratedDownload>emptyList());
}
}
DefaultEventBus.get().fireEventFromSource(new GetGeneratedDownloadsSuccess(input, output), GeneratedDownloadController.this);
}
@Override
public void onFailure(Throwable caught) {
getGeneratedDownloadsRequest = null;
DefaultEventBus.get().fireEventFromSource(new GetGeneratedDownloadsFailure(input, caught), GeneratedDownloadController.this);
}
});
}
Aggregations