List of usage examples for com.vaadin.ui DateField DateField
public DateField(ValueChangeListener<LocalDate> valueChangeListener)
From source file:com.klwork.explorer.ui.task.NewTaskPopupWindow.java
License:Apache License
protected void initForm() { form = new Form(); form.setValidationVisibleOnCommit(true); form.setImmediate(true);//from w w w .j a v a2s.c o m setContent(form); // 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); }
From source file:com.morevaadin.vaadin.externallayout.View.java
License:Apache License
public View() { FormLayout layout = new FormLayout(); layout.addComponent(new TextField("First name")); layout.addComponent(new TextField("Last name")); layout.addComponent(new DateField("Birth date")); layout.addComponent(new Button("Submit")); setCompositionRoot(layout);/*w w w . j ava 2 s. c om*/ }
From source file:com.openhris.calendar.CalendarScheduleWindow.java
private DateField createDateField(String caption) { DateField f = new DateField(caption); f.setSizeFull();//from www . ja v a2 s. c om if (isUseSecondResolution()) { f.setResolution(DateField.RESOLUTION_SEC); } else { f.setResolution(DateField.RESOLUTION_MIN); } return f; }
From source file:com.pms.component.ganttchart.DemoUI.java
License:Apache License
private DateField createStartDateField() { DateField f = new DateField("Start date"); f.setResolution(Resolution.SECOND);/*from w w w. j a v a 2 s. co m*/ f.setImmediate(true); f.addValueChangeListener(startDateValueChangeListener); return f; }
From source file:com.pms.component.ganttchart.DemoUI.java
License:Apache License
private DateField createEndDateField() { DateField f = new DateField("End date"); f.setResolution(Resolution.SECOND);/* w w w .j a v a2 s . c o m*/ f.setImmediate(true); f.addValueChangeListener(endDateValueChangeListener); return f; }
From source file:com.pms.component.ganttchart.DemoUI.java
License:Apache License
private void openStepEditor(AbstractStep step) { final Window win = new Window("Step Editor"); win.setResizable(false);// w ww . ja va 2s. c o m win.center(); final Collection<Component> hidden = new ArrayList<Component>(); BeanItem<AbstractStep> item = new BeanItem<AbstractStep>(step); final FieldGroup group = new FieldGroup(item); group.setBuffered(true); TextField captionField = new TextField("Caption"); captionField.setNullRepresentation(""); group.bind(captionField, "caption"); TextField descriptionField = new TextField("Description"); descriptionField.setNullRepresentation(""); group.bind(descriptionField, "description"); descriptionField.setVisible(false); hidden.add(descriptionField); NativeSelect captionMode = new NativeSelect("Caption Mode"); captionMode.addItem(Step.CaptionMode.TEXT); captionMode.addItem(Step.CaptionMode.HTML); group.bind(captionMode, "captionMode"); captionMode.setVisible(false); hidden.add(captionMode); final NativeSelect parentStepSelect = new NativeSelect("Parent Step"); parentStepSelect.setEnabled(false); if (!gantt.getSteps().contains(step)) { // new step parentStepSelect.setEnabled(true); for (Step parentStepCanditate : gantt.getSteps()) { parentStepSelect.addItem(parentStepCanditate); parentStepSelect.setItemCaption(parentStepCanditate, parentStepCanditate.getCaption()); if (step instanceof SubStep) { if (parentStepCanditate.getSubSteps().contains(step)) { parentStepSelect.setValue(parentStepCanditate); parentStepSelect.setEnabled(false); break; } } } } parentStepSelect.setVisible(false); hidden.add(parentStepSelect); TextField bgField = new TextField("Background color"); bgField.setNullRepresentation(""); group.bind(bgField, "backgroundColor"); bgField.setVisible(false); hidden.add(bgField); DateField startDate = new DateField("Start date"); startDate.setLocale(gantt.getLocale()); startDate.setTimeZone(gantt.getTimeZone()); startDate.setResolution(Resolution.SECOND); startDate.setConverter(new DateToLongConverter()); group.bind(startDate, "startDate"); DateField endDate = new DateField("End date"); endDate.setLocale(gantt.getLocale()); endDate.setTimeZone(gantt.getTimeZone()); endDate.setResolution(Resolution.SECOND); endDate.setConverter(new DateToLongConverter()); group.bind(endDate, "endDate"); CheckBox showMore = new CheckBox("Show all settings"); showMore.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { for (Component c : hidden) { c.setVisible((Boolean) event.getProperty().getValue()); } win.center(); } }); VerticalLayout content = new VerticalLayout(); content.setMargin(true); content.setSpacing(true); win.setContent(content); content.addComponent(captionField); content.addComponent(captionMode); content.addComponent(descriptionField); content.addComponent(parentStepSelect); content.addComponent(bgField); content.addComponent(startDate); content.addComponent(endDate); content.addComponent(showMore); HorizontalLayout buttons = new HorizontalLayout(); content.addComponent(buttons); Button ok = new Button("Ok", new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { group.commit(); AbstractStep step = ((BeanItem<AbstractStep>) group.getItemDataSource()).getBean(); gantt.markStepDirty(step); if (parentStepSelect.isEnabled() && parentStepSelect.getValue() != null) { SubStep subStep = addSubStep(parentStepSelect, step); step = subStep; } if (step instanceof Step && !gantt.getSteps().contains(step)) { gantt.addStep((Step) step); } if (ganttListener != null && step instanceof Step) { ganttListener.stepModified((Step) step); } win.close(); } catch (CommitException e) { Notification.show("Commit failed", e.getMessage(), Type.ERROR_MESSAGE); e.printStackTrace(); } } private SubStep addSubStep(final NativeSelect parentStepSelect, AbstractStep dataSource) { SubStep subStep = new SubStep(); subStep.setCaption(dataSource.getCaption()); subStep.setCaptionMode(dataSource.getCaptionMode()); subStep.setStartDate(dataSource.getStartDate()); subStep.setEndDate(dataSource.getEndDate()); subStep.setBackgroundColor(dataSource.getBackgroundColor()); subStep.setDescription(dataSource.getDescription()); subStep.setStyleName(dataSource.getStyleName()); ((Step) parentStepSelect.getValue()).addSubStep(subStep); return subStep; } }); Button cancel = new Button("Cancel", new ClickListener() { @Override public void buttonClick(ClickEvent event) { group.discard(); win.close(); } }); Button delete = new Button("Delete", new ClickListener() { @Override public void buttonClick(ClickEvent event) { AbstractStep step = ((BeanItem<AbstractStep>) group.getItemDataSource()).getBean(); if (step instanceof SubStep) { SubStep substep = (SubStep) step; substep.getOwner().removeSubStep(substep); } else { gantt.removeStep((Step) step); if (ganttListener != null) { ganttListener.stepDeleted((Step) step); } } win.close(); } }); buttons.addComponent(ok); buttons.addComponent(cancel); buttons.addComponent(delete); win.setClosable(true); DashboardUI.getCurrent().getUI().addWindow(win); }
From source file:com.save.clients.AcknowledgementPromoForm.java
VerticalLayout acknowledgementFormContent() { VerticalLayout content = new VerticalLayout(); content.setSizeFull();//from w w w . j a v a 2s.c om content.setMargin(true); content.setSpacing(true); GridLayout glayout = new GridLayout(4, 5); glayout.setWidth("100%"); glayout.setSpacing(true); entryDate = new DateField("Date: "); entryDate.setWidth("100%"); glayout.addComponent(entryDate, 0, 0); promoItem = new TextField("Promo Items: "); promoItem.setWidth("100%"); glayout.addComponent(promoItem, 1, 0, 3, 0); promoAmount = new TextField("Amount: "); promoAmount.setWidth("100%"); promoAmount.setStyleName("align-right"); glayout.addComponent(promoAmount, 0, 1); quantity = new TextField("Quantity: "); quantity.setWidth("100%"); quantity.setStyleName("align-right"); glayout.addComponent(quantity, 1, 1); productItems = CommonComboBox.productItems(); productItems.setWidth("100%"); glayout.addComponent(productItems, 2, 1, 3, 1); startDate = new DateField("From: "); startDate.setWidth("100%"); glayout.addComponent(startDate, 0, 2); endDate = new DateField("To: "); endDate.setWidth("100%"); glayout.addComponent(endDate, 1, 2); salesRep.setWidth("100%"); glayout.addComponent(salesRep, 2, 2, 3, 2); areaSales.setWidth("100%"); glayout.addComponent(areaSales, 2, 3, 3, 3); remarks = new TextArea("Remarks: "); remarks.setWidth("100%"); remarks.setRows(4); glayout.addComponent(remarks, 0, 3, 1, 4); Button submitBtn = new Button(); submitBtn.setCaption("SAVE"); submitBtn.setWidth("100%"); submitBtn.addClickListener(this); glayout.addComponent(submitBtn, 2, 4, 3, 4); glayout.setComponentAlignment(submitBtn, Alignment.BOTTOM_CENTER); if (getPromoId() != 0) { PromoDeals pd = pds.getPromoDealById(getPromoId()); submitBtn.setCaption("UPDATE"); entryDate.setValue(pd.getEntryDate()); startDate.setValue(pd.getStartDate()); endDate.setValue(pd.getEndDate()); promoItem.setValue(pd.getPromoItem()); promoAmount.setValue(String.valueOf(pd.getPromoAmount())); quantity.setValue(String.valueOf(pd.getQuantity())); productItems.setValue(pd.getProductId()); areaSales.setValue(pd.getAreaSalesId()); salesRep.setValue(pd.getSalesRepId()); remarks.setValue(pd.getRemarks()); } content.addComponent(glayout); return content; }
From source file:com.save.employee.maintenance.MRFormWindow.java
FormLayout buildForms() { FormLayout form = new FormLayout(); form.setWidth("100%"); form.setMargin(true);//from w w w. j a va 2 s.c om formType = CommonComboBox.getFormType("Select Form Type.."); formType.setValue(1); formType.setWidth("60%"); form.addComponent(formType); area = CommonComboBox.areas(); area.setWidth("60%"); form.addComponent(area); plateNo = new TextField("Plate No: "); plateNo.setWidth("60%"); form.addComponent(plateNo); dateCovered = new DateField("Date Covered: "); dateCovered.setWidth("60%"); form.addComponent(dateCovered); amount = new TextField("Amount: "); amount.setWidth("60%"); amount.addStyleName("align-right"); form.addComponent(amount); description = new TextArea("Description: "); description.setWidth("100%"); description.setRows(3); form.addComponent(description); actionButton = new Button(); actionButton.setCaption("SAVE"); actionButton.setWidth("100%"); actionButton.addStyleName(ValoTheme.BUTTON_PRIMARY); actionButton.addClickListener(buttonClickListener); form.addComponent(actionButton); formType.addValueChangeListener((Property.ValueChangeEvent e) -> { if (e.getProperty().getValue().toString().equals("1")) { if (getMrId() != 0) { actionButton.setCaption("UPDATE"); } else { actionButton.setCaption("SAVE"); } panel.setCaption("MAINTENANCE FORM"); } else { if (getMrId() != 0) { actionButton.setCaption("UPDATE"); } else { actionButton.setCaption("SAVE"); } panel.setCaption("REIMBURSEMENT FORM"); } }); editForm(); viewForm(form); return form; }
From source file:com.save.employee.PersonalInformationForm.java
public PersonalInformationForm(HorizontalSplitPanel hsplit, int employeeId, Grid grid, Object itemId) { this.hsplit = hsplit; this.employeeId = employeeId; this.grid = grid; this.itemId = itemId; setMargin(new MarginInfo(true, true, false, false)); setWidth("80%"); addStyleName("light"); editBtn = new Button(BUTTON_CAPTION, editBtnListener); editBtn.setEnabled(false);/*from w ww . ja va 2 s . com*/ cancelBtn = new Button("CANCEL"); cancelBtn.setEnabled(false); newEntryBtn = new Button("NEW ACCOUNT"); employeeNoField = new TextField("Employee ID: "); employeeNoField.setWidth("50%"); employeeNoField.setRequired(true); employeeNoField.setRequiredError("Required Employee ID!"); addComponent(employeeNoField); firstname = new TextField("Firstname: "); firstname.setWidth("50%"); firstname.setRequired(true); firstname.setRequiredError("Required Firstname!"); addComponent(firstname); middlename = new TextField("Middlename: "); middlename.setWidth("50%"); middlename.setRequired(true); middlename.setRequiredError("Required Middlename!"); addComponent(middlename); lastname = new TextField("Lastname: "); lastname.setWidth("50%"); lastname.setRequired(true); lastname.setRequiredError("Required Lastname!"); addComponent(lastname); gender = new OptionGroup("Gender: "); gender.addItem("Female"); gender.addItem("Male"); gender.addStyleName("horizontal"); addComponent(gender); status = new ComboBox("Status: "); status.setNullSelectionAllowed(false); status.addItem("Single"); status.addItem("Married"); status.addItem("Widow"); status.addItem("Separated"); addComponent(status); birthday = new DateField("Birthday"); birthday.setValue(new Date()); addComponent(birthday); if (getEmployeeId() != 0) { Employee e = es.getEmployeesPersonalDataById(getEmployeeId()); employeeNoField.setValue(e.getEmployeeNo()); firstname.setValue(e.getFirstname()); middlename.setValue(e.getMiddlename()); lastname.setValue(e.getLastname()); gender.setValue(CommonUtilities.capitalizeFirstLetter(e.getGender())); status.setValue(e.getPersonalStatus()); birthday.setValue((e.getDob() == null) ? new Date() : e.getDob()); editBtn.setEnabled(true); cancelBtn.setEnabled(true); } setReadOnly(true); HorizontalLayout footer = new HorizontalLayout(); footer.setMargin(new MarginInfo(true, false, true, false)); footer.setSpacing(true); footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); addComponent(footer); footer.addComponent(editBtn); footer.addComponent(cancelBtn); footer.addComponent(newEntryBtn); removeBtn = new Button("REMOVE ACCOUNT"); removeBtn.addClickListener(removeBtnListener); addComponent(removeBtn); cancelBtn.addClickListener((Button.ClickEvent event) -> { setReadOnly(false); addStyleName("light"); editBtn.setCaption(BUTTON_CAPTION); editBtn.removeStyleName("primary"); setReadOnly(true); disableFields(false); newEntryBtn.setEnabled(true); }); newEntryBtn.addClickListener((Button.ClickEvent event) -> { setReadOnly(true); addStyleName("light"); editBtn.setCaption(BUTTON_CAPTION); editBtn.removeStyleName("primary"); Window sub = new CreateNewAccountWindow(getHsplit()); UI.getCurrent().addWindow(sub); }); disableFields(false); }
From source file:com.save.employee.request.RequestFormWindow.java
Component buildRequestForm() { GridLayout glayout = new GridLayout(4, 7); glayout.setSizeFull();/*ww w . j a v a 2 s . c o m*/ glayout.setSpacing(true); glayout.setMargin(true); controlNo = new TextField("Control No."); controlNo.setWidth("100%"); controlNo.addStyleName(ValoTheme.TEXTFIELD_SMALL); glayout.addComponent(controlNo, 0, 0); dateOfActivity = new DateField("Date of Activity: "); dateOfActivity.setWidth("100%"); dateOfActivity.addStyleName(ValoTheme.DATEFIELD_SMALL); glayout.addComponent(dateOfActivity, 1, 0); area = CommonComboBox.areas(); area.setWidth("100%"); glayout.addComponent(area, 2, 0); activity = new TextField("Activity: "); activity.setWidth("100%"); activity.addStyleName(ValoTheme.TEXTFIELD_SMALL); glayout.addComponent(activity, 0, 1, 1, 1); venue = new TextField("Venue: "); venue.setWidth("100%"); venue.addStyleName(ValoTheme.TEXTFIELD_SMALL); glayout.addComponent(venue, 0, 2, 1, 2); requirements = new TextArea("Requirements: "); requirements.setWidth("100%"); requirements.addStyleName(ValoTheme.TEXTAREA_SMALL); glayout.addComponent(requirements, 2, 1, 3, 2); Label lodging = new Label("Lodging: "); lodging.setWidthUndefined(); glayout.addComponent(lodging, 0, 3); glayout.setComponentAlignment(lodging, Alignment.MIDDLE_CENTER); lodgingPax = new TextField("Pax: "); lodgingPax.setWidth("100%"); lodgingPax.setValue("0"); lodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); lodgingPax.addStyleName("align-right"); glayout.addComponent(lodgingPax, 1, 3); lodgingAmount = new TextField("Amount: "); lodgingAmount.setWidth("100%"); lodgingAmount.setValue("0.00"); lodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); lodgingAmount.addStyleName("align-right"); lodgingAmount.setEnabled(false); lodgingAmount.setImmediate(true); glayout.addComponent(lodgingAmount, 3, 3); lodgingBudget = new TextField("Budget: "); lodgingBudget.setWidth("100%"); lodgingBudget.setValue("0.00"); lodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); lodgingBudget.addStyleName("align-right"); lodgingBudget.addValueChangeListener((ValueChangeEvent event) -> { if (!CommonUtilities.checkInputIfInteger(lodgingPax.getValue().trim())) { Notification.show("Enter a numeric value for Pax", Notification.Type.ERROR_MESSAGE); return; } if (!CommonUtilities.checkInputIfDouble(lodgingBudget.getValue().trim())) { Notification.show("Enter a numeric value for Budget", Notification.Type.ERROR_MESSAGE); return; } lodgingAmount.setValue(String.valueOf(CommonUtilities.convertStringToInt(lodgingPax.getValue().trim()) * CommonUtilities.convertStringToDouble(lodgingBudget.getValue().trim()))); }); lodgingBudget.setImmediate(true); glayout.addComponent(lodgingBudget, 2, 3); Label meals = new Label("Meals: "); meals.setWidthUndefined(); glayout.addComponent(meals, 0, 4); glayout.setComponentAlignment(meals, Alignment.MIDDLE_CENTER); mealsPax = new TextField("Pax: "); mealsPax.setWidth("100%"); mealsPax.setValue("0"); mealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); mealsPax.addStyleName("align-right"); glayout.addComponent(mealsPax, 1, 4); mealsAmount = new TextField("Amount: "); mealsAmount.setWidth("100%"); mealsAmount.setValue("0.00"); mealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); mealsAmount.addStyleName("align-right"); mealsAmount.setEnabled(false); mealsAmount.setImmediate(liquidated); glayout.addComponent(mealsAmount, 3, 4); mealsBudget = new TextField("Budget: "); mealsBudget.setWidth("100%"); mealsBudget.setValue("0.00"); mealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); mealsBudget.addStyleName("align-right"); mealsBudget.addValueChangeListener((ValueChangeEvent event) -> { if (!CommonUtilities.checkInputIfInteger(mealsPax.getValue().trim())) { Notification.show("Enter a numeric value for Pax", Notification.Type.ERROR_MESSAGE); return; } if (!CommonUtilities.checkInputIfDouble(mealsBudget.getValue().trim())) { Notification.show("Enter a numeric value for Budget", Notification.Type.ERROR_MESSAGE); return; } mealsAmount.setValue(String.valueOf(CommonUtilities.convertStringToInt(mealsPax.getValue().trim()) * CommonUtilities.convertStringToDouble(mealsBudget.getValue().trim()))); }); mealsAmount.setImmediate(true); glayout.addComponent(mealsBudget, 2, 4); others = new TextArea("Others: "); others.setWidth("100%"); others.setRows(3); others.addStyleName(ValoTheme.TEXTAREA_SMALL); glayout.addComponent(others, 0, 5, 2, 6); othersAmount = new TextField("Amount: "); othersAmount.setWidth("100%"); othersAmount.setValue("0.00"); othersAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); othersAmount.addStyleName("align-right"); glayout.addComponent(othersAmount, 3, 5); glayout.setComponentAlignment(othersAmount, Alignment.TOP_CENTER); Button rlButton = new Button(); rlButton.setCaption("SAVE"); rlButton.setWidth("100%"); rlButton.addStyleName(ValoTheme.BUTTON_PRIMARY); rlButton.addStyleName(ValoTheme.BUTTON_SMALL); rlButton.addClickListener(buttonClickListener); glayout.addComponent(rlButton, 3, 6); glayout.setComponentAlignment(rlButton, Alignment.TOP_CENTER); if (getRequestId() != 0) { LiquidationForm lf = rls.getRLById(getRequestId()); controlNo.setValue(String.valueOf(lf.getControlNo())); dateOfActivity.setValue(lf.getDateOfActivity()); area.setValue(lf.getAreaId()); activity.setValue(lf.getActivity()); requirements.setValue(lf.getRequirements()); venue.setValue(lf.getVenue()); others.setValue(lf.getOthersRemarks()); othersAmount.setValue(String.valueOf(lf.getOthersAmount())); lodgingAmount.setValue(String.valueOf(lf.getLodgingAmount())); mealsAmount.setValue(String.valueOf(lf.getMealsAmount())); if (getLiquidated() == true) { setCaption("LIQUIDATE FROM"); rlButton.setCaption("LIQUIDATE"); controlNo.setReadOnly(liquidated); dateOfActivity.setReadOnly(liquidated); area.setReadOnly(liquidated); activity.setReadOnly(liquidated); requirements.setReadOnly(liquidated); venue.setReadOnly(liquidated); } else { rlButton.setCaption("EDIT"); lodgingPax.setValue(String.valueOf(lf.getLodgingPax())); lodgingBudget.setValue(String.valueOf(lf.getLodgingBudget())); mealsPax.setValue(String.valueOf(lf.getMealsPax())); mealsBudget.setValue(String.valueOf(lf.getMealsBudget())); rlButton.setEnabled(rls.getRLById(getRequestId()).getLiquidated() == 0); } // delete.setVisible(true); } return glayout; }