@Override public int size(Query<T, F> t) { return dataProvider.size(new Query<>(t.getOffset(), t.getLimit(), t.getSortOrders(), t.getInMemorySorting(), getFilter(t))); }
/** * Getter method for finding the size of DataProvider. Can be overridden by * a subclass that uses a specific type of DataProvider and/or query. * * @return the size of data provider with current filter */ @SuppressWarnings({ "unchecked", "rawtypes" }) public int getDataProviderSize() { return getDataProvider().size(new Query(getFilter())); }
@Override public Stream<T> fetch(Query<T, F> t) { return dataProvider.fetch(new Query<>(t.getOffset(), t.getLimit(), t.getSortOrders(), t.getInMemorySorting(), getFilter(t))); }
@Override public Stream<T> fetch(Query<T, C> t) { if (t instanceof HierarchicalQuery<?, ?>) { return dataProvider.fetch(new HierarchicalQuery<>( t.getOffset(), t.getLimit(), t.getSortOrders(), t.getInMemorySorting(), getFilter(t), ((HierarchicalQuery<T, C>) t).getParent())); } throw new IllegalArgumentException( "Hierarchical data provider doesn't support non-hierarchical queries"); } };
@Override public int size(Query<T, C> t) { if (t instanceof HierarchicalQuery<?, ?>) { return dataProvider.size(new HierarchicalQuery<>( t.getOffset(), t.getLimit(), t.getSortOrders(), t.getInMemorySorting(), getFilter(t), ((HierarchicalQuery<T, C>) t).getParent())); } throw new IllegalArgumentException( "Hierarchical data provider doesn't support non-hierarchical queries"); }
/** * Gets the stream of direct children for given node. * * @param parent * the parent node * @return the stream of direct children */ private Stream<T> getDirectChildren(T parent) { return doFetchDirectChildren(parent, Range.between(0, getDataProvider() .getChildCount(new HierarchicalQuery<>(filter, parent)))); }
/** * Returns whether given item has children. * * @param item * the node to test * @return {@code true} if node has children; {@code false} if not */ public boolean hasChildren(T item) { return getDataProvider().hasChildren(item); }
@Override public void refreshItem(T item) { fireEvent(new DataRefreshEvent<>(this, item)); }
@Override public void setBackEndSorting(List<QuerySortOrder> sortOrder) { if (mapper != null) { mapper.setBackEndSorting(sortOrder); } super.setBackEndSorting(sortOrder); }
@Override public void setInMemorySorting(Comparator<T> comparator) { if (mapper != null) { mapper.setInMemorySorting(comparator); } super.setInMemorySorting(comparator); }
/** * Drops all data associated with this data communicator. */ protected void dropAllData() { for (DataGenerator<T> g : generators) { g.destroyAllData(); } handler.destroyAllData(); }
/** * Constructs a new Tree Component with given caption and {@code TreeData}. * * @param caption * the caption for component * @param treeData * the tree data for component */ public Tree(String caption, TreeData<T> treeData) { this(caption, new TreeDataProvider<>(treeData)); }
/** * Creates a new {@code AbstractListing} with a default data communicator. * <p> */ protected AbstractListing() { this(new DataCommunicator<>()); }
/** * Gets the column this sorting information is attached to. * * @return the column being sorted */ @Override public Column<T, ?> getSorted() { return super.getSorted(); }
/** * Removes any filter that has been set or added previously. * * @see #setFilter(SerializablePredicate) */ public default void clearFilters() { setFilter(null); }
/** * Constructs a new TwinColSelect with caption and the given options. * * @param caption * the caption to set, can be {@code null} * @param options * the options, cannot be {@code null} */ public TwinColSelect(String caption, Collection<T> options) { this(caption, DataProvider.ofCollection(options)); }
@Override public void setSortComparator(SerializableComparator<T> comparator) { sortOrder = comparator; refreshAll(); }
/** * Collapses the given item and removes its sub-hierarchy. Calling this * method will have no effect if the row is already collapsed. * * @param item * the item to collapse */ public void collapse(T item) { collapse(item, true); }