本文整理汇总了Java中com.vaadin.ui.DateField类的典型用法代码示例。如果您正苦于以下问题:Java DateField类的具体用法?Java DateField怎么用?Java DateField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DateField类属于com.vaadin.ui包,在下文中一共展示了DateField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import com.vaadin.ui.DateField; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@BeforeClass
public static void setup() {
binder.buildAndBind("flightId");
form.airline = (TextField) binder.getFieldForProperty("flightId.airline").get();
form.flightNumber = (TextField) binder.getFieldForProperty("flightId.flightNumber").get();
form.flightSuffix = (TextField) binder.getFieldForProperty("flightId.flightSuffix").get();
form.date = (DateField) binder.getFieldForProperty("flightId.date").get();
form.legType = (AbstractSingleSelect<LegType>) binder.getFieldForProperty("flightId.legType").get();
form.sbt = (DateTimeField) binder.getFieldForProperty("sbt").get();
form.ebt = (DateTimeField) binder.getFieldForProperty("ebt").get();
form.abt = (DateTimeField) binder.getFieldForProperty("abt").get();
form.gate = (TextField) binder.getFieldForProperty("gate").get();
form.canceled = (CheckBox) binder.getFieldForProperty("canceled").get();
}
示例2: valueChange
import com.vaadin.ui.DateField; //导入依赖的package包/类
@Override
public void valueChange(final Property.ValueChangeEvent event) {
// do not delete this method, even when removing the code inside this
// method. This method overwrites the super method, which is
// necessary, that parsing works correctly on pressing enter key
if (!(event.getProperty() instanceof DurationField)) {
return;
}
final Date value = (Date) event.getProperty().getValue();
// setValue() calls valueChanged again, when the minimum is greater
// than the maximum this can lead to an endless loop
if (value != null && minimumDuration != null && maximumDuration != null
&& minimumDuration.before(maximumDuration)) {
if (compareTimeOfDates(value, maximumDuration) > 0) {
((DateField) event.getProperty()).setValue(maximumDuration);
}
if (compareTimeOfDates(minimumDuration, value) > 0) {
((DateField) event.getProperty()).setValue(minimumDuration);
}
}
}
示例3: genDateField
import com.vaadin.ui.DateField; //导入依赖的package包/类
public static <T> DateField genDateField(Binder<T> binder, String propertyId, final java.text.SimpleDateFormat dateFormat) {
DateField dateField = new DateField();
binder.bind(dateField, propertyId);
if (dateFormat != null) {
dateField.setDateFormat(dateFormat.toPattern());
}
dateField.setWidth("100%");
dateField.setResolution(DateResolution.DAY);
dateField.addStyleName(STYLENAME_GRIDCELLFILTER);
dateField.addStyleName(ValoTheme.DATEFIELD_TINY);
dateField.addValueChangeListener(e -> {
if (binder.isValid()) {
dateField.setComponentError(null);
}
});
return dateField;
}
示例4: buildEntryForm
import com.vaadin.ui.DateField; //导入依赖的package包/类
protected FormLayout buildEntryForm() {
FormLayout form = new FormLayout();
form.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
form.setMargin(true);
nameField = new TextField("Name");
nameField.setValue(releasePackage.getName() != null ? releasePackage.getName() : "");
nameField.setReadOnly(releasePackage.isReleased());
form.addComponent(nameField);
versionLabelField = new TextField("Version");
versionLabelField.setValue(releasePackage.getVersionLabel() != null ? releasePackage.getVersionLabel() : "");
versionLabelField.setReadOnly(releasePackage.isReleased());
form.addComponent(versionLabelField);
releaseDateField = new DateField("Release Date");
releaseDateField.setValue(releasePackage.getReleaseDate() != null ? releasePackage.getReleaseDate() : null);
releaseDateField.setReadOnly(releasePackage.isReleased());
form.addComponent(releaseDateField);
return form;
}
示例5: initComponents
import com.vaadin.ui.DateField; //导入依赖的package包/类
private void initComponents() {
companyNameTextField = new TextField("Name");
companyStreetTextField = new TextField("Street");
companyCityTextField = new TextField("City");
companyPostcodeTextField = new TextField("Postcode");
customerNameTextField = new TextField("Name");
customerStreetTextField = new TextField("Street");
customerCityTextField = new TextField("City");
customerPostcodeTextField = new TextField("Postcode");
invoiceDateField = new DateField("Invoice Date");
dueDateField = new DateField("Due Date");
companyLabel = new Label("<b>Company</b>", ContentMode.HTML);
customerLabel = new Label("<b>Customer</b>", ContentMode.HTML);
invoiceInfoLabel = new Label("<b>Invoice Information</b>", ContentMode.HTML);
referenceNumberField = new TextField("Reference Number");
invoiceNumberField = new TextField("Invoice Number");
}
示例6: ReportParameterDateTimeRange
import com.vaadin.ui.DateField; //导入依赖的package包/类
public ReportParameterDateTimeRange(String caption, String startParameterName, String endParameterName)
{
super(caption, new String[] { startParameterName, endParameterName });
Preconditions.checkNotNull(startParameterName);
Preconditions.checkNotNull(endParameterName);
this.startParameterName = startParameterName;
this.endParameterName = endParameterName;
startfield = new DateField(caption, new DateTime().withTimeAtStartOfDay().toDate());
startfield.setResolution(Resolution.DAY);
startfield.setDateFormat("yyyy/MM/dd");
startfield.setValidationVisible(true);
endfield = new DateField("To", new DateTime().withTimeAtStartOfDay().toDate());
endfield.setResolution(Resolution.DAY);
endfield.setDateFormat("yyyy/MM/dd");
endfield.setValidationVisible(true);
createValidators();
endAdjustment = -1;
}
示例7: setValueAsString
import com.vaadin.ui.DateField; //导入依赖的package包/类
@Override
public void setValueAsString(String value, String parameterName)
throws ReadOnlyException, ConversionException, ParseException
{
SimpleDateFormat sdf = new SimpleDateFormat(parameterFormat);
DateField field;
if (parameterName.equalsIgnoreCase(startParameterName))
{
field = startfield;
}
else
{
field = endfield;
}
field.setValue(sdf.parse(value));
}
示例8: valueChange
import com.vaadin.ui.DateField; //导入依赖的package包/类
@Override
public void valueChange(final ValueChangeEvent event)
{
// The start date has just changed so make certain the end date is in
// the future
// by default we set it to two hours into the future.
final DateField startDateField = (DateField) event.getProperty();
final DateTime startDate = new DateTime(startDateField.getValue());
if (this.endDateField.getValue() != null && this.endDateField.getValue().before(startDate.toDate()))
{
this.endDateField.setValue(startDate.plusHours(2).toDate());
}
}
示例9: valueChange
import com.vaadin.ui.DateField; //导入依赖的package包/类
@Override
public void valueChange(final ValueChangeEvent event)
{
if (!this.readonly)
{
// The start date has just changed so make certain the end date is
// in
// the future
// by default we set it to two hours into the future.
final DateField startDateField = (DateField) event.getProperty();
final DateTime startDate = new DateTime(startDateField.getValue());
if (this.endDateField.getValue() != null && this.endDateField.getValue().before(startDateField.getValue()))
{
this.endDateField.setValue(startDate.plusHours(2).toDate());
}
}
}
示例10: valueChange
import com.vaadin.ui.DateField; //导入依赖的package包/类
@Override
public void valueChange(final ValueChangeEvent event)
{
// The start date has just changed so make certain the end date is in
// the future
// by default we set it to two hours into the future.
final DateField startDateField = (DateField) event.getProperty();
final DateTime startDate = new DateTime(startDateField.getValue());
if (this.endDateField.getValue() != null && this.endDateField.getValue().before(startDateField.getValue()))
{
this.endDateField.setValue(startDate.plusHours(2).toDate());
}
}
示例11: LocalDateField
import com.vaadin.ui.DateField; //导入依赖的package包/类
public LocalDateField(Boolean tiny) {
dateField = new DateField();
if (tiny){
dateField.addStyleName(ValoTheme.DATEFIELD_TINY);
}
dateField.setWidth(100,Unit.PERCENTAGE);
dateField.addValueChangeListener(e->showOrHideErrorDateField());
dateField.setImmediate(true);
}
示例12: LocalDateTimeField
import com.vaadin.ui.DateField; //导入依赖的package包/类
public LocalDateTimeField() {
dateField = new DateField();
dateField.addValueChangeListener(e->showOrHideErrorDateField());
hourNs = new NativeSelect();
hourNs.addValueChangeListener(e->fireValueChange(false));
minuteNs = new NativeSelect();
minuteNs.addValueChangeListener(e->fireValueChange(false));
hlContent = new HorizontalLayout();
//hlContent.setSizeFull();
hlContent.setSpacing(true);
dateField.setImmediate(true);
hlContent.addComponent(dateField);
for (Integer i = 0; i<24; i++){
hourNs.addItem(i);
hourNs.setItemCaption(i, MethodUtils.getLabelMinuteHeure(i));
}
hourNs.setNullSelectionAllowed(false);
hourNs.setImmediate(true);
hourNs.setValue(0);
for (Integer i = 0; i<60; i++){
minuteNs.addItem(i);
minuteNs.setItemCaption(i, MethodUtils.getLabelMinuteHeure(i));
}
minuteNs.setNullSelectionAllowed(false);
minuteNs.setImmediate(true);
minuteNs.setValue(0);
hlContent.addComponent(hourNs);
hlContent.setComponentAlignment(hourNs, Alignment.MIDDLE_LEFT);
Label label1 = new Label(":");
hlContent.addComponent(label1);
hlContent.setComponentAlignment(label1, Alignment.MIDDLE_LEFT);
hlContent.addComponent(minuteNs);
hlContent.setComponentAlignment(minuteNs, Alignment.MIDDLE_LEFT);
Label label2 = new Label("(HH:MM)");
hlContent.addComponent(label2);
hlContent.setComponentAlignment(label2, Alignment.MIDDLE_LEFT);
}
示例13: buildAndBind
import com.vaadin.ui.DateField; //导入依赖的package包/类
/** ajoute le champs ainsi que le validateur, le required, et initialise le field
* @param caption
* @param propertyId
* @return le field
*/
public Field<?> buildAndBind(String caption, String propertyId) {
Field<?> field = super.buildAndBind(caption, propertyId);
if (MethodUtils.getIsNotNull(this.beanType,propertyId)){
field.setRequiredError(applicationContext.getMessage("validation.obigatoire", null, UI.getCurrent().getLocale()));
field.setRequired(true);
}
if (field instanceof AbstractTextField) {
((AbstractTextField) field).setNullRepresentation("");
((AbstractTextField) field).setNullSettingAllowed(true);
}
if (field instanceof DateField) {
((DateField)field).setParseErrorMessage(applicationContext.getMessage("validation.parse.date", null, UI.getCurrent().getLocale()));
}
if (field instanceof RequiredIntegerField) {
((RequiredIntegerField)field).setConversionError(applicationContext.getMessage("validation.parse.int", null, UI.getCurrent().getLocale()));
}
if (field instanceof I18nField) {
if (cacheController.getLangueEnServiceWithoutDefault().size()!=0){
field.setRequiredError(applicationContext.getMessage("validation.i18n.obigatoire", null, UI.getCurrent().getLocale()));
}
field.addValidator(new I18nValidator(applicationContext.getMessage("validation.i18n.one.missing", null, UI.getCurrent().getLocale()),
applicationContext.getMessage("validation.i18n.same.lang", null, UI.getCurrent().getLocale())));
}
IRequiredField requiredField = (IRequiredField) field;
requiredField.initField(true);
return field;
}
示例14: provideEditorComponent
import com.vaadin.ui.DateField; //导入依赖的package包/类
@Override
public DateField provideEditorComponent(ColumnDefinition columnDefinition) {
DateField dateField = new DateField();
if (columnDefinition.getFormat().isPresent()) {
dateField.setDateFormat(columnDefinition.getFormat().get());
} else if (configurationProvider.getDateFormatPattern().isPresent()) {
dateField.setDateFormat(configurationProvider.getDateFormatPattern().get());
}
return dateField;
}
示例15: getDateField
import com.vaadin.ui.DateField; //导入依赖的package包/类
/**
* @param caption
* @param bindName
* @return
*/
private DateField getDateField(String caption, String bindName) {
DateField dateField = new DateField(caption);
dateField.setImmediate(true);
dateField.setValidationVisible(false);
dateField.setDateFormat(DATE_FORMAT);
fieldGroup.bind(dateField, bindName);
return dateField;
}