Search in sources :

Example 61 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.

the class PageController method fetchPages.

private void fetchPages() {
    final GetPagesRequest input = ApiHelper.setAccessCode(new GetPagesRequest());
    input.pager = pager;
    input.session = SessionController.get().sessionForApiCall();
    input.includePosts = Boolean.FALSE;
    if (getPagesRequest != null) {
        getPagesRequest.cancel();
    }
    getPagesRequest = ApiHelper.createPageClient().getPages(input, new AsyncCallback<GetPagesResponse>() {

        @Override
        public void onSuccess(GetPagesResponse output) {
            getPagesRequest = null;
            if (output.status == StatusType.StatusTypeSuccess) {
                if (output.pages != null && output.pages.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.pages);
                } else {
                    updateRowCount(input.pager.start.intValue(), true);
                    updateRowData(input.pager.start.intValue(), Collections.<Page>emptyList());
                }
            }
            DefaultEventBus.get().fireEventFromSource(new GetPagesSuccess(input, output), PageController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            getPagesRequest = null;
            DefaultEventBus.get().fireEventFromSource(new GetPagesFailure(input, caught), PageController.this);
        }
    });
}
Also used : GetPagesRequest(com.willshex.blogwt.shared.api.page.call.GetPagesRequest) GetPagesFailure(com.willshex.blogwt.client.api.page.event.GetPagesEventHandler.GetPagesFailure) GetPagesSuccess(com.willshex.blogwt.client.api.page.event.GetPagesEventHandler.GetPagesSuccess) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetPagesResponse(com.willshex.blogwt.shared.api.page.call.GetPagesResponse)

Example 62 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.

the class PostController method fetchPosts.

private void fetchPosts() {
    final GetPostsRequest input = ApiHelper.setAccessCode(new GetPostsRequest());
    input.session = SessionController.get().sessionForApiCall();
    input.includePostContents = Boolean.FALSE;
    input.archiveEntry = archiveEntry;
    input.showAll = Boolean.valueOf(isAdminMode);
    if (SessionController.get().isValidSession()) {
        pager.sortBy = PostSortType.PostSortTypeCreated.toString();
    } else {
        pager.sortBy = PostSortType.PostSortTypePublished.toString();
    }
    input.pager = pager;
    input.tag = tag;
    if (getPostsRequest != null) {
        getPostsRequest.cancel();
    }
    getPostsRequest = ApiHelper.createBlogClient().getPosts(input, new AsyncCallback<GetPostsResponse>() {

        @Override
        public void onSuccess(GetPostsResponse output) {
            getPostsRequest = null;
            if (output.status == StatusType.StatusTypeSuccess) {
                if (output.posts != null && output.posts.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.posts);
                } else {
                    updateRowCount(input.pager.start.intValue(), true);
                    updateRowData(input.pager.start.intValue(), Collections.<Post>emptyList());
                }
            }
            DefaultEventBus.get().fireEventFromSource(new GetPostsSuccess(input, output), PostController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            getPostsRequest = null;
            DefaultEventBus.get().fireEventFromSource(new GetPostsFailure(input, caught), PostController.this);
        }
    });
}
Also used : GetPostsRequest(com.willshex.blogwt.shared.api.blog.call.GetPostsRequest) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetPostsSuccess(com.willshex.blogwt.client.api.blog.event.GetPostsEventHandler.GetPostsSuccess) GetPostsResponse(com.willshex.blogwt.shared.api.blog.call.GetPostsResponse) GetPostsFailure(com.willshex.blogwt.client.api.blog.event.GetPostsEventHandler.GetPostsFailure)

Example 63 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.

the class SearchController method fetchSearchResults.

private void fetchSearchResults(String query) {
    final SearchAllRequest input = ApiHelper.setAccessCode(new SearchAllRequest());
    input.session = SessionController.get().sessionForApiCall();
    input.query = query;
    if (searchAllRequest != null) {
        searchAllRequest.cancel();
    }
    searchAllRequest = ApiHelper.createSearchClient().searchAll(input, new AsyncCallback<SearchAllResponse>() {

        @Override
        public void onSuccess(SearchAllResponse output) {
            searchAllRequest = null;
            if (output.status == StatusType.StatusTypeSuccess) {
                List<SearchResult> results = new ArrayList<SearchController.SearchResult>();
                if (output.posts != null) {
                    for (Post post : output.posts) {
                        results.add(new SearchResult(post));
                    }
                }
                if (output.pages != null) {
                    for (Page page : output.pages) {
                        results.add(new SearchResult(page));
                    }
                }
                if (output.users != null) {
                    for (User user : output.users) {
                        results.add(new SearchResult(user));
                    }
                }
                updateRowCount(results.size(), true);
                updateRowData(0, results);
            }
            DefaultEventBus.get().fireEventFromSource(new SearchAllSuccess(input, output), SearchController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            searchAllRequest = null;
            DefaultEventBus.get().fireEventFromSource(new SearchAllFailure(input, caught), SearchController.this);
        }
    });
}
Also used : SearchAllResponse(com.willshex.blogwt.shared.api.search.call.SearchAllResponse) SearchAllFailure(com.willshex.blogwt.client.api.search.event.SearchAllEventHandler.SearchAllFailure) SearchAllSuccess(com.willshex.blogwt.client.api.search.event.SearchAllEventHandler.SearchAllSuccess) User(com.willshex.blogwt.shared.api.datatype.User) Post(com.willshex.blogwt.shared.api.datatype.Post) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) ArrayList(java.util.ArrayList) Page(com.willshex.blogwt.shared.api.datatype.Page) SearchAllRequest(com.willshex.blogwt.shared.api.search.call.SearchAllRequest)

Example 64 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.

the class PropertyController method fetchProperties.

private void fetchProperties() {
    final GetPropertiesRequest input = ApiHelper.setAccessCode(new GetPropertiesRequest());
    input.pager = pager;
    input.session = SessionController.get().sessionForApiCall();
    if (getPropertiesRequest != null) {
        getPropertiesRequest.cancel();
    }
    getPropertiesRequest = ApiHelper.createBlogClient().getProperties(input, new AsyncCallback<GetPropertiesResponse>() {

        @Override
        public void onSuccess(GetPropertiesResponse output) {
            getPropertiesRequest = null;
            if (output.status == StatusType.StatusTypeSuccess) {
                if (output.properties != null && output.properties.size() > 0) {
                    pager = output.pager;
                    JsonArray propertyArray = new JsonArray();
                    for (Property p : output.properties) {
                        propertyArray.add(p.toJson());
                    }
                    Window.get().setProperties(propertyArray.toString());
                }
            }
            DefaultEventBus.get().fireEventFromSource(new GetPropertiesSuccess(input, output), PropertyController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            getPropertiesRequest = null;
            DefaultEventBus.get().fireEventFromSource(new GetPropertiesFailure(input, caught), PropertyController.this);
        }
    });
}
Also used : JsonArray(com.google.gson.JsonArray) GetPropertiesRequest(com.willshex.blogwt.shared.api.blog.call.GetPropertiesRequest) GetPropertiesFailure(com.willshex.blogwt.client.api.blog.event.GetPropertiesEventHandler.GetPropertiesFailure) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetPropertiesSuccess(com.willshex.blogwt.client.api.blog.event.GetPropertiesEventHandler.GetPropertiesSuccess) GetPropertiesResponse(com.willshex.blogwt.shared.api.blog.call.GetPropertiesResponse) Property(com.willshex.blogwt.shared.api.datatype.Property)

Example 65 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.

the class RoleController method fetchRoles.

private void fetchRoles() {
    final GetRolesRequest input = ApiHelper.setAccessCode(new GetRolesRequest());
    input.pager = pager;
    input.session = SessionController.get().sessionForApiCall();
    if (getRolesRequest != null) {
        getRolesRequest.cancel();
    }
    getRolesRequest = ApiHelper.createUserClient().getRoles(input, new AsyncCallback<GetRolesResponse>() {

        @Override
        public void onSuccess(GetRolesResponse output) {
            getRolesRequest = null;
            if (output.status == StatusType.StatusTypeSuccess) {
                if (output.roles != null && output.roles.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.roles);
                } else {
                    updateRowCount(input.pager.start.intValue(), true);
                    updateRowData(input.pager.start.intValue(), Collections.<Role>emptyList());
                }
            }
            DefaultEventBus.get().fireEventFromSource(new GetRolesSuccess(input, output), RoleController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            getRolesRequest = null;
            DefaultEventBus.get().fireEventFromSource(new GetRolesFailure(input, caught), RoleController.this);
        }
    });
}
Also used : GetRolesFailure(com.willshex.blogwt.client.api.user.event.GetRolesEventHandler.GetRolesFailure) GetRolesSuccess(com.willshex.blogwt.client.api.user.event.GetRolesEventHandler.GetRolesSuccess) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetRolesRequest(com.willshex.blogwt.shared.api.user.call.GetRolesRequest) GetRolesResponse(com.willshex.blogwt.shared.api.user.call.GetRolesResponse)

Aggregations

AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)85 Test (org.junit.Test)13 GetSchema (org.activityinfo.shared.command.GetSchema)9 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)8 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)8 FormDialogCallback (org.activityinfo.client.page.common.dialog.FormDialogCallback)7 SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)6 FormDialogCallback (org.activityinfo.ui.client.page.common.dialog.FormDialogCallback)6 CallbackGroup (com.google.gerrit.client.rpc.CallbackGroup)4 FormDialogTether (org.activityinfo.client.page.common.dialog.FormDialogTether)4 ProjectDTO (org.activityinfo.legacy.shared.model.ProjectDTO)4 VoidResult (org.activityinfo.shared.command.result.VoidResult)4 FormDialogTether (org.activityinfo.ui.client.page.common.dialog.FormDialogTether)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 Set (java.util.Set)3 GetActivityForm (org.activityinfo.legacy.shared.command.GetActivityForm)3 VoidResult (org.activityinfo.legacy.shared.command.result.VoidResult)3 CreateResult (org.activityinfo.shared.command.result.CreateResult)3 ProjectDTO (org.activityinfo.shared.dto.ProjectDTO)3