public interface ListModel<T>
Represents the data structure of the list, thus allowing a list to represent any potential data source by referencing different implementations of this interface, notice that we strongly discourage usage of lists.. E.g. a list model can be implemented in such a way that it retrieves data directly from storage (although caching would be recommended).
It is the responsibility of the list to notify observers (specifically the view
List
of any changes to its state (items removed/added/changed etc.)
thus the data would get updated on the view.
A ListModel
can be used in conjunction with an ImageViewer
to fetch images dynamically into the view:
Modifier and Type | Method and Description |
---|---|
void |
addDataChangedListener(DataChangedListener l)
Invoked to indicate interest in future change events
|
void |
addItem(T item)
Adds the specified item to the end of this list.
|
void |
addSelectionListener(SelectionListener l)
Invoked to indicate interest in future selection events
|
T |
getItemAt(int index)
Returns the item at the given offset
|
int |
getSelectedIndex()
Returns the selected list offset
|
int |
getSize()
Returns the number of items in the list
|
void |
removeDataChangedListener(DataChangedListener l)
Invoked to indicate no further interest in future change events
|
void |
removeItem(int index)
Removes the item at the specified position in this list.
|
void |
removeSelectionListener(SelectionListener l)
Invoked to indicate no further interest in future selection events
|
void |
setSelectedIndex(int index)
Sets the selected list offset can be set to -1 to clear selection
|
T getItemAt(int index)
index
- an index into this listint getSize()
int getSelectedIndex()
void setSelectedIndex(int index)
index
- an index into this listvoid addDataChangedListener(DataChangedListener l)
l
- a data changed listenervoid removeDataChangedListener(DataChangedListener l)
l
- a data changed listenervoid addSelectionListener(SelectionListener l)
l
- a selection listenervoid removeSelectionListener(SelectionListener l)
l
- a selection listenervoid addItem(T item)
item
- the item to be addedvoid removeItem(int index)
index
- the index of the item to removed