M
- the model typepublic class ListStore<M> extends Store<M>
List
-like client side cache for elements. All operations are performed on the currently visible set of
elements.Store.Change<M,V>, Store.PropertyChange<M,V>, Store.Record, Store.StoreFilter<M>, Store.StoreSortInfo<M>
Constructor and Description |
---|
ListStore(ModelKeyProvider<? super M> keyProvider)
Creates a new store.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
M item)
Like add(M), except the item will be inserted at the given index in the visible items.
|
void |
add(M item)
Adds the given item to the end of the list.
|
boolean |
addAll(Collection<? extends M> items)
Adds all items to the end of the list.
|
boolean |
addAll(int index,
Collection<? extends M> items)
Adds all items at the given position.
|
protected void |
applyFilters()
Sets the filters to run again, whether they need it or not.
|
void |
applySort(boolean suppressEvent)
Tells the store to re-apply sort settings and to fire an event when
complete.
|
void |
clear()
Removes all items from the store.
|
M |
findModelWithKey(String key)
Finds the model with the given key, using
ModelKeyProvider as
necessary. |
protected void |
fireSortedAddEvents(Collection<? extends M> items)
Takes a collection of newly added items and fires a
StoreAddEvent for each one. |
M |
get(int index)
Gets the given item from the list.
|
List<M> |
getAll()
Returns a list of all items contained in the store.
|
int |
indexOf(M item)
Gets the position of the item in the set of visible items.
|
protected boolean |
isFilteredOut(M item)
Returns true if the given item is set to be removed by any filter.
|
M |
remove(int index)
A ListStore acts like a Java List, and stuff is arranged in a linear fashion, so it may be advantageous to remove
based on index.
|
boolean |
remove(M model)
Removes the given item, visible or not, from the store.
|
void |
replaceAll(List<? extends M> newItems)
Replaces all the items in the store with given list of new items.
|
int |
size()
Returns the number of visible items.
|
List<M> |
subList(int start,
int end)
Creates a new list containing references to the items in the specified range.
|
void |
update(M item)
Replaces the item that matches the key of the given item, and fires a
StoreUpdateEvent to indicate that
this change has occurred. |
addFilter, addSortInfo, addSortInfo, addStoreAddHandler, addStoreClearHandler, addStoreDataChangeHandler, addStoreFilterHandler, addStoreHandlers, addStoreRecordChangeHandler, addStoreRemoveHandler, addStoreSortHandler, addStoreUpdateHandler, buildFullComparator, clearSortInfo, commitChanges, ensureHandlers, findModel, fireEvent, getFilters, getKeyProvider, getModifiedRecords, getRecord, getSortInfo, hasMatchingKey, hasRecord, isAutoCommit, isEnableFilters, isFiltered, isSorted, rejectChanges, removeFilter, removeFilters, setAutoCommit, setEnableFilters, wrapRecordValueProvider
public ListStore(ModelKeyProvider<? super M> keyProvider)
keyProvider
- the key providerpublic void add(int index, M item)
index
- - the index in the visible items. Must be a valid index, in the range [0,size()). If the store is
sorted, the index will be ignoreditem
- the item to be addedpublic void add(M item)
item
- the item to be addedpublic boolean addAll(Collection<? extends M> items)
items
- the items to be addedpublic boolean addAll(int index, Collection<? extends M> items)
index
- the insert indexitems
- the items to be addedpublic void applySort(boolean suppressEvent)
Store
Store.addSortInfo(StoreSortInfo)
,
Store.addSortInfo(int, StoreSortInfo)
, and Store.clearSortInfo()
.public void clear()
Store
public M findModelWithKey(String key)
Store
ModelKeyProvider
as
necessary.findModelWithKey
in class Store<M>
key
- the key of the model to findpublic M get(int index)
index
- the specified index.public List<M> getAll()
Store
public int indexOf(M item)
item
- the visible itempublic M remove(int index)
index
- the index of the item to removepublic boolean remove(M model)
public void replaceAll(List<? extends M> newItems)
newItems
- the new contents of the storepublic int size()
public List<M> subList(int start, int end)
start
- the starting indexend
- the ending indexpublic void update(M item)
Store
StoreUpdateEvent
to indicate that
this change has occurred. Any changes to the previous model via it's record instance will be lost and the record
will be removed.
This will not cause the sort or filter to be re-applied to the object.protected void applyFilters()
Store
applyFilters
in class Store<M>
protected void fireSortedAddEvents(Collection<? extends M> items)
StoreAddEvent
for each one. The events are fired in
store sequence order (i.e. the order in which the items appear in the store).items
- a collection of items that have been added to the storeprotected boolean isFilteredOut(M item)
item
- the modelCopyright © 2018. All rights reserved.