Search in sources :

Example 1 with FormDialogTether

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

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

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

the class LockedPeriodGrid method startCreate.

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

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

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

Example 4 with FormDialogTether

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

Example 5 with FormDialogTether

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

the class DbPartnerEditor method showEditDialog.

private void showEditDialog(PartnerDTO partner) {
    PartnerForm form = new PartnerForm(otherPartnerNames(partner));
    form.getBinding().bind(partner);
    FormDialogImpl<PartnerForm> dlg = new FormDialogImpl<>(form);
    dlg.setWidth(450);
    dlg.setHeight(300);
    dlg.setHeadingText(I18N.CONSTANTS.newPartner());
    dlg.show(new FormDialogCallback() {

        @Override
        public void onValidated(FormDialogTether dlg) {
            dispatcher.execute(new UpdatePartner(db.getId(), partner), 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) {
                        LOGGER.fine("DbPartnerEditor tried to add partner '" + partner.getName() + "' to database " + db.getId() + " but it already exists");
                        MessageBox.alert(I18N.CONSTANTS.newPartner(), I18N.CONSTANTS.duplicatePartner(), null);
                    } else {
                        LOGGER.fine("DbPartnerEditor added/updated new partner '" + partner.getName() + "' to database " + db.getId());
                        eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
                        dlg.hide();
                        updateStore(partner, result);
                    }
                }
            });
        }
    });
}
Also used : PartnerForm(org.activityinfo.ui.client.page.config.form.PartnerForm) DuplicateCreateResult(org.activityinfo.legacy.shared.command.result.DuplicateCreateResult) FormDialogImpl(org.activityinfo.ui.client.page.common.dialog.FormDialogImpl) FormDialogCallback(org.activityinfo.ui.client.page.common.dialog.FormDialogCallback) DuplicateCreateResult(org.activityinfo.legacy.shared.command.result.DuplicateCreateResult) CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) FormDialogTether(org.activityinfo.ui.client.page.common.dialog.FormDialogTether) UpdatePartner(org.activityinfo.legacy.shared.command.UpdatePartner)

Aggregations

FormDialogTether (org.activityinfo.ui.client.page.common.dialog.FormDialogTether)6 FormDialogCallback (org.activityinfo.ui.client.page.common.dialog.FormDialogCallback)5 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)4 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)3 ProjectDTO (org.activityinfo.legacy.shared.model.ProjectDTO)3 PartnerDTO (org.activityinfo.legacy.shared.model.PartnerDTO)2 Record (com.extjs.gxt.ui.client.store.Record)1 AddProject (org.activityinfo.legacy.shared.command.AddProject)1 AddTarget (org.activityinfo.legacy.shared.command.AddTarget)1 UpdateEntity (org.activityinfo.legacy.shared.command.UpdateEntity)1 UpdatePartner (org.activityinfo.legacy.shared.command.UpdatePartner)1 DuplicateCreateResult (org.activityinfo.legacy.shared.command.result.DuplicateCreateResult)1 VoidResult (org.activityinfo.legacy.shared.command.result.VoidResult)1 TargetDTO (org.activityinfo.legacy.shared.model.TargetDTO)1 FormDialogImpl (org.activityinfo.ui.client.page.common.dialog.FormDialogImpl)1 PartnerForm (org.activityinfo.ui.client.page.config.form.PartnerForm)1