public interface IListViewDatasource
An IListViewDatasource
provides methods to help manage and
represent the data model used to display a ListView
object. To
provide information about the appearance of a ListView
use
IListViewDelegate
instead.
Currently JSONDatasource
is the only available implementation. You
can use AbstractListViewDatasource
as abstract base implementation
to extend for your own needs.
Modifier and Type | Method and Description |
---|---|
void |
addElement(java.lang.Object object)
Add a new object to the data model.
|
void |
addElementAtIndex(java.lang.Object object,
int index)
Insert a new object to the data model at the given row index.
|
void |
addElements(java.util.Vector objects)
Add multiple new objects to the data model.
|
IListViewComparator |
getComparator()
Use this method to get the current
IListViewComparator used by the
ListView . |
java.lang.Object |
getElementAtIndex(int index)
Call this method to get the object of the data model at a given index.
|
java.util.Vector |
getElements()
Call this method to get all objects in the data model managed by this
datasource.
|
java.lang.Object |
getExpressionValue(java.lang.String expression)
Call this method to get the object of the data model using an expression.
|
java.lang.Object |
getExpressionValue(java.lang.String relativeExpression,
int elementIndex)
Call this method to get the object of the data model using an expression that is
relative to on object in the data model with the given row index.
|
java.lang.String |
getFilterExpression()
Returns the filter expression currently used.
|
int |
getNumberOfElements()
Call this method to get the total number of objects in the data model
managed by this datasource
|
java.lang.Object |
getSelectedElement()
Returns the currently selected object of the
ListView or null
if no object was set as selected. |
void |
reloadElements()
Use to reload the objects managed by the datasource.
|
void |
removeAllElements()
Removes all objects from the data model.
|
void |
removeElement(java.lang.Object object)
Remove the given object from the data model.
|
void |
removeElementAtIndex(int index)
Remove the object at the given index of the data model.
|
void |
resort()
Call this method to manually resort the contents of the data model.
|
void |
setComparator(IListViewComparator comparator)
Use this method to set a
IListViewComparator implementation to be used
when sorting or resort ing the data model represention in the
ListView . |
void |
setFilterExpression(java.lang.String filter)
Use this method to set a filter expression and enable filtering for the datasource.
|
void |
setSelectedElement(java.lang.Object object)
Set the object selected by the
ListView . |
void reloadElements()
Use to reload the objects managed by the datasource.
int getNumberOfElements()
Call this method to get the total number of objects in the data model managed by this datasource.
java.util.Vector getElements()
Call this method to get all objects in the data model managed by this
datasource. Changing the Vector
returned will not change the
contents of the data model.
java.lang.Object getElementAtIndex(int index)
Call this method to get the object of the data model at a given index.
index
- the row index of the object starting at 0.java.lang.Object getExpressionValue(java.lang.String expression) throws java.lang.Exception
Call this method to get the object of the data model using an expression.
An expression can be any String an IListViewDatasource
implementation
uses to reference an object.
expression
- String that references an object in the data modelnull
if there was no objectjava.lang.Exception
- if an error occured evaluating the given expressionjava.lang.Object getExpressionValue(java.lang.String relativeExpression, int elementIndex) throws java.lang.Exception
Call this method to get the object of the data model using an expression that is
relative to on object in the data model with the given row index.
An expression can be any String an IListViewDatasource
implementation
uses to reference an object.
expression
- String that references an object in the data modelelementIndex
- the index of the object to be used to evaluate the given expressionnull
if there was no objectjava.lang.Exception
- if an error occured evaluating the given expressionvoid setFilterExpression(java.lang.String filter)
Use this method to set a filter expression and enable filtering for the datasource. If
filtering is enabled, only the objects matching the filter expression will be returned by
getNumberOfElements()
, getElements()
, etc. You typically use filter
to implement searches in a . An expression can be any String an
IListViewDatasource
implementation uses to reference an object.
filter
- the filter string the datasource uses to filter it's contentjava.lang.String getFilterExpression()
Returns the filter expression currently used. If no filter expression is used,
null
will be returned
void removeElementAtIndex(int index)
Remove the object at the given index of the data model.
index
- the row index of the object to be removedvoid removeElement(java.lang.Object object)
Remove the given object from the data model.
object
- the object to be removedvoid removeAllElements()
void addElement(java.lang.Object object)
Add a new object to the data model. Objects are added to the end.
object
- the object to be added to the data modelvoid addElementAtIndex(java.lang.Object object, int index)
Insert a new object to the data model at the given row index.
object
- the object to be added to the data modelindex
- the index to add the object atvoid addElements(java.util.Vector objects)
Add multiple new objects to the data model. Objects are added to the end.
objects
- a Vector
of objects to be addedvoid setSelectedElement(java.lang.Object object)
Set the object selected by the ListView
.
object
- the selected objectjava.lang.Object getSelectedElement()
Returns the currently selected object of the ListView
or null
if no object was set as selected.
ListView
void setComparator(IListViewComparator comparator)
Use this method to set a IListViewComparator
implementation to be used
when sorting or resort
ing the data model represention in the
ListView
.
comparator
- the comparator implementation used for sortingIListViewComparator getComparator()
Use this method to get the current IListViewComparator
used by the
ListView
.
IListViewComparator
implementation currently used or null
if sorting is disabled.void resort()
Call this method to manually resort the contents of the data model. Changing the order
of objects by resorting requires a ListView.reload()
to reflect the changes
in the user interface.