use of com.vaadin.demo.domain.Person in project docs by vaadin.
the class GridDynamicHeight method setupGrid.
private void setupGrid() {
// tag::snippet[]
grid = new Grid<>(Person.class, false);
grid.setAllRowsVisible(true);
// end::snippet[]
grid.addColumn(Person::getFullName).setHeader("Name");
grid.addColumn(Person::getEmail).setHeader("Email");
grid.addColumn(person -> person.getAddress().getPhone()).setHeader("Phone");
grid.addColumn(new ComponentRenderer<>(Button::new, (button, person) -> {
button.addThemeVariants(ButtonVariant.LUMO_ICON, ButtonVariant.LUMO_ERROR, ButtonVariant.LUMO_TERTIARY);
button.addClickListener(e -> this.removeInvitation(person));
button.setIcon(new Icon(VaadinIcon.TRASH));
})).setHeader("Manage");
grid.setItems(invitedPeople);
hint = new Div();
hint.setText("No invitation has been sent");
hint.getStyle().set("padding", "var(--lumo-size-l)").set("text-align", "center").set("font-style", "italic").set("color", "var(--lumo-contrast-70pct)");
add(hint, grid);
}
use of com.vaadin.demo.domain.Person in project docs by vaadin.
the class DialogResizable method createDialogLayout.
private static VerticalLayout createDialogLayout() {
Grid<Person> grid = new Grid<>(Person.class, false);
grid.addColumn(Person::getFirstName).setHeader("First name");
grid.addColumn(Person::getLastName).setHeader("Last name");
grid.addColumn(Person::getEmail).setHeader("Email");
grid.addColumn(Person::getProfession).setHeader("Profession");
grid.addColumn(Person::getMembership).setHeader("Membership");
List<Person> people = DataService.getPeople();
grid.setItems(people);
VerticalLayout dialogLayout = new VerticalLayout(grid);
dialogLayout.setPadding(false);
dialogLayout.setAlignItems(FlexComponent.Alignment.STRETCH);
dialogLayout.getStyle().set("min-width", "300px").set("max-width", "100%").set("height", "100%");
return dialogLayout;
}
use of com.vaadin.demo.domain.Person in project docs by vaadin.
the class GridDynamicHeight method setupInvitationForm.
private void setupInvitationForm() {
List<Person> people = DataService.getPeople();
ComboBox<Person> comboBox = new ComboBox<>();
comboBox.setItems(people);
comboBox.setItemLabelGenerator(Person::getFullName);
Button button = new Button("Send invite");
button.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
button.addClickListener(e -> {
sendInvitation(comboBox.getValue());
comboBox.setValue(null);
});
HorizontalLayout layout = new HorizontalLayout(comboBox, button);
layout.setFlexGrow(1, comboBox);
add(layout);
}
use of com.vaadin.demo.domain.Person in project docs by vaadin.
the class CrudColumns method createEditor.
private CrudEditor<Person> createEditor() {
TextField firstName = new TextField("First name");
EmailField email = new EmailField("Email");
TextField profession = new TextField("Profession");
DatePicker birthday = new DatePicker("Birthday");
FormLayout form = new FormLayout(firstName, email, profession, birthday);
Binder<Person> binder = new Binder<>(Person.class);
binder.forField(firstName).asRequired().bind(Person::getFirstName, Person::setFirstName);
binder.forField(email).asRequired().bind(Person::getEmail, Person::setEmail);
binder.forField(profession).asRequired().bind(Person::getProfession, Person::setProfession);
binder.forField(birthday).asRequired().withConverter(new LocalDateToDateConverter()).bind(Person::getBirthday, Person::setBirthday);
return new BinderCrudEditor<>(binder, form);
}
use of com.vaadin.demo.domain.Person in project docs by vaadin.
the class CrudEditorBottom method createEditor.
private CrudEditor<Person> createEditor() {
TextField firstName = new TextField("First name");
TextField lastName = new TextField("Last name");
EmailField email = new EmailField("Email");
TextField profession = new TextField("Profession");
FormLayout form = new FormLayout(firstName, lastName, email, profession);
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(email).asRequired().bind(Person::getEmail, Person::setEmail);
binder.forField(profession).asRequired().bind(Person::getProfession, Person::setProfession);
return new BinderCrudEditor<>(binder, form);
}
Aggregations