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.emuanalytics.vaadin.enhancedjavascript.BasicTestUI.java

License:Apache License

private Component createTestPanel() {

    TextField valueField = new TextField("Server value to send:");
    valueField.setId("server-value-input");

    Button setValueButton = new Button("Set Value From Server", clickEvent -> {
        sampleComponent.setValue(valueField.getValue());
    });/*from  w  w w  .j av a 2 s  .c  o  m*/
    setValueButton.setId("set-value-button");

    Button setTitleButton = new Button("Set Title From Server", clickEvent -> {
        sampleComponent.setTitle(valueField.getValue());
    });
    setTitleButton.setId("set-title-button");

    Button setValueRPCButton = new Button("Set Value Via RPC", clickEvent -> {
        sampleComponent.setValueViaRPC(valueField.getValue());
    });
    setValueRPCButton.setId("set-value-rpc-button");

    CheckBox immediateCheckbox = new CheckBox("Immediate variable notification");
    immediateCheckbox.addValueChangeListener(e -> {
        sampleComponent.setImmediate(immediateCheckbox.getValue());
    });
    immediateCheckbox.setId("immediate-checkbox");

    lastEventField = new TextField("Last event:");
    lastEventField.setId("last-event-field");

    lastVariableChangeField = new TextField("Last variable change:");
    lastVariableChangeField.setId("last-variable-change-field");

    VerticalLayout testLayout = new VerticalLayout(valueField, setValueButton, setTitleButton,
            setValueRPCButton, immediateCheckbox, lastEventField, lastVariableChangeField);

    testLayout.setWidth("300px");
    testLayout.setSpacing(true);

    for (Component c : testLayout) {
        c.setWidth("100%");
    }

    return testLayout;
}

From source file:com.esspl.datagen.DataGenApplication.java

License:Open Source License

public void addRow(int noOfRow) {
    log.debug("DataGenApplication - addRow() start");
    int maxSize = tableLength + noOfRow;
    for (int i = tableLength; i <= maxSize; i++) {
        log.info("DataGenApplication - addRow(): Adding row- " + i);
        Select dataType = new Select();
        dataType.addItem("Name");
        dataType.addItem("Title");
        dataType.addItem("Phone/Fax");
        dataType.addItem("Email");
        dataType.addItem("Date");
        dataType.addItem("Street Address");
        dataType.addItem("City");
        dataType.addItem("Postal/Zip");
        dataType.addItem("State/Provience/County");
        dataType.addItem("Country");
        dataType.addItem("Random Text");
        dataType.addItem("Fixed Text");
        dataType.addItem("Incremental Number");
        dataType.addItem("Number Range");
        dataType.addItem("Alphanumeric");
        dataType.addItem("Marital Status");
        dataType.addItem("Department Name");
        dataType.addItem("Company Name");
        dataType.addItem("Boolean Flag");
        dataType.addItem("Passport Number");
        dataType.setWidth("100%");
        dataType.setImmediate(true);/*ww  w.j av a 2 s.c o  m*/
        dataType.setData(i);
        dataType.setCaption("DataType");
        dataType.addListener(this);

        Select format = new Select();
        format.setData(i);
        format.setCaption("Format");
        format.setImmediate(true);
        format.setWidth("100%");
        format.setEnabled(false);
        format.addListener(this);

        Label example = new Label("NA");
        example.setWidth("100%");

        TextField field = new TextField("");

        HorizontalLayout addBar = new HorizontalLayout();
        addBar.setWidth("100%");
        addBar.addComponent(new Label("NA"));

        listing.addItem(new Object[] { i, field, dataType, format, example, addBar }, i);
        tableLength = i;
    }
    log.debug("DataGenApplication - addRow() end");
}

From source file:com.etest.valo.Forms.java

License:Apache License

public Forms() {
    setSpacing(true);/*from  w w  w.j a  v a 2s  .  c om*/
    setMargin(true);

    Label title = new Label("Forms");
    title.addStyleName("h1");
    addComponent(title);

    final FormLayout form = new FormLayout();
    form.setMargin(false);
    form.setWidth("800px");
    form.addStyleName("light");
    addComponent(form);

    Label section = new Label("Personal Info");
    section.addStyleName("h2");
    section.addStyleName("colored");
    form.addComponent(section);
    StringGenerator sg = new StringGenerator();

    TextField name = new TextField("Name");
    name.setValue(sg.nextString(true) + " " + sg.nextString(true));
    name.setWidth("50%");
    form.addComponent(name);

    DateField birthday = new DateField("Birthday");
    birthday.setValue(new Date(80, 0, 31));
    form.addComponent(birthday);

    TextField username = new TextField("Username");
    username.setValue(sg.nextString(false) + sg.nextString(false));
    username.setRequired(true);
    form.addComponent(username);

    OptionGroup sex = new OptionGroup("Sex");
    sex.addItem("Female");
    sex.addItem("Male");
    sex.select("Male");
    sex.addStyleName("horizontal");
    form.addComponent(sex);

    section = new Label("Contact Info");
    section.addStyleName("h3");
    section.addStyleName("colored");
    form.addComponent(section);

    TextField email = new TextField("Email");
    email.setValue(sg.nextString(false) + "@" + sg.nextString(false) + ".com");
    email.setWidth("50%");
    email.setRequired(true);
    form.addComponent(email);

    TextField location = new TextField("Location");
    location.setValue(sg.nextString(true) + ", " + sg.nextString(true));
    location.setWidth("50%");
    location.setComponentError(new UserError("This address doesn't exist"));
    form.addComponent(location);

    TextField phone = new TextField("Phone");
    phone.setWidth("50%");
    form.addComponent(phone);

    HorizontalLayout wrap = new HorizontalLayout();
    wrap.setSpacing(true);
    wrap.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    wrap.setCaption("Newsletter");
    CheckBox newsletter = new CheckBox("Subscribe to newsletter", true);
    wrap.addComponent(newsletter);

    ComboBox period = new ComboBox();
    period.setTextInputAllowed(false);
    period.addItem("Daily");
    period.addItem("Weekly");
    period.addItem("Monthly");
    period.setNullSelectionAllowed(false);
    period.select("Weekly");
    period.addStyleName("small");
    period.setWidth("10em");
    wrap.addComponent(period);
    form.addComponent(wrap);

    section = new Label("Additional Info");
    section.addStyleName("h4");
    section.addStyleName("colored");
    form.addComponent(section);

    TextField website = new TextField("Website");
    website.setInputPrompt("http://");
    website.setWidth("100%");
    form.addComponent(website);

    TextArea shortbio = new TextArea("Short Bio");
    shortbio.setValue(
            "Quis aute iure reprehenderit in voluptate velit esse. Cras mattis iudicium purus sit amet fermentum.");
    shortbio.setWidth("100%");
    shortbio.setRows(2);
    form.addComponent(shortbio);

    final RichTextArea bio = new RichTextArea("Bio");
    bio.setWidth("100%");
    bio.setValue(
            "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi  dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>");
    form.addComponent(bio);

    form.setReadOnly(true);
    bio.setReadOnly(true);

    Button edit = new Button("Edit", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            boolean readOnly = form.isReadOnly();
            if (readOnly) {
                bio.setReadOnly(false);
                form.setReadOnly(false);
                form.removeStyleName("light");
                event.getButton().setCaption("Save");
                event.getButton().addStyleName("primary");
            } else {
                bio.setReadOnly(true);
                form.setReadOnly(true);
                form.addStyleName("light");
                event.getButton().setCaption("Edit");
                event.getButton().removeStyleName("primary");
            }
        }
    });

    HorizontalLayout footer = new HorizontalLayout();
    footer.setMargin(new MarginInfo(true, false, true, false));
    footer.setSpacing(true);
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    form.addComponent(footer);
    footer.addComponent(edit);

    Label lastModified = new Label("Last modified by you a minute ago");
    lastModified.addStyleName("light");
    footer.addComponent(lastModified);
}

From source file:com.example.testzbox.vista.TabCarga.java

private void iniciarElementos() {

    //layout.setSpacing(true);
    layout.setWidth(200.0f, Unit.PERCENTAGE);
    //layout.setSizeFull();

    cmbArea = new ComboBox("Area");
    cmbArea.setWidth(30.0f, Unit.PERCENTAGE);
    cmbArea.setNullSelectionAllowed(false);
    cmbArea.setTextInputAllowed(false);/*from   w w  w.  ja va 2  s  . c o  m*/
    cmbArea.setInputPrompt("Seleccione");
    cmbArea.addItem("adjustment");
    //        cmbArea.addItem("theft");
    //        cmbArea.addItem("siu");
    //        cmbArea.addItem("glasses");
    //        cmbArea.addItem("payments");
    //        cmbArea.addItem("valuation");
    //                
    cmbOperacion = new ComboBox("Operacin");
    cmbOperacion.setWidth(30.0f, Unit.PERCENTAGE);
    cmbOperacion.setNullSelectionAllowed(false);
    cmbOperacion.setTextInputAllowed(false);
    cmbOperacion.setInputPrompt("Seleccione");
    cmbOperacion.addItem("Asegurado");
    cmbOperacion.addItem("Tercero");

    txtNombreDoc = new TextField("Nombre Documento");
    txtNombreDoc.setWidth(30.0f, Unit.PERCENTAGE);

    //SINIESTRO
    txtNumSiniestro = new TextField("Nmero Siniestro");
    txtNumSiniestro.setWidth(30.0f, Unit.PERCENTAGE);
    txtNumPoliza = new TextField("Nmero de Pliza");
    txtNumPoliza.setWidth(30.0f, Unit.PERCENTAGE);
    txtNombAsegurado = new TextField("Nombre Asegurado");
    txtNombAsegurado.setWidth(30.0f, Unit.PERCENTAGE);
    dateFechaDocumento = new DateField("Fecha Creacin");
    dateFechaDocumento.setWidth(30.0f, Unit.PERCENTAGE);
    txtIdUsuarioCmp = new TextField("Id Usuario");
    txtIdUsuarioCmp.setWidth(30.0f, Unit.PERCENTAGE);

    //TIPO DOCUMENTAL
    cmbTipoDoc = new ComboBox("Tipo Documental");
    cmbTipoDoc.setWidth(30.0f, Unit.PERCENTAGE);
    cmbTipoDoc.setNullSelectionAllowed(false);
    cmbTipoDoc.setTextInputAllowed(false);
    cmbTipoDoc.setInputPrompt("Seleccione");
    cmbTipoDoc.addItem("averiguacionPrevia");
    cmbTipoDoc.addItem("declaracionUniversalAccidente");
    cmbTipoDoc.addItem("declaracionUniversalAccidenteSIPAC");
    cmbTipoDoc.addItem("demanda");
    cmbTipoDoc.addItem("poderNotarial");
    cmbTipoDoc.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            dateFechaExpedicion.setVisible(true);
            txtFolioActa.setVisible(true);
            cmbTipoEvento.setVisible(true);
        }
    });

    dateFechaExpedicion = new DateField("Fecha Expedicin");
    dateFechaExpedicion.setWidth(30.0f, Unit.PERCENTAGE);
    dateFechaExpedicion.setVisible(false);
    txtFolioActa = new TextField("Folio Acta");
    txtFolioActa.setWidth(30.0f, Unit.PERCENTAGE);
    txtFolioActa.setVisible(false);
    cmbTipoEvento = new ComboBox("Tipo Evento");
    cmbTipoEvento.setWidth(30.0f, Unit.PERCENTAGE);
    cmbTipoEvento.setVisible(false);
    cmbTipoEvento.setNullSelectionAllowed(false);
    cmbTipoEvento.setTextInputAllowed(false);
    cmbTipoEvento.setInputPrompt("Seleccione");
    cmbTipoEvento.addItem("Averiguacin Previa");
    cmbTipoEvento.addItem("DUA");
    cmbTipoEvento.addItem("DUA SIPAC");
    cmbTipoEvento.addItem("DUA Cristaleras");
    cmbTipoEvento.addItem("Demanda");
    cmbTipoEvento.addItem("Poder Notarial");

    lblPathArchivo = new Label();
    lblPathArchivo.setVisible(false);
    lblExtensionArchivo = new Label();
    lblExtensionArchivo.setVisible(false);

    //  form.setSpacing(true);
    form.addComponents(cmbArea, cmbOperacion, txtNombreDoc, txtNumSiniestro, txtNumPoliza, txtNombAsegurado,
            dateFechaDocumento, txtIdUsuarioCmp, cmbTipoDoc, dateFechaExpedicion, txtFolioActa, cmbTipoEvento);

    uploader = uploadContents();
    btnEnviar = new Button("Enviar");
    btnEnviar.addStyleName(ValoTheme.BUTTON_PRIMARY);
    btnEnviar.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            //Path pathFile = Paths.get("C:\\Documento Prueba.pdf");
            Path pathFile = Paths.get(lblPathArchivo.getCaption());

            DocumentoVO documentoVO = new DocumentoVO();

            documentoVO.setNombreDocumento(txtNombreDoc.getValue() + "." + lblExtensionArchivo.getCaption());
            documentoVO.setSubTipoDocumental(cmbTipoDoc.getValue().toString());
            documentoVO.setInputStream(pathFile.toFile());

            Map<String, String> metadatos = new HashMap<>();
            metadatos.put("folioActa", txtFolioActa.getValue());
            metadatos.put("tipoEvento", cmbTipoEvento.getValue().toString());
            metadatos.put("fechaExpedicion", convertDate(dateFechaExpedicion));
            metadatos.put("numeroSiniestro", txtNumSiniestro.getValue());
            metadatos.put("numeroPoliza", txtNumPoliza.getValue());
            metadatos.put("nombreAsegurado", txtNombAsegurado.getValue());
            metadatos.put("fechaCreacionDocumento", convertDate(dateFechaDocumento));
            metadatos.put("idUsuarioCmp", txtIdUsuarioCmp.getValue());
            metadatos.put("area", cmbArea.getValue().toString());
            metadatos.put("operacion", cmbOperacion.getValue().toString());

            documentoVO.setMetadatos(metadatos);

            cargarDocumento(documentoVO);

        }

    });

    footer.setSpacing(true);
    footer.setWidth(38.0f, Unit.PERCENTAGE);
    footer.addComponents(uploader, btnEnviar);
    footer.setComponentAlignment(btnEnviar, Alignment.BOTTOM_RIGHT);

    layout.addComponents(form, lblPathArchivo, footer);

    setCaption("Carga");
    setMargin(true);
    //setSpacing(true);
    addComponents(layout, panel);

}

From source file:com.example.testzbox.vista.TabChecklist.java

private void initElements() {

    txtNumSiniestro = new TextField("Nmero Siniestro");
    txtNumSiniestro.setWidth(30.0f, Sizeable.Unit.PERCENTAGE);

    cmbChecklist = new ComboBox("Checklist");
    cmbChecklist.setWidth(30.0f, Sizeable.Unit.PERCENTAGE);
    cmbChecklist.setNullSelectionAllowed(false);
    cmbChecklist.setTextInputAllowed(false);
    cmbChecklist.setInputPrompt("Seleccione");
    cmbChecklist.addItem("CHKLST_AJT_ASG_001");
    cmbChecklist.addItem("CHKLST_AJT_TRC_001");
    cmbChecklist.addItem("CHKLST_PAG_PT_006");
    cmbChecklist.addItem("CHKLST_PAG_PD_001");

    form.addComponents(txtNumSiniestro, cmbChecklist);

    btnVerificar = new Button("Verificar");
    btnVerificar.addStyleName(ValoTheme.BUTTON_PRIMARY);
    btnVerificar.addClickListener(new Button.ClickListener() {
        @Override/*ww  w. ja va  2 s .  c  o m*/
        public void buttonClick(Button.ClickEvent event) {

            CheckListVO checkListVO = new CheckListVO();

            checkListVO.setIdCheckList(cmbChecklist.getValue().toString());

            Map<String, String> parametros = new HashMap<>();
            parametros.put("numeroSiniestro", txtNumSiniestro.getValue());

            checkListVO.setParametros(parametros);

            verificarChecklist(checkListVO);

        }

    });

    footer.setSpacing(true);
    footer.setWidth(38.0f, Unit.PERCENTAGE);
    footer.addComponents(btnVerificar);
    footer.setComponentAlignment(btnVerificar, Alignment.BOTTOM_RIGHT);

    panel1.setVisible(false);

    setCaption("Checklist");
    setSpacing(true);
    setMargin(true);
    addComponents(form, footer, panel1);

}

From source file:com.example.tomeevaadin.ui.BookUI.java

private HorizontalLayout addInputFields() {
    HorizontalLayout hl = new HorizontalLayout();
    hl.addComponent(new Label("Enter a book"));
    TextField field = new TextField(stringModel);
    Button button = new Button("press this to save");
    button.addClickListener(new Button.ClickListener() {

        @Override//from   w ww . j  a  va  2  s. c o  m
        public void buttonClick(Button.ClickEvent event) {
            if (bookService == null) {
                System.out.println("uho, ejb is null");
            }
            Notification.show("button is pressed " + stringModel.getValue());
            Book book = new Book();
            book.setBookTitle(stringModel.getValue());
            bookService.addBook(book);
            updateBeanContainer();

        }
    });
    hl.addComponent(field);
    hl.addComponent(button);
    return hl;
}

From source file:com.foc.vaadin.gui.windows.CreateLayoutWindow.java

License:Apache License

public CreateLayoutWindow(final FVLayout layout) {
    setModal(true);//from w  ww .  jav  a2  s .c o  m
    setWidth("250px");
    setHeight("250px");

    mainLayout = new VerticalLayout();
    buttonsLayout = new HorizontalLayout();

    width = new TextField("Width:");
    height = new TextField("Height:");
    border = new CheckBox("Border:");

    if (layout instanceof FVGridLayout) {
        rows = new TextField("Rows:");
        cols = new TextField("Columns:");
    }

    create = new Button("Create");
    cancel = new Button("Cancel");

    cancel.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });

    create.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            layout.setHeight(height.getValue().toString());
            layout.setWidth(width.getValue().toString());

            AttributesImpl attributesImpl = new AttributesImpl(layout.getAttributes());
            attributesImpl.addAttribute("", "name", "name", "CDATA", "null");
            attributesImpl.addAttribute("", "width", "width", "CDATA", width.getValue() + "px");
            attributesImpl.addAttribute("", "height", "height", "CDATA", height.getValue() + "px");

            if (rows != null) {
                ((FVGridLayout) layout).setRows(Integer.parseInt(rows.getValue().toString()));
                ((FVGridLayout) layout).setColumns(Integer.parseInt(cols.getValue().toString()));

                attributesImpl.addAttribute("", "cols", "cols", "CDATA", cols.getValue() + "");
                attributesImpl.addAttribute("", "rows", "rows", "CDATA", rows.getValue() + "");
            }

            layout.setAttributes(attributesImpl);

            if (border.booleanValue()) {
                layout.addStyleName("border");
            }

            close();
        }
    });

    buttonsLayout.setMargin(true);
    buttonsLayout.setSpacing(true);
    buttonsLayout.addComponent(create);
    buttonsLayout.addComponent(cancel);
    mainLayout.addComponent(width);
    mainLayout.addComponent(height);
    if (rows != null) {
        mainLayout.addComponent(rows);
        mainLayout.addComponent(cols);
        mainLayout.setComponentAlignment(rows, Alignment.MIDDLE_CENTER);
        mainLayout.setComponentAlignment(cols, Alignment.MIDDLE_CENTER);
    }
    mainLayout.addComponent(border);
    mainLayout.addComponent(buttonsLayout);
    mainLayout.setComponentAlignment(width, Alignment.MIDDLE_CENTER);
    mainLayout.setComponentAlignment(height, Alignment.MIDDLE_CENTER);
    mainLayout.setComponentAlignment(border, Alignment.MIDDLE_CENTER);
    mainLayout.setComponentAlignment(buttonsLayout, Alignment.MIDDLE_CENTER);
    setContent(mainLayout);
}

From source file:com.foc.vaadin.gui.windows.LineLabelCreator.java

License:Apache License

public LineLabelCreator(final FVLabel label) {
    setModal(true);//from  w  w  w  .j  av a  2s . c  o m
    setWidth("250px");
    setHeight("200px");

    layout = new VerticalLayout();
    buttonsLayout = new HorizontalLayout();

    lineHeight = new TextField("Line Height:");
    lineWidth = new TextField("Line Width:");

    create = new Button("Create");
    cancel = new Button("Cancel");

    cancel.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });

    create.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            AttributesImpl attributes = new AttributesImpl();
            attributes.addAttribute("", "name", "name", "CDATA", "null");
            attributes.addAttribute("", "value", "value", "CDATA", " ");
            attributes.addAttribute("", "bgColor", "bgColor", "CDATA", "#CCCCCC");

            if (!lineHeight.getValue().toString().isEmpty()) {
                attributes.addAttribute("", "height", "height", "CDATA", lineHeight.getValue() + "px");
            }

            if (!lineWidth.getValue().toString().isEmpty()) {
                attributes.addAttribute("", "width", "width", "CDATA", lineWidth.getValue() + "px");
            }

            label.setAttributes(attributes);
            label.initLabel();

            label.requestRepaint();

            close();
        }
    });

    buttonsLayout.setMargin(true);
    buttonsLayout.setSpacing(true);
    buttonsLayout.addComponent(create);
    buttonsLayout.addComponent(cancel);
    layout.addComponent(lineHeight);
    layout.addComponent(lineWidth);
    layout.addComponent(buttonsLayout);
    layout.setComponentAlignment(lineHeight, Alignment.MIDDLE_CENTER);
    layout.setComponentAlignment(lineWidth, Alignment.MIDDLE_CENTER);
    layout.setComponentAlignment(buttonsLayout, Alignment.MIDDLE_CENTER);
    setContent(layout);
}

From source file:com.github.carljmosca.MainLayout.java

private void init() {
    setSizeFull();//from  w ww.  j  av  a  2  s. c o m
    addStyleName("menylayout");
    Responsive.makeResponsive(this);
    ComboBox<Person> cmbPerson = new ComboBox<>();
    cmbPerson.setItems(personProcessor.findAll());
    cmbPerson.setItemCaptionGenerator(c -> c.getTitle() + " " + c.getFirstName() + " " + c.getLastName());
    cmbPerson.addValueChangeListener((HasValue.ValueChangeEvent<Person> event) -> {
        binder.setBean(cmbPerson.getValue());
    });
    title = new ComboBox("Title", Arrays.asList(titles));
    firstName = new TextField("First");
    middleName = new TextField("Middle");
    lastName = new TextField("Last");
    Button btnNew = new Button("New");
    btnNew.addClickListener((Button.ClickEvent event) -> {
        person = new Person();
        binder.setBean(person);
    });
    Button btnSave = new Button("Save");
    btnSave.addClickListener((Button.ClickEvent event) -> {
        personProcessor.addPerson(person);
        cmbPerson.setItems(personProcessor.findAll());
    });
    personLayout.setWidth(null);
    personLayout.setSpacing(true);
    personLayout.addStyleName("menu");
    personLayout.addComponent(title);
    personLayout.addComponent(firstName);
    personLayout.addComponent(middleName);
    personLayout.addComponent(lastName);
    personLayout.addComponent(btnNew);
    addComponent(btnSave);
    addComponent(cmbPerson);
    addComponent(personLayout);
    //addComponent(buttonLayout);
    doBinding();
}

From source file:com.github.daytron.tablebean.tableColumn.DateSourcePlay.java

License:Open Source License

public DateSourcePlay() {

    Property<String> property = new ObjectProperty<>("ABC");
    final TextField tf = new TextField(property);
    tf.setBuffered(true);/*  w  ww.  j a v a2  s.c o m*/

    tf.addTextChangeListener(new FieldEvents.TextChangeListener() {

        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            Notification.show("Text change (event): " + event.getText(), Notification.Type.TRAY_NOTIFICATION);
        }
    });

    Button commitButton = new Button("Save");
    commitButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Notification.show("Before commit (property): " + tf.getPropertyDataSource().getValue(),
                    Notification.Type.TRAY_NOTIFICATION);

            tf.commit();

            Notification.show("After commit (property): " + tf.getPropertyDataSource().getValue(),
                    Notification.Type.TRAY_NOTIFICATION);
        }
    });

    Button discardButton = new Button("Cancel");
    discardButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Notification.show("Before discard (property): " + tf.getPropertyDataSource().getValue(),
                    Notification.Type.TRAY_NOTIFICATION);

            tf.discard();

            Notification.show("After discard (property): " + tf.getPropertyDataSource().getValue(),
                    Notification.Type.TRAY_NOTIFICATION);
        }
    });

    addComponent(tf);
    addComponent(commitButton);
    addComponent(discardButton);
}