Search in sources :

Example 16 with AsyncCallback

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

the class PageOracle method lookup.

/* (non-Javadoc)
	 * 
	 * @see
	 * com.willshex.blogwt.client.oracle.SuggestOracle#lookup(com.google.gwt
	 * .user.client.ui.SuggestOracle.Request,
	 * com.google.gwt.user.client.ui.SuggestOracle.Callback) */
@Override
protected void lookup(final Request request, final Callback callback) {
    final GetPagesRequest input = ApiHelper.setAccessCode(new GetPagesRequest());
    input.session = SessionController.get().sessionForApiCall();
    input.includePosts = Boolean.FALSE;
    input.query = request.getQuery();
    input.pager = PagerHelper.createDefaultPager();
    input.pager.count = Integer.valueOf(request.getLimit());
    if (getPagesRequest != null) {
        getPagesRequest.cancel();
    }
    getPagesRequest = ApiHelper.createPageClient().getPages(input, new AsyncCallback<GetPagesResponse>() {

        @Override
        public void onSuccess(GetPagesResponse output) {
            if (output.status == StatusType.StatusTypeSuccess && output.pager != null) {
                foundItems(request, callback, output.pages);
            } else {
                foundItems(request, callback, Collections.<Page>emptyList());
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            GWT.log("Error getting pages with query " + input.query, caught);
            foundItems(request, callback, Collections.<Page>emptyList());
        }
    });
}
Also used : GetPagesRequest(com.willshex.blogwt.shared.api.page.call.GetPagesRequest) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetPagesResponse(com.willshex.blogwt.shared.api.page.call.GetPagesResponse)

Example 17 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project activityinfo by bedatadriven.

the class ImportPresenter method persistData.

protected void persistData() {
    persistFinished = false;
    persistFailed = false;
    dialogBox.getFinishButton().setEnabled(false);
    dialogBox.setStatusText(I18N.CONSTANTS.importing());
    PromisesExecutionMonitor monitor = new PromisesExecutionMonitor() {

        @Override
        public void onChange(PromisesExecutionStatistic statistic) {
            lastStatistic = statistic;
            if (persistFinished) {
                if (persistFailed) {
                    showFailure();
                }
            } else {
                dialogBox.setStatusText(I18N.MESSAGES.importingData(statistic.getCompleted(), statistic.getTotal(), statistic.getRetries()));
            }
        }
    };
    AsyncCallback<Void> callback = new AsyncCallback<Void>() {

        @Override
        public void onFailure(Throwable caught) {
            persistFinished = true;
            persistFailed = true;
            Log.error(caught.getMessage(), caught);
            showDelayedFailure();
        }

        @Override
        public void onSuccess(Void result) {
            persistFinished = true;
            overlay.hide();
            Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {

                @Override
                public void execute() {
                    eventBus.fireEvent(new ImportResultEvent(true));
                }
            });
        }
    };
    if (retryFailedRows) {
        importer.getResourceLocator().persistOperation(lastStatistic.getNotFinishedOperations(), monitor).then(callback);
        retryFailedRows = false;
        return;
    }
    importer.persist(importModel, monitor).then(callback);
}
Also used : Scheduler(com.google.gwt.core.client.Scheduler) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) PromisesExecutionMonitor(org.activityinfo.promise.PromisesExecutionMonitor)

Example 18 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project activityinfo by bedatadriven.

the class DbTargetEditor method onEdit.

@Override
protected void onEdit(final TargetDTO dto) {
    this.view.showAddDialog(dto, db, true, new FormDialogCallback() {

        @Override
        public void onValidated(final FormDialogTether dlg) {
            final Record record = store.getRecord(dto);
            service.execute(new UpdateEntity(dto, getChangedProperties(record)), dlg, new AsyncCallback<VoidResult>() {

                @Override
                public void onFailure(Throwable caught) {
                    Log.error("Failed to edit target. " + caught.getMessage(), caught);
                }

                @Override
                public void onSuccess(VoidResult result) {
                    if (record.get("partnerId") != null) {
                        PartnerDTO partner = db.getPartnerById((Integer) record.get("partnerId"));
                        dto.setPartner(partner);
                    } else {
                        dto.setPartner(null);
                    }
                    if (record.get("projectId") != null) {
                        ProjectDTO project = db.getProjectById((Integer) record.get("projectId"));
                        dto.setProject(project);
                    } else {
                        dto.setProject(null);
                    }
                    store.commitChanges();
                    eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
                    dlg.hide();
                }
            });
        }
    });
}
Also used : ProjectDTO(org.activityinfo.legacy.shared.model.ProjectDTO) FormDialogCallback(org.activityinfo.ui.client.page.common.dialog.FormDialogCallback) UpdateEntity(org.activityinfo.legacy.shared.command.UpdateEntity) VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult) PartnerDTO(org.activityinfo.legacy.shared.model.PartnerDTO) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) FormDialogTether(org.activityinfo.ui.client.page.common.dialog.FormDialogTether) Record(com.extjs.gxt.ui.client.store.Record)

Example 19 with AsyncCallback

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, false, 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());
                    if (newTarget.get("partnerId") != null) {
                        PartnerDTO partner = db.getPartnerById((Integer) newTarget.get("partnerId"));
                        newTarget.setPartner(partner);
                    }
                    if (newTarget.get("projectId") != null) {
                        ProjectDTO project = db.getProjectById((Integer) newTarget.get("projectId"));
                        newTarget.setProject(project);
                    }
                    store.add(newTarget);
                    store.commitChanges();
                    eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
                    dlg.hide();
                }
            });
        }
    });
}
Also used : ProjectDTO(org.activityinfo.legacy.shared.model.ProjectDTO) FormDialogCallback(org.activityinfo.ui.client.page.common.dialog.FormDialogCallback) CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) PartnerDTO(org.activityinfo.legacy.shared.model.PartnerDTO) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) FormDialogTether(org.activityinfo.ui.client.page.common.dialog.FormDialogTether) AddTarget(org.activityinfo.legacy.shared.command.AddTarget) TargetDTO(org.activityinfo.legacy.shared.model.TargetDTO)

Example 20 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project activityinfo by bedatadriven.

the class DefaultColumnModelProvider method fetchColumnModels.

@Override
public void fetchColumnModels(final Filter filter, final GroupingModel grouping, final AsyncCallback<ColumnModel> callback) {
    if (filter.isDimensionRestrictedToSingleCategory(DimensionType.Activity)) {
        final int activityId = filter.getRestrictedCategory(DimensionType.Activity);
        dispatcher.execute(new GetActivityForm(activityId)).then(new AsyncCallback<ActivityFormDTO>() {

            @Override
            public void onFailure(Throwable caught) {
                callback.onFailure(caught);
            }

            @Override
            public void onSuccess(ActivityFormDTO activity) {
                dispatcher.execute(new GetSchema()).then(new AsyncCallback<SchemaDTO>() {

                    @Override
                    public void onFailure(Throwable caught) {
                        callback.onFailure(caught);
                    }

                    @Override
                    public void onSuccess(SchemaDTO schema) {
                        callback.onSuccess(forSingleActivity(grouping, schema.getDatabaseById(activity.getDatabaseId()), activity));
                    }
                });
            }
        });
    } else {
        dispatcher.execute(new GetSchema()).then(new AsyncCallback<SchemaDTO>() {

            @Override
            public void onFailure(Throwable caught) {
                callback.onFailure(caught);
            }

            @Override
            public void onSuccess(SchemaDTO result) {
                if (filter.isDimensionRestrictedToSingleCategory(DimensionType.Database)) {
                    UserDatabaseDTO singleDatabase = result.getDatabaseById(filter.getRestrictedCategory(DimensionType.Database));
                    callback.onSuccess(forSingleDatabase(grouping, singleDatabase));
                } else {
                    callback.onSuccess(forMultipleDatabases(grouping, result));
                }
            }
        });
    }
}
Also used : ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) UserDatabaseDTO(org.activityinfo.legacy.shared.model.UserDatabaseDTO) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO)

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