Example usage for com.vaadin.ui TextField TextField

List of usage examples for com.vaadin.ui TextField TextField

Introduction

In this page you can find the example usage for com.vaadin.ui TextField TextField.

Prototype

public TextField(ValueChangeListener<String> valueChangeListener) 

Source Link

Document

Constructs a new TextField with a value change listener.

Usage

From source file:com.trivago.mail.pigeon.web.components.sender.ModalAddNewSender.java

License:Apache License

public ModalAddNewSender(final SenderList sl) {
    super();/* ww  w  .j  a  v  a  2s . c  om*/
    setClosable(false);
    setModal(true);
    setWidth("300px");

    Panel rootPanel = new Panel("Add new Sender");
    final VerticalLayout verticalLayout = new VerticalLayout();
    final TextField tfName = new TextField("Name");
    final TextField tfFromMail = new TextField("From E-Mail");
    final TextField tfReplyTo = new TextField("ReplyTo E-Mail");

    verticalLayout.addComponent(tfName);
    verticalLayout.addComponent(tfFromMail);
    verticalLayout.addComponent(tfReplyTo);

    HorizontalLayout buttonLayout = new HorizontalLayout();

    Button saveButton = new Button("Save");
    Button cancelButton = new Button("Cancel");

    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) {
            if (tfName.getValue().equals("")) {
                tfName.setComponentError(new UserError("Name must not be empty"));
            } else {
                tfName.setComponentError(null);
            }

            if (tfFromMail.getValue().equals("")) {
                tfFromMail.setComponentError(new UserError("From E-Mail must not be empty"));
            } else {
                tfFromMail.setComponentError(null);
            }

            if (tfReplyTo.getValue().equals("")) {
                tfReplyTo.setComponentError(new UserError("Reply-To E-Mail must not be empty"));
            } else {
                tfReplyTo.setComponentError(null);
            }

            if (!tfName.getValue().equals("") && !tfFromMail.getValue().equals("")
                    && !tfReplyTo.getValue().equals("")) {
                tfName.setComponentError(null);
                tfFromMail.setComponentError(null);
                tfReplyTo.setComponentError(null);

                long senderId = Util.generateId();
                try {
                    Sender s = new Sender(senderId, tfFromMail.getValue().toString(),
                            tfReplyTo.getValue().toString(), 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);
                    sl.getBeanContainer().addItem(s.getId(), s);

                    // The sender select could be placed anywhere but must be reloaded to reflect the changes.
                    SenderSelectBox.reloadSelect();
                } catch (RuntimeException e) {
                    // Should never happen ... hopefully :D
                }
            }
        }
    });

    buttonLayout.setSpacing(true);
    buttonLayout.addComponent(saveButton);
    buttonLayout.addComponent(cancelButton);

    verticalLayout.addComponent(buttonLayout);
    rootPanel.addComponent(verticalLayout);
    this.addComponent(rootPanel);
}

From source file:com.trivago.mail.pigeon.web.components.templates.ModalAddTemplate.java

License:Apache License

public ModalAddTemplate(final TemplateList tl, final Long templateId) {
    setResizable(true);/*from www  .j  a  v  a  2  s .  c  o m*/
    setWidth("972px");
    setHeight("700px");
    Panel rootPanel = new Panel("Add new Template");
    TabSheet tSheet = new TabSheet();
    HorizontalLayout hLayout = new HorizontalLayout();

    final TextField title = new TextField("Template description");
    final TextField subject = new TextField("Newsletter Subject");

    final TextArea textContent = new TextArea("Text Version");
    textContent.setRows(40);
    textContent.setColumns(100);

    final CKEditorTextField htmlContent = new CKEditorTextField();
    htmlContent.setWidth("100%");
    htmlContent.setHeight("650px");

    // Load the content, if we receive a template id
    if (templateId != null) {
        MailTemplate mt = new MailTemplate(templateId);
        title.setValue(mt.getTitle());
        subject.setValue(mt.getSubject());
        textContent.setValue(mt.getText());
        htmlContent.setValue(mt.getHtml());
    }

    Button saveButton = new Button("Save");
    Button cancel = new Button("Cancel");

    saveButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            boolean hasError = false;
            if (title.getValue().equals("")) {
                title.setComponentError(new UserError("Name must not be empty"));
                hasError = true;
            } else {
                title.setComponentError(null);
            }

            if (subject.getValue().equals("")) {
                subject.setComponentError(new UserError("Subject must not be empty"));
                hasError = true;
            } else {
                subject.setComponentError(null);
            }

            if (htmlContent.getValue().equals("")) {
                htmlContent.setComponentError(new UserError("Please provide some HTML content"));
                hasError = true;
            } else {
                htmlContent.setComponentError(null);
            }

            if (textContent.getValue().equals("")) {
                textContent.setComponentError(new UserError("Please provide some text content"));
                hasError = true;
            } else {
                textContent.setComponentError(null);
            }

            if (!hasError) {
                if (templateId == null) {
                    long templateId = Util.generateId();
                    try {
                        MailTemplate mt = new MailTemplate(templateId, title.getValue().toString(),
                                textContent.getValue().toString(), htmlContent.getValue().toString(),
                                subject.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);
                        tl.getBeanContainer().addItem(mt.getId(), mt);
                    } catch (RuntimeException e) {
                        // Should never happen ... hopefully :D
                    }
                } else {
                    MailTemplate mt = new MailTemplate(templateId);

                    mt.setHtml(htmlContent.getValue().toString());
                    mt.setSubject(subject.getValue().toString());
                    mt.setText(textContent.getValue().toString());
                    mt.setTitle(title.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);

                    final int beanIndex = tl.getBeanContainer().indexOfId(mt.getId());
                    tl.getBeanContainer().removeItem(mt.getId());
                    tl.getBeanContainer().addItemAt(beanIndex, mt.getId(), mt);
                }
                TemplateSelectBox.reloadSelect();
            }
        }
    });

    hLayout.addComponent(saveButton);
    hLayout.addComponent(cancel);
    hLayout.setSpacing(true);

    VerticalLayout metaDataLayout = new VerticalLayout();

    Panel textFieldPanel = new Panel("Meta Data");
    VerticalLayout metaLayout = new VerticalLayout();
    metaLayout.addComponent(title);
    metaLayout.addComponent(subject);
    textFieldPanel.addComponent(metaLayout);

    Panel helpPanel = new Panel("Template Documentation");
    assembleHelpComponents(helpPanel);

    metaDataLayout.addComponent(textFieldPanel);
    metaDataLayout.addComponent(helpPanel);

    tSheet.addTab(metaDataLayout).setCaption("Meta Data");

    VerticalLayout textLayout = new VerticalLayout();
    textLayout.addComponent(textContent);
    tSheet.addTab(textLayout).setCaption("Text Content");

    VerticalLayout htmlLayout = new VerticalLayout();
    htmlLayout.addComponent(htmlContent);
    tSheet.addTab(htmlLayout).setCaption("HTML Content");

    rootPanel.addComponent(tSheet);
    rootPanel.addComponent(hLayout);
    addComponent(rootPanel);
}

From source file:com.trivago.mail.pigeon.web.components.wizard.setup.steps.WizardAddRecipientGroupComponent.java

License:Apache License

@Override
public Component getContent() {
    Label label = new Label("<p>The Recipient Group is the highest order of collection recipients. "
            + "You need a Recipient Group in order to send a Newsletter.</p>", Label.CONTENT_XHTML);
    Panel rootPanel = new Panel("Add new group");
    final VerticalLayout verticalLayout = new VerticalLayout();
    tfName = new TextField("Name");
    verticalLayout.addComponent(label);//w  w w.j  a  va  2  s . c  o m
    verticalLayout.addComponent(tfName);
    rootPanel.addComponent(verticalLayout);
    return rootPanel;
}

From source file:com.trivago.mail.pigeon.web.components.wizard.setup.steps.WizardAddSenderComponent.java

License:Apache License

@Override
public Component getContent() {
    final Panel rootPanel = new Panel("Add new Sender");
    final VerticalLayout verticalLayout = new VerticalLayout();
    Label label = new Label("The sender is a person or group that is shown as the sender of the newsletter.");
    tfName = new TextField("Name");
    tfFromMail = new TextField("From E-Mail");
    tfReplyTo = new TextField("ReplyTo E-Mail");

    verticalLayout.addComponent(label);/*w ww.  j  a v a 2s  .c o m*/
    verticalLayout.addComponent(tfName);
    verticalLayout.addComponent(tfFromMail);
    verticalLayout.addComponent(tfReplyTo);
    rootPanel.addComponent(verticalLayout);
    return rootPanel;
}

From source file:com.wcs.wcslib.vaadin.widget.jquerymask.DemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    setContent(root);//from   www  .  j  a  v a2  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);

}

From source file:com.wcs.wcslib.vaadin.widget.recaptcha.demo.ConfigComponent.java

License:Apache License

private Layout createLangconfLayout() throws FieldGroup.BindException {
    VerticalLayout langLayout = new VerticalLayout();
    langField = new TextField("lang");
    langLayout.addComponent(new FormLayout(langField));
    final FormLayout translationsLayout = new FormLayout();
    translationsLayout.setSpacing(false);
    useTranslations = new CheckBox("use translations below");
    langLayout.addComponent(useTranslations);
    useTranslations.addValueChangeListener(new Property.ValueChangeListener() {

        @Override/*from   w w w . j a  v  a  2  s  . c  o m*/
        public void valueChange(Property.ValueChangeEvent event) {
            Boolean checked = useTranslations.getValue();
            for (Component c : translationsLayout) {
                c.setEnabled(checked);
            }
        }
    });
    translations = new CustomTranslationsBean();
    BeanFieldGroup<CustomTranslationsBean> translationsFieldGroup = new BeanFieldGroup<CustomTranslationsBean>(
            CustomTranslationsBean.class);
    translationsFieldGroup.setItemDataSource((CustomTranslationsBean) translations);
    Collection<Object> propertyIds = translationsFieldGroup.getUnboundPropertyIds();
    translationsFieldGroup.setBuffered(false);
    for (Object property : propertyIds) {
        Field<?> field = translationsFieldGroup.buildAndBind(property);
        ((TextField) field).setNullRepresentation("");
        field.setCaption(field.getCaption().toLowerCase());
        field.setEnabled(false);
        translationsLayout.addComponent(field);
    }
    langLayout.addComponent(translationsLayout);
    return langLayout;
}

From source file:com.wintindustries.pfserver.interfaces.view.dashboard.LoginView.java

private Component buildFields() {
    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);/*from  w  w w.j av  a  2s  .c o m*/
    fields.addStyleName("fields");

    final TextField username = new TextField("Username");
    username.setIcon(FontAwesome.USER);
    username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final PasswordField password = new PasswordField("Password");
    password.setIcon(FontAwesome.LOCK);
    password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final Button signin = new Button("Sign In");
    signin.addStyleName(ValoTheme.BUTTON_PRIMARY);
    signin.setClickShortcut(KeyCode.ENTER);
    signin.focus();

    fields.addComponents(username, password, signin);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);

    signin.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {

            System.out.println("TRIGGER LOGIN");
            DashboardEventBus.post(new UserLoginRequestedEvent(username.getValue(), password.getValue()));
        }
    });
    return fields;
}

From source file:com.yoncabt.ebr.ui.ReportWindow.java

private void showFields(ReportDefinition definition, final Window w, final FormLayout fl)
        throws AssertionError, JSONException {
    fl.removeAllComponents();//from ww w.  ja v a 2 s. c  o m
    w.setCaption(definition.getCaption());
    for (ReportParam param : definition.getReportParams()) {
        AbstractField comp = null;
        if (param.getInputType() == InputType.COMBO) {
            ComboBox f = new ComboBox(param.getLabel());
            param.getLovData().forEach((k, v) -> {
                f.addItem(k);
                f.setItemCaption(k, (String) v);
            });
            comp = f;
        } else {
            switch (param.getFieldType()) {
            case STRING: {
                TextField f = new TextField(param.getLabel());
                comp = f;
                break;
            }
            case INTEGER: {
                TextField f = new TextField(param.getLabel());
                f.addValidator(new IntegerRangeValidator("Say kontrol", (Integer) param.getMin(),
                        (Integer) param.getMax()));
                comp = f;
                break;
            }
            case LONG: {
                TextField f = new TextField(param.getLabel());
                f.addValidator(new LongRangeValidator("Say kontrol", (Long) param.getMin(),
                        (Long) param.getMax()));
                comp = f;
                break;
            }
            case DOUBLE: {
                TextField f = new TextField(param.getLabel());
                f.addValidator(new DoubleRangeValidator("Say kontrol", (Double) param.getMin(),
                        (Double) param.getMax()));
                comp = f;
                break;
            }
            case DATE: {
                DateField f = new DateField(param.getLabel());
                f.setDateFormat(param.getFormat());
                comp = f;
                break;
            }
            default: {
                throw new AssertionError(param.getName() + " in tipi tannmyor :" + param.getJavaType());
            }
            }
        }
        if (param.getDefaultValue() != null) {
            comp.setValue(param.getDefaultValue());
        }
        comp.setImmediate(true);
        comp.setValidationVisible(false);
        comp.setId(param.getName());
        fl.addComponent(comp);

    }
    if (report instanceof SQLReport) {
        reportType.addItem(ReportOutputFormat.xls);
        reportType.setItemCaption(ReportOutputFormat.xls, ReportOutputFormat.xls.getTypeName());
    } else {
        for (ReportOutputFormat value : ReportOutputFormat.values()) {
            reportType.addItem(value);
            reportType.setItemCaption(value, value.getTypeName());
        }
    }
    reportType.setValue(ReportOutputFormat.xls);
    fl.addComponent(reportType);
    fl.addComponent(reportLocale);
    fl.addComponent(email);
}

From source file:cz.iivos.todo.components.InputFormLayout.java

/**
 * Vytvori pole pre textField a zviaze ho s FG.
 *
 * @param fn/*from w w w  . j  a v a  2s .com*/
 * @return
 */
public TextField bindTextField(String fn) {
    TextField field = new TextField(fn);
    field.setNullRepresentation("");
    field.setInputPrompt("Nadpis...");
    fg.bind(field, fn);
    return field;
}

From source file:de.catma.ui.tagmanager.PropertyDefinitionDialog.java

License:Open Source License

private void initComponents(String caption) {
    setMargin(true);/* ww  w.ja v a2 s.c  o m*/
    setSpacing(true);

    GridLayout propPanel = new GridLayout(3, 3);
    propPanel.setSpacing(true);

    nameInput = new TextField("Name");
    nameInput.setRequired(true);
    if (propertyDefinition != null) {
        nameInput.setValue(propertyDefinition.getName());
    }
    propPanel.addComponent(nameInput, 0, 0, 2, 0);

    if (propertyDefinition != null) {
        valueInput = new ListSelect("Possible values",
                propertyDefinition.getPossibleValueList().getPropertyValueList().getValues());
    } else {
        valueInput = new ListSelect("Possible values");
    }
    valueInput.setWidth("100%");
    valueInput.setRequired(true);
    valueInput.setNullSelectionAllowed(false);

    propPanel.addComponent(valueInput, 0, 1, 2, 1);

    newValueInput = new TextField("Add possible value");
    propPanel.addComponent(newValueInput, 0, 2);

    btAdd = new Button("+");
    propPanel.addComponent(btAdd, 1, 2);
    propPanel.setComponentAlignment(btAdd, Alignment.BOTTOM_CENTER);

    btRemove = new Button("-");
    propPanel.addComponent(btRemove, 2, 2);
    propPanel.setComponentAlignment(btRemove, Alignment.BOTTOM_CENTER);

    addComponent(propPanel);

    HorizontalLayout buttonPanel = new HorizontalLayout();
    buttonPanel.setSpacing(true);

    btSave = new Button("Save");
    buttonPanel.addComponent(btSave);
    buttonPanel.setComponentAlignment(btSave, Alignment.MIDDLE_RIGHT);

    btCancel = new Button("Cancel");
    buttonPanel.addComponent(btCancel);
    buttonPanel.setComponentAlignment(btCancel, Alignment.MIDDLE_RIGHT);

    addComponent(buttonPanel);
    setComponentAlignment(buttonPanel, Alignment.MIDDLE_RIGHT);

    window = new Window(caption);
    window.setContent(this);
    window.setWidth("30%");
    window.setHeight("70%");
    window.center();
}