final DateBox dateBox = new DateBox(); dateBox.addValueChangeHandler(new ValueChangeHandler<Date>() { @Override public void onValueChange(final ValueChangeEvent<Date> dateValueChangeEvent) { if (dateValueChangeEvent.getValue().before(today())) { dateBox.setValue(today(), false); } } }); dateBox.getDatePicker().addShowRangeHandler(new ShowRangeHandler<Date>() { @Override public void onShowRange(final ShowRangeEvent<Date> dateShowRangeEvent) { final Date today = today(); Date d = zeroTime(dateShowRangeEvent.getStart()); while (d.before(today)) { dateBox.getDatePicker().setTransientEnabledOnDates(false, d); d = nextDay(d); } } });
@Override protected void resetImpl() { notificationSchemaInfo.reset(); expiredAt.setValue(null); notificationData.reset(); }
/** * Add a style name to the given dates. */ public void addStyleToDates(String styleName, Date date) { styler.setStyleName(date, styleName, true); if (isDateVisible(date)) { getView().addStyleToDate(styleName, date); } }
@Override public void onSelected(boolean selected) { if (selected) { getDatePicker().setValue(getValue(), true); if (isFiller()) { getDatePicker().setCurrentMonth(getValue()); } } updateStyle(); }
@Override public void addStyleToDate(String styleName, Date date) { assert getDatePicker().isDateVisible(date) : "You tried to add style " + styleName + " to " + date + ". The calendar is currently showing " + getFirstDate() + " to " + getLastDate(); getCell(date).addStyleName(styleName); }
/** * Create a new date picker. */ public DatePicker() { this(new DefaultMonthSelector(), new DefaultCalendarView(), new CalendarModel()); }
/** * Removes the styleName from the given dates (even if it is transient). */ public void removeStyleFromDates(String styleName, Date date) { styler.setStyleName(date, styleName, false); if (isDateVisible(date)) { getView().removeStyleFromDate(styleName, date); } }
/** * Sets a visible date to be enabled or disabled. This is only set until the * next time the DatePicker is refreshed. */ public final void setTransientEnabledOnDates(boolean enabled, Date date) { assert isDateVisible(date) : date + " must be visible"; getView().setEnabledOnDate(enabled, date); }
/** * Shifts the currently specified date by the given number of months. The day * of the month will be pinned to the original value as far as possible. * * @param deltaMonths - number of months to be added to the current date */ public void shiftCurrentMonth(int deltaMonths) { CalendarUtil.addMonthsToDate(currentMonth, deltaMonths); refresh(); }
/** * Adds the given style name to the specified dates, which must be visible. * This is only set until the next time the DatePicker is refreshed. */ public void addTransientStyleToDates(String styleName, Date date) { assert isDateVisible(date) : date + " must be visible"; getView().addStyleToDate(styleName, date); }
/** * Is the visible date enabled? * * @param date the date, which must be visible * * @return is the date enabled? */ public boolean isDateEnabled(Date date) { assert isDateVisible(date) : date + " is not visible"; return getView().isDateEnabled(date); }
@Override public void onHighlighted(boolean highlighted) { setHighlightedDate(getValue()); updateStyle(); }
public final void setSelected(Cell cell) { Cell last = getSelectedCell(); selectedCell = cell; if (last != null) { last.onSelected(false); } if (selectedCell != null) { selectedCell.onSelected(true); } onSelected(last, selectedCell); }
/** * Allows the calendar view to update the date picker's highlighted date. * * @param date the highlighted date */ protected final void setHighlightedDate(Date date) { getDatePicker().setHighlightedDate(date); } }
/** * Refreshes the {@link DatePicker}, {@link CalendarView}, and * {@link CalendarModel}. */ protected void refreshAll() { getDatePicker().refreshAll(); }
@Override public void setAriaSelectedCell(Date date) { if (ariaSelectedCell != null) { ariaSelectedCell.setAriaSelected(false); } DateCell newSelectedCell = date != null ? getCell(date) : null; if (newSelectedCell != null) { newSelectedCell.setAriaSelected(true); } ariaSelectedCell = newSelectedCell; }
/** * Sets the highlighted date. * * @param highlighted highlighted date */ void setHighlightedDate(Date highlighted) { this.highlighted = highlighted; fireEvent(new DateHighlightEvent(highlighted)); } }
@Override public void removeStyleFromDate(String styleName, Date date) { getCell(date).removeStyleName(styleName); }