Search in sources :

Example 1 with GetGeneratedDownloadsSuccess

use of com.willshex.blogwt.client.api.download.event.GetGeneratedDownloadsEventHandler.GetGeneratedDownloadsSuccess 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);
        }
    });
}
Also used : GetGeneratedDownloadsResponse(com.willshex.blogwt.shared.api.download.call.GetGeneratedDownloadsResponse) GetGeneratedDownloadsSuccess(com.willshex.blogwt.client.api.download.event.GetGeneratedDownloadsEventHandler.GetGeneratedDownloadsSuccess) GetGeneratedDownloadsFailure(com.willshex.blogwt.client.api.download.event.GetGeneratedDownloadsEventHandler.GetGeneratedDownloadsFailure) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetGeneratedDownloadsRequest(com.willshex.blogwt.shared.api.download.call.GetGeneratedDownloadsRequest)

Aggregations

AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 GetGeneratedDownloadsFailure (com.willshex.blogwt.client.api.download.event.GetGeneratedDownloadsEventHandler.GetGeneratedDownloadsFailure)1 GetGeneratedDownloadsSuccess (com.willshex.blogwt.client.api.download.event.GetGeneratedDownloadsEventHandler.GetGeneratedDownloadsSuccess)1 GetGeneratedDownloadsRequest (com.willshex.blogwt.shared.api.download.call.GetGeneratedDownloadsRequest)1 GetGeneratedDownloadsResponse (com.willshex.blogwt.shared.api.download.call.GetGeneratedDownloadsResponse)1