Search in sources :

Example 1 with Element

use of com.vaadin.flow.component.combobox.test.entity.Element in project flow-components by vaadin.

the class ComboBoxView method customFiltering.

private void customFiltering() {
    Div div = new Div();
    div.setText("Example uses case-sensitive starts-with filtering");
    ComboBox<Element> filteringComboBox = new ComboBox<>();
    List<Element> elementsList = getElements();
    /*
         * Providing a custom item filter allows filtering based on all of the
         * rendered properties:
         */
    ItemFilter<Element> filter = (element, filterString) -> element.getName().startsWith(filterString);
    filteringComboBox.setItems(filter, elementsList);
    filteringComboBox.setItemLabelGenerator(Element::getName);
    filteringComboBox.setClearButtonVisible(true);
    addCard("Filtering", "Custom filtering", div, filteringComboBox);
}
Also used : Div(com.vaadin.flow.component.html.Div) ItemFilter(com.vaadin.flow.component.combobox.ComboBox.ItemFilter) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) Person(com.vaadin.flow.component.combobox.test.entity.Person) Image(com.vaadin.flow.component.html.Image) SortDirection(com.vaadin.flow.data.provider.SortDirection) Component(com.vaadin.flow.component.Component) ProjectData(com.vaadin.flow.component.combobox.test.data.ProjectData) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) ElementData(com.vaadin.flow.component.combobox.test.data.ElementData) Div(com.vaadin.flow.component.html.Div) ComboBox(com.vaadin.flow.component.combobox.ComboBox) Song(com.vaadin.flow.component.combobox.test.entity.Song) ArrayList(java.util.ArrayList) Route(com.vaadin.flow.router.Route) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent) FlexLayout(com.vaadin.flow.component.orderedlayout.FlexLayout) TemplateRenderer(com.vaadin.flow.data.renderer.TemplateRenderer) IntegerField(com.vaadin.flow.component.textfield.IntegerField) ElementConstants(com.vaadin.flow.dom.ElementConstants) Department(com.vaadin.flow.component.combobox.test.entity.Department) Paragraph(com.vaadin.flow.component.html.Paragraph) Notification(com.vaadin.flow.component.notification.Notification) Ticket(com.vaadin.flow.component.combobox.test.entity.Ticket) Project(com.vaadin.flow.component.combobox.test.entity.Project) Anchor(com.vaadin.flow.component.html.Anchor) Query(com.vaadin.flow.data.provider.Query) ComboBoxLazyDataView(com.vaadin.flow.component.combobox.dataview.ComboBoxLazyDataView) Collection(java.util.Collection) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) PersonService(com.vaadin.flow.component.combobox.test.service.PersonService) H2(com.vaadin.flow.component.html.H2) Element(com.vaadin.flow.component.combobox.test.entity.Element) DepartmentData(com.vaadin.flow.component.combobox.test.data.DepartmentData) List(java.util.List) Button(com.vaadin.flow.component.button.Button) Stream(java.util.stream.Stream) ComboBoxListDataView(com.vaadin.flow.component.combobox.dataview.ComboBoxListDataView) Span(com.vaadin.flow.component.html.Span) ComboBox(com.vaadin.flow.component.combobox.ComboBox) Element(com.vaadin.flow.component.combobox.test.entity.Element)

Example 2 with Element

use of com.vaadin.flow.component.combobox.test.entity.Element in project flow-components by vaadin.

the class ElementData method createElementList.

private static List<Element> createElementList() {
    List<Element> elementList = new ArrayList<>();
    elementList.add(new Element("Hydrogen"));
    elementList.add(new Element("Helium"));
    elementList.add(new Element("Lithium"));
    elementList.add(new Element("Beryllium"));
    elementList.add(new Element("Boron"));
    elementList.add(new Element("Carbon"));
    elementList.add(new Element("Nitrogen"));
    elementList.add(new Element("Oxygen"));
    elementList.add(new Element("Fluorine"));
    elementList.add(new Element("Neon"));
    elementList.add(new Element("Sodium"));
    elementList.add(new Element("Magnesium"));
    elementList.add(new Element("Aluminum"));
    elementList.add(new Element("Silicon"));
    elementList.add(new Element("Phosphorus"));
    elementList.add(new Element("Sulfur"));
    elementList.add(new Element("Chlorine"));
    elementList.add(new Element("Argon"));
    elementList.add(new Element("Potassium"));
    elementList.add(new Element("Calcium"));
    elementList.add(new Element("Scandium"));
    elementList.add(new Element("Titanium"));
    elementList.add(new Element("Vanadium"));
    elementList.add(new Element("Chromium"));
    elementList.add(new Element("Manganese"));
    elementList.add(new Element("Iron"));
    elementList.add(new Element("Cobalt"));
    elementList.add(new Element("Nickel"));
    elementList.add(new Element("Copper"));
    elementList.add(new Element("Zinc"));
    elementList.add(new Element("Gallium"));
    elementList.add(new Element("Germanium"));
    elementList.add(new Element("Arsenic"));
    elementList.add(new Element("Selenium"));
    elementList.add(new Element("Bromine"));
    elementList.add(new Element("Krypton"));
    elementList.add(new Element("Rubidium"));
    elementList.add(new Element("Strontium"));
    elementList.add(new Element("Yttrium"));
    elementList.add(new Element("Zirconium"));
    elementList.add(new Element("Niobium"));
    elementList.add(new Element("Molybdenum"));
    elementList.add(new Element("Technetium"));
    elementList.add(new Element("Ruthenium"));
    elementList.add(new Element("Rhodium"));
    elementList.add(new Element("Palladium"));
    elementList.add(new Element("Silver"));
    elementList.add(new Element("Cadmium"));
    elementList.add(new Element("Indium"));
    elementList.add(new Element("Tin"));
    elementList.add(new Element("Antimony"));
    elementList.add(new Element("Tellurium"));
    elementList.add(new Element("Iodine"));
    elementList.add(new Element("Xenon"));
    elementList.add(new Element("Cesium"));
    elementList.add(new Element("Barium"));
    elementList.add(new Element("Lanthanum"));
    elementList.add(new Element("Cerium"));
    elementList.add(new Element("Praseodymium"));
    elementList.add(new Element("Neodymium"));
    elementList.add(new Element("Promethium"));
    elementList.add(new Element("Samarium"));
    elementList.add(new Element("Europium"));
    elementList.add(new Element("Gadolinium"));
    elementList.add(new Element("Terbium"));
    elementList.add(new Element("Dysprosium"));
    elementList.add(new Element("Holmium"));
    elementList.add(new Element("Erbium"));
    elementList.add(new Element("Thulium"));
    elementList.add(new Element("Ytterbium"));
    elementList.add(new Element("Lutetium"));
    elementList.add(new Element("Hafnium"));
    elementList.add(new Element("Tantalum"));
    elementList.add(new Element("Tungsten"));
    elementList.add(new Element("Rhenium"));
    elementList.add(new Element("Osmium"));
    elementList.add(new Element("Iridium"));
    elementList.add(new Element("Platinum"));
    elementList.add(new Element("Gold"));
    elementList.add(new Element("Mercury"));
    elementList.add(new Element("Thallium"));
    elementList.add(new Element("Lead"));
    elementList.add(new Element("Bismuth"));
    elementList.add(new Element("Polonium"));
    elementList.add(new Element("Astatine"));
    elementList.add(new Element("Radon"));
    elementList.add(new Element("Francium"));
    elementList.add(new Element("Radium"));
    elementList.add(new Element("Actinium"));
    elementList.add(new Element("Thorium"));
    elementList.add(new Element("Protactinium"));
    elementList.add(new Element("Uranium"));
    elementList.add(new Element("Neptunium"));
    elementList.add(new Element("Plutonium"));
    elementList.add(new Element("Americium"));
    elementList.add(new Element("Curium"));
    elementList.add(new Element("Berkelium"));
    elementList.add(new Element("Californium"));
    elementList.add(new Element("Einsteinium"));
    elementList.add(new Element("Fermium"));
    elementList.add(new Element("Mendelevium"));
    elementList.add(new Element("Nobelium"));
    elementList.add(new Element("Lawrencium"));
    elementList.add(new Element("Rutherfordium"));
    elementList.add(new Element("Dubnium"));
    elementList.add(new Element("Seaborgium"));
    elementList.add(new Element("Bohrium"));
    elementList.add(new Element("Hassium"));
    elementList.add(new Element("Meitnerium"));
    elementList.add(new Element("Ununnilium"));
    elementList.add(new Element("Unununium"));
    elementList.add(new Element("Ununbium"));
    elementList.add(new Element("Ununtrium"));
    elementList.add(new Element("Ununquadium"));
    elementList.add(new Element("Ununpentium"));
    elementList.add(new Element("Ununhexium"));
    elementList.add(new Element("Ununseptium"));
    elementList.add(new Element("Ununoctium"));
    return elementList;
}
Also used : Element(com.vaadin.flow.component.combobox.test.entity.Element) ArrayList(java.util.ArrayList)

Aggregations

Element (com.vaadin.flow.component.combobox.test.entity.Element)2 ArrayList (java.util.ArrayList)2 Component (com.vaadin.flow.component.Component)1 Button (com.vaadin.flow.component.button.Button)1 ComboBox (com.vaadin.flow.component.combobox.ComboBox)1 ItemFilter (com.vaadin.flow.component.combobox.ComboBox.ItemFilter)1 ComboBoxLazyDataView (com.vaadin.flow.component.combobox.dataview.ComboBoxLazyDataView)1 ComboBoxListDataView (com.vaadin.flow.component.combobox.dataview.ComboBoxListDataView)1 DepartmentData (com.vaadin.flow.component.combobox.test.data.DepartmentData)1 ElementData (com.vaadin.flow.component.combobox.test.data.ElementData)1 ProjectData (com.vaadin.flow.component.combobox.test.data.ProjectData)1 Department (com.vaadin.flow.component.combobox.test.entity.Department)1 Person (com.vaadin.flow.component.combobox.test.entity.Person)1 Project (com.vaadin.flow.component.combobox.test.entity.Project)1 Song (com.vaadin.flow.component.combobox.test.entity.Song)1 Ticket (com.vaadin.flow.component.combobox.test.entity.Ticket)1 PersonService (com.vaadin.flow.component.combobox.test.service.PersonService)1 Anchor (com.vaadin.flow.component.html.Anchor)1 Div (com.vaadin.flow.component.html.Div)1 H2 (com.vaadin.flow.component.html.H2)1