this.form.setFields(staticTextItem);
} else {
this.form.setNumCols(4);
this.form.setColWidths("140", "90", "105", "*");
final IntegerItem valueItem = new IntegerItem(FIELD_VALUE, title);
valueItem.setShowTitle(getShowTitle());
valueItem.setValue(getValue());
IntegerRangeValidator integerRangeValidator = new IntegerRangeValidator();
integerRangeValidator.setMin(1);
integerRangeValidator.setMax(Integer.MAX_VALUE);
valueItem.setValidators(integerRangeValidator);
valueItem.setValidateOnChange(true);
valueItem.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent event) {
updateValue();
}
});
SelectItem unitsItem = new SelectItem(FIELD_UNITS);
unitsItem.setShowTitle(false);
LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
if (this.supportedUnitTypes.contains(UnitType.ITERATIONS)) {
valueMap.put("times", MSG.common_unit_times());
}
if (this.supportedUnitTypes.contains(UnitType.TIME)) {
for (TimeUnit unit : supportedUnits) {
valueMap.put(unit.name().toLowerCase(), unit.getDisplayName());
}
}
unitsItem.setValueMap(valueMap);
if (this.defaultTimeUnit != null) {
unitsItem.setDefaultValue(this.defaultTimeUnit.name().toLowerCase());
} else {
unitsItem.setDefaultToFirstOption(true);
}
unitsItem.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent event) {
updateValue();
}
});
this.form.setFields(valueItem, unitsItem);
valueItem.setWidth(90);
unitsItem.setWidth(105);
}
setCanvas(this.form);
}