Search in sources :

Example 1 with DateResolution

use of com.vaadin.shared.ui.datefield.DateResolution in project cuba by cuba-platform.

the class CubaDateFieldWidget method updateValue.

@Override
public void updateValue(Date newDate) {
    DateResolution currentResolution = getCurrentResolution();
    if (getDate() == null && currentResolution != null && currentResolution.compareTo(DateResolution.DAY) > 0) {
        Date date = newDate;
        // Collects a map of current date values depending on date resolution
        Map<DateResolution, Integer> dateValues = getResolutions().collect(Collectors.toMap(Function.identity(), res -> currentResolution.compareTo(res) <= 0 ? res == DateResolution.MONTH ? date.getMonth() + 1 : date.getYear() + 1900 : null));
        if (!dateValues.isEmpty()) {
            newDate = makeDate(dateValues);
            calendar.setDate(newDate);
        }
    }
    super.updateValue(newDate);
}
Also used : VPopupCalendar(com.vaadin.client.ui.VPopupCalendar) DOM(com.google.gwt.user.client.DOM) Date(java.util.Date) DateTimeService(com.vaadin.client.DateTimeService) ShortcutActionHandler(com.vaadin.client.ui.ShortcutActionHandler) Map(java.util.Map) Event(com.google.gwt.user.client.Event) CubaMaskedFieldWidget(com.haulmont.cuba.web.widgets.client.textfield.CubaMaskedFieldWidget) DateResolution(com.vaadin.shared.ui.datefield.DateResolution) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) DateResolution(com.vaadin.shared.ui.datefield.DateResolution) Date(java.util.Date)

Example 2 with DateResolution

use of com.vaadin.shared.ui.datefield.DateResolution in project cuba by cuba-platform.

the class WebDatePicker method setResolution.

@Override
public void setResolution(Resolution resolution) {
    Preconditions.checkNotNullArgument(resolution);
    this.resolution = resolution;
    DateResolution vResolution = WebWrapperUtils.convertDateResolution(resolution);
    component.setResolution(vResolution);
}
Also used : DateResolution(com.vaadin.shared.ui.datefield.DateResolution)

Aggregations

DateResolution (com.vaadin.shared.ui.datefield.DateResolution)2 DOM (com.google.gwt.user.client.DOM)1 Event (com.google.gwt.user.client.Event)1 CubaMaskedFieldWidget (com.haulmont.cuba.web.widgets.client.textfield.CubaMaskedFieldWidget)1 DateTimeService (com.vaadin.client.DateTimeService)1 ShortcutActionHandler (com.vaadin.client.ui.ShortcutActionHandler)1 VPopupCalendar (com.vaadin.client.ui.VPopupCalendar)1 Date (java.util.Date)1 Map (java.util.Map)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1