M - the model typepublic abstract class Store<M> extends Object implements StoreHandlers.HasStoreHandlers<M>
| Modifier and Type | Class and Description |
|---|---|
static interface |
Store.Change<M,V>
Represents a change that can occur to a given model.
|
static class |
Store.PropertyChange<M,V>
ValueProvider-based change impl - takes a ValueProvider and the new value
to be changed.
|
class |
Store.Record
Records wrap model instances and provide specialized editing features,
including modification tracking and editing capabilities.
|
static interface |
Store.StoreFilter<M>
Defines the interface for store filters.
|
static class |
Store.StoreSortInfo<M>
Sort information for a Store to use.
|
| Constructor and Description |
|---|
Store(ModelKeyProvider<? super M> keyProvider)
Creates a store with the given key provider.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFilter(Store.StoreFilter<M> filter)
Adds the filter to the end of the store's set of filters.
|
void |
addSortInfo(int index,
Store.StoreSortInfo<M> info)
Adds the sort info at the specified index.
|
void |
addSortInfo(Store.StoreSortInfo<M> info)
Adds the specified sort info to the store.
|
HandlerRegistration |
addStoreAddHandler(StoreAddEvent.StoreAddHandler<M> handler)
Adds a
StoreAddEvent handler. |
HandlerRegistration |
addStoreClearHandler(StoreClearEvent.StoreClearHandler<M> handler)
Adds a
StoreClearEvent handler. |
HandlerRegistration |
addStoreDataChangeHandler(StoreDataChangeEvent.StoreDataChangeHandler<M> handler)
Adds a
StoreDataChangeEvent handler. |
HandlerRegistration |
addStoreFilterHandler(StoreFilterEvent.StoreFilterHandler<M> handler)
Adds a
StoreFilterEvent handler. |
HandlerRegistration |
addStoreHandlers(StoreHandlers<M> handlers)
Adds a common store event handler.
|
HandlerRegistration |
addStoreRecordChangeHandler(StoreRecordChangeEvent.StoreRecordChangeHandler<M> handler)
Adds a
StoreRecordChangeEvent handler. |
HandlerRegistration |
addStoreRemoveHandler(StoreRemoveEvent.StoreRemoveHandler<M> handler)
Adds a
StoreRemoveEvent handler. |
HandlerRegistration |
addStoreSortHandler(StoreSortEvent.StoreSortHandler<M> handler)
Adds a
StoreSortEvent handler. |
HandlerRegistration |
addStoreUpdateHandler(StoreUpdateEvent.StoreUpdateHandler<M> handler)
Adds a
StoreUpdateEvent handler. |
abstract void |
applySort(boolean supressEvent)
Tells the store to re-apply sort settings and to fire an event when
complete.
|
void |
clearSortInfo()
Removes all of the sort info from the store, so subsequent calls to
applySort will not change the order.
|
void |
commitChanges()
Commits the outstanding changes.
|
M |
findModel(M model)
Finds the matching model using the store's key provider.
|
abstract M |
findModelWithKey(String key)
Finds the model with the given key, using
ModelKeyProvider as
necessary. |
void |
fireEvent(GwtEvent<?> event) |
abstract List<M> |
getAll()
Returns a list of all items contained in the store.
|
LinkedHashSet<Store.StoreFilter<M>> |
getFilters()
Returns the stores filters.
|
ModelKeyProvider<? super M> |
getKeyProvider()
Returns the stores model key provider.
|
Collection<Store.Record> |
getModifiedRecords()
Returns a list of records that have been changed and not committed.
|
Store.Record |
getRecord(M data)
Gets the current Record instance for the given item.
|
List<Store.StoreSortInfo<M>> |
getSortInfo()
Gets the list of sort info objects.
|
boolean |
hasMatchingKey(M model1,
M model2)
Returns true if the two models have the same key.
|
boolean |
hasRecord(M data)
Returns true if a record exists for the given model.
|
boolean |
isAutoCommit()
Returns true if auto commit is enabled.
|
boolean |
isEnableFilters()
Returns true if filtering is enabled, whether or not filters are present.
|
boolean |
isFiltered()
Returns true if filtering is enabled AND the store has filters.
|
void |
rejectChanges()
Cancel outstanding changes on all changed records.
|
void |
removeFilter(Store.StoreFilter<M> filter)
Removes the filter from the store's set of filters.
|
void |
removeFilters()
Removes all filters.
|
void |
setAutoCommit(boolean isAutoCommit)
Enables or disables auto commit.
|
void |
setEnableFilters(boolean enableFilters)
Enables or disables the filters.
|
abstract 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. |
public Store(ModelKeyProvider<? super M> keyProvider)
keyProvider - the key provider, responsible for returning a unique key
for a given modelpublic void addFilter(Store.StoreFilter<M> filter)
filter - the filter to addpublic void addSortInfo(int index,
Store.StoreSortInfo<M> info)
index - the sort indexinfo - the sort infopublic void addSortInfo(Store.StoreSortInfo<M> info)
info - the sort infopublic HandlerRegistration addStoreAddHandler(StoreAddEvent.StoreAddHandler<M> handler)
StoreAddEvent.HasStoreAddHandlersStoreAddEvent handler.addStoreAddHandler in interface StoreAddEvent.HasStoreAddHandlers<M>handler - the handlerpublic HandlerRegistration addStoreClearHandler(StoreClearEvent.StoreClearHandler<M> handler)
StoreClearEvent.HasStoreClearHandlerStoreClearEvent handler.addStoreClearHandler in interface StoreClearEvent.HasStoreClearHandler<M>handler - the handlerpublic HandlerRegistration addStoreDataChangeHandler(StoreDataChangeEvent.StoreDataChangeHandler<M> handler)
StoreDataChangeEvent.HasStoreDataChangeHandlersStoreDataChangeEvent handler.addStoreDataChangeHandler in interface StoreDataChangeEvent.HasStoreDataChangeHandlers<M>handler - the handlerpublic HandlerRegistration addStoreFilterHandler(StoreFilterEvent.StoreFilterHandler<M> handler)
StoreFilterEvent.HasStoreFilterHandlersStoreFilterEvent handler.addStoreFilterHandler in interface StoreFilterEvent.HasStoreFilterHandlers<M>handler - the handlerpublic HandlerRegistration addStoreHandlers(StoreHandlers<M> handlers)
StoreHandlers.HasStoreHandlersaddStoreHandlers in interface StoreHandlers.HasStoreHandlers<M>public HandlerRegistration addStoreRecordChangeHandler(StoreRecordChangeEvent.StoreRecordChangeHandler<M> handler)
StoreRecordChangeEvent.HasStoreRecordChangeHandlersStoreRecordChangeEvent handler.addStoreRecordChangeHandler in interface StoreRecordChangeEvent.HasStoreRecordChangeHandlers<M>handler - the handlerpublic HandlerRegistration addStoreRemoveHandler(StoreRemoveEvent.StoreRemoveHandler<M> handler)
StoreRemoveEvent.HasStoreRemoveHandlerStoreRemoveEvent handler.addStoreRemoveHandler in interface StoreRemoveEvent.HasStoreRemoveHandler<M>handler - the handlerpublic HandlerRegistration addStoreSortHandler(StoreSortEvent.StoreSortHandler<M> handler)
StoreSortEvent.HasStoreSortHandlerStoreSortEvent handler.addStoreSortHandler in interface StoreSortEvent.HasStoreSortHandler<M>handler - the handlerpublic HandlerRegistration addStoreUpdateHandler(StoreUpdateEvent.StoreUpdateHandler<M> handler)
StoreUpdateEvent.HasStoreUpdateHandlersStoreUpdateEvent handler.addStoreUpdateHandler in interface StoreUpdateEvent.HasStoreUpdateHandlers<M>handler - the handlerpublic abstract void applySort(boolean supressEvent)
addSortInfo(StoreSortInfo),
addSortInfo(int, StoreSortInfo), and clearSortInfo().supressEvent - true to suppress event from firingpublic void clearSortInfo()
public void commitChanges()
public M findModel(M model)
model - target modelpublic abstract M findModelWithKey(String key)
ModelKeyProvider as
necessary.key - the key of the model to findpublic void fireEvent(GwtEvent<?> event)
fireEvent in interface HasHandlerspublic abstract List<M> getAll()
public LinkedHashSet<Store.StoreFilter<M>> getFilters()
public ModelKeyProvider<? super M> getKeyProvider()
public Collection<Store.Record> getModifiedRecords()
public Store.Record getRecord(M data)
data - the data keypublic List<Store.StoreSortInfo<M>> getSortInfo()
applySort(boolean) must be called. Note
that addSortInfo(StoreSortInfo) and
addSortInfo(int, StoreSortInfo) will add the new sort info the
this list, and then call applySort directly.public boolean hasMatchingKey(M model1, M model2)
model1 - the first modelmodel2 - the second modelpublic boolean hasRecord(M data)
data - the modelpublic boolean isAutoCommit()
public boolean isEnableFilters()
public boolean isFiltered()
public void rejectChanges()
public void removeFilter(Store.StoreFilter<M> filter)
filter - the filter to be removedpublic void removeFilters()
public void setAutoCommit(boolean isAutoCommit)
isAutoCommit - true to enable auto commitStore.Record.addChange(ValueProvider, Object)public void setEnableFilters(boolean enableFilters)
enableFilters - true to enable filterspublic abstract void update(M item)
StoreUpdateEvent to indicate that this change has occurred.
This will not cause the sort or filter to be re-applied to the object.item - the new item to take its place in the Store.Copyright © 2012. All Rights Reserved.