|
|
@@ -22,6 +22,8 @@ import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
import com.vaadin.data.provider.BackEndDataProvider; |
|
|
|
import com.vaadin.data.provider.DataProvider; |
|
|
|
import com.vaadin.data.provider.ListDataProvider; |
|
|
|
import com.vaadin.ui.Component; |
|
|
|
|
|
|
|
/** |
|
|
@@ -33,9 +35,33 @@ import com.vaadin.ui.Component; |
|
|
|
* the type of the displayed item |
|
|
|
*/ |
|
|
|
public interface HasItems<T> extends Component, Serializable { |
|
|
|
|
|
|
|
/** |
|
|
|
* Returns the source of data items used by this listing. |
|
|
|
* |
|
|
|
* @return the data provider, not null |
|
|
|
*/ |
|
|
|
public DataProvider<T, ?> getDataProvider(); |
|
|
|
|
|
|
|
/** |
|
|
|
* Sets the data items of this component provided as a collection. |
|
|
|
* <p> |
|
|
|
* The provided items are wrapped into a {@link ListDataProvider} and this |
|
|
|
* instance is used as a data provider for the |
|
|
|
* {@link #setDataProvider(DataProvider)} method. It means that the items |
|
|
|
* collection can be accessed later on via |
|
|
|
* {@link ListDataProvider#getItems()}: |
|
|
|
* |
|
|
|
* <pre> |
|
|
|
* <code> |
|
|
|
* HasDataProvider<String> listing = new CheckBoxGroup<>(); |
|
|
|
* listing.setItems(Arrays.asList("a","b")); |
|
|
|
* ... |
|
|
|
* |
|
|
|
* Collection<String> collection = ((ListDataProvider<String>)listing.getDataProvider()).getItems(); |
|
|
|
* </code> |
|
|
|
* </pre> |
|
|
|
* <p> |
|
|
|
* The provided collection instance may be used as-is. Subsequent |
|
|
|
* modification of the collection might cause inconsistent data to be shown |
|
|
|
* in the component unless it is explicitly instructed to read the data |
|
|
@@ -49,7 +75,26 @@ public interface HasItems<T> extends Component, Serializable { |
|
|
|
|
|
|
|
/** |
|
|
|
* Sets the data items of this listing. |
|
|
|
* |
|
|
|
* <p> |
|
|
|
* The provided items are wrapped into a {@link ListDataProvider} and this |
|
|
|
* instance is used as a data provider for the |
|
|
|
* {@link #setDataProvider(DataProvider)} method. It means that the items |
|
|
|
* collection can be accessed later on via |
|
|
|
* {@link ListDataProvider#getItems()}: |
|
|
|
* |
|
|
|
* <pre> |
|
|
|
* <code> |
|
|
|
* HasDataProvider<String> listing = new CheckBoxGroup<>(); |
|
|
|
* listing.setItems(Arrays.asList("a","b")); |
|
|
|
* ... |
|
|
|
* |
|
|
|
* Collection<String> collection = ((ListDataProvider<String>)listing.getDataProvider()).getItems(); |
|
|
|
* </code> |
|
|
|
* </pre> |
|
|
|
* <p> |
|
|
|
* |
|
|
|
* @see #setItems(Collection) |
|
|
|
* |
|
|
|
* @param items |
|
|
|
* the data items to display |
|
|
|
*/ |
|
|
@@ -65,6 +110,25 @@ public interface HasItems<T> extends Component, Serializable { |
|
|
|
* instead of its array and Collection variations, doesn't save any memory. |
|
|
|
* If you have a large data set to bind, using a lazy data provider is |
|
|
|
* recommended. See {@link BackEndDataProvider} for more info. |
|
|
|
* <p> |
|
|
|
* The provided items are wrapped into a {@link ListDataProvider} and this |
|
|
|
* instance is used as a data provider for the |
|
|
|
* {@link #setDataProvider(DataProvider)} method. It means that the items |
|
|
|
* collection can be accessed later on via |
|
|
|
* {@link ListDataProvider#getItems()}: |
|
|
|
* |
|
|
|
* <pre> |
|
|
|
* <code> |
|
|
|
* HasDataProvider<String> listing = new CheckBoxGroup<>(); |
|
|
|
* listing.setItems(Arrays.asList("a","b")); |
|
|
|
* ... |
|
|
|
* |
|
|
|
* Collection<String> collection = ((ListDataProvider<String>)listing.getDataProvider()).getItems(); |
|
|
|
* </code> |
|
|
|
* </pre> |
|
|
|
* <p> |
|
|
|
* |
|
|
|
* @see #setItems(Collection) |
|
|
|
* |
|
|
|
* @param streamOfItems |
|
|
|
* the stream of data items to display, not {@code null} |