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); }
void configureComponents() { saveButton.setClickShortcut(ShortcutAction.KeyCode.ENTER); saveButton.setStyleName(ValoTheme.BUTTON_PRIMARY); cloneDinnerButton.setStyleName(ValoTheme.BUTTON_FRIENDLY); removeButton.setStyleName(ValoTheme.BUTTON_DANGER); dinnerDate.setResolution(Resolution.DAY); soup.setContainerDataSource(new BeanItemContainer<>(DinnerComponent.class)); meat.setContainerDataSource(new BeanItemContainer<>(DinnerComponent.class)); starch.setContainerDataSource(new BeanItemContainer<>(DinnerComponent.class)); vegetables.setContainerDataSource(new BeanItemContainer<>(DinnerComponent.class)); }
private DateField getDateField(TimeZone timezone, SimpleDateFormat dateformat) { final DateField dateField = new DateField(); try { Date initialDate = dateformat.parse(initialDateString); dateField.setResolution(Resolution.DAY); dateField.setTimeZone(timezone); dateField.setValue(initialDate); } catch (ParseException e) { e.printStackTrace(); } return dateField; }
@Override protected void setup() { Locale locale = new Locale("fi", "FI"); Calendar cal = Calendar.getInstance(); cal.set(2010, 0, 1); DateField df = new DateField(); df.setResolution(Resolution.DAY); df.setLocale(locale); df.setWidth("300px"); String pattern = "d. MMMM'ta 'yyyy 'klo 'H.mm.ss"; df.setDateFormat(pattern); df.setValue(cal.getTime()); addComponent(df); }
/** * The constructor should first build the main layout, set the composition root and then do any * custom initialization. * * <p>The constructor will not be automatically regenerated by the visual editor. * * @throws Exception * @throws IllegalArgumentException */ public JobViewForm() throws IllegalArgumentException, Exception { buildMainLayout(); setCompositionRoot(mainLayout); // TODO add user code here initComponents(); cronExpressionField.setVisible(false); future_timeField.setEnabled(false); startTimeField.setResolution(DateField.RESOLUTION_SEC); endTimeField.setResolution(DateField.RESOLUTION_SEC); // configure Type data areaField.setItemCaptionMode(Select.ITEM_CAPTION_MODE_PROPERTY); areaField.setItemCaptionPropertyId("name"); jobTriggerTypeField.setItemCaptionMode(Select.ITEM_CAPTION_MODE_PROPERTY); jobTriggerTypeField.setItemCaptionPropertyId("description"); jobIntervalTypeField.setItemCaptionMode(Select.ITEM_CAPTION_MODE_PROPERTY); jobIntervalTypeField.setItemCaptionPropertyId("description"); // get form services from OSGi Service Registry getServices(); // load data sources loadData(); futureField.setImmediate(true); futureField.addListener( new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (event.getProperty().getValue() == null) return; if ((Boolean) event.getProperty().getValue()) future_timeField.setEnabled(true); else { future_timeField.setValue(null); future_timeField.setEnabled(false); } } }); jobTriggerTypeField.setImmediate(true); jobTriggerTypeField.setNullSelectionAllowed(false); jobTriggerTypeField.addListener( new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (event.getProperty().getValue() == null) return; if (((JobTriggerType) event.getProperty().getValue()) .getCode() .equals(Job.JOB_TRIGGER_TYPE.SIMPLE.name())) { jobIntervalField.setVisible(true); jobIntervalTypeField.setVisible(true); repeatCountField.setVisible(true); cronExpressionField.setVisible(false); } else { jobIntervalField.setVisible(false); jobIntervalTypeField.setVisible(false); repeatCountField.setVisible(false); cronExpressionField.setVisible(true); } } }); }
public DateFields() { setMargin(true); Label h1 = new Label("Date Fields"); h1.addStyleName(ValoTheme.LABEL_H1); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING); row.setSpacing(true); addComponent(row); DateField date = new DateField("Default resolution"); setDate(date); row.addComponent(date); date = new DateField("Error"); setDate(date); date.setComponentError(new UserError("Fix it, now!")); row.addComponent(date); date = new DateField("Error, borderless"); setDate(date); date.setComponentError(new UserError("Fix it, now!")); date.addStyleName(ValoTheme.DATEFIELD_BORDERLESS); row.addComponent(date); CssLayout group = new CssLayout(); group.setCaption("Grouped with a Button"); group.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); row.addComponent(group); final DateField date2 = new DateField(); group.addComponent(date2); Button today = new Button( "Today", new ClickListener() { @Override public void buttonClick(ClickEvent event) { date2.setValue(new Date()); } }); group.addComponent(today); date = new DateField("Default resolution, explicit size"); setDate(date); row.addComponent(date); date.setWidth("260px"); date.setHeight("60px"); date = new DateField("Second resolution"); setDate(date); date.setResolution(Resolution.SECOND); row.addComponent(date); date = new DateField("Minute resolution"); setDate(date); date.setResolution(Resolution.MINUTE); row.addComponent(date); date = new DateField("Hour resolution"); setDate(date); date.setResolution(Resolution.HOUR); row.addComponent(date); date = new DateField("Disabled"); setDate(date); date.setResolution(Resolution.HOUR); date.setEnabled(false); row.addComponent(date); date = new DateField("Day resolution"); setDate(date); date.setResolution(Resolution.DAY); row.addComponent(date); date = new DateField("Month resolution"); setDate(date); date.setResolution(Resolution.MONTH); row.addComponent(date); date = new DateField("Year resolution"); setDate(date); date.setResolution(Resolution.YEAR); row.addComponent(date); date = new DateField("Custom color"); setDate(date); date.setResolution(Resolution.DAY); date.addStyleName("color1"); row.addComponent(date); date = new DateField("Custom color"); setDate(date); date.setResolution(Resolution.DAY); date.addStyleName("color2"); row.addComponent(date); date = new DateField("Custom color"); setDate(date); date.setResolution(Resolution.DAY); date.addStyleName("color3"); row.addComponent(date); date = new DateField("Small"); setDate(date); date.setResolution(Resolution.DAY); date.addStyleName(ValoTheme.DATEFIELD_SMALL); row.addComponent(date); date = new DateField("Large"); setDate(date); date.setResolution(Resolution.DAY); date.addStyleName(ValoTheme.DATEFIELD_LARGE); row.addComponent(date); date = new DateField("Borderless"); setDate(date); date.setResolution(Resolution.DAY); date.addStyleName(ValoTheme.DATEFIELD_BORDERLESS); row.addComponent(date); date = new DateField("Week numbers"); setDate(date); date.setResolution(Resolution.DAY); date.setLocale(new Locale("fi", "fi")); date.setShowISOWeekNumbers(true); row.addComponent(date); date = new DateField("US locale"); setDate(date); date.setResolution(Resolution.SECOND); date.setLocale(new Locale("en", "US")); row.addComponent(date); date = new DateField("Custom format"); setDate(date); date.setDateFormat("E dd/MM/yyyy"); row.addComponent(date); date = new DateField("Tiny"); setDate(date); date.setResolution(Resolution.DAY); date.addStyleName(ValoTheme.DATEFIELD_TINY); row.addComponent(date); date = new DateField("Huge"); setDate(date); date.setResolution(Resolution.DAY); date.addStyleName(ValoTheme.DATEFIELD_HUGE); row.addComponent(date); date = new InlineDateField("Date picker"); setDate(date); setDateRange(date); row.addComponent(date); date = new InlineDateField("Date picker with week numbers"); setDate(date); date.setLocale(new Locale("fi", "fi")); date.setShowISOWeekNumbers(true); row.addComponent(date); PropertysetItem item = new PropertysetItem(); item.addItemProperty("date", new ObjectProperty<Date>(getDefaultDate())); FormLayout form = new FormLayout(); form.setMargin(false); FieldGroup binder = new FieldGroup(item); form.addComponent(binder.buildAndBind("Picker in read-only field group", "date")); binder.setReadOnly(true); row.addComponent(form); }