}
@Override
public Field getPropertyField(FormProperty formProperty) {
// Writable string
PopupDateField dateField = new PopupDateField(getPropertyLabel(formProperty));
String datePattern = (String) formProperty.getType().getInformation("datePattern");
dateField.setDateFormat(datePattern);
dateField.setRequired(formProperty.isRequired());
dateField.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
dateField.setEnabled(formProperty.isWritable());
if (formProperty.getValue() != null) {
// Try parsing the current value
SimpleDateFormat dateFormat = new SimpleDateFormat(datePattern);
try {
Date date = dateFormat.parse(formProperty.getValue());
dateField.setValue(date);
} catch (ParseException e) {
// TODO: what happens if current value is illegal date?
}
}
return dateField;