Search in sources :

Example 1 with TimePicker

use of com.vaadin.flow.component.timepicker.TimePicker in project karnak by OsiriX-Foundation.

the class TransferStatusGrid method createTransferDateFilter.

/**
 * Creation of the filter for transfer date
 *
 * @param transferDateColumn Column
 * @param filterRow Row filter
 */
private void createTransferDateFilter(Column<TransferStatusEntity> transferDateColumn, HeaderRow filterRow) {
    // Date
    DatePicker datePicker = new DatePicker();
    datePicker.setLocale(Locale.FRANCE);
    UIS.setTooltip(datePicker, TOOLTIP_FORMAT_DD_MM_YYYY);
    datePicker.setPlaceholder("Date");
    datePicker.setMinWidth(30, Unit.PERCENTAGE);
    datePicker.setMaxWidth(40, Unit.PERCENTAGE);
    datePicker.setClearButtonVisible(true);
    // Time Start
    TimePicker startTimePicker = new TimePicker();
    startTimePicker.setPlaceholder("Start");
    UIS.setTooltip(startTimePicker, TOOLTIP_FORMAT_HH_MM);
    startTimePicker.setMinWidth(25, Unit.PERCENTAGE);
    startTimePicker.setMaxWidth(30, Unit.PERCENTAGE);
    startTimePicker.setClearButtonVisible(true);
    // Time End
    TimePicker endTimePicker = new TimePicker();
    endTimePicker.setPlaceholder("End");
    UIS.setTooltip(endTimePicker, TOOLTIP_FORMAT_HH_MM);
    endTimePicker.setMinWidth(25, Unit.PERCENTAGE);
    endTimePicker.setMaxWidth(30, Unit.PERCENTAGE);
    endTimePicker.setClearButtonVisible(true);
    // Listeners
    buildListenerDate(datePicker, startTimePicker, endTimePicker);
    buildListenerStartTime(datePicker, startTimePicker, endTimePicker);
    buildListenerEndTime(datePicker, startTimePicker, endTimePicker);
    // Add components
    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.add(datePicker, startTimePicker, endTimePicker);
    horizontalLayout.setSizeFull();
    filterRow.getCell(transferDateColumn).setComponent(horizontalLayout);
}
Also used : TimePicker(com.vaadin.flow.component.timepicker.TimePicker) DatePicker(com.vaadin.flow.component.datepicker.DatePicker) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 2 with TimePicker

use of com.vaadin.flow.component.timepicker.TimePicker in project WebComponentKit by itsoulltd.

the class AbstractBeanEditor method getValueField.

protected HasValue getValueField(Property prop) {
    HasValue hasValue = null;
    if (prop.getType() == DataType.BOOL) {
        Checkbox box = new Checkbox();
        box.setLabel(prop.getKey());
        if (prop.getValue() != null)
            box.setValue((Boolean) prop.getValue());
        else
            box.setIndeterminate(true);
        hasValue = box;
    } else if (prop.getType() == DataType.SQLDATE) {
        DatePicker datePicker = new DatePicker();
        datePicker.setValue(LocalDate.now());
        datePicker.setClearButtonVisible(true);
        hasValue = datePicker;
    } else if (prop.getType() == DataType.SQLTIMESTAMP) {
        TimePicker timePicker = new TimePicker();
        timePicker.setValue(LocalTime.now());
        timePicker.setClearButtonVisible(true);
        hasValue = timePicker;
    } else {
        TextField field = new TextField();
        field.setLabel(prop.getKey());
        hasValue = field;
    }
    return hasValue;
}
Also used : TimePicker(com.vaadin.flow.component.timepicker.TimePicker) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) TextField(com.vaadin.flow.component.textfield.TextField) DatePicker(com.vaadin.flow.component.datepicker.DatePicker)

Example 3 with TimePicker

use of com.vaadin.flow.component.timepicker.TimePicker in project flow-components by vaadin.

the class TimePickerLocaleTest method newTimePicker_returnsUiLocale.

@Test
public void newTimePicker_returnsUiLocale() {
    Locale finnishLocale = new Locale("fi-FI");
    ui.setLocale(finnishLocale);
    TimePicker timePicker = new TimePicker();
    Assert.assertEquals(finnishLocale, timePicker.getLocale());
}
Also used : Locale(java.util.Locale) TimePicker(com.vaadin.flow.component.timepicker.TimePicker) Test(org.junit.Test)

Example 4 with TimePicker

use of com.vaadin.flow.component.timepicker.TimePicker in project flow-components by vaadin.

the class TimePickerTest method testSetStep_minutesNotDivideEvenly_throwsException.

@Test(expected = IllegalArgumentException.class)
public void testSetStep_minutesNotDivideEvenly_throwsException() {
    TimePicker timePicker = new TimePicker();
    timePicker.setStep(Duration.ofMinutes(35));
}
Also used : TimePicker(com.vaadin.flow.component.timepicker.TimePicker) GeneratedVaadinTimePicker(com.vaadin.flow.component.timepicker.GeneratedVaadinTimePicker) Test(org.junit.Test)

Example 5 with TimePicker

use of com.vaadin.flow.component.timepicker.TimePicker in project flow-components by vaadin.

the class TimePickerTest method setInitialValue.

@Test
public void setInitialValue() {
    TimePicker picker = new TimePicker(LocalTime.of(9, 32));
    assertEquals(LocalTime.of(9, 32), picker.getValue());
    assertEquals("09:32", picker.getElement().getProperty("value"));
}
Also used : TimePicker(com.vaadin.flow.component.timepicker.TimePicker) GeneratedVaadinTimePicker(com.vaadin.flow.component.timepicker.GeneratedVaadinTimePicker) Test(org.junit.Test)

Aggregations

TimePicker (com.vaadin.flow.component.timepicker.TimePicker)35 Test (org.junit.Test)23 GeneratedVaadinTimePicker (com.vaadin.flow.component.timepicker.GeneratedVaadinTimePicker)20 Div (com.vaadin.flow.component.html.Div)5 NativeButton (com.vaadin.flow.component.html.NativeButton)3 LocalTime (java.time.LocalTime)3 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)2 DatePicker (com.vaadin.flow.component.datepicker.DatePicker)2 Span (com.vaadin.flow.component.html.Span)2 TextField (com.vaadin.flow.component.textfield.TextField)2 Duration (java.time.Duration)2 Locale (java.util.Locale)2 HasLabel (com.vaadin.flow.component.HasLabel)1 ComboBox (com.vaadin.flow.component.combobox.ComboBox)1 FormLayout (com.vaadin.flow.component.formlayout.FormLayout)1 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)1 RichTextEditor (com.vaadin.flow.component.richtexteditor.RichTextEditor)1 Select (com.vaadin.flow.component.select.Select)1 IntegerField (com.vaadin.flow.component.textfield.IntegerField)1 Binder (com.vaadin.flow.data.binder.Binder)1