picker.setValue(d);
return picker;
};
private Widget stylingPicker() {
final DatePicker picker = new DatePicker();
HorizontalPanel panel = new HorizontalPanel();
panel.add(picker);
VerticalPanel styling = new VerticalPanel();
panel.add(styling);
styling.add(new ShowRangeHandlerCheckBox(
"First and last displayed date will be underlined and bold", picker,
new ShowRangeHandler<Date>() {
public void onShowRange(ShowRangeEvent<Date> event) {
Date startDate = event.getStart();
Date endDate = event.getEnd();
picker.addStyleToVisibleDate(startDate, "underlined-and-bold-text");
picker.addStyleToVisibleDate(endDate, "underlined-and-bold-text");
}
}));
styling.add(new ShowRangeHandlerCheckBox("5th of the month will be red",
picker, new ShowRangeHandler<Date>() {
public void onShowRange(ShowRangeEvent<Date> event) {
Date monthShown = picker.getDateShown();
Date d = new Date(monthShown.getTime());
d.setDate(5);
Log.info("Adding a red style to the 5th day of the month");
picker.addStyleToVisibleDate(d, "red-date");
}
}));
styling.add(new SelectionHandlerCheckBox(
"Add random style to selected date", picker,
new SelectionHandler<Date>() {
String[] styles = {
"blue-background", "green-border", "red-text", "big-text",
"green-background", "underlined-and-bold-text",
"yellow-background"};
int styleIndex = 0;
public void onSelection(SelectionEvent<Date> event) {
if (event.getNewValue() != null) {
styleIndex = ++styleIndex % styles.length;
String styling = styles[styleIndex];
Log.info(event.getNewValue() + " has style " + styling, "styling");
picker.addGlobalStyleToDate(event.getNewValue(), styling);
}
}
}));
return panel;