Search in sources :

Example 1 with Field

use of com.extjs.gxt.ui.client.widget.form.Field in project activityinfo by bedatadriven.

the class OnlyValidFieldBinding method updateField.

@Override
public void updateField(boolean updateOriginalValue) {
    if (field instanceof RadioGroup) {
        // special handling for radio group
        RadioGroup radioGroup = (RadioGroup) field;
        Object val = onConvertModelValue(model.get(property));
        // hack : boolean represented with radio buttons : order is important - true is first button, false is second button
        if (val instanceof Boolean) {
            Field nestedField = radioGroup.get((Boolean) val ? 0 : 1);
            nestedField.setValue(Boolean.TRUE);
            return;
        }
    // we do not support other cases right now, fallback to default implementation
    }
    super.updateField(updateOriginalValue);
}
Also used : Field(com.extjs.gxt.ui.client.widget.form.Field) RadioGroup(com.extjs.gxt.ui.client.widget.form.RadioGroup)

Example 2 with Field

use of com.extjs.gxt.ui.client.widget.form.Field in project activityinfo by bedatadriven.

the class IndicatorSection method addQuantityTable.

private void addQuantityTable(IndicatorGroup group) {
    // Layout in three columns
    // Label | Field | Units
    TableData fieldLayout = new TableData();
    fieldLayout.setWidth(NUMBER_FIELD_WIDTH + "px");
    fieldLayout.setVerticalAlign(Style.VerticalAlignment.TOP);
    TableData unitLayout = new TableData();
    unitLayout.setWidth(UNITS_FIELD_WIDTH + "px");
    unitLayout.setVerticalAlign(Style.VerticalAlignment.TOP);
    TableLayout layout = new TableLayout();
    layout.setWidth("100%");
    layout.setColumns(3);
    layout.setCellPadding(5);
    LayoutContainer table = new LayoutContainer();
    table.setLayout(layout);
    table.setAutoHeight(true);
    for (IndicatorDTO indicator : group.getIndicators()) {
        if (!indicator.isCalculated() && indicator.isVisible()) {
            Text fieldLabel = createLabel(indicator);
            Field field = createField(indicator);
            field.setWidth(NUMBER_FIELD_WIDTH);
            Text unitLabel = new Text(indicator.getUnits());
            unitLabel.setWidth(UNITS_FIELD_WIDTH);
            unitLabel.setStyleAttribute("fontSize", "9pt");
            table.add(fieldLabel);
            table.add(field, fieldLayout);
            table.add(unitLabel, unitLayout);
        }
    }
    add(table);
}
Also used : TextField(com.extjs.gxt.ui.client.widget.form.TextField) NumberField(com.extjs.gxt.ui.client.widget.form.NumberField) Field(com.extjs.gxt.ui.client.widget.form.Field) IndicatorDTO(org.activityinfo.legacy.shared.model.IndicatorDTO) LayoutContainer(com.extjs.gxt.ui.client.widget.LayoutContainer) Text(com.extjs.gxt.ui.client.widget.Text) TableData(com.extjs.gxt.ui.client.widget.layout.TableData) TableLayout(com.extjs.gxt.ui.client.widget.layout.TableLayout)

Example 3 with Field

use of com.extjs.gxt.ui.client.widget.form.Field in project activityinfo by bedatadriven.

the class OnlyValidFieldBinding method updateModel.

@Override
public void updateModel() {
    if (field.isValid()) {
        if (field instanceof RadioGroup) {
            // special handing for radio group
            RadioGroup radioGroup = (RadioGroup) field;
            // hack : boolean represented with radio buttons : order is important - true is first button, false is second button
            if ("classicView".equals(property)) {
                Field nestedField = radioGroup.getValue();
                int selectedIndex = radioGroup.getAll().indexOf(nestedField);
                boolean val = selectedIndex == 0;
                if (store != null) {
                    Record r = store.getRecord(model);
                    if (r != null) {
                        r.setValid(property, field.isValid());
                        r.set(property, val);
                    }
                } else {
                    model.set(property, val);
                }
                return;
            }
        }
        super.updateModel();
    }
}
Also used : Field(com.extjs.gxt.ui.client.widget.form.Field) RadioGroup(com.extjs.gxt.ui.client.widget.form.RadioGroup) Record(com.extjs.gxt.ui.client.store.Record)

Aggregations

Field (com.extjs.gxt.ui.client.widget.form.Field)3 RadioGroup (com.extjs.gxt.ui.client.widget.form.RadioGroup)2 Record (com.extjs.gxt.ui.client.store.Record)1 LayoutContainer (com.extjs.gxt.ui.client.widget.LayoutContainer)1 Text (com.extjs.gxt.ui.client.widget.Text)1 NumberField (com.extjs.gxt.ui.client.widget.form.NumberField)1 TextField (com.extjs.gxt.ui.client.widget.form.TextField)1 TableData (com.extjs.gxt.ui.client.widget.layout.TableData)1 TableLayout (com.extjs.gxt.ui.client.widget.layout.TableLayout)1 IndicatorDTO (org.activityinfo.legacy.shared.model.IndicatorDTO)1