Search in sources :

Example 1 with AbstractDesignForm

use of org.activityinfo.ui.client.page.config.form.AbstractDesignForm in project activityinfo by bedatadriven.

the class DbEditor method showNewForm.

private FormDialogTether showNewForm(EntityDTO entity, FormDialogCallback callback) {
    AbstractDesignForm form = createForm(entity);
    form.getBinding().bind(entity);
    form.getBinding().setStore(tree.getStore());
    for (FieldBinding field : form.getBinding().getBindings()) {
        field.getField().clearInvalid();
    }
    FormDialogImpl dlg = new FormDialogImpl(form);
    dlg.setWidth(form.getPreferredDialogWidth());
    dlg.setHeight(form.getPreferredDialogHeight());
    dlg.setScrollMode(Style.Scroll.AUTOY);
    if (entity instanceof IsActivityDTO) {
        dlg.setHeadingText(I18N.CONSTANTS.newActivity());
    } else if (entity instanceof AttributeGroupDTO) {
        dlg.setHeadingText(I18N.CONSTANTS.newAttributeGroup());
    } else if (entity instanceof AttributeDTO) {
        dlg.setHeadingText(I18N.CONSTANTS.newAttribute());
    } else if (entity instanceof IndicatorDTO) {
        dlg.setHeadingText(I18N.CONSTANTS.newIndicator());
    } else if (entity instanceof LocationTypeDTO) {
        dlg.setHeadingText(I18N.CONSTANTS.newLocationType());
    }
    dlg.show(callback);
    return dlg;
}
Also used : FieldBinding(com.extjs.gxt.ui.client.binding.FieldBinding) AbstractDesignForm(org.activityinfo.ui.client.page.config.form.AbstractDesignForm)

Example 2 with AbstractDesignForm

use of org.activityinfo.ui.client.page.config.form.AbstractDesignForm in project activityinfo by bedatadriven.

the class DbEditor method showForm.

private void showForm(ModelData model) {
    // do we have the right form?
    Class formClass = formClassForSelection(model);
    AbstractDesignForm currentForm = null;
    if (formContainer.getItemCount() != 0) {
        currentForm = (AbstractDesignForm) formContainer.getItem(0);
    }
    if (formClass == null) {
        if (currentForm != null) {
            currentForm.getBinding().unbind();
            formContainer.removeAll();
        }
        return;
    } else {
        if (currentForm == null || (!formClass.equals(currentForm.getClass()))) {
            if (currentForm != null) {
                formContainer.removeAll();
                currentForm.getBinding().unbind();
            }
            currentForm = createForm(model);
            currentForm.setReadOnly(!isDesignAllowed(model));
            currentForm.setHeaderVisible(false);
            currentForm.setBorders(false);
            currentForm.setFrame(false);
            currentForm.getBinding().setStore(tree.getStore());
            formContainer.add(currentForm);
            formContainer.layout();
        }
    }
    currentForm.getBinding().bind(model);
}
Also used : FieldTypeClass(org.activityinfo.model.type.FieldTypeClass) AbstractDesignForm(org.activityinfo.ui.client.page.config.form.AbstractDesignForm)

Aggregations

AbstractDesignForm (org.activityinfo.ui.client.page.config.form.AbstractDesignForm)2 FieldBinding (com.extjs.gxt.ui.client.binding.FieldBinding)1 FieldTypeClass (org.activityinfo.model.type.FieldTypeClass)1