Search in sources :

Example 11 with AsyncCallback

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

the class PermissionController method fetchPermissions.

private void fetchPermissions() {
    final GetPermissionsRequest input = ApiHelper.setAccessCode(new GetPermissionsRequest());
    input.pager = pager;
    input.session = SessionController.get().sessionForApiCall();
    if (getPermissionsRequest != null) {
        getPermissionsRequest.cancel();
    }
    getPermissionsRequest = ApiHelper.createUserClient().getPermissions(input, new AsyncCallback<GetPermissionsResponse>() {

        @Override
        public void onSuccess(GetPermissionsResponse output) {
            getPermissionsRequest = null;
            if (output.status == StatusType.StatusTypeSuccess) {
                if (output.permissions != null && output.permissions.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.permissions);
                } else {
                    updateRowCount(input.pager.start.intValue(), true);
                    updateRowData(input.pager.start.intValue(), Collections.<Permission>emptyList());
                }
            }
            DefaultEventBus.get().fireEventFromSource(new GetPermissionsSuccess(input, output), PermissionController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            getPermissionsRequest = null;
            DefaultEventBus.get().fireEventFromSource(new GetPermissionsFailure(input, caught), PermissionController.this);
        }
    });
}
Also used : GetPermissionsRequest(com.willshex.blogwt.shared.api.user.call.GetPermissionsRequest) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetPermissionsSuccess(com.willshex.blogwt.client.api.user.event.GetPermissionsEventHandler.GetPermissionsSuccess) GetPermissionsFailure(com.willshex.blogwt.client.api.user.event.GetPermissionsEventHandler.GetPermissionsFailure) GetPermissionsResponse(com.willshex.blogwt.shared.api.user.call.GetPermissionsResponse)

Example 12 with AsyncCallback

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

the class PostController method getPost.

public void getPost(Post post) {
    final GetPostRequest input = SessionController.get().setSession(ApiHelper.setAccessCode(new GetPostRequest())).post(post);
    if (getPostRequest != null) {
        getPostRequest.cancel();
    }
    getPostRequest = ApiHelper.createBlogClient().getPost(input, new AsyncCallback<GetPostResponse>() {

        @Override
        public void onSuccess(GetPostResponse output) {
            getPostRequest = null;
            boolean retryingGetWithSlug = false;
            if (output.status == StatusType.StatusTypeSuccess) {
                if (output.post != null) {
                }
            } else {
                if (input.post.id != null) {
                    getPost(new Post().slug(input.post.id.toString()));
                    retryingGetWithSlug = true;
                }
            }
            if (!retryingGetWithSlug) {
                DefaultEventBus.get().fireEventFromSource(new GetPostSuccess(input, output), PostController.this);
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            getPostRequest = null;
            DefaultEventBus.get().fireEventFromSource(new GetPostFailure(input, caught), PostController.this);
        }
    });
}
Also used : Post(com.willshex.blogwt.shared.api.datatype.Post) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetPostRequest(com.willshex.blogwt.shared.api.blog.call.GetPostRequest) GetPostSuccess(com.willshex.blogwt.client.api.blog.event.GetPostEventHandler.GetPostSuccess) GetPostFailure(com.willshex.blogwt.client.api.blog.event.GetPostEventHandler.GetPostFailure) GetPostResponse(com.willshex.blogwt.shared.api.blog.call.GetPostResponse)

Example 13 with AsyncCallback

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

the class ResourceController method fetchResources.

private void fetchResources() {
    final GetResourcesRequest input = ApiHelper.setAccessCode(new GetResourcesRequest());
    input.pager = pager;
    input.session = SessionController.get().sessionForApiCall();
    if (getResourcesRequest != null) {
        getResourcesRequest.cancel();
    }
    getResourcesRequest = ApiHelper.createBlogClient().getResources(input, new AsyncCallback<GetResourcesResponse>() {

        @Override
        public void onSuccess(GetResourcesResponse output) {
            getResourcesRequest = null;
            if (output.status == StatusType.StatusTypeSuccess) {
                if (output.resources != null && output.resources.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.resources);
                } else {
                    updateRowCount(input.pager.start.intValue(), true);
                    updateRowData(input.pager.start.intValue(), Collections.<Resource>emptyList());
                }
            }
            DefaultEventBus.get().fireEventFromSource(new GetResourcesSuccess(input, output), ResourceController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            getResourcesRequest = null;
            DefaultEventBus.get().fireEventFromSource(new GetResourcesFailure(input, caught), ResourceController.this);
        }
    });
}
Also used : GetResourcesRequest(com.willshex.blogwt.shared.api.blog.call.GetResourcesRequest) GetResourcesSuccess(com.willshex.blogwt.client.api.blog.event.GetResourcesEventHandler.GetResourcesSuccess) GetResourcesFailure(com.willshex.blogwt.client.api.blog.event.GetResourcesEventHandler.GetResourcesFailure) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetResourcesResponse(com.willshex.blogwt.shared.api.blog.call.GetResourcesResponse)

Example 14 with AsyncCallback

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

the class SessionController method createAsyncResponse.

/**
 * @param input
 * @return
 */
private AsyncCallback<LoginResponse> createAsyncResponse(final LoginRequest input) {
    return new AsyncCallback<LoginResponse>() {

        @Override
        public void onSuccess(LoginResponse result) {
            if (result.status == StatusType.StatusTypeSuccess && result.session != null) {
                session = result.session;
                Cookies.setCookie(COOKIE_KEY_ID, session.id.toString(), DateTimeHelper.millisFromNow(DateTimeHelper.MILLIS_PER_DAY * 365L * 20L));
                if (user() != null && user().lastLoggedIn == null) {
                    user().lastLoggedIn = new Date();
                }
            }
            DefaultEventBus.get().fireEventFromSource(new LoginSuccess(input, result), SessionController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            DefaultEventBus.get().fireEventFromSource(new LoginFailure(input, caught), SessionController.this);
        }
    };
}
Also used : LoginResponse(com.willshex.blogwt.shared.api.user.call.LoginResponse) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) LoginSuccess(com.willshex.blogwt.client.api.user.event.LoginEventHandler.LoginSuccess) LoginFailure(com.willshex.blogwt.client.api.user.event.LoginEventHandler.LoginFailure) Date(java.util.Date)

Example 15 with AsyncCallback

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

the class UserController method fetchUsers.

private void fetchUsers() {
    final GetUsersRequest input = ApiHelper.setAccessCode(new GetUsersRequest());
    input.pager = pager;
    input.session = SessionController.get().sessionForApiCall();
    if (getUsersRequest != null) {
        getUsersRequest.cancel();
    }
    getUsersRequest = ApiHelper.createUserClient().getUsers(input, new AsyncCallback<GetUsersResponse>() {

        @Override
        public void onSuccess(GetUsersResponse output) {
            getUsersRequest = null;
            if (output.status == StatusType.StatusTypeSuccess) {
                if (output.users != null && output.users.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.users);
                } else {
                    updateRowCount(input.pager.start.intValue(), true);
                    updateRowData(input.pager.start.intValue(), Collections.<User>emptyList());
                }
            }
            DefaultEventBus.get().fireEventFromSource(new GetUsersSuccess(input, output), UserController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            getUsersRequest = null;
            DefaultEventBus.get().fireEventFromSource(new GetUsersFailure(input, caught), UserController.this);
        }
    });
}
Also used : GetUsersResponse(com.willshex.blogwt.shared.api.user.call.GetUsersResponse) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetUsersFailure(com.willshex.blogwt.client.api.user.event.GetUsersEventHandler.GetUsersFailure) GetUsersSuccess(com.willshex.blogwt.client.api.user.event.GetUsersEventHandler.GetUsersSuccess) GetUsersRequest(com.willshex.blogwt.shared.api.user.call.GetUsersRequest)

Aggregations

AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)64 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)8 Test (org.junit.Test)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)5 ProjectDTO (org.activityinfo.legacy.shared.model.ProjectDTO)4 FormDialogTether (org.activityinfo.ui.client.page.common.dialog.FormDialogTether)4 ChangeInfo (com.google.gerrit.client.info.ChangeInfo)3 Date (java.util.Date)3 GetActivityForm (org.activityinfo.legacy.shared.command.GetActivityForm)3 VoidResult (org.activityinfo.legacy.shared.command.result.VoidResult)3 MaskingAsyncMonitor (org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor)3 FormDialogImpl (org.activityinfo.ui.client.page.common.dialog.FormDialogImpl)3 Operation (org.eclipse.che.api.promises.client.Operation)3 OperationException (org.eclipse.che.api.promises.client.OperationException)3 PromiseError (org.eclipse.che.api.promises.client.PromiseError)3 Path (org.eclipse.che.ide.resource.Path)3 EditInfo (com.google.gerrit.client.info.ChangeInfo.EditInfo)2 RevisionInfo (com.google.gerrit.client.info.ChangeInfo.RevisionInfo)2