T
- the data type of the listpublic class ListDataProvider<T> extends AbstractDataProvider<T>
AbstractDataProvider
that is backed by an
in-memory list.
Modifications (inserts, removes, sets, etc.) to the list returned by
getList()
will be reflected in the model. However, mutations to the
items contained within the list will NOT be reflected in the model. You must
call List.set(int, Object)
to update the item within the list and
push the change to the display, or call refresh()
to push all rows
to the displays. List.set(int, Object)
performs better because it
allows the data provider to push only those rows which have changed, and
usually allows the display to re-render only a subset of the rows.
Constructor and Description |
---|
ListDataProvider()
Creates an empty model.
|
ListDataProvider(List<T> listToWrap)
Creates a list model that wraps the given list.
|
ListDataProvider(List<T> listToWrap,
ProvidesKey<T> keyProvider)
Creates a list model that wraps the given list.
|
ListDataProvider(ProvidesKey<T> keyProvider)
Creates an empty list model that wraps the given collection.
|
Modifier and Type | Method and Description |
---|---|
void |
flush()
Flush pending list changes to the displays.
|
List<T> |
getList()
Get the list that backs this model.
|
protected void |
onRangeChanged(HasData<T> display)
Called when a display changes its range of interest.
|
void |
refresh()
Refresh all of the displays listening to this adapter.
|
void |
setList(List<T> listToWrap)
Replace this model's list with the specified list.
|
addDataDisplay, getDataDisplays, getKey, getKeyProvider, getRanges, removeDataDisplay, updateRowCount, updateRowData, updateRowData
public ListDataProvider()
public ListDataProvider(List<T> listToWrap)
The wrapped list should no longer be modified as the data provider cannot
detect changes to the wrapped list. Instead, call getList()
to
retrieve a wrapper that can be modified and will correctly forward changes
to displays.
listToWrap
- the List to be wrappedpublic ListDataProvider(ProvidesKey<T> keyProvider)
keyProvider
- an instance of ProvidesKeypublic ListDataProvider(List<T> listToWrap, ProvidesKey<T> keyProvider)
The wrapped list should no longer be modified as the data provider cannot
detect changes to the wrapped list. Instead, call getList()
to
retrieve a wrapper that can be modified and will correctly forward changes
to displays.
listToWrap
- the List to be wrappedkeyProvider
- an instance of ProvidesKeypublic void flush()
public List<T> getList()
NOTE: Mutations to the items contained within the list will NOT be
reflected in the model. You must call List.set(int, Object)
to
update the item within the list and push the change to the display, or call
refresh()
to push all rows to the displays.
List.set(int, Object)
performs better because it allows the data
provider to push only those rows which have changed, and usually allows the
display to re-render only a subset of the rows.
setList(List)
public void refresh()
Use refresh()
to push mutations to the underlying data items
contained within the list. The data provider cannot detect changes to data
objects within the list, so you must call this method if you modify items.
This is a shortcut for calling List.set(int, Object)
on every item
that you modify, but note that calling List.set(int, Object)
performs better because the data provider knows which rows were modified
and can push only the modified rows the displays.
public void setList(List<T> listToWrap)
The wrapped list should no longer be modified as the data provider cannot
detect changes to the wrapped list. Instead, call getList()
to
retrieve a wrapper that can be modified and will correctly forward changes
to displays.
listToWrap
- the model's new listgetList()
protected void onRangeChanged(HasData<T> display)
AbstractDataProvider
onRangeChanged
in class AbstractDataProvider<T>
display
- the display whose range has changedCopyright © 2018. All rights reserved.