use of com.google.gwt.user.client.rpc.AsyncCallback in project activityinfo by bedatadriven.
the class DbTargetEditor method onAdd.
@Override
protected void onAdd() {
final TargetDTO newTarget = new TargetDTO();
this.view.showAddDialog(newTarget, db, new FormDialogCallback() {
@Override
public void onValidated(final FormDialogTether dlg) {
service.execute(new AddTarget(db.getId(), newTarget), dlg, new AsyncCallback<CreateResult>() {
@Override
public void onFailure(Throwable caught) {
MessageBox.alert(I18N.CONSTANTS.error(), I18N.CONSTANTS.errorOnServer(), null);
}
@Override
public void onSuccess(CreateResult result) {
newTarget.setId(result.getNewId());
PartnerDTO partner = db.getPartnerById((Integer) newTarget.get("partnerId"));
newTarget.setPartner(partner);
ProjectDTO project = db.getProjectById((Integer) newTarget.get("projectId"));
newTarget.setProject(project);
store.add(newTarget);
store.commitChanges();
eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
dlg.hide();
}
});
}
});
}
use of com.google.gwt.user.client.rpc.AsyncCallback in project activityinfo by bedatadriven.
the class SiteHistoryTab method setSite.
// retrieve all needed data: sitehistoryresult, schema, and locations
public void setSite(final SiteDTO site) {
renderLoading();
dispatcher.execute(new GetSiteHistory(site.getId()), new AsyncCallback<GetSiteHistoryResult>() {
@Override
public void onFailure(Throwable caught) {
renderNotAvailable(site);
}
@Override
public void onSuccess(final GetSiteHistoryResult historyResult) {
if (historyResult.hasHistories()) {
dispatcher.execute(new GetLocations(historyResult.collectLocationIds()), new AsyncCallback<GetLocationsResult>() {
@Override
public void onFailure(Throwable caught) {
renderNotAvailable(site);
}
@Override
public void onSuccess(final GetLocationsResult locationsResult) {
dispatcher.execute(new GetSchema(), new AsyncCallback<SchemaDTO>() {
@Override
public void onFailure(Throwable caught) {
renderNotAvailable(site);
}
@Override
public void onSuccess(SchemaDTO schema) {
render(schema, locationsResult.getLocations(), site, historyResult.getSiteHistories());
}
});
}
});
} else {
renderNotAvailable(site);
}
}
});
}
use of com.google.gwt.user.client.rpc.AsyncCallback in project activityinfo by bedatadriven.
the class ReportGridPanel method delete.
private void delete() {
final ReportMetadataDTO report = grid.getSelectionModel().getSelectedItem();
MessageBox.confirm(I18N.CONSTANTS.delete(), I18N.MESSAGES.confirmDeleteReport(report.getTitle()), new Listener<MessageBoxEvent>() {
@Override
public void handleEvent(MessageBoxEvent be) {
if (be.getButtonClicked().getItemId().equals(Dialog.YES)) {
dispatcher.execute(new DeleteReport(report.getId()), new MaskingAsyncMonitor(ReportGridPanel.this, I18N.CONSTANTS.delete()), new AsyncCallback<VoidResult>() {
@Override
public void onFailure(Throwable caught) {
// handled by monitor
}
@Override
public void onSuccess(VoidResult result) {
grid.getStore().remove(report);
}
});
}
}
});
}
use of com.google.gwt.user.client.rpc.AsyncCallback in project activityinfo by bedatadriven.
the class RemoteDispatcherTest method commandsSuccessfullyExecutedThroughProxiesShouldNotBeSentToServer.
@Test
public void commandsSuccessfullyExecutedThroughProxiesShouldNotBeSentToServer() {
GetSchema command = new GetSchema();
expect(proxy.maybeExecute(eq(command))).andReturn(new CacheResult(new SchemaDTO()));
replay(proxy);
// no calls should be made to the remote service
replay(service);
AsyncCallback callback = makeCallbackThatExpectsNonNullSuccess();
proxyManager.registerProxy(GetSchema.class, proxy);
dispatcher.execute(new GetSchema(), callback);
processPendingCommands();
verify(proxy, service, callback);
}
use of com.google.gwt.user.client.rpc.AsyncCallback in project activityinfo by bedatadriven.
the class RemoteDispatcherTest method makeCallbackThatExpectsNonNullSuccess.
private AsyncCallback makeCallbackThatExpectsNonNullSuccess() {
AsyncCallback callback = createMock(AsyncCallback.class);
callback.onSuccess(notNull());
replay(callback);
return callback;
}
Aggregations