All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.holonplatform.vaadin7.internal.components.LocalDateField Maven / Gradle / Ivy

There is a newer version: 5.2.4
Show newest version
/*
 * Copyright 2016-2017 Axioma srl.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.holonplatform.vaadin7.internal.components;

import java.time.LocalDate;
import java.time.ZoneId;
import java.util.TimeZone;

import com.holonplatform.vaadin7.components.Input;
import com.holonplatform.vaadin7.components.builders.TemporalInputBuilder.TemporalWithoutTimeFieldBuilder;
import com.holonplatform.vaadin7.internal.converters.DateToLocalDateConverter;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.ui.DateField;
import com.vaadin.ui.Field;
import com.vaadin.ui.InlineDateField;

/**
 * Temporal Field implementation handling {@link LocalDate} value types.
 * 
 * 

* This field is rendered using a {@link DateField} or an {@link InlineDateField} with DAY resolution. *

* * @since 5.0.0 */ public class LocalDateField extends AbstractTemporalField { private static final long serialVersionUID = -360868004192038841L; /** * Constructor * @param inline true to render the field using and inline calendar input */ public LocalDateField(boolean inline) { this(inline, null); } /** * Constructor * @param inline true to render the field using and inline calendar input * @param caption Field caption */ public LocalDateField(boolean inline, String caption) { super(LocalDate.class, inline); setCaption(caption); // init init(); } /* * (non-Javadoc) * @see * com.holonplatform.vaadin.internal.components.AbstractTemporalField#configureDateField(com.vaadin.ui.DateField) */ @Override protected void configureDateField(DateField field) { field.setResolution(Resolution.DAY); field.setConverter(new DateToLocalDateConverter()); } // Builder public static class Builder extends AbstractTemporalFieldBuilder> implements TemporalWithoutTimeFieldBuilder { /** * Constructor * @param inline True to render the field as an inline calendar */ public Builder(boolean inline) { super(new LocalDateField(inline)); } /* * (non-Javadoc) * @see com.holonplatform.vaadin.components.builders.TemporalFieldBuilder#timeZone(java.time.ZoneId) */ @Override public TemporalWithoutTimeFieldBuilder timeZone(ZoneId zoneId) { getInstance().setTimeZone((zoneId == null) ? null : TimeZone.getTimeZone(zoneId)); return builder(); } /* * (non-Javadoc) * @see com.holonplatform.vaadin.internal.components.builders.AbstractComponentBuilder#builder() */ @Override protected TemporalWithoutTimeFieldBuilder builder() { return this; } /* * (non-Javadoc) * @see * com.holonplatform.vaadin.internal.components.builders.AbstractFieldBuilder#build(com.vaadin.ui.AbstractField) */ @Override protected Input build(LocalDateField instance) { return instance; } /* * (non-Javadoc) * @see com.holonplatform.vaadin.internal.components.builders.AbstractFieldBuilder#buildAsField(com.vaadin.ui. * AbstractField) */ @Override protected Field buildAsField(LocalDateField instance) { return instance; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy