List of usage examples for com.vaadin.ui InlineDateField InlineDateField
public InlineDateField(String caption, ValueChangeListener<LocalDate> valueChangeListener)
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); } } }); }