List of usage examples for com.vaadin.ui DateField DateField
public DateField(ValueChangeListener<LocalDate> valueChangeListener)
From source file:com.save.employee.request.ViewRLWindow.java
FormLayout buildFormLayout() { FormLayout f = new FormLayout(); f.setWidth("100%"); f.setMargin(true);// ww w.j av a 2 s .com LiquidationForm lf = rls.getRLById(getRequestId()); controlNo = new TextField("Control No."); controlNo.setWidth("100%"); controlNo.addStyleName(ValoTheme.TEXTFIELD_SMALL); controlNo.setValue(String.valueOf(lf.getControlNo())); controlNo.setEnabled(false); f.addComponent(controlNo); dateOfActivity = new DateField("Date of Activity: "); dateOfActivity.setWidth("100%"); dateOfActivity.addStyleName(ValoTheme.DATEFIELD_SMALL); dateOfActivity.setValue(lf.getDateOfActivity()); dateOfActivity.setEnabled(false); f.addComponent(dateOfActivity); area = CommonComboBox.areas(); area.setWidth("100%"); area.setValue(lf.getAreaId()); area.setEnabled(false); f.addComponent(area); activity = new TextField("Activity: "); activity.setWidth("100%"); activity.addStyleName(ValoTheme.TEXTFIELD_SMALL); activity.setValue(lf.getActivity()); activity.setEnabled(false); f.addComponent(activity); venue = new TextField("Venue: "); venue.setWidth("100%"); venue.addStyleName(ValoTheme.TEXTFIELD_SMALL); venue.setValue(lf.getVenue()); venue.setEnabled(false); f.addComponent(venue); requirements = new TextArea("Requirements: "); requirements.setWidth("100%"); requirements.addStyleName(ValoTheme.TEXTAREA_SMALL); requirements.setValue(lf.getRequirements()); requirements.setEnabled(false); f.addComponent(requirements); HorizontalLayout h1 = new HorizontalLayout(); h1.setWidth("100%"); h1.setCaption("Request Lodging"); h1.addStyleName("light"); // h1.setReadOnly(true); requestLodgingPax = new TextField(); requestLodgingPax.setWidth("100%"); requestLodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); requestLodgingPax.addStyleName("align-right"); requestLodgingPax.setValue("Pax: " + String.valueOf(lf.getLodgingPax())); requestLodgingPax.setEnabled(false); h1.addComponent(requestLodgingPax); requestLodgingBudget = new TextField(); requestLodgingBudget.setWidth("100%"); requestLodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); requestLodgingBudget.addStyleName("align-right"); requestLodgingBudget.setValue("Budget: " + String.valueOf(lf.getLodgingBudget())); requestLodgingBudget.setEnabled(false); h1.addComponent(requestLodgingBudget); requestLodgingAmount = new TextField(); requestLodgingAmount.setWidth("100%"); requestLodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); requestLodgingAmount.addStyleName("align-right"); requestLodgingAmount.setValue("Amount: " + String.valueOf(lf.getLodgingAmount())); requestLodgingAmount.setEnabled(false); h1.addComponent(requestLodgingAmount); f.addComponent(h1); f.setComponentAlignment(h1, Alignment.MIDDLE_LEFT); HorizontalLayout h2 = new HorizontalLayout(); h2.setWidth("100%"); h2.setCaption("Request Meals"); // h2.setReadOnly(true); requestMealsPax = new TextField(); requestMealsPax.setWidth("100%"); requestMealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); requestMealsPax.addStyleName("align-right"); requestMealsPax.setValue("Pax: " + String.valueOf(lf.getMealsPax())); requestMealsPax.setEnabled(false); h2.addComponent(requestMealsPax); requestMealsBudget = new TextField(); requestMealsBudget.setWidth("100%"); requestMealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); requestMealsBudget.addStyleName("align-right"); requestMealsBudget.setValue("Budget: " + String.valueOf(lf.getMealsBudget())); requestMealsBudget.setEnabled(false); h2.addComponent(requestMealsBudget); requestMealsAmount = new TextField(); requestMealsAmount.setWidth("100%"); requestMealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); requestMealsAmount.addStyleName("align-right"); requestMealsAmount.setValue("Amount: " + String.valueOf(lf.getMealsAmount())); requestMealsAmount.setEnabled(false); h2.addComponent(requestMealsAmount); f.addComponent(h2); f.setComponentAlignment(h2, Alignment.MIDDLE_LEFT); HorizontalLayout h3 = new HorizontalLayout(); h3.setWidth("100%"); h3.setCaption("Liquidated Lodging"); // h3.setReadOnly(true); liquidateLodgingPax = new TextField(); liquidateLodgingPax.setWidth("100%"); liquidateLodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); liquidateLodgingPax.addStyleName("align-right"); liquidateLodgingPax.setValue("Pax: " + String.valueOf(lf.getLiquidationLodgingPax())); liquidateLodgingPax.setEnabled(false); h3.addComponent(liquidateLodgingPax); liquidateLodgingBudget = new TextField(); liquidateLodgingBudget.setWidth("100%"); liquidateLodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); liquidateLodgingBudget.addStyleName("align-right"); liquidateLodgingBudget.setValue("Budget: " + String.valueOf(lf.getLiquidationLodgingBudget())); liquidateLodgingBudget.setEnabled(false); h3.addComponent(liquidateLodgingBudget); liquidateLodgingAmount = new TextField(); liquidateLodgingAmount.setWidth("100%"); liquidateLodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); liquidateLodgingAmount.addStyleName("align-right"); liquidateLodgingAmount.setValue("Amount: " + String.valueOf(lf.getLiquidationLodgingAmount())); liquidateLodgingAmount.setEnabled(false); h3.addComponent(liquidateLodgingAmount); f.addComponent(h3); f.setComponentAlignment(h3, Alignment.MIDDLE_LEFT); HorizontalLayout h4 = new HorizontalLayout(); h4.setWidth("100%"); h4.setCaption("Liquidated Meals"); h4.setReadOnly(true); liquidateMealsPax = new TextField(); liquidateMealsPax.setWidth("100%"); liquidateMealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); liquidateMealsPax.addStyleName("align-right"); liquidateMealsPax.setValue("Pax: " + String.valueOf(lf.getLiquidationMealsPax())); liquidateMealsPax.setEnabled(false); h4.addComponent(liquidateMealsPax); liquidateMealsBudget = new TextField(); liquidateMealsBudget.setWidth("100%"); liquidateMealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); liquidateMealsBudget.addStyleName("align-right"); liquidateMealsBudget.setValue("Budget: " + String.valueOf(lf.getLiquidationMealsBudget())); liquidateMealsBudget.setEnabled(false); h4.addComponent(liquidateMealsBudget); liquidateMealsAmount = new TextField(); liquidateMealsAmount.setWidth("100%"); liquidateMealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); liquidateMealsAmount.addStyleName("align-right"); liquidateMealsAmount.setValue("Amount: " + String.valueOf(lf.getLiquidationMealsAmount())); liquidateMealsAmount.setEnabled(false); h4.addComponent(liquidateMealsAmount); f.addComponent(h4); f.setComponentAlignment(h4, Alignment.MIDDLE_LEFT); reimbursement = new TextField("Reimbursement: "); reimbursement.setWidth("50%"); reimbursement.addStyleName(ValoTheme.TEXTFIELD_SMALL); reimbursement.setValue(String.valueOf(lf.getReimbursedAmount())); reimbursement.setEnabled(false); f.addComponent(reimbursement); f.addStyleName("light"); f.setReadOnly(true); return f; }
From source file:com.skysql.manager.ui.CalendarDialog.java
License:Open Source License
/** * Initializes a modal window to edit schedule event. * * @param event the event/*from w w w. jav a 2 s . com*/ * @param newEvent the new event */ private void createCalendarEventPopup(CalendarCustomEvent event, boolean newEvent) { VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); scheduleEventPopup = new Window(null, layout); scheduleEventPopup.setWidth("400px"); scheduleEventPopup.setModal(true); scheduleEventPopup.center(); Date occurrence = event.getOccurrence(); if (!newEvent && occurrence != null) { Form form = new Form(); form.setCaption("This is a repeat occurrence"); layout.addComponent(form); DateField dateField = new DateField("Occurrence Start"); if (useSecondResolution) { dateField.setResolution(Resolution.SECOND); } else { dateField.setResolution(Resolution.MINUTE); } dateField.setValue(event.getStart()); dateField.setEnabled(false); form.addField("dateField", dateField); form.setFooter(null); HorizontalLayout editLayout = new HorizontalLayout(); editLayout.setSpacing(true); layout.addComponent(editLayout); final Label label = new Label("Click to change the original event below:"); editLayout.addComponent(label); editLayout.setComponentAlignment(label, Alignment.BOTTOM_LEFT); editOriginalButton = new Button("Edit", new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent clickEvent) { scheduleEventForm.setEnabled(true); applyEventButton.setEnabled(true); label.setValue("Editing original event:"); editOriginalButton.setVisible(false); } }); editLayout.addComponent(editOriginalButton); scheduleEventForm.setEnabled(false); } else { scheduleEventForm.setEnabled(true); } layout.addComponent(scheduleEventForm); applyEventButton = new Button("Add", new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { commitCalendarEvent(); } }); Button cancel = new Button("Cancel", new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { discardCalendarEvent(); } }); deleteEventButton = new Button("Delete", new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { deleteCalendarEvent(); } }); scheduleEventPopup.addListener(new CloseListener() { private static final long serialVersionUID = 1L; public void windowClose(CloseEvent e) { discardCalendarEvent(); } }); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.addComponent(deleteEventButton); buttons.addComponent(cancel); buttons.addComponent(applyEventButton); layout.addComponent(buttons); layout.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT); }
From source file:com.skysql.manager.ui.CalendarDialog.java
License:Open Source License
/** * Update calendar event form./*from w w w . j a v a 2s .c o m*/ * * @param event the event */ @SuppressWarnings("deprecation") private void updateCalendarEventForm(CalendarEvent event) { // Lets create a CalendarEvent BeanItem and pass it to the form's data // source. BeanItem<CalendarEvent> item = new BeanItem<CalendarEvent>(event); scheduleEventForm.setBuffered(true); scheduleEventForm.setItemDataSource(item); scheduleEventForm.setFormFieldFactory(new FormFieldFactory() { private static final long serialVersionUID = 1L; public Field createField(Item item, Object propertyId, Component uiContext) { if (propertyId.equals("caption")) { TextField f = createTextField("Caption"); f.focus(); return f; } else if (propertyId.equals("description")) { TextField f = createTextField("Description"); //f.setRows(3); return f; } else if (propertyId.equals("styleName")) { return createStyleNameSelect(); } else if (propertyId.equals("start")) { startDateField = createDateField("Start"); return startDateField; } else if (propertyId.equals("end")) { return createDateField("End"); } else if (propertyId.equals("allDay")) { CheckBox cb = createCheckBox("All-day"); cb.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -7104996493482558021L; public void valueChange(ValueChangeEvent event) { Object value = event.getProperty().getValue(); if (value instanceof Boolean && Boolean.TRUE.equals(value)) { setFormDateResolution(Resolution.DAY); } else { setFormDateResolution(Resolution.MINUTE); } } }); return cb; } else if (propertyId.equals("repeat")) { repeatSelectField = createRepeatSelect(); repeatSelectField.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; public void valueChange(ValueChangeEvent event) { if (untilSelectField != null) { boolean isRepeat = !(event.getProperty().getValue() .equals(CalendarCustomEvent.RECUR_NONE)); untilSelectField.setVisible(isRepeat); untilSelectField.markAsDirty(); } } }); return repeatSelectField; } else if (propertyId.equals("untilSelect")) { untilSelectField = createUntilSelect(); if (repeatSelectField != null && repeatSelectField.getValue().equals(CalendarCustomEvent.RECUR_NONE)) { untilSelectField.setVisible(false); } untilSelectField.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; public void valueChange(ValueChangeEvent event) { Until until = Until.valueOf((String) event.getProperty().getValue()); boolean untilCount = false; boolean untilDate = false; switch (until) { case never: break; case count: untilCount = true; break; case date: untilDate = true; break; } if (untilCountField != null) { untilCountField.setVisible(untilCount); untilCountField.markAsDirty(); } if (untilDateField != null) { untilDateField.setVisible(untilDate); untilDateField.markAsDirty(); } } }); return untilSelectField; } else if (propertyId.equals("untilCount")) { untilCountField = createTextField("Times"); if (!untilSelectField.getValue().equals(Until.count.name())) { untilCountField.setVisible(false); } return untilCountField; } else if (propertyId.equals("untilDate")) { untilDateField = createDateField("On Date"); if (!untilSelectField.getValue().equals(Until.date.name())) { untilDateField.setVisible(false); } return untilDateField; } else if (propertyId.equals("node")) { NativeSelect ns = createNodeSelect(); ns.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; public void valueChange(ValueChangeEvent event) { String nodeID = ((String) event.getProperty().getValue()); } }); return ns; } return null; } private CheckBox createCheckBox(String caption) { CheckBox cb = new CheckBox(caption); cb.setImmediate(true); return cb; } private TextField createTextField(String caption) { TextField f = new TextField(caption); f.setNullRepresentation(""); return f; } private DateField createDateField(String caption) { DateField f = new DateField(caption); if (useSecondResolution) { f.setResolution(Resolution.SECOND); } else { f.setResolution(Resolution.MINUTE); } return f; } private NativeSelect createStyleNameSelect() { NativeSelect s = new NativeSelect("Color"); s.addContainerProperty("c", String.class, ""); s.setItemCaptionPropertyId("c"); Item i = s.addItem("color1"); i.getItemProperty("c").setValue("Green"); i = s.addItem("color2"); i.getItemProperty("c").setValue("Blue"); i = s.addItem("color3"); i.getItemProperty("c").setValue("Red"); i = s.addItem("color4"); i.getItemProperty("c").setValue("Orange"); return s; } private NativeSelect createRepeatSelect() { NativeSelect s = new NativeSelect("Repeat"); s.setImmediate(true); s.setNullSelectionAllowed(false); s.addContainerProperty("r", String.class, ""); s.setItemCaptionPropertyId("r"); Item i = s.addItem(CalendarCustomEvent.RECUR_NONE); i.getItemProperty("r").setValue("None"); i = s.addItem(Recur.HOURLY); i.getItemProperty("r").setValue("Every Hour"); i = s.addItem(Recur.DAILY); i.getItemProperty("r").setValue("Every Day"); i = s.addItem(Recur.WEEKLY); i.getItemProperty("r").setValue("Every Week"); i = s.addItem(Recur.MONTHLY); i.getItemProperty("r").setValue("Every Month"); i = s.addItem(Recur.YEARLY); i.getItemProperty("r").setValue("Every Year"); return s; } private NativeSelect createUntilSelect() { NativeSelect s = new NativeSelect("End"); s.setImmediate(true); s.setNullSelectionAllowed(false); s.addContainerProperty("u", String.class, ""); s.setItemCaptionPropertyId("u"); Item i = s.addItem(Until.never.name()); i.getItemProperty("u").setValue("Never"); i = s.addItem(Until.count.name()); i.getItemProperty("u").setValue("After"); i = s.addItem(Until.date.name()); i.getItemProperty("u").setValue("On Date"); return s; } private NativeSelect createNodeSelect() { //Select s = new Select("Node"); final NativeSelect s = new NativeSelect("Node"); s.setImmediate(true); s.setNullSelectionAllowed(false); s.addContainerProperty("n", String.class, ""); s.setItemCaptionPropertyId("n"); for (NodeInfo node : nodes) { Item i = s.addItem(node.getID()); i.getItemProperty("n").setValue(node.getName()); } return s; } }); scheduleEventForm.setVisibleItemProperties(new Object[] { "caption", "description", "node", "start", "repeat", "untilSelect", "untilCount", "untilDate" }); Date occurrence = ((CalendarCustomEvent) event).getOccurrence(); if (occurrence != null) { startDateField.setValue(occurrence); } }
From source file:com.squadd.UI.EditInfoLayout.java
public EditInfoLayout() { cancel = new Button("cancel"); submit = new Button("submit"); date = new DateField("New Date"); grName = new TextField("New Group Name"); descr = new TextField("New Description"); place = new TextField("New Place"); configureLayout();//from ww w . j av a 2s . c o m }
From source file:com.squadd.UI.EditVersionLayout.java
public EditVersionLayout(Group group) { this.group = group; groupPhoto = new ImageGetter().get(group); uploadPhoto = new Button("upload new photo"); groupName = new TextField("Group Name: "); groupName.setValue((group.getName() == null) ? "" : group.getName()); placeName = new TextField("Place: "); placeName.setValue((group.getPlaceId().getCity() == null) ? "" : group.getPlaceId().getCity()); date = new DateField("Date: "); date.setValue(group.getTime());//from ww w . ja va2 s . c om description = new TextArea("Description: "); description.setWordwrap(true); description.setValue((group.getDescription() == null) ? "" : group.getDescription()); save = new Button("save"); cancel = new Button("cancel"); buildLayout(); }
From source file:com.squadd.UI.PersonalInformationLayout.java
private void configureComponents() { name = new TextField("Name"); lastName = new TextField("Last Name"); birthDate = new DateField("Birth Date"); sex = new OptionGroup("Sex"); sex.addStyleName("horizontal"); sex.addItems("Male", "Female"); }
From source file:com.tripoin.util.ui.calendar.BeanItemContainerTestUI.java
License:Apache License
/** * Opens up a modal dialog window where an event can be modified * //w ww . java 2s . c o m * @param event * The event to modify */ private void editEvent(final BasicEvent event) { Window modal = new Window("Add event"); modal.setModal(true); modal.setResizable(false); modal.setDraggable(false); modal.setWidth("300px"); final FieldGroup fieldGroup = new FieldGroup(); FormLayout formLayout = new FormLayout(); TextField captionField = new TextField("Caption"); captionField.setImmediate(true); TextField descriptionField = new TextField("Description"); descriptionField.setImmediate(true); DateField startField = new DateField("Start"); startField.setResolution(Resolution.MINUTE); startField.setImmediate(true); DateField endField = new DateField("End"); endField.setImmediate(true); endField.setResolution(Resolution.MINUTE); formLayout.addComponent(captionField); formLayout.addComponent(descriptionField); formLayout.addComponent(startField); formLayout.addComponent(endField); fieldGroup.bind(captionField, ContainerEventProvider.CAPTION_PROPERTY); fieldGroup.bind(descriptionField, ContainerEventProvider.DESCRIPTION_PROPERTY); fieldGroup.bind(startField, ContainerEventProvider.STARTDATE_PROPERTY); fieldGroup.bind(endField, ContainerEventProvider.ENDDATE_PROPERTY); fieldGroup.setItemDataSource(new BeanItem<BasicEvent>(event, Arrays.asList(ContainerEventProvider.CAPTION_PROPERTY, ContainerEventProvider.DESCRIPTION_PROPERTY, ContainerEventProvider.STARTDATE_PROPERTY, ContainerEventProvider.ENDDATE_PROPERTY))); modal.setContent(formLayout); modal.addCloseListener(new Window.CloseListener() { /** * */ private static final long serialVersionUID = -3427881784024691882L; @Override public void windowClose(CloseEvent e) { // Commit changes to bean try { fieldGroup.commit(); } catch (CommitException e1) { e1.printStackTrace(); } if (events.containsId(event)) { /* * BeanItemContainer does not notify container listeners * when the bean changes so we need to trigger a * ItemSetChange event */ BasicEvent dummy = new BasicEvent(); events.addBean(dummy); events.removeItem(dummy); } else { events.addBean(event); } } }); getUI().addWindow(modal); }
From source file:com.trivago.mail.pigeon.web.components.mail.ModalAddNewsletter.java
License:Apache License
public ModalAddNewsletter(final NewsletterList nl) { super();//from w ww.ja v a 2 s.co m setModal(true); setWidth("600px"); setClosable(false); Panel rootPanel = new Panel("Add new Newsletter"); final VerticalLayout verticalLayout = new VerticalLayout(); final SenderSelectBox senderSelectBox = new SenderSelectBox(); final HorizontalLayout buttonLayout = new HorizontalLayout(); final GroupSelectBox groupSelectBox = new GroupSelectBox(); final UploadTextFileComponent uploadTextfile = new UploadTextFileComponent(); final UploadHtmlFileComponent uploadHtmlfile = new UploadHtmlFileComponent(); final TemplateSelectBox templateSelectBox = new TemplateSelectBox(); final TextField tfSubject = new TextField("Subject"); final DateField tfSendDate = new DateField("Send Date"); final Button cancelButton = new Button("Cancel"); final Button saveButton = new Button("Send"); tfSendDate.setInvalidAllowed(false); tfSendDate.setResolution(DateField.RESOLUTION_MIN); tfSendDate.setValue(new Date()); cancelButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { event.getButton().getWindow().setVisible(false); event.getButton().getWindow().getParent().removeComponent(event.getButton().getWindow()); } }); saveButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { boolean hasError = false; // Validation if (tfSubject.getValue().equals("") && templateSelectBox.getSelectedTemplate() == null) { hasError = true; tfSubject.setComponentError( new UserError("Subject cannot be empty if you do not choose a template.")); } else { tfSubject.setComponentError(null); } if (tfSendDate.getValue() == null) { hasError = true; tfSendDate.setComponentError(new UserError("Date cannot be empty")); } else { tfSendDate.setComponentError(null); } if (templateSelectBox.getSelectedTemplate() == null) { if (!uploadTextfile.isUploadFinished()) { hasError = true; uploadTextfile.setComponentError( new UserError("You must provide a text file if you do not choose a template")); } else { uploadTextfile.setComponentError(null); } if (!uploadHtmlfile.isUploadFinished()) { hasError = true; uploadHtmlfile.setComponentError( new UserError("You must provide a html file if you do not choose a template")); } else { uploadHtmlfile.setComponentError(null); } } if (senderSelectBox.getSelectedSender() == 0) { hasError = true; senderSelectBox.setComponentError(new UserError("You must select a sender")); } else { senderSelectBox.setComponentError(null); } if (groupSelectBox.getSelectedGroup() == 0) { hasError = true; groupSelectBox.setComponentError(new UserError("You must select a recipient group")); } else { groupSelectBox.setComponentError(null); } log.debug("Has Error: " + hasError); if (!hasError) { log.info("No validation errors found, processing request"); long mailId = Util.generateId(); try { Sender s = new Sender(senderSelectBox.getSelectedSender()); String text; String html; String subject; if (templateSelectBox.getSelectedTemplate() == null) { text = uploadTextfile.getTextData(); html = uploadHtmlfile.getHtmlData(); subject = tfSubject.getValue().toString(); } else { MailTemplate mt = new MailTemplate(templateSelectBox.getSelectedTemplate()); text = mt.getText(); html = mt.getHtml(); subject = mt.getSubject(); } Mail m = new Mail(mailId, text, html, (Date) tfSendDate.getValue(), subject, s); QueueNewsletter queueNewsletter = new QueueNewsletter(); queueNewsletter.queueNewsletter(m, s, new RecipientGroup(groupSelectBox.getSelectedGroup())); event.getButton().getWindow().setVisible(false); event.getButton().getWindow().getParent().removeComponent(event.getButton().getWindow()); event.getButton().getWindow().getParent().showNotification("Queued successfully", Notification.TYPE_HUMANIZED_MESSAGE); nl.getBeanContainer().addItem(m.getId(), m); } catch (RuntimeException e) { log.error("RuntimeException", e); event.getButton().getApplication().getMainWindow().showNotification( "An error occured: " + e.getLocalizedMessage(), Notification.TYPE_ERROR_MESSAGE); } } } }); buttonLayout.setSpacing(true); buttonLayout.addComponent(saveButton); buttonLayout.addComponent(cancelButton); Panel metaData = new Panel("Basic Data"); metaData.addComponent(tfSendDate); verticalLayout.addComponent(metaData); verticalLayout.addComponent(senderSelectBox); verticalLayout.addComponent(groupSelectBox); verticalLayout.addComponent(templateSelectBox); verticalLayout.addComponent(tfSubject); verticalLayout.addComponent(uploadTextfile); verticalLayout.addComponent(uploadHtmlfile); verticalLayout.addComponent(buttonLayout); rootPanel.addComponent(verticalLayout); this.addComponent(rootPanel); }
From source file:com.trivago.mail.pigeon.web.components.mail.NewsletterProgressComponent.java
License:Apache License
public NewsletterProgressComponent(final Mail mail) { Panel rootPanel = new Panel("Progress for Mail with Suject " + mail.getSubject()); VerticalLayout vl = new VerticalLayout(); vl.setSpacing(true);/*from w w w. j a va 2 s. co m*/ DateField df = new DateField("Send Date"); df.setValue(mail.getSendDate()); df.setReadOnly(true); df.setResolution(DateField.RESOLUTION_MIN); indicator = new ProgressIndicator(new Float(0.0)); indicator.setPollingInterval(500); int cnt = 0; Iterable<Relationship> recipients = mail.getRecipients(); for (Relationship rec : recipients) { ++cnt; } final int recpCount = cnt; class WorkerThread extends Thread { int current = 0; public volatile int stop = 0; public void run() { while (true) { if (stop > 0) { break; } try { QueueNewsletter qn = new QueueNewsletter(); int progress = qn.getProgress(mail.getId()); current = recpCount - progress; if (current == recpCount) { mail.setDone(); break; } double result = (recpCount / 100.00) * current; indicator.setValue(new Float(result / 100.00)); sleep(500); } catch (InterruptedException e) { } } } } final WorkerThread workerThread = new WorkerThread(); final Button startButton = new Button("Poll status"); final Button stopButton = new Button("Stop polling"); startButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { workerThread.start(); event.getButton().setVisible(false); stopButton.setVisible(true); } }); stopButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { workerThread.stop = 1; workerThread.interrupt(); event.getButton().setVisible(false); startButton.setVisible(true); } }); stopButton.setVisible(false); vl.addComponent(df); vl.addComponent(indicator); vl.addComponent(startButton); vl.addComponent(stopButton); rootPanel.addComponent(vl); setCompositionRoot(rootPanel); }
From source file:com.wcs.wcslib.vaadin.widget.jquerymask.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { setContent(root);/*from w w w .ja v a 2 s . c om*/ root.setMargin(true); final TextField textField = new TextField("test"); JqInputMask.mask(textField, "(999) 999-9999").apply(); root.addComponent(new HorizontalLayout(textField, new Button("unmask test", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { JqInputMask.remove(textField); } }))); DateField dateField = new DateField("date"); dateField.setDateFormat("yyyy.MM.dd"); JqInputMask.date(dateField, "yyyy.mm.dd").placeholder(".hh.nn").apply(); root.addComponent(dateField); TextField ip = new TextField("IP"); JqInputMask.ip(ip).apply(); root.addComponent(ip); TextField decimal = new TextField("decimal"); JqInputMask.decimal(decimal).groupSeparator(',').groupSize(3).autoGroup(true).radixPoint('.') .allowMinus(false).apply(); root.addComponent(decimal); TextField hexa = new TextField("hexa"); JqInputMask.mask(hexa, "XXXX") .define('X', new Definition().validator("[0-9A-Fa-f]").cardinality(1).casingUpper()).apply(); root.addComponent(hexa); TextField phone = new TextField("phone"); JqInputMask.mask(phone, "+99-999[999999999999]").mask("+36-99-999-999[9]").greedy(false).apply(); root.addComponent(phone); }