Example usage for com.google.gwt.gen2.event.logical.shared ShowRangeEvent getEnd

List of usage examples for com.google.gwt.gen2.event.logical.shared ShowRangeEvent getEnd

Introduction

In this page you can find the example usage for com.google.gwt.gen2.event.logical.shared ShowRangeEvent getEnd.

Prototype

public Value getEnd() 

Source Link

Document

Gets the end of the range.

Usage

From source file:com.google.gwt.gen2.demo.datepicker.client.DatePickerDemo.java

License:Apache License

private Widget stylingPicker() {
    final DatePicker picker = new DatePicker();
    HorizontalPanel panel = new HorizontalPanel();
    panel.add(picker);//from   w ww. ja  v  a  2s.  c o m
    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;
}