Search in sources :

Example 1 with AdvancedSearchListener

use of au.com.vaadinutils.crud.AdvancedSearchListener in project VaadinUtils by rlsutton1.

the class ComboBoxWithSearchFieldChooserWindow method getPopupContent2.

@SuppressWarnings("unchecked")
public Component getPopupContent2() {
    grid = new SearchableGrid<T, C>() {

        /**
         */
        private static final long serialVersionUID = 1L;

        @Override
        public GridHeadingPropertySetIfc<T> getHeadingPropertySet() {
            return headingProps;
        }

        @Override
        protected Filter getContainerFilter(String filterString, boolean advancedSearchActive) {
            List<Filter> filters = new ArrayList<>();
            if (baseFilters != null) {
                filters.add(baseFilters);
            }
            if (filterString.length() > 0) {
                filters.add(new SimpleStringFilter(sortColumns[0], filterString, true, false));
            }
            if (filters.size() == 0) {
                return null;
            }
            return new And(filters.toArray(new Filter[] {}));
        }

        @Override
        protected String getTitle() {
            return null;
        }

        @Override
        public C getContainer() {
            return localContainer;
        }

        @Override
        protected AbstractLayout getAdvancedSearchLayout() {
            if (advancedSearchProvider == null) {
                return null;
            }
            return advancedSearchProvider.getAdvancedSearchLayout();
        }

        @Override
        protected AdvancedSearchListener getAdvancedSearchListener() {
            return advancedSearchListener;
        }
    };
    grid.init(caption, (Class<T>) type);
    // grid.getGrid().removeHeaderRow(0);
    ItemClickListener itemClickListener = new ItemClickListener() {

        private static final long serialVersionUID = -4659382639878762429L;

        @Override
        public void itemClick(ItemClickEvent event) {
            listener.selected(event.getItemId());
        }
    };
    Sort sort = Sort.by(sortColumns[0]);
    for (int i = 1; i < sortColumns.length; i++) {
        sort.then(sortColumns[i]);
    }
    grid.sort(sort);
    grid.setSelectionMode(SelectionMode.SINGLE);
    grid.addItemClickListener(itemClickListener);
    grid.setSizeFull();
    holder = new VerticalLayout();
    holder.setWidth("100%");
    holder.setHeight("300");
    holder.addComponent(grid);
    return holder;
}
Also used : ItemClickListener(com.vaadin.event.ItemClickEvent.ItemClickListener) ItemClickEvent(com.vaadin.event.ItemClickEvent) AdvancedSearchListener(au.com.vaadinutils.crud.AdvancedSearchListener) Filter(com.vaadin.data.Container.Filter) SimpleStringFilter(com.vaadin.data.util.filter.SimpleStringFilter) And(com.vaadin.data.util.filter.And) Sort(com.vaadin.data.sort.Sort) VerticalLayout(com.vaadin.ui.VerticalLayout) ArrayList(java.util.ArrayList) List(java.util.List) AbstractLayout(com.vaadin.ui.AbstractLayout) GridHeadingPropertySetIfc(au.com.vaadinutils.crud.GridHeadingPropertySetIfc) SimpleStringFilter(com.vaadin.data.util.filter.SimpleStringFilter)

Aggregations

AdvancedSearchListener (au.com.vaadinutils.crud.AdvancedSearchListener)1 GridHeadingPropertySetIfc (au.com.vaadinutils.crud.GridHeadingPropertySetIfc)1 Filter (com.vaadin.data.Container.Filter)1 Sort (com.vaadin.data.sort.Sort)1 And (com.vaadin.data.util.filter.And)1 SimpleStringFilter (com.vaadin.data.util.filter.SimpleStringFilter)1 ItemClickEvent (com.vaadin.event.ItemClickEvent)1 ItemClickListener (com.vaadin.event.ItemClickEvent.ItemClickListener)1 AbstractLayout (com.vaadin.ui.AbstractLayout)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1