Example usage for com.vaadin.ui InlineDateField InlineDateField

List of usage examples for com.vaadin.ui InlineDateField InlineDateField

Introduction

In this page you can find the example usage for com.vaadin.ui InlineDateField InlineDateField.

Prototype

public InlineDateField(String caption, ValueChangeListener<LocalDate> valueChangeListener) 

Source Link

Document

Constructs a new InlineDateField with the given caption and a value change listener.

Usage

From source file:org.escidoc.browser.elabsmodul.views.DatePickerWindow.java

License:Open Source License

private void createInLineDateField() {
    this.dateField = new InlineDateField(ELabsViewContants.DATEPICKER_CAPTION,
            Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault()).getTime());
    this.dateField.setResolution(InlineDateField.RESOLUTION_MIN);
    this.dateField.setImmediate(true);
    this.dateField.setShowISOWeekNumbers(true);
    this.dateField.setLocale(Locale.getDefault());
    this.dateField.setTimeZone(TimeZone.getDefault());
    this.dateField.setEnabled(false);

    this.dateField.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = -2403060484955547831L;

        @Override/* w  w w  .j a v a  2  s  .c o  m*/
        public void valueChange(ValueChangeEvent event) {
            LOG.debug("DataPicker's value changed to: " + dateField.getValue().toString());
            Calendar now = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault());
            Calendar selected = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault());
            selected.setTime((Date) dateField.getValue());
            Calendar limit = (Calendar) now.clone();
            limit.add(Calendar.DAY_OF_YEAR, 14);
            if (selected.before(now) || selected.after(limit)) {
                DatePickerWindow.this.getApplication().getMainWindow().showNotification("Wrong date",
                        "Selected Date must be in the next two weeks from now",
                        Notification.TYPE_WARNING_MESSAGE);
            }
        }
    });
}