Search in sources :

Example 1 with FormDialogTether

use of org.activityinfo.client.page.common.dialog.FormDialogTether in project activityinfo by bedatadriven.

the class DbPartnerEditor method onAdd.

// public void onSelectionChanged(PartnerDTO selectedItem) {
// this.view.setActionEnabled(UIActions.delete, selectedItem != null);
// }
@Override
protected void onAdd() {
    final PartnerDTO newPartner = new PartnerDTO();
    this.view.showAddDialog(newPartner, new FormDialogCallback() {

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

                @Override
                public void onFailure(Throwable caught) {
                    Log.debug("DbPartnerEditor caught exception while executing command AddPartner: ", caught);
                }

                @Override
                public void onSuccess(CreateResult result) {
                    if (result instanceof DuplicateCreateResult) {
                        Log.debug("DbPartnerEditor tried to add partner '" + newPartner.getName() + "' to database " + db.getId() + " but it already exists");
                        MessageBox.alert(I18N.CONSTANTS.newPartner(), I18N.CONSTANTS.duplicatePartner(), null);
                    } else {
                        Log.debug("DbPartnerEditor added new partner '" + newPartner.getName() + "' to database " + db.getId());
                        newPartner.setId(result.getNewId());
                        store.add(newPartner);
                        eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
                        dlg.hide();
                    }
                }
            });
        }
    });
}
Also used : DuplicateCreateResult(org.activityinfo.shared.command.result.DuplicateCreateResult) PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) FormDialogCallback(org.activityinfo.client.page.common.dialog.FormDialogCallback) CreateResult(org.activityinfo.shared.command.result.CreateResult) DuplicateCreateResult(org.activityinfo.shared.command.result.DuplicateCreateResult) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) FormDialogTether(org.activityinfo.client.page.common.dialog.FormDialogTether) AddPartner(org.activityinfo.shared.command.AddPartner)

Example 2 with FormDialogTether

use of org.activityinfo.client.page.common.dialog.FormDialogTether in project activityinfo by bedatadriven.

the class LockedPeriodGrid method startCreate.

@Override
public void startCreate() {
    addLockedPeriod.startCreate();
    form = new FormDialogImpl<AddLockedPeriodDialog>(addLockedPeriod);
    form.setHeading(I18N.CONSTANTS.addTimeLock());
    form.setWidth(400);
    form.setHeight(350);
    form.show(new FormDialogCallback() {

        @Override
        public void onValidated() {
            super.onValidated();
        }

        @Override
        public void onValidated(FormDialogTether dlg) {
            LockedPeriodGrid.this.lockedPeriod = addLockedPeriod.getValue();
            eventBus.fireEvent(new CreateEvent());
        }

        @Override
        public void onCancelled() {
            eventBus.fireEvent(new CancelCreateEvent());
        }
    });
}
Also used : FormDialogCallback(org.activityinfo.client.page.common.dialog.FormDialogCallback) FormDialogTether(org.activityinfo.client.page.common.dialog.FormDialogTether)

Example 3 with FormDialogTether

use of org.activityinfo.client.page.common.dialog.FormDialogTether in project activityinfo by bedatadriven.

the class DbListPresenterTest method niceFormDialogMock.

private FormDialogTether niceFormDialogMock() {
    FormDialogTether mock = createNiceMock(FormDialogTether.class);
    replay(mock);
    return mock;
}
Also used : FormDialogTether(org.activityinfo.client.page.common.dialog.FormDialogTether)

Example 4 with FormDialogTether

use of org.activityinfo.client.page.common.dialog.FormDialogTether in project activityinfo by bedatadriven.

the class DesignPresenter method createEntity.

private void createEntity(final ModelData parent, final EntityDTO newEntity) {
    view.showNewForm(newEntity, new FormDialogCallback() {

        @Override
        public void onValidated(final FormDialogTether tether) {
            service.execute(new CreateEntity(newEntity), tether, new AsyncCallback<CreateResult>() {

                @Override
                public void onFailure(Throwable caught) {
                    GWT.log(caught.getMessage());
                }

                @Override
                public void onSuccess(CreateResult result) {
                    // todo add
                    newEntity.set("id", result.getNewId());
                    if (parent == null) {
                        treeStore.add(newEntity, false);
                    } else {
                        treeStore.add(parent, newEntity, false);
                    }
                    if (newEntity instanceof ActivityDTO) {
                        treeStore.add(newEntity, new AttributeGroupFolder(messages.attributes()), false);
                        treeStore.add(newEntity, new IndicatorFolder(messages.indicators()), false);
                    }
                    tether.hide();
                    eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
                }
            });
        }
    });
}
Also used : CreateEntity(org.activityinfo.shared.command.CreateEntity) FormDialogCallback(org.activityinfo.client.page.common.dialog.FormDialogCallback) CreateResult(org.activityinfo.shared.command.result.CreateResult) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) FormDialogTether(org.activityinfo.client.page.common.dialog.FormDialogTether) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO)

Example 5 with FormDialogTether

use of org.activityinfo.client.page.common.dialog.FormDialogTether 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

FormDialogTether (org.activityinfo.client.page.common.dialog.FormDialogTether)8 FormDialogCallback (org.activityinfo.client.page.common.dialog.FormDialogCallback)6 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)5 CreateResult (org.activityinfo.shared.command.result.CreateResult)4 PartnerDTO (org.activityinfo.shared.dto.PartnerDTO)3 ProjectDTO (org.activityinfo.shared.dto.ProjectDTO)3 ModelData (com.extjs.gxt.ui.client.data.ModelData)1 Record (com.extjs.gxt.ui.client.store.Record)1 AddPartner (org.activityinfo.shared.command.AddPartner)1 AddProject (org.activityinfo.shared.command.AddProject)1 AddTarget (org.activityinfo.shared.command.AddTarget)1 CreateEntity (org.activityinfo.shared.command.CreateEntity)1 UpdateEntity (org.activityinfo.shared.command.UpdateEntity)1 DuplicateCreateResult (org.activityinfo.shared.command.result.DuplicateCreateResult)1 VoidResult (org.activityinfo.shared.command.result.VoidResult)1 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)1 TargetDTO (org.activityinfo.shared.dto.TargetDTO)1 DuplicatePartnerException (org.activityinfo.shared.exception.DuplicatePartnerException)1