public abstract class AbstractListViewDatasource extends Observable implements IListViewDatasource
Abstract base implementation of an IListViewDatasource
based on a
Vector
to manage its data model. It uses Observable
to notify
changes to a number of Observer
.
Constructor and Description |
---|
AbstractListViewDatasource() |
AbstractListViewDatasource(Observer observer) |
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.
|
int |
compare(java.lang.Object o1,
java.lang.Object o2) |
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.
|
abstract java.lang.Object |
getExpressionValue(java.lang.String rootExpression)
Call this method to get the object of the data model using an expression.
|
abstract 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. |
abstract 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 valueFilter)
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 . |
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, notifyObservers
public AbstractListViewDatasource()
public AbstractListViewDatasource(Observer observer)
public abstract void reloadElements()
IListViewDatasource
Use to reload the objects managed by the datasource.
reloadElements
in interface IListViewDatasource
public java.lang.String getFilterExpression()
IListViewDatasource
Returns the filter expression currently used. If no filter expression is used,
null
will be returned
getFilterExpression
in interface IListViewDatasource
public void setFilterExpression(java.lang.String valueFilter)
IListViewDatasource
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
IListViewDatasource.getNumberOfElements()
, IListViewDatasource.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.
setFilterExpression
in interface IListViewDatasource
valueFilter
- the filter string the datasource uses to filter it's contentpublic java.util.Vector getElements()
IListViewDatasource
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.
getElements
in interface IListViewDatasource
public int getNumberOfElements()
IListViewDatasource
Call this method to get the total number of objects in the data model managed by this datasource.
getNumberOfElements
in interface IListViewDatasource
public abstract java.lang.Object getExpressionValue(java.lang.String rootExpression) throws java.lang.Exception
IListViewDatasource
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.
getExpressionValue
in interface IListViewDatasource
rootExpression
- String that references an object in the data modelnull
if there was no objectjava.lang.Exception
- if an error occured evaluating the given expressionpublic abstract java.lang.Object getExpressionValue(java.lang.String relativeExpression, int elementIndex) throws java.lang.Exception
IListViewDatasource
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.
getExpressionValue
in interface IListViewDatasource
elementIndex
- 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 expressionpublic void removeElementAtIndex(int index)
IListViewDatasource
Remove the object at the given index of the data model.
removeElementAtIndex
in interface IListViewDatasource
index
- the row index of the object to be removedpublic void removeElement(java.lang.Object object)
IListViewDatasource
Remove the given object from the data model.
removeElement
in interface IListViewDatasource
object
- the object to be removedpublic void removeAllElements()
IListViewDatasource
removeAllElements
in interface IListViewDatasource
public void addElement(java.lang.Object object)
IListViewDatasource
Add a new object to the data model. Objects are added to the end.
addElement
in interface IListViewDatasource
object
- the object to be added to the data modelpublic void addElementAtIndex(java.lang.Object object, int index)
IListViewDatasource
Insert a new object to the data model at the given row index.
addElementAtIndex
in interface IListViewDatasource
object
- the object to be added to the data modelindex
- the index to add the object atpublic void addElements(java.util.Vector objects)
IListViewDatasource
Add multiple new objects to the data model. Objects are added to the end.
addElements
in interface IListViewDatasource
objects
- a Vector
of objects to be addedpublic java.lang.Object getElementAtIndex(int index)
IListViewDatasource
Call this method to get the object of the data model at a given index.
getElementAtIndex
in interface IListViewDatasource
index
- the row index of the object starting at 0.public void setSelectedElement(java.lang.Object object)
IListViewDatasource
Set the object selected by the ListView
.
setSelectedElement
in interface IListViewDatasource
object
- the selected objectpublic java.lang.Object getSelectedElement()
IListViewDatasource
Returns the currently selected object of the ListView
or null
if no object was set as selected.
getSelectedElement
in interface IListViewDatasource
ListView
public void setComparator(IListViewComparator comparator)
IListViewDatasource
Use this method to set a IListViewComparator
implementation to be used
when sorting or resort
ing the data model represention in the
ListView
.
setComparator
in interface IListViewDatasource
comparator
- the comparator implementation used for sortingpublic IListViewComparator getComparator()
IListViewDatasource
Use this method to get the current IListViewComparator
used by the
ListView
.
getComparator
in interface IListViewDatasource
IListViewComparator
implementation currently used or null
if sorting is disabled.public int compare(java.lang.Object o1, java.lang.Object o2)
public void resort()
IListViewDatasource
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.
resort
in interface IListViewDatasource