use of com.vaadin.flow.component.icon.VaadinIcon.SEARCH in project furms by unity-idm.
the class ProjectsView method createSearchFilterLayout.
private HorizontalLayout createSearchFilterLayout(Grid<ProjectViewGridModel> grid, Button addButton) {
TextField textField = new TextField();
textField.setPlaceholder(getTranslation("view.community-admin.projects.field.search"));
textField.setPrefixComponent(SEARCH.create());
textField.setValueChangeMode(ValueChangeMode.EAGER);
textField.setClearButtonVisible(true);
textField.addValueChangeListener(event -> {
String value = textField.getValue().toLowerCase();
List<ProjectViewGridModel> filteredUsers = projectsViewDataSnapshot.projectViewGridModels.stream().filter(project -> project.matches(value)).collect(toList());
grid.setItems(filteredUsers);
// TODO This is a work around to fix disappearing text cursor
addButton.focus();
textField.focus();
});
HorizontalLayout search = new HorizontalLayout(textField);
search.setJustifyContentMode(FlexComponent.JustifyContentMode.END);
return search;
}
Aggregations