@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(); }
@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); } } }
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; }
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; }
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"); }
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; }
@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)); }
@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()); } }
@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()); } } }
@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()); } }
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); }
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); }
/** 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; }
@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; }
/** * @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; }
protected void initForm() { form = new Form(); form.setValidationVisibleOnCommit(true); form.setImmediate(true); addComponent(form); // name nameField = new TextField(i18nManager.getMessage(Messages.TASK_NAME)); nameField.focus(); nameField.setRequired(true); nameField.setRequiredError(i18nManager.getMessage(Messages.TASK_NAME_REQUIRED)); form.addField("name", nameField); // description descriptionArea = new TextArea(i18nManager.getMessage(Messages.TASK_DESCRIPTION)); descriptionArea.setColumns(25); form.addField("description", descriptionArea); // duedate dueDateField = new DateField(i18nManager.getMessage(Messages.TASK_DUEDATE)); dueDateField.setResolution(DateField.RESOLUTION_DAY); form.addField("duedate", dueDateField); // priority priorityComboBox = new PriorityComboBox(i18nManager); form.addField("priority", priorityComboBox); }
protected void initDueDateField() { dueDateField = new DateField(); if (task.getDueDate() != null) { dueDateField.setValue(task.getDueDate()); } else { dueDateField.setValue(new Date()); } dueDateField.setWidth(125, UNITS_PIXELS); dueDateField.setResolution(DateField.RESOLUTION_DAY); dueDateField.setImmediate(true); }
@Override public DateIntervalFilterEditor<A> getCopy() { DateField newStart = new DateField(); DateField newEnd = new DateField(); newStart.setValue(start.getValue()); newEnd.setValue(end.getValue()); DateIntervalFilterEditor<A> res = new DateIntervalFilterEditor<A>( localizer); res.end = newEnd; res.start = newStart; return res; }
@Test public void testDynamicEnums() throws Exception { URL url = ClassLoader.getSystemResource(PARSER_TEST_DYNAMIC_ENUM); VisualTreeNode visualTreeNode = Parser.parse(url, null); DateField fieldSecond = visualTreeNode.findComponentById("dateFieldSecond"); DateField fieldMonth = visualTreeNode.findComponentById("dateFieldMonth"); assertThat(fieldSecond.getResolution()).isEqualTo(Resolution.SECOND); assertThat(fieldMonth.getResolution()).isEqualTo(Resolution.MONTH); }
/** * Creates a date field. * @param pid property name. * @param propertyType property type. * @return a new field to select a date. */ public Field createDateField(String pid, Class<?> propertyType) { Field field = null; if(Date.class.isAssignableFrom(propertyType)) { DateField dateField = new DateField(); dateField.setResolution(DateField.RESOLUTION_DAY); dateField.setDateFormat(Utils.getDateFormatPattern()); field = dateField; } return field; }
@SuppressWarnings("rawtypes") private void generateFilterComponents() { for (Map.Entry<String, Object> entry : internalFilterComponents.entrySet()) { String key = entry.getKey(); Component component = (Component) entry.getValue(); if (component instanceof TextField) parameters.put(key, ((TextField)component).getValue()); else if (component instanceof CheckBox) parameters.put(key, ((CheckBox)component).getValue()); else if (component instanceof DateField) parameters.put(key, ((DateField)component).getValue()); else if (component instanceof ComboBox) { ListParameter parameter; try { parameter = (ListParameter) getParamByKey(key); Class c = ((ComboBox)component).getValue().getClass(); Method m = c.getMethod(toProperty(parameter.getValueId()), null); parameters.put(key, m.invoke(((ComboBox) component).getValue())); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
public DateField bindDateField(String label, String member, String dateFormat, Resolution resolution) { DateField field = bindDateField(form, group, label, member, dateFormat, resolution); field.setWidth(STANDARD_COMBO_WIDTH); this.fieldList.add(field); return field; }
public DateField bindDateField(String label, SingularAttribute<? super E, Date> member, String dateFormat, Resolution resolution) { DateField field = bindDateField(form, group, label, member.getName(), dateFormat, resolution); field.setWidth(STANDARD_COMBO_WIDTH); this.fieldList.add(field); return field; }
public <M> DateField bindDateField(AbstractLayout form, ValidatingFieldGroup<E> group, String fieldLabel, SingularAttribute<E, M> member, String dateFormat, Resolution resolution) { DateField field = bindDateField(form, group, fieldLabel, member.getName(), dateFormat, resolution); this.fieldList.add(field); return field; }
public DateField bindDateField(AbstractLayout form, ValidatingFieldGroup<E> group, String fieldLabel, String fieldName, String dateFormat, Resolution resolution) { DateField field = new SplitDateField(fieldLabel); field.setDateFormat(dateFormat); field.setResolution(resolution); field.setImmediate(true); field.setWidth("100%"); addValueChangeListeners(field); doBinding(group, fieldName, field); form.addComponent(field); return field; }
public DateField bindDateField(String fieldLabel, SingularAttribute<E, ? extends Date> dateField, String dateFormat, Resolution resolution) { DateField field = formHelper.bindDateField(this, fieldGroup, fieldLabel, dateField, dateFormat, resolution); this.fieldList.add(field); return field; }
/** * * @param caption * - shown on the UI * @param parameterName * - parameter name passed to ireport * @param resolution * - Vaadin calendar control resolution * @param displayFormat * - format to display to the user * @param parameterFormat * - format of the value passed to ireport */ public ReportParameterDateTimeRange(String caption, String startParameterName, String endParameterName, Resolution resolution, String displayFormat, String parameterFormat, int endAdjustment) { super(caption, new String[] { startParameterName, endParameterName }); Preconditions.checkNotNull(startParameterName); Preconditions.checkNotNull(endParameterName); this.startParameterName = startParameterName; this.endParameterName = endParameterName; startfield = new DateField(caption, new DateTime().toDate()); startfield.setResolution(resolution); startfield.setDateFormat(displayFormat); this.parameterFormat = parameterFormat; startfield.setImmediate(true); startfield.setValidationVisible(true); endfield = new DateField("To", new DateTime().toDate()); endfield.setResolution(resolution); endfield.setDateFormat(displayFormat); this.parameterFormat = parameterFormat; endfield.setImmediate(true); endfield.setValidationVisible(true); createValidators(); this.endAdjustment = endAdjustment; }
public EntityParamUpdater(String name, ComboBox offsetType, DateField startDateField, TimePicker startTimePicker, DateField endDateField, TimePicker endTimePicker) { this.name = name; this.offsetType = offsetType; this.startDateField = startDateField; this.startTimePicker = startTimePicker; this.endDateField = endDateField; this.endTimePicker = endTimePicker; }
private void backgroundTab() { // Background tab final SMMultiColumnFormLayout<Contact> background = new SMMultiColumnFormLayout<Contact>(2, this.fieldGroup); background.setColumnLabelWidth(0, 120); this.tabs.addTab(background, "Background"); background.setMargin(true); background.colspan(2); background.bindTextAreaField("Hobbies", Contact_.hobbies, 4); background.newLine(); background.colspan(2); background.bindDateField("Affiliated Since", Contact_.affiliatedSince, "yyyy-MM-dd", Resolution.DAY); background.newLine(); background.colspan(2); background.bindTextField("Current Employer", Contact_.currentEmployer); background.newLine(); background.colspan(2); background.bindTextField("Job Title", Contact_.jobTitle); background.newLine(); background.bindBooleanField("License", Contact_.hasLicense); background.newLine(); background.bindBooleanField("Has WWC", Contact_.hasWWC); final DateField wwcExpiryDate = background.bindDateField("WWC Expiry", Contact_.wwcExpiry, "yyyy-MM-dd", Resolution.DAY); // WWC expiry is five years. wwcExpiryDate.setValue(new DateTime().plusYears(5).toDate()); background.bindTextField("WWC No.", Contact_.wwcNo); background.newLine(); background.bindBooleanField("Has Police Check", Contact_.hasPoliceCheck); final DateField policeCheckExpiry = background.bindDateField("Police Check Expiry", Contact_.policeCheckExpiry, "yyyy-MM-dd", Resolution.DAY); policeCheckExpiry.setValue(new DateTime().plusYears(5).toDate()); background.newLine(); background.bindBooleanField("Has Food Handling", Contact_.hasFoodHandlingCertificate); background.bindBooleanField("Has First Aid Certificate", Contact_.hasFirstAidCertificate); }
/** * Create a new DateField with format for current locale and given style. * @param style DateFormat style * @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; }
@Override protected DateField buildInternalField(Class<? extends T> type) { DateField field = isInline() ? new InlineDateField() : new DateField(); configureDateField(field); return field; }
@Override protected void configureDateField(DateField field) { field.setResolution(Resolution.DAY); field.setConverter(new DateToLocalDateConverter()); }
@Override protected void configureDateField(DateField field) { field.setResolution(Resolution.MINUTE); field.setConverter(new DateToLocalDateTimeConverter()); }
public DateField getField() { return field; }
@Override protected AbstractDateField<LocalDate, ?> buildInternalField(Class<? extends LocalDate> type) { return isInline() ? new InlineDateField() : new DateField(); }
private void createOptionGroup() { autoStartOptionGroup = new FlexibleOptionGroup(); autoStartOptionGroup.addItem(AutoStartOption.MANUAL); autoStartOptionGroup.addItem(AutoStartOption.AUTO_START); autoStartOptionGroup.addItem(AutoStartOption.SCHEDULED); selectDefaultOption(); final FlexibleOptionGroupItemComponent manualItem = autoStartOptionGroup .getItemComponent(AutoStartOption.MANUAL); manualItem.setStyleName(STYLE_DIST_WINDOW_AUTO_START); // set Id for Forced radio button. manualItem.setId(UIComponentIdProvider.ROLLOUT_START_MANUAL_ID); addComponent(manualItem); final Label manualLabel = new Label(); manualLabel.setStyleName("statusIconPending"); manualLabel.setIcon(FontAwesome.HAND_PAPER_O); manualLabel.setCaption(i18n.getMessage("caption.rollout.start.manual")); manualLabel.setDescription(i18n.getMessage("caption.rollout.start.manual.desc")); manualLabel.setStyleName("padding-right-style"); addComponent(manualLabel); final FlexibleOptionGroupItemComponent autoStartItem = autoStartOptionGroup .getItemComponent(AutoStartOption.AUTO_START); autoStartItem.setId(UIComponentIdProvider.ROLLOUT_START_AUTO_ID); autoStartItem.setStyleName(STYLE_DIST_WINDOW_AUTO_START); addComponent(autoStartItem); final Label autoStartLabel = new Label(); autoStartLabel.setSizeFull(); autoStartLabel.setIcon(FontAwesome.PLAY); autoStartLabel.setCaption(i18n.getMessage("caption.rollout.start.auto")); autoStartLabel.setDescription(i18n.getMessage("caption.rollout.start.auto.desc")); autoStartLabel.setStyleName("padding-right-style"); addComponent(autoStartLabel); final FlexibleOptionGroupItemComponent scheduledItem = autoStartOptionGroup .getItemComponent(AutoStartOption.SCHEDULED); scheduledItem.setStyleName(STYLE_DIST_WINDOW_AUTO_START); // setted Id for Time Forced radio button. scheduledItem.setId(UIComponentIdProvider.ROLLOUT_START_SCHEDULED_ID); addComponent(scheduledItem); final Label scheduledLabel = new Label(); scheduledLabel.setStyleName("statusIconPending"); scheduledLabel.setIcon(FontAwesome.CLOCK_O); scheduledLabel.setCaption(i18n.getMessage("caption.rollout.start.scheduled")); scheduledLabel.setDescription(i18n.getMessage("caption.rollout.start.scheduled.desc")); scheduledLabel.setStyleName(STYLE_DIST_WINDOW_AUTO_START); addComponent(scheduledLabel); startAtDateField = new DateField(); startAtDateField.setInvalidAllowed(false); startAtDateField.setInvalidCommitted(false); startAtDateField.setEnabled(false); startAtDateField.setStyleName("dist-window-forcedtime"); final TimeZone tz = SPDateTimeUtil.getBrowserTimeZone(); startAtDateField.setValue( Date.from(LocalDateTime.now().plusMinutes(30).atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant())); startAtDateField.setImmediate(true); startAtDateField.setTimeZone(tz); startAtDateField.setLocale(HawkbitCommonUtil.getLocale()); startAtDateField.setResolution(Resolution.MINUTE); startAtDateField.addStyleName(ValoTheme.DATEFIELD_SMALL); addComponent(startAtDateField); }
public DateField getStartAtDateField() { return startAtDateField; }