Search in sources :

Example 46 with TextField

use of com.vaadin.flow.component.textfield.TextField in project flow-components by vaadin.

the class TreeGridComponentHierarchyColumnPage method createTextField.

private TextField createTextField(String value) {
    TextField textField = new TextField();
    textField.setReadOnly(true);
    textField.setValue(value);
    return textField;
}
Also used : TextField(com.vaadin.flow.component.textfield.TextField)

Example 47 with TextField

use of com.vaadin.flow.component.textfield.TextField in project flow-components by vaadin.

the class FormLayoutView method createResponsiveLayout.

private void createResponsiveLayout() {
    FormLayout nameLayout = new FormLayout();
    TextField titleField = new TextField();
    titleField.setLabel("Title");
    titleField.setPlaceholder("Sir");
    TextField firstNameField = new TextField();
    firstNameField.setLabel("First name");
    firstNameField.setPlaceholder("John");
    TextField lastNameField = new TextField();
    lastNameField.setLabel("Last name");
    lastNameField.setPlaceholder("Doe");
    nameLayout.add(titleField, firstNameField, lastNameField);
    // Default number of columns in a FormLayout is 2. By setting the
    // responsive steps we specify different numbers for columns with
    // breakpoints at “40em” “32em” and “25em”. Now by changing the size of
    // the browser horizontally, you can notice that the number of the
    // columns in the FormLayout changes.
    nameLayout.setResponsiveSteps(new ResponsiveStep("1px", 1), new ResponsiveStep("600px", 2), new ResponsiveStep("700px", 3));
    addCard("A form layout with custom responsive layouting", nameLayout);
}
Also used : FormLayout(com.vaadin.flow.component.formlayout.FormLayout) TextField(com.vaadin.flow.component.textfield.TextField) ResponsiveStep(com.vaadin.flow.component.formlayout.FormLayout.ResponsiveStep)

Example 48 with TextField

use of com.vaadin.flow.component.textfield.TextField in project DoodleVerse by davidemarcoli.

the class CitizenManagementView method createEditor.

/**
 * Create the CRUD Editor
 * @return the CrudEditor
 */
private CrudEditor<Person> createEditor() {
    TextField firstName = new TextField("First name");
    TextField lastName = new TextField("Last name");
    NumberField money = new NumberField("Money");
    money.setReadOnly(true);
    Double randomMoneyAmount = rand.nextDouble(100000 + 1 - 10000) + 10000;
    money.setValue(randomMoneyAmount);
    FormLayout form = new FormLayout(firstName, lastName, money);
    form.setColspan(money, 2);
    form.setMaxWidth("480px");
    form.setResponsiveSteps(new FormLayout.ResponsiveStep("0", 1), new FormLayout.ResponsiveStep("30em", 2));
    Binder<Person> binder = new Binder<>(Person.class);
    binder.forField(firstName).asRequired().bind(Person::getFirstName, Person::setFirstName);
    binder.forField(lastName).asRequired().bind(Person::getLastName, Person::setLastName);
    binder.forField(money).asRequired().bind(Person::getMoney, Person::setMoney).setReadOnly(true);
    return new BinderCrudEditor<>(binder, form);
}
Also used : FormLayout(com.vaadin.flow.component.formlayout.FormLayout) Binder(com.vaadin.flow.data.binder.Binder) TextField(com.vaadin.flow.component.textfield.TextField) BinderCrudEditor(com.vaadin.flow.component.crud.BinderCrudEditor) Person(com.dala.data.person.Person) NumberField(com.vaadin.flow.component.textfield.NumberField)

Example 49 with TextField

use of com.vaadin.flow.component.textfield.TextField in project iesi by metadew.

the class TemplateView method createTopBar.

public HorizontalLayout createTopBar() {
    filter = new TextField();
    filter.setPlaceholder("Filter name or description");
    // Apply the filter to grid's data provider. TextField value is never null
    filter.addValueChangeListener(event -> dataProvider.setFilter(event.getValue()));
    filter.addFocusShortcut(Key.KEY_F, KeyModifier.CONTROL);
    newRequestTemplate = new Button("New Template");
    newRequestTemplate.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
    newRequestTemplate.setIcon(VaadinIcon.PLUS_CIRCLE.create());
    newRequestTemplate.addClickListener(click -> viewLogic.newRequestTemplate());
    // CTRL+N will create a new window which is unavoidable
    newRequestTemplate.addClickShortcut(Key.KEY_N, KeyModifier.ALT);
    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setWidth("100%");
    topLayout.add(filter);
    topLayout.add(newRequestTemplate);
    topLayout.setVerticalComponentAlignment(Alignment.START, filter);
    topLayout.expand(filter);
    return topLayout;
}
Also used : Button(com.vaadin.flow.component.button.Button) TextField(com.vaadin.flow.component.textfield.TextField) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 50 with TextField

use of com.vaadin.flow.component.textfield.TextField in project iesi by metadew.

the class ComponentView method createTopBar.

public HorizontalLayout createTopBar() {
    filter = new TextField();
    filter.setPlaceholder("Filter name or description");
    // Apply the filter to grid's data provider. TextField value is never null
    filter.addValueChangeListener(event -> dataProvider.setFilter(event.getValue()));
    filter.addFocusShortcut(Key.KEY_F, KeyModifier.CONTROL);
    newComponent = new Button("New Component");
    newComponent.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
    newComponent.setIcon(VaadinIcon.PLUS_CIRCLE.create());
    newComponent.addClickListener(click -> viewLogic.newComponent());
    // CTRL+N will create a new window which is unavoidable
    newComponent.addClickShortcut(Key.KEY_N, KeyModifier.ALT);
    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setWidth("100%");
    topLayout.add(filter);
    topLayout.add(newComponent);
    topLayout.setVerticalComponentAlignment(Alignment.START, filter);
    topLayout.expand(filter);
    return topLayout;
}
Also used : Button(com.vaadin.flow.component.button.Button) TextField(com.vaadin.flow.component.textfield.TextField) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Aggregations

TextField (com.vaadin.flow.component.textfield.TextField)227 Test (org.junit.jupiter.api.Test)61 Button (com.vaadin.flow.component.button.Button)54 Div (com.vaadin.flow.component.html.Div)38 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)32 FormLayout (com.vaadin.flow.component.formlayout.FormLayout)29 Binder (com.vaadin.flow.data.binder.Binder)29 GeneratedVaadinTextField (com.vaadin.flow.component.textfield.GeneratedVaadinTextField)28 Element (com.vaadin.flow.dom.Element)26 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)23 Route (com.vaadin.flow.router.Route)21 Component (com.vaadin.flow.component.Component)16 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)15 BinderCrudEditor (com.vaadin.flow.component.crud.BinderCrudEditor)15 Grid (com.vaadin.flow.component.grid.Grid)15 Span (com.vaadin.flow.component.html.Span)15 List (java.util.List)15 EmailField (com.vaadin.flow.component.textfield.EmailField)14 TextArea (com.vaadin.flow.component.textfield.TextArea)14 Test (org.junit.Test)14