Search in sources :

Example 1 with FieldBinding

use of com.extjs.gxt.ui.client.binding.FieldBinding 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 FieldBinding

use of com.extjs.gxt.ui.client.binding.FieldBinding in project activityinfo by bedatadriven.

the class LocalDateBinding method create.

public static FieldBinding create(DateField dateField, String datePropertyName) {
    FieldBinding binding = new FieldBinding(dateField, datePropertyName);
    binding.setConverter(new Converter() {

        @Override
        public Object convertModelValue(Object value) {
            if (value == null) {
                return null;
            } else {
                return ((LocalDate) value).atMidnightInMyTimezone();
            }
        }

        @Override
        public Object convertFieldValue(Object value) {
            if (value == null) {
                return null;
            } else {
                Date dateValue = (Date) value;
                return new LocalDate(dateValue);
            }
        }
    });
    return binding;
}
Also used : FieldBinding(com.extjs.gxt.ui.client.binding.FieldBinding) Converter(com.extjs.gxt.ui.client.binding.Converter) LocalDate(com.bedatadriven.rebar.time.calendar.LocalDate) Date(java.util.Date) LocalDate(com.bedatadriven.rebar.time.calendar.LocalDate)

Aggregations

FieldBinding (com.extjs.gxt.ui.client.binding.FieldBinding)2 LocalDate (com.bedatadriven.rebar.time.calendar.LocalDate)1 Converter (com.extjs.gxt.ui.client.binding.Converter)1 Date (java.util.Date)1 AbstractDesignForm (org.activityinfo.ui.client.page.config.form.AbstractDesignForm)1