dateFrom.setText(dts.formatDate(intervalStartDate,
dateFormatInfo.getEditFormat().getPattern()));
}
}
});
dateFrom.addFocusHandler(new FocusHandler() {
@Override
public void onFocus(FocusEvent event) {
dateFrom.setStyleName(CLASSNAME_DATEFIELDEDIT);
dateFrom.setText(dts.formatDate(intervalStartDate,
dateFormatInfo.getEditFormat().getPattern()));
dateFrom.selectAll();
}
});
dateFrom.addBlurHandler(new BlurHandler() {
@Override
public void onBlur(BlurEvent event) {
dateFrom.setStyleName(CLASSNAME_DATEFIELD);
dateFrom.setText(dts.formatDate(intervalStartDate,
dateFormatInfo.getDisplayFormat().getPattern()));
}
});
dateFrom.setReadOnly(!dateSelectEnabled);
dateFrom.setStyleName(CLASSNAME_DATEFIELD);
dateRangeBar.add(dateFrom);
Label dash = new Label();
dash.setText("-");
dateRangeBar.add(dash);
dateTo = new TextBox();
dateTo.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
try {
Date newDate = dts.parseDate(event.getValue(),
dateFormatInfo.getEditFormat().getPattern(), true);
if ((newDate.equals(startDate) || newDate.after(startDate))
&& (newDate.equals(endDate) || newDate
.before(endDate))) {
intervalEndDate = newDate;
setBrowserRange(intervalStartDate, intervalEndDate);
setDisplayRange(intervalStartDate, intervalEndDate);
dateTo.setFocus(false);
} else {
dateTo.setText(dts.formatDate(intervalEndDate,
dateFormatInfo.getEditFormat().getPattern()));
}
} catch (IllegalArgumentException iae) {
dateTo.setText(dts.formatDate(intervalEndDate,
dateFormatInfo.getEditFormat().getPattern()));
}
}
});
dateTo.addFocusHandler(new FocusHandler() {
@Override
public void onFocus(FocusEvent event) {
dateTo.setStyleName(CLASSNAME_DATEFIELDEDIT);
dateTo.setText(dts.formatDate(intervalEndDate, dateFormatInfo
.getEditFormat().getPattern()));