List of usage examples for com.vaadin.ui DateField DateField
public DateField()
DateField
with no caption. From source file:org.generationcp.breeding.manager.crossingmanager.AdditionalDetailsCrossInfoComponent.java
License:Open Source License
@Override public void afterPropertiesSet() throws Exception { setHeight("95px"); setWidth("700px"); harvestDateLabel = new Label(); harvestDtDateField = new DateField(); harvestDtDateField.setResolution(DateField.RESOLUTION_DAY); harvestDtDateField.setDateFormat(CrossingManagerMain.DATE_FORMAT); harvestLocationLabel = new Label(); harvestLocComboBox = new ComboBox(); harvestLocComboBox.setWidth("400px"); harvestLocComboBox.setNullSelectionAllowed(true); // layout components addComponent(harvestDateLabel, "top:30px;left:20px"); addComponent(harvestDtDateField, "top:10px;left:140px"); addComponent(harvestLocationLabel, "top:60px;left:20px"); addComponent(harvestLocComboBox, "top:40px;left:140px"); locations = germplasmDataManager.getAllBreedingLocations(); populateHarvestLocation();/*from w ww . j a v a 2 s.c o m*/ }
From source file:org.generationcp.breeding.manager.crossingmanager.CrossingManagerDetailsComponent.java
License:Open Source License
@Override public void afterPropertiesSet() throws Exception { setHeight("300px"); setWidth("800px"); germplasmListNameLabel = new Label(); germplasmListDescriptionLabel = new Label(); germplasmListTypeLabel = new Label(); germplasmListDateLabel = new Label(); germplasmListName = new TextField(); germplasmListDescription = new TextField(); germplasmListType = new ComboBox(); germplasmListDate = new DateField(); backButton = new Button(); backButton.setData(BACK_BUTTON_ID);/*from ww w. j a va 2 s .c om*/ doneButton = new Button(); doneButton.setData(DONE_BUTTON_ID); germplasmListName.setWidth("450px"); germplasmListDescription.setWidth("450px"); germplasmListType.setWidth("450px"); germplasmListType.setNullSelectionAllowed(false); addComponent(germplasmListNameLabel, "top:50px; left:30px;"); addComponent(germplasmListDescriptionLabel, "top:80px; left:30px;"); addComponent(germplasmListTypeLabel, "top:110px; left:30px;"); addComponent(germplasmListDateLabel, "top:140px; left:30px;"); addComponent(germplasmListName, "top:30px; left:200px;"); addComponent(germplasmListDescription, "top:60px; left:200px;"); addComponent(germplasmListType, "top:90px; left:200px;"); addComponent(germplasmListDate, "top:120px; left:200px;"); addComponent(backButton, "top:260px; left: 625px;"); addComponent(doneButton, "top:260px; left: 700px;"); germplasmListDate.setResolution(DateField.RESOLUTION_DAY); germplasmListDate.setDateFormat(CrossingManagerMain.DATE_FORMAT); germplasmListDate.setResolution(DateField.RESOLUTION_DAY); germplasmListDate.setValue(new Date()); initializeListTypeComboBox(); CrossingManagerImportButtonClickListener listener = new CrossingManagerImportButtonClickListener(this); doneButton.addListener(listener); backButton.addListener(listener); }
From source file:org.investovator.ui.nngaming.StockAnalysisView.java
License:Open Source License
private void createDatePickers() { startDatePicker = new DateField(); startDatePicker.setImmediate(true);//from w w w . j ava 2 s .co m startDatePicker.setTimeZone(TimeZone.getTimeZone("UTC")); startDatePicker.setLocale(Locale.US); startDatePicker.setResolution(Resolution.DAY); startDatePicker.setCaption("Start Date"); startDatePicker.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(final Property.ValueChangeEvent event) { final String valueString = String.valueOf(event.getProperty().getValue()); startDate = startDatePicker.getValue(); if (startDate.before(minDate) || startDate.after(maxDate)) { Notification.show("Please select a date within " + minDate + " - " + maxDate + " range", Notification.Type.TRAY_NOTIFICATION); return; } java.util.Calendar tmp = java.util.Calendar.getInstance(); tmp.setTime(startDate); tmp.add(java.util.Calendar.MONTH, 1); endDate = tmp.getTime(); endDatePicker.setRangeStart(startDate); endDatePicker.setRangeEnd(endDate); startDatePicker.setRangeStart(startDate); startDatePicker.setRangeEnd(endDate); endDatePicker.setValue(endDate); } }); endDatePicker = new DateField(); endDatePicker.setImmediate(true); endDatePicker.setTimeZone(TimeZone.getTimeZone("UTC")); endDatePicker.setLocale(Locale.US); endDatePicker.setResolution(Resolution.DAY); endDatePicker.setCaption("End Date"); endDatePicker.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(final Property.ValueChangeEvent event) { endDate = endDatePicker.getValue(); if (endDate.before(minDate) || endDate.after(maxDate)) { Notification.show("Please select a date within " + minDate + " - " + maxDate + " range", Notification.Type.TRAY_NOTIFICATION); return; } java.util.Calendar tmp = java.util.Calendar.getInstance(); tmp.setTime(endDate); tmp.add(java.util.Calendar.MONTH, -1); startDate = tmp.getTime(); startDatePicker.setRangeStart(startDate); startDatePicker.setRangeEnd(endDate); endDatePicker.setRangeStart(startDate); endDatePicker.setRangeEnd(endDate); startDatePicker.setValue(startDate); } }); startDatePicker.setWidth("100px"); endDatePicker.setWidth("100px"); }
From source file:org.jdal.vaadin.ui.FormUtils.java
License:Apache License
/** * Create a new DateField with format for current locale and given style. * @param style DateFormat style//w ww. java 2s .co m * @return a new DateField */ public static DateField newDateField(int style) { DateField df = new DateField(); Locale locale = LocaleContextHolder.getLocale(); df.setLocale(locale); DateFormat dateFormat = DateFormat.getDateInstance(style); if (dateFormat instanceof SimpleDateFormat) { SimpleDateFormat sdf = (SimpleDateFormat) dateFormat; df.setDateFormat(sdf.toPattern()); } return df; }
From source file:org.jpos.qi.components.DateRangeComponent.java
License:Open Source License
private DateField createDatePicker(String caption) { DateField field = new DateField(); field.setCaption(caption);/*from w w w . j a v a2 s . c o m*/ field.setStyleName(ValoTheme.DATEFIELD_SMALL); field.setDateFormat(app.getMessage("daterange.format")); field.setResolution(DateResolution.DAY); field.addValueChangeListener(event -> { if (event.getValue() != null && dateRanges != null) dateRanges.setValue(null); }); return field; }
From source file:org.lunifera.runtime.web.ecview.presentation.vaadin.internal.DateTimePresentation.java
License:Open Source License
/** * {@inheritDoc}//w w w . j ava 2 s . c om */ @Override public Component doCreateWidget(Object parent) { if (componentBase == null) { componentBase = new CssLayout(); componentBase.addStyleName(CSS_CLASS_CONTROL_BASE); if (modelAccess.isCssIdValid()) { componentBase.setId(modelAccess.getCssID()); } else { componentBase.setId(getEditpart().getId()); } associateWidget(componentBase, modelAccess.yDateTime); dateField = new DateField(); dateField.addStyleName(CSS_CLASS_CONTROL); dateField.setImmediate(true); associateWidget(dateField, modelAccess.yDateTime); property = new ObjectProperty<Date>(null, Date.class); dateField.setPropertyDataSource(property); // creates the binding for the field createBindings(modelAccess.yDateTime, dateField); componentBase.addComponent(dateField); if (modelAccess.isCssClassValid()) { dateField.addStyleName(modelAccess.getCssClass()); } doApplyDatatype(modelAccess.yDateTime.getDatatype()); applyCaptions(); initializeField(dateField); } return componentBase; }
From source file:org.vaadin.spring.samples.i18n.TranslatedUI.java
License:Apache License
@Override protected void initUI(VaadinRequest request) { final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true);/*w w w .ja v a2s . c om*/ layout.setSpacing(true); setContent(layout); english = new Button("English", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { setLocale(Locale.ENGLISH); } }); layout.addComponent(english); swedish = new Button("Svenska", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { setLocale(new Locale("sv")); } }); layout.addComponent(swedish); bigDecimalTextField = new TextField(); bigDecimalTextField.setConverter(new StringToBigDecimalConverter()); bigDecimalTextField.setPropertyDataSource(bigDecimalObjectProperty); bigDecimalTextField.setImmediate(true); bigDecimalTextField.setNullSettingAllowed(false); layout.addComponent(bigDecimalTextField); dateField = new DateField(); dateField.setValue(new Date()); layout.addComponent(dateField); }
From source file:pt.ist.vaadinframework.ui.DefaultFieldFactory.java
License:Open Source License
/** * @see pt.ist.vaadinframework.ui.AbstractFieldFactory#makeField(com.vaadin.data.Item, java.lang.Object, * com.vaadin.ui.Component)/* w w w .jav a2s . co m*/ */ @Override protected Field makeField(Item item, Object propertyId, Component uiContext) { Class<?> type = item.getItemProperty(propertyId).getType(); if (String.class.isAssignableFrom(type)) { TextField field = new TextField(); field.setNullSettingAllowed(true); field.setNullRepresentation(StringUtils.EMPTY); return field; } if (Collection.class.isAssignableFrom(type) && item.getItemProperty(propertyId) instanceof AbstractBufferedContainer) { return new ContainerEditor<Object>(this, bundlename, ((AbstractBufferedContainer<?, ?, ?>) item.getItemProperty(propertyId)).getElementType()); } if (AbstractDomainObject.class.isAssignableFrom(type)) { Select select = new Select(); select.setWidth(100, Sizeable.UNITS_PERCENTAGE); select.setImmediate(true); return select; } if (Collection.class.isAssignableFrom(type)) { OptionGroup group = new OptionGroup(); group.setMultiSelect(true); group.setWidth(100, Sizeable.UNITS_PERCENTAGE); group.setImmediate(true); return group; } if (Byte.class.isAssignableFrom(type)) { return new PrimitiveField(new ByteValidator(), Byte.toString(Byte.MAX_VALUE).length() + 1); } if (Short.class.isAssignableFrom(type)) { return new PrimitiveField(new ShortValidator(), Short.toString(Short.MAX_VALUE).length() + 1); } if (Integer.class.isAssignableFrom(type)) { return new PrimitiveField(new IntegerValidator(), Integer.toString(Integer.MAX_VALUE).length() + 1); } if (Long.class.isAssignableFrom(type)) { return new PrimitiveField(new LongValidator(), Long.toString(Long.MAX_VALUE).length() + 1); } if (Float.class.isAssignableFrom(type)) { return new PrimitiveField(new FloatValidator(), Float.toString(Float.MAX_VALUE).length() + 1); } if (Double.class.isAssignableFrom(type)) { return new PrimitiveField(new DoubleValidator(), Double.toString(Double.MAX_VALUE).length() + 1); } if (Boolean.class.isAssignableFrom(type)) { return new CheckBox(); } if (Character.class.isAssignableFrom(type)) { return new PrimitiveField(new CharacterValidator(), 1); } if (BigDecimal.class.isAssignableFrom(type)) { return new PrimitiveField(new BigDecimalValidator(), -1); } if (Enum.class.isAssignableFrom(type)) { return new EnumField((Class<? extends Enum<?>>) item.getItemProperty(propertyId).getType()); } if (Date.class.isAssignableFrom(type)) { DateField field = new DateField(); field.setResolution(DateField.RESOLUTION_DAY); return field; } if (Item.class.isAssignableFrom(type)) { Form form = new Form() { @Override public void setPropertyDataSource(Property newDataSource) { setItemDataSource((Item) newDataSource); }; }; form.setImmediate(true); form.setFormFieldFactory(this); return form; } if (MultiLanguageString.class.isAssignableFrom(type)) { return new MultiLanguageStringField(bundlename, Language.pt, Language.en); } if (DateTime.class.isAssignableFrom(type)) { PopupDateTimeField field = new PopupDateTimeField(); field.setResolution(DateField.RESOLUTION_SEC); return field; } if (LocalDate.class.isAssignableFrom(type)) { PopupLocalDateField field = new PopupLocalDateField(); field.setResolution(DateField.RESOLUTION_DAY); return field; } if (URL.class.isAssignableFrom(type)) { TextField field = new TextField(); field.setNullSettingAllowed(true); field.setNullRepresentation(StringUtils.EMPTY); field.addValidator(new URLValidator()); return field; } Select select = new Select(); select.setWidth(100, Sizeable.UNITS_PERCENTAGE); select.setImmediate(true); return select; }
From source file:ro.zg.netcell.vaadin.action.FormGenerator.java
License:Apache License
private Field getFieldForType(String uiType) { if (uiType == null) { return new TextField(); }/*from w w w . j av a 2 s .c om*/ if (uiType.equals("richtextarea")) { return new RichTextArea(); } if (uiType.equals("checkbox")) { return new CheckBox(); } if (uiType.equals("combobox")) { return new ComboBox(); } if (uiType.equals("date")) { final DateField df = new DateField(); df.setResolution(DateField.RESOLUTION_DAY); return df; } return new TextField(); }
From source file:uicomponents.LigandExtractPanel.java
License:Open Source License
public void setTissueSamples(List<AOpenbisSample> extracts) { extractionExperiments.removeAllItems(); tableIdToBarcode = new HashMap<Integer, String>(); int i = 0;/* ww w . j a v a2 s. c o m*/ for (AOpenbisSample s : extracts) { i++; tableIdToBarcode.put(i, s.getCode()); List<Object> row = new ArrayList<Object>(); row.add(s.getQ_SECONDARY_NAME()); row.add(generateTableIntegerInput()); DateField date = new DateField(); date.setDateFormat("dd.MM.yy"); date.setWidth("110px"); date.setStyleName(Styles.fieldTheme); row.add(date); row.add(generateTableAntibodyBox()); row.add(generateTableIntegerInput()); row.add(generateTableAntibodyBox()); row.add(generateTableIntegerInput()); row.add(generateTableAntibodyBox()); row.add(generateTableIntegerInput()); extractionExperiments.addItem(row.toArray(new Object[row.size()]), i); } extractionExperiments.setPageLength(extracts.size()); }