public DatePickerDialog(boolean lightTheme) { setPrimaryStyleName(lightTheme ? Styles.Windows.LIGHT : Styles.Windows.DARK); addStyleName(Styles.Windows.NO_HEADER); field = new InlineDateField(); field.setPrimaryStyleName(lightTheme ? Styles.DatePickers.LIGHT : Styles.DatePickers.DARK); field.addStyleName(FlexItem.FlexGrow.GROW_1); field.addStyleName(FlexLayout.Overflow.AUTO.getStyleName()); // Header header = new DatePickerHeader(field, lightTheme); // Footer footer = new DatePickerFooter(field, lightTheme); // Content wrapper content = new FlexLayout(FlexLayout.FlexDirection.COLUMN, header, field, footer); setContent(content); }
public DatePickerFooter(InlineDateField field, boolean lightTheme) { setAlignItems(FlexLayout.AlignItems.CENTER); setJustifyContent(FlexLayout.JustifyContent.FLEX_END); addStyleName(Paddings.All.SMALL); addStyleName(Spacings.Right.SMALL); addStyleName(FlexItem.FlexShrink.SHRINK_0); cancel = new Button("Cancel"); cancel.setPrimaryStyleName(lightTheme ? Styles.Buttons.Flat.LIGHT : Styles.Buttons.Flat.DARK); ok = new Button("OK"); ok.setPrimaryStyleName(lightTheme ? Styles.Buttons.Flat.LIGHT : Styles.Buttons.Flat.DARK); ok.setEnabled(field.getValue() != null); this.field = field; this.field.addValueChangeListener(event -> ok.setEnabled(this.field.getValue() != null)); addComponents(cancel, ok); }
public DatePickerHeader(InlineDateField field, boolean lightTheme) { setFlexDirection(FlexDirection.COLUMN); setJustifyContent(JustifyContent.CENTER); addStyleName(Paddings.Horizontal.LARGE); addStyleName(FlexItem.FlexShrink.SHRINK_0); this.field = field; field.addValueChangeListener((HasValue.ValueChangeListener<LocalDate>) event -> { year.setValue(field.getValue().format(DateTimeFormatter.ofPattern("yyyy"))); date.setValue(field.getValue().format(DateTimeFormatter.ofPattern("EEE, MMM d"))); }); setHeight(Metrics.DatePicker.HEADER_HEIGHT, Unit.PIXELS); addStyleName(lightTheme ? MaterialColor.BLUE_500.getBackgroundColorStyle() : MaterialColor.GREY_700.getBackgroundColorStyle()); year.setPrimaryStyleName(Typography.Light.Body2.SECONDARY); date.setPrimaryStyleName(Typography.Light.DatePicker.Title.PRIMARY); addComponents(year, date); }
public PickersView() { setAlignItems(FlexLayout.AlignItems.FLEX_START); setAlignSelf(AlignSelf.BASELINE); setFlexWrap(FlexLayout.FlexWrap.WRAP); setJustifyContent(JustifyContent.CENTER); addStyleName(Spacings.All.LARGE); InlineDateField idf1 = new InlineDateField(); idf1.setPrimaryStyleName(Styles.DatePickers.LIGHT); FlexLayout c1 = new FlexLayout(FlexDirection.COLUMN, idf1); c1.addStyleName("card"); InlineDateField idf2 = new InlineDateField(); idf2.setPrimaryStyleName(Styles.DatePickers.LIGHT); FlexLayout c2 = new FlexLayout(FlexDirection.COLUMN, new DatePickerHeader(idf2, true), idf2, createFooter(idf2, true)); c2.addStyleName("card"); InlineDateField idf3 = new InlineDateField(); idf3.setPrimaryStyleName(Styles.DatePickers.DARK); FlexLayout c3 = new FlexLayout(FlexDirection.COLUMN, idf3); c3.addStyleName("card" + " " + MaterialColor.GREY_800.getBackgroundColorStyle()); InlineDateField idf4 = new InlineDateField(); idf4.setPrimaryStyleName(Styles.DatePickers.DARK); FlexLayout c4 = new FlexLayout(FlexDirection.COLUMN, new DatePickerHeader(idf4, false), idf4, createFooter(idf4, false)); c4.addStyleName("card" + " " + MaterialColor.GREY_800.getBackgroundColorStyle()); addComponents(c1, c2, c3, c4); }
public CssLayout createFooter(InlineDateField field, boolean lightTheme) { DatePickerFooter footer = new DatePickerFooter(field, lightTheme); if (!lightTheme) { footer.getDismissiveActionButton().addStyleName(MaterialColor.BLUE_200.getFontColorStyle()); footer.getAffirmativeActionButton().addStyleName(MaterialColor.BLUE_200.getFontColorStyle()); } return footer; }
@Override protected AbstractDateField<LocalDate, ?> buildInternalField(Class<? extends Date> type) { AbstractLocalDateField field = isInline() ? new InlineDateField() : new com.vaadin.ui.DateField(); if (getResolution() == Resolution.MONTH) { field.setResolution(DateResolution.MONTH); } if (getResolution() == Resolution.YEAR) { field.setResolution(DateResolution.YEAR); } return field; }
/** * Creates an inline date field. * @param pid property name. * @param propertyType property type. * @return a new field to select a date. */ public Field createInlineDateField(String pid, Class<?> propertyType) { Field field = null; if(Date.class.isAssignableFrom(propertyType)) { InlineDateField dateField = new InlineDateField(); dateField.setResolution(InlineDateField.RESOLUTION_DAY); dateField.setDateFormat(Utils.getDateFormatPattern()); field = dateField; } return field; }
@Override protected DateField buildInternalField(Class<? extends T> type) { DateField field = isInline() ? new InlineDateField() : new DateField(); configureDateField(field); return field; }
public InlineDateField getField() { return field; }
public void setField(InlineDateField field) { this.field = field; }
@Override protected AbstractDateField<LocalDate, ?> buildInternalField(Class<? extends LocalDate> type) { return isInline() ? new InlineDateField() : new DateField(); }