Search in sources :

Example 1 with DuplicatePartnerException

use of org.activityinfo.shared.exception.DuplicatePartnerException in project activityinfo by bedatadriven.

the class DbProjectEditor method onAdd.

@Override
protected void onAdd() {
    final ProjectDTO newProject = new ProjectDTO();
    this.view.showAddDialog(newProject, new FormDialogCallback() {

        @Override
        public void onValidated(final FormDialogTether dlg) {
            service.execute(new AddProject(db.getId(), newProject), dlg, new AsyncCallback<CreateResult>() {

                @Override
                public void onFailure(Throwable caught) {
                    if (caught instanceof DuplicatePartnerException) {
                        MessageBox.alert(I18N.CONSTANTS.error(), I18N.CONSTANTS.errorOnServer(), null);
                    } else {
                        MessageBox.alert(I18N.CONSTANTS.error(), I18N.CONSTANTS.errorOnServer(), null);
                    }
                }

                @Override
                public void onSuccess(CreateResult result) {
                    newProject.setId(result.getNewId());
                    store.add(newProject);
                    db.getProjects().add(newProject);
                    eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
                    dlg.hide();
                }
            });
        }
    });
}
Also used : ProjectDTO(org.activityinfo.shared.dto.ProjectDTO) FormDialogCallback(org.activityinfo.client.page.common.dialog.FormDialogCallback) CreateResult(org.activityinfo.shared.command.result.CreateResult) AddProject(org.activityinfo.shared.command.AddProject) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) DuplicatePartnerException(org.activityinfo.shared.exception.DuplicatePartnerException) FormDialogTether(org.activityinfo.client.page.common.dialog.FormDialogTether)

Aggregations

AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 FormDialogCallback (org.activityinfo.client.page.common.dialog.FormDialogCallback)1 FormDialogTether (org.activityinfo.client.page.common.dialog.FormDialogTether)1 AddProject (org.activityinfo.shared.command.AddProject)1 CreateResult (org.activityinfo.shared.command.result.CreateResult)1 ProjectDTO (org.activityinfo.shared.dto.ProjectDTO)1 DuplicatePartnerException (org.activityinfo.shared.exception.DuplicatePartnerException)1