Search in sources :

Example 1 with SearchOverlayButton

use of com.github.appreciated.app.layout.addons.search.overlay.SearchOverlayButton in project vaadin-app-layout by appreciated.

the class MainAppLayout method initSearchOverlayButton.

private SearchOverlayButton<TestSearchResult, SerializablePredicate<TestSearchResult>> initSearchOverlayButton() {
    // The data provider that provides the entities for the search
    ListDataProvider<TestSearchResult> listDataProvider = new ListDataProvider<>(Arrays.asList(new TestSearchResult("Header1", "Description1"), new TestSearchResult("Header2", "Description2"), new TestSearchResult("Header3", "Description3"), new TestSearchResult("Header4", "Description4"), new TestSearchResult("Header5", "Description5"), new TestSearchResult("Header6", "Description6"), new TestSearchResult("Header7", "Description7"), new TestSearchResult("Header8", "Description8"), new TestSearchResult("Header9", "Description9"), new TestSearchResult("Header10", "Description10")));
    return new SearchOverlayButtonBuilder<TestSearchResult, SerializablePredicate<TestSearchResult>>().withDataProvider(listDataProvider).withQueryProvider(s -> new Query<>(testEntity -> !s.equals("") && testEntity.getHeader().startsWith(s))).withDataViewProvider(queryResult -> {
        RippleClickableCard card = new RippleClickableCard(new Item(queryResult.getHeader(), queryResult.getDescription()));
        card.setWidthFull();
        card.setBackground("var(--lumo-base-color)");
        return card;
    }).withQueryResultListener(testSearchResult -> Notification.show(testSearchResult.getHeader())).build();
}
Also used : ListDataProvider(com.vaadin.flow.data.provider.ListDataProvider) SearchOverlayButtonBuilder(com.github.appreciated.app.layout.addons.search.overlay.SearchOverlayButtonBuilder) LeftLayouts(com.github.appreciated.app.layout.component.applayout.LeftLayouts) Arrays(java.util.Arrays) SearchOverlayButton(com.github.appreciated.app.layout.addons.search.overlay.SearchOverlayButton) Query(com.vaadin.flow.data.provider.Query) SearchButton(com.github.appreciated.app.layout.addons.search.SearchButton) AppLayoutBuilder(com.github.appreciated.app.layout.component.builder.AppLayoutBuilder) FOOTER(com.github.appreciated.app.layout.entity.Section.FOOTER) AppLayoutRouterLayout(com.github.appreciated.app.layout.component.router.AppLayoutRouterLayout) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) HEADER(com.github.appreciated.app.layout.entity.Section.HEADER) LeftHeaderItem(com.github.appreciated.app.layout.component.menu.left.items.LeftHeaderItem) RippleClickableCard(com.github.appreciated.card.RippleClickableCard) LeftAppMenuBuilder(com.github.appreciated.app.layout.component.menu.left.builder.LeftAppMenuBuilder) LeftClickableItem(com.github.appreciated.app.layout.component.menu.left.items.LeftClickableItem) Item(com.github.appreciated.card.content.Item) SerializablePredicate(com.vaadin.flow.function.SerializablePredicate) AppBarBuilder(com.github.appreciated.app.layout.component.appbar.AppBarBuilder) Viewport(com.vaadin.flow.component.page.Viewport) Notification(com.vaadin.flow.component.notification.Notification) LeftNavigationItem(com.github.appreciated.app.layout.component.menu.left.items.LeftNavigationItem) Push(com.vaadin.flow.component.page.Push) ListDataProvider(com.vaadin.flow.data.provider.ListDataProvider) LeftHeaderItem(com.github.appreciated.app.layout.component.menu.left.items.LeftHeaderItem) LeftClickableItem(com.github.appreciated.app.layout.component.menu.left.items.LeftClickableItem) Item(com.github.appreciated.card.content.Item) LeftNavigationItem(com.github.appreciated.app.layout.component.menu.left.items.LeftNavigationItem) Query(com.vaadin.flow.data.provider.Query) RippleClickableCard(com.github.appreciated.card.RippleClickableCard) SerializablePredicate(com.vaadin.flow.function.SerializablePredicate)

Example 2 with SearchOverlayButton

use of com.github.appreciated.app.layout.addons.search.overlay.SearchOverlayButton in project vaadin-app-layout by appreciated.

the class SearchView method furtherConfiguration.

@Override
public void furtherConfiguration(AppLayoutBuilder builder) {
    ListDataProvider<TestSearchResult> dataProvider = new ListDataProvider<>(Arrays.asList(new TestSearchResult("Header1", "Description1"), new TestSearchResult("Header2", "Description2"), new TestSearchResult("Header3", "Description3"), new TestSearchResult("Header4", "Description4"), new TestSearchResult("Header5", "Description5"), new TestSearchResult("Header6", "Description6"), new TestSearchResult("Header7", "Description7"), new TestSearchResult("Header8", "Description8"), new TestSearchResult("Header9", "Description9"), new TestSearchResult("Header10", "Description10")));
    SearchOverlayButton<TestSearchResult, SerializablePredicate<TestSearchResult>> button = new SearchOverlayButtonBuilder<TestSearchResult, SerializablePredicate<TestSearchResult>>().withDataProvider(dataProvider).withQueryProvider(s -> new Query<TestSearchResult, SerializablePredicate<TestSearchResult>>(testEntity -> !s.equals("") && testEntity.getHeader().startsWith(s))).withDataViewProvider(result -> {
        RippleClickableCard card = new RippleClickableCard(new Item(result.getHeader(), result.getDescription()));
        card.setWidthFull();
        card.setBackground("var(--lumo-base-color)");
        return card;
    }).withQueryResultListener(testSearchResult -> Notification.show(testSearchResult.header + " clicked")).build();
    button.setId("it-test-search-button");
    button.getSearchView().getSearchField().setId("it-test-search-field");
    button.getSearchView().getCloseButton().setId("it-test-search-close");
    builder.withAppBar(button);
}
Also used : ListDataProvider(com.vaadin.flow.data.provider.ListDataProvider) SearchOverlayButtonBuilder(com.github.appreciated.app.layout.addons.search.overlay.SearchOverlayButtonBuilder) LeftLayouts(com.github.appreciated.app.layout.component.applayout.LeftLayouts) Arrays(java.util.Arrays) SearchOverlayButton(com.github.appreciated.app.layout.addons.search.overlay.SearchOverlayButton) Query(com.vaadin.flow.data.provider.Query) AppLayoutBuilder(com.github.appreciated.app.layout.component.builder.AppLayoutBuilder) Component(com.vaadin.flow.component.Component) com.github.appreciated.app.layout.test.addon.search.view(com.github.appreciated.app.layout.test.addon.search.view) RoutePrefix(com.vaadin.flow.router.RoutePrefix) RippleClickableCard(com.github.appreciated.card.RippleClickableCard) AppLayout(com.github.appreciated.app.layout.component.applayout.AppLayout) AbstractLeftBehaviorBasicView(com.github.appreciated.app.layout.test.base.AbstractLeftBehaviorBasicView) Item(com.github.appreciated.card.content.Item) SerializablePredicate(com.vaadin.flow.function.SerializablePredicate) Notification(com.vaadin.flow.component.notification.Notification) ListDataProvider(com.vaadin.flow.data.provider.ListDataProvider) Item(com.github.appreciated.card.content.Item) Query(com.vaadin.flow.data.provider.Query) RippleClickableCard(com.github.appreciated.card.RippleClickableCard) SerializablePredicate(com.vaadin.flow.function.SerializablePredicate)

Aggregations

SearchOverlayButton (com.github.appreciated.app.layout.addons.search.overlay.SearchOverlayButton)2 SearchOverlayButtonBuilder (com.github.appreciated.app.layout.addons.search.overlay.SearchOverlayButtonBuilder)2 LeftLayouts (com.github.appreciated.app.layout.component.applayout.LeftLayouts)2 AppLayoutBuilder (com.github.appreciated.app.layout.component.builder.AppLayoutBuilder)2 RippleClickableCard (com.github.appreciated.card.RippleClickableCard)2 Item (com.github.appreciated.card.content.Item)2 Notification (com.vaadin.flow.component.notification.Notification)2 ListDataProvider (com.vaadin.flow.data.provider.ListDataProvider)2 Query (com.vaadin.flow.data.provider.Query)2 SerializablePredicate (com.vaadin.flow.function.SerializablePredicate)2 Arrays (java.util.Arrays)2 SearchButton (com.github.appreciated.app.layout.addons.search.SearchButton)1 AppBarBuilder (com.github.appreciated.app.layout.component.appbar.AppBarBuilder)1 AppLayout (com.github.appreciated.app.layout.component.applayout.AppLayout)1 LeftAppMenuBuilder (com.github.appreciated.app.layout.component.menu.left.builder.LeftAppMenuBuilder)1 LeftClickableItem (com.github.appreciated.app.layout.component.menu.left.items.LeftClickableItem)1 LeftHeaderItem (com.github.appreciated.app.layout.component.menu.left.items.LeftHeaderItem)1 LeftNavigationItem (com.github.appreciated.app.layout.component.menu.left.items.LeftNavigationItem)1 AppLayoutRouterLayout (com.github.appreciated.app.layout.component.router.AppLayoutRouterLayout)1 FOOTER (com.github.appreciated.app.layout.entity.Section.FOOTER)1