Search in sources :

Example 1 with ProjectForm

use of org.activityinfo.ui.client.page.config.form.ProjectForm 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 2 with ProjectForm

use of org.activityinfo.ui.client.page.config.form.ProjectForm 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)2 UniqueNameValidator (org.activityinfo.ui.client.page.config.design.UniqueNameValidator)2 ProjectForm (org.activityinfo.ui.client.page.config.form.ProjectForm)2 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 VoidResult (org.activityinfo.legacy.shared.command.result.VoidResult)1 ProjectDTO (org.activityinfo.legacy.shared.model.ProjectDTO)1 FormDialogCallback (org.activityinfo.ui.client.page.common.dialog.FormDialogCallback)1