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);
}
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);
}
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();
}
}
Aggregations