final IntegerItem intervalItem = new IntegerItem();
intervalItem.setWrapTitle(false);
intervalItem.setWidth(75);
intervalItem.setName(ITEM_INTERVAL);
intervalItem.setTitle(MSG.view_inventory_collectionInterval());
final IntegerRangeValidator integerRangeValidator = new IntegerRangeValidator();
integerRangeValidator.setMin(1);
integerRangeValidator.setMax(10000000); // avoids exceptions if someone enters really large nums; no one needs to go higher anyway
intervalItem.setValidators(integerRangeValidator);
intervalItem.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent changedEvent) {
refresh(UpdateCollectionIntervalWidget.this.schedulesView.getListGrid());
}
});
// Specify a null title so no label is rendered to the left of the combo box.
SelectItem unitsItem = new SelectItem(ITEM_UNITS, null);
unitsItem.setValueMap(VALUE_MAP);
unitsItem.setDefaultValue(UNITS_MINUTES);
unitsItem.setShowTitle(false);
unitsItem.setWidth(125);
unitsItem.addChangedHandler(new ChangedHandler() {
@Override
public void onChanged(ChangedEvent event) {
String value = (String) event.getValue();
if (value.equals(UNITS_SECONDS)) {
integerRangeValidator.setMin(30);
} else {
integerRangeValidator.setMin(1);
}
refresh(UpdateCollectionIntervalWidget.this.schedulesView.getListGrid());
}
});