Search in sources :

Example 1 with FormDialogImpl

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

the class DbListPresenter method onRename.

public void onRename() {
    DatabaseForm form = new DatabaseForm(dispatcher);
    form.getBinding().bind(selection);
    // it's not allowed to change country by design
    form.hideCountryField();
    final FormDialogImpl dialog = new FormDialogImpl(form);
    dialog.setWidth(400);
    dialog.setHeight(170);
    dialog.setHeadingText(I18N.CONSTANTS.renameDatabase());
    dialog.show(new FormDialogCallback() {

        @Override
        public void onValidated() {
            update(selection, dialog);
        }
    });
}
Also used : FormDialogImpl(org.activityinfo.ui.client.page.common.dialog.FormDialogImpl) FormDialogCallback(org.activityinfo.ui.client.page.common.dialog.FormDialogCallback) DatabaseForm(org.activityinfo.ui.client.page.config.form.DatabaseForm)

Example 2 with FormDialogImpl

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

the class DbProjectGrid method showAddDialog.

@Override
public FormDialogTether showAddDialog(ProjectDTO project, FormDialogCallback callback) {
    ProjectForm form = new ProjectForm();
    form.getBinding().bind(project);
    form.getNameField().setValidator(new UniqueNameValidator(grid.getStore().getModels()));
    FormDialogImpl<ProjectForm> dlg = new FormDialogImpl<>(form);
    dlg.setWidth(450);
    dlg.setHeight(300);
    dlg.setHeadingText(messages.createProject());
    dlg.show(callback);
    return dlg;
}
Also used : ProjectForm(org.activityinfo.ui.client.page.config.form.ProjectForm) FormDialogImpl(org.activityinfo.ui.client.page.common.dialog.FormDialogImpl) UniqueNameValidator(org.activityinfo.ui.client.page.config.design.UniqueNameValidator)

Example 3 with FormDialogImpl

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

the class DbTargetGrid method showAddDialog.

@Override
public FormDialogTether showAddDialog(TargetDTO target, UserDatabaseDTO db, boolean editDialog, FormDialogCallback callback) {
    TargetForm form = new TargetForm(db);
    form.getBinding().setStore(store);
    form.getBinding().bind(store.getRecord(target).getModel());
    FormDialogImpl<TargetForm> dlg = new FormDialogImpl<TargetForm>(form);
    dlg.setWidth(450);
    dlg.setHeight(300);
    if (editDialog) {
        dlg.setHeadingText(messages.editTarget());
    } else {
        dlg.setHeadingText(messages.createTarget());
    }
    dlg.show(callback);
    return dlg;
}
Also used : FormDialogImpl(org.activityinfo.ui.client.page.common.dialog.FormDialogImpl) TargetForm(org.activityinfo.ui.client.page.config.form.TargetForm)

Example 4 with FormDialogImpl

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

Example 5 with FormDialogImpl

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

the class DbProjectEditor method onEdit.

@Override
protected void onEdit(final ProjectDTO model) {
    final ProjectDTO copy = new ProjectDTO();
    copy.setProperties(model.getProperties());
    final FormDialogImpl<ProjectForm> dialog = new FormDialogImpl<ProjectForm>(new ProjectForm()) {

        @Override
        public void onCancel() {
            model.setProperties(copy.getProperties());
        }
    };
    dialog.setWidth(450);
    dialog.setHeight(300);
    dialog.getForm().getBinding().bind(model);
    List<ProjectDTO> allowed = Lists.newArrayList(store.getModels());
    allowed.remove(model);
    dialog.getForm().getNameField().setValidator(new UniqueNameValidator(allowed));
    dialog.show(new FormDialogCallback() {

        @Override
        public void onValidated() {
            service.execute(RequestChange.update(model, "name", "description"), dialog, new AsyncCallback<VoidResult>() {

                @Override
                public void onFailure(Throwable caught) {
                // handled by monitor
                }

                @Override
                public void onSuccess(VoidResult result) {
                    dialog.hide();
                    eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
                    view.refresh();
                }
            });
        }
    });
}
Also used : ProjectDTO(org.activityinfo.legacy.shared.model.ProjectDTO) ProjectForm(org.activityinfo.ui.client.page.config.form.ProjectForm) FormDialogImpl(org.activityinfo.ui.client.page.common.dialog.FormDialogImpl) FormDialogCallback(org.activityinfo.ui.client.page.common.dialog.FormDialogCallback) VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) UniqueNameValidator(org.activityinfo.ui.client.page.config.design.UniqueNameValidator)

Aggregations

FormDialogImpl (org.activityinfo.ui.client.page.common.dialog.FormDialogImpl)7 FormDialogCallback (org.activityinfo.ui.client.page.common.dialog.FormDialogCallback)5 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)3 VoidResult (org.activityinfo.legacy.shared.command.result.VoidResult)2 UniqueNameValidator (org.activityinfo.ui.client.page.config.design.UniqueNameValidator)2 ProjectForm (org.activityinfo.ui.client.page.config.form.ProjectForm)2 ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)1 FormEvent (com.extjs.gxt.ui.client.event.FormEvent)1 HiddenField (com.extjs.gxt.ui.client.widget.form.HiddenField)1 UpdatePartner (org.activityinfo.legacy.shared.command.UpdatePartner)1 UpdateUserPermissions (org.activityinfo.legacy.shared.command.UpdateUserPermissions)1 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)1 DuplicateCreateResult (org.activityinfo.legacy.shared.command.result.DuplicateCreateResult)1 UserExistsException (org.activityinfo.legacy.shared.command.result.UserExistsException)1 ProjectDTO (org.activityinfo.legacy.shared.model.ProjectDTO)1 FormDialogTether (org.activityinfo.ui.client.page.common.dialog.FormDialogTether)1 DatabaseForm (org.activityinfo.ui.client.page.config.form.DatabaseForm)1 FolderAssignmentException (org.activityinfo.ui.client.page.config.form.FolderAssignmentException)1 PartnerForm (org.activityinfo.ui.client.page.config.form.PartnerForm)1 PermissionAssignmentException (org.activityinfo.ui.client.page.config.form.PermissionAssignmentException)1