Package com.google.gwt.view.client
Class AbstractDataProvider<T>
- java.lang.Object
-
- com.google.gwt.view.client.AbstractDataProvider<T>
-
- Type Parameters:
T
- the data type of records in the list
- All Implemented Interfaces:
ProvidesKey<T>
- Direct Known Subclasses:
AsyncDataProvider
,ListDataProvider
public abstract class AbstractDataProvider<T> extends java.lang.Object implements ProvidesKey<T>
A base implementation of a data source forHasData
implementations.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractDataProvider()
Construct an AbstractDataProvider without a key provider.protected
AbstractDataProvider(ProvidesKey<T> keyProvider)
Construct an AbstractDataProvider with a given key provider.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addDataDisplay(HasData<T> display)
Adds a data display to this adapter.java.util.Set<HasData<T>>
getDataDisplays()
Get the set of displays currently assigned to this adapter.java.lang.Object
getKey(T item)
Get the key for a list item.ProvidesKey<T>
getKeyProvider()
Get theProvidesKey
that provides keys for list items.Range[]
getRanges()
Get the current ranges of all displays.protected abstract void
onRangeChanged(HasData<T> display)
Called when a display changes its range of interest.void
removeDataDisplay(HasData<T> display)
Remove the given data display.protected void
updateRowCount(int count, boolean exact)
Inform the displays of the total number of items that are available.protected void
updateRowData(int start, java.util.List<T> values)
Inform the displays of the new data.protected void
updateRowData(HasData<T> display, int start, java.util.List<T> values)
Informs a single display of new data.
-
-
-
Constructor Detail
-
AbstractDataProvider
protected AbstractDataProvider()
Construct an AbstractDataProvider without a key provider.
-
AbstractDataProvider
protected AbstractDataProvider(ProvidesKey<T> keyProvider)
Construct an AbstractDataProvider with a given key provider.- Parameters:
keyProvider
- aProvidesKey
object
-
-
Method Detail
-
addDataDisplay
public void addDataDisplay(HasData<T> display)
Adds a data display to this adapter. The current range of interest of the display will be populated with data.- Parameters:
display
- aHasData
.
-
getDataDisplays
public java.util.Set<HasData<T>> getDataDisplays()
Get the set of displays currently assigned to this adapter.- Returns:
- the set of
HasData
-
getKey
public java.lang.Object getKey(T item)
Get the key for a list item. The default implementation returns the item itself.- Specified by:
getKey
in interfaceProvidesKey<T>
- Parameters:
item
- the list item- Returns:
- the key that represents the item
-
getKeyProvider
public ProvidesKey<T> getKeyProvider()
Get theProvidesKey
that provides keys for list items.- Returns:
- the
ProvidesKey
-
getRanges
public Range[] getRanges()
Get the current ranges of all displays.- Returns:
- the ranges
-
removeDataDisplay
public void removeDataDisplay(HasData<T> display)
Remove the given data display.- Parameters:
display
- aHasData
instance- Throws:
java.lang.IllegalStateException
- if the display is not present
-
onRangeChanged
protected abstract void onRangeChanged(HasData<T> display)
Called when a display changes its range of interest.- Parameters:
display
- the display whose range has changed
-
updateRowCount
protected void updateRowCount(int count, boolean exact)
Inform the displays of the total number of items that are available.- Parameters:
count
- the new total row countexact
- true if the count is exact, false if it is an estimate
-
updateRowData
protected void updateRowData(int start, java.util.List<T> values)
Inform the displays of the new data.- Parameters:
start
- the start indexvalues
- the data values
-
-