List of usage examples for com.vaadin.ui TextField TextField
public TextField(ValueChangeListener<String> valueChangeListener)
From source file:com.terralcode.gestion.frontend.view.widgets.customer.CustomerView.java
private void buildCustomerHeader() { codeField = new TextField("Cdigo"); taxCodeField = new TextField("CIF"); nameField = new TextField("Nombre"); //telephoneField = new TextField("Telfono"); statusField = new ComboBox("Estado"); statusField.setTextInputAllowed(false); typeField = new ComboBox("Tipo"); typeField.setTextInputAllowed(false); prestigeField = new CheckBox("Imagen"); prestigeField.setReadOnly(true);/*from ww w. j a va 2 s.c om*/ exclusiveField = new CheckBox("Exclusividad"); exclusiveField.setReadOnly(true); canGrowField = new CheckBox("Puede crecer"); canGrowField.setReadOnly(true); consultingLevelField = new TextField("Nivel Asesor."); consultingLevelField.setReadOnly(true); salesLevelField = new TextField("Nivel Ventas"); salesLevelField.setReadOnly(true); codeField.setReadOnly(true); taxCodeField.setReadOnly(true); nameField.setReadOnly(true); mainLayout.addComponent(codeField); mainLayout.addComponent(taxCodeField); mainLayout.addComponent(nameField); //mainLayout.addComponent(telephoneField); mainLayout.addComponent(statusField); mainLayout.addComponent(typeField); mainLayout.addComponent(prestigeField); mainLayout.addComponent(exclusiveField); mainLayout.addComponent(canGrowField); mainLayout.addComponent(consultingLevelField); mainLayout.addComponent(salesLevelField); }
From source file:com.terralcode.gestion.frontend.view.widgets.customeredit.CustomerDetailsView.java
private Component buildCustomerDetail() { VerticalLayout verticalLayout = new VerticalLayout(); TextField id = new TextField("id"); TextField companyName = new TextField("Empresa"); TextField phoneNumber = new TextField("Nmero de telefono"); TextField address = new TextField("Direccin"); verticalLayout.addComponent(id);/*from w ww.j a v a 2 s. c o m*/ verticalLayout.addComponent(companyName); verticalLayout.addComponent(phoneNumber); verticalLayout.addComponent(address); return verticalLayout; }
From source file:com.toptal.ui.view.LoginView.java
License:Open Source License
/** * Generates content.// ww w .ja v a2 s . c o m * @return Content. */ private Component content() { final HorizontalLayout content = new HorizontalLayout(); content.setSpacing(true); this.username = new TextField("Username"); this.username.setIcon(FontAwesome.USER); this.username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); this.password = new PasswordField("Password"); this.password.setIcon(FontAwesome.LOCK); this.password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); final Button login = new Button("Log In"); login.addStyleName(ValoTheme.BUTTON_FRIENDLY); login.setClickShortcut(KeyCode.ENTER); login.focus(); login.addClickListener(e -> this.login(this.username.getValue(), this.password.getValue())); final Button signup = new Button("Sign Up"); signup.addStyleName(ValoTheme.BUTTON_PRIMARY); signup.addClickListener(e -> this.signup(this.username.getValue(), this.password.getValue())); content.addComponents(this.username, this.password, login, signup); content.setComponentAlignment(login, Alignment.BOTTOM_LEFT); content.setComponentAlignment(signup, Alignment.BOTTOM_LEFT); return content; }
From source file:com.trender.user.component.UserForm.java
public Component regForm() { init("???");// w w w. j a v a2 s. co m surnameField = new TextField("?"); surnameField.addStyleName("v-textfield-borderless"); surnameField.addValidator(new StringLengthValidator( " , " + "? 2 ?, ?? 45", 2, 45, false)); surnameField.addValidator(new NullValidator("? ", false)); surnameField.addValidator(new RegexpValidator(regexpValue, " " + " ?? ? ?")); surnameField.setInputPrompt("?"); surnameField.setRequired(true); nameField = new TextField("?"); nameField.addStyleName("v-textfield-borderless"); nameField.addValidator(new StringLengthValidator(" ?, ? " + " 2 ?, ?? 45", 2, 45, false)); nameField.addValidator(new RegexpValidator(regexpValue, " " + " ?? ? ?")); nameField.addValidator(new NullValidator("? ", false)); nameField.setInputPrompt("?"); nameField.setRequired(true); addComponent(surnameField); addComponent(nameField); addComponent(horizontalLayout); setMargin(new MarginInfo(false, false, true, true)); performButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { UserForm.this.singUp(); } }); clearButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { UserForm.this.clearForm(true); } }); return this; }
From source file:com.trender.user.component.UserForm.java
public Component ProfilForm() { addStyleName("light"); setWidth(90, Unit.PERCENTAGE);//from w ww .j a v a2s.c o m Label title = new Label(); title.setStyleName("h2"); title.setValue(""); passwordField = new PasswordField(" "); passwordField.setInputPrompt("12345678"); passwordField.setWidth(80, Unit.PERCENTAGE); surnameField = new TextField("?"); surnameField.addValidator(new StringLengthValidator( " , " + "? 2 ?, ?? 45", 2, 45, false)); surnameField.addValidator(new RegexpValidator(regexpValue, " " + " ?? ? ?")); surnameField.setInputPrompt("?"); surnameField.setWidth(80, Unit.PERCENTAGE); nameField = new TextField("?"); nameField.addValidator(new StringLengthValidator(" ?, ? " + " 2 ?, ?? 45", 2, 45, false)); nameField.addValidator(new RegexpValidator(regexpValue, " " + " ?? ? ?")); nameField.setInputPrompt("?"); nameField.setWidth(80, Unit.PERCENTAGE); performButton = new Button(""); performButton.setStyleName("v-button-friendly"); clearButton = new Button("?"); clearButton.setStyleName("v-button-quiet"); horizontalLayout = new HorizontalLayout(); horizontalLayout.addComponent(performButton); horizontalLayout.addComponent(clearButton); horizontalLayout.setSpacing(true); horizontalLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); horizontalLayout.setMargin(new MarginInfo(true, false, false, true)); addComponent(title); addComponent(passwordField); addComponent(surnameField); addComponent(nameField); addComponent(horizontalLayout); return this; }
From source file:com.trender.user.component.UserForm.java
private void init(String valueButtonPerform) { setStyleName("v-formlayout-contentcell"); emailField = new TextField(" Email ?"); emailField.addStyleName("v-textfield-borderless"); emailField.addValidator(new EmailValidator( " ? ? ")); emailField.setRequired(true);/*from ww w. j av a2 s .c om*/ emailField.setInputPrompt("user@domen.com"); passwordField = new PasswordField(" "); passwordField.setInputPrompt("12345678"); passwordField.setStyleName("v-textfield-borderless"); passwordField.setRequired(true); performButton = new Button(valueButtonPerform); performButton.setStyleName("v-button-friendly"); clearButton = new Button("?"); clearButton.setStyleName("v-button-quiet"); horizontalLayout = new HorizontalLayout(); horizontalLayout.addComponent(performButton); horizontalLayout.addComponent(clearButton); horizontalLayout.setSpacing(true); addComponent(emailField); addComponent(passwordField); //// clearButton.addClickListener(new Button.ClickListener() { //// @Override //// public void buttonClick(Button.ClickEvent event) { //// UserForm.this.clearForm(false); //// } //// }); //// //// performButton.addClickListener(new Button.ClickListener() { //// @Override //// public void buttonClick(Button.ClickEvent event) { //// UserForm.this.chengProfil(); //// } //// }); }
From source file:com.trender.user.component.wizard.SetupStepWizardStudy.java
@Override public Component getContent() { try {// www .j a va 2 s. c om content = new VerticalLayout(); content.setSizeFull(); content.setMargin(true); form = new FormLayout(); form.addStyleName("light"); mainText = new Label(" "); mainText.setStyleName("h2"); form.addComponent(mainText); List<Question> question = questionService.getAll(); questionField = new TextField[question.size()]; for (int i = 0; i < question.size(); i++) { questionField[i] = new TextField(question.get(i).getValue()); questionField[i].setWidth(95, Unit.PERCENTAGE); form.addComponent(questionField[i]); } content.addComponent(form); } catch (ServiceException ex) { Logger.getLogger(SetupStepWizardStudy.class.getName()).log(Level.SEVERE, null, ex); } return content; }
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 * /*from w w w. ja v a2s. co 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.groups.ModalAddNewGroup.java
License:Apache License
public ModalAddNewGroup(final GroupList gl) { super();//from w w w . j a v a 2 s. c om setModal(true); setWidth("300px"); setClosable(false); Panel rootPanel = new Panel("Add new group"); VerticalLayout verticalLayout = new VerticalLayout(); VerticalLayout formLayout = new VerticalLayout(); final TextField tfName = new TextField("Name"); verticalLayout.addComponent(tfName); HorizontalLayout buttonLayout = new HorizontalLayout(); Button saveButton = new Button("Save"); Button cancelButton = new Button("Cancel"); saveButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (tfName.getValue().equals("")) { tfName.setComponentError(new UserError("Name must not be empty")); } else { tfName.setComponentError(null); } /* TODO XXX check for existing group: no duplicates! */ if (!tfName.getValue().equals("")) { tfName.setComponentError(null); long groupId = Util.generateId(); try { RecipientGroup g = new RecipientGroup(groupId, tfName.getValue().toString()); event.getButton().getWindow().setVisible(false); event.getButton().getWindow().getParent().removeComponent(event.getButton().getWindow()); event.getButton().getWindow().getParent().showNotification("Saved successfully", Notification.TYPE_HUMANIZED_MESSAGE); gl.getBeanContainer().addItem(g.getId(), g); // The group select could be placed anywhere but must be reloaded to reflect the changes. GroupSelectBox.reloadSelect(); } catch (RuntimeException e) { // Should never happen ... hopefully :D } } event.getButton().getWindow().setVisible(false); event.getButton().getWindow().getParent().removeComponent(event.getButton().getWindow()); } }); 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()); } }); buttonLayout.addComponent(saveButton); buttonLayout.addComponent(cancelButton); verticalLayout.addComponent(formLayout); verticalLayout.addComponent(buttonLayout); rootPanel.addComponent(verticalLayout); this.addComponent(rootPanel); }
From source file:com.trivago.mail.pigeon.web.components.mail.ModalAddNewsletter.java
License:Apache License
public ModalAddNewsletter(final NewsletterList nl) { super();//from w w w . ja va2s . 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); }