|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jgoodies.binding.beans.Model
com.jgoodies.binding.list.ListHolder
public class ListHolder
A ListModel implementation that looks up its elements
from a List held by a ValueModel.
This class provides public convenience methods for firing ListDataEvents,
see the methods #fireContentsChanged
,
#fireIntervalAdded
, and #fireIntervalRemoved
.
The current class name "ListHolder" and accessor #getListHolder may confuse users: what's the difference between the class (a ListModel) and its list holder (a ValueModel)?
TODO: Find a better name and provide a transition to the new class name. I consider using "IndirectList" as the new name. The Binding 1.2 may offer the new class and keep the old as deprecated version. In the Binding 1.3 (or 2.0) the deprecated class can be removed.
ListModelHolder
,
SelectionInList2
,
Serialized FormField Summary | |
---|---|
protected List |
list
Holds a copy of the listHolder's value. |
static String |
PROPERTYNAME_LIST
The name of the bound read-write list property. |
static String |
PROPERTYNAME_LIST_HOLDER
The name of the bound read-write listHolder property. |
Constructor Summary | |
---|---|
ListHolder()
Constructs a ListHolder with an empty initial ArrayList. |
|
ListHolder(List list)
Constructs a ListHolder on the given List. |
|
ListHolder(ValueModel listHolder)
Constructs a ListHolder on the given List. |
Method Summary | |
---|---|
void |
addListDataListener(ListDataListener l)
Adds a listener to the list that's notified each time a change to the data model occurs. |
void |
fireContentsChanged(int index0,
int index1)
Notifies all registered ListDataListeners that the contents of one or more list elements has changed. |
void |
fireIntervalAdded(int index0,
int index1)
Notifies all registered ListDataListeners that one or more elements have been added to this SelectionInList's List/ListModel. |
void |
fireIntervalRemoved(int index0,
int index1)
Notifies all registered ListDataListeners that one or more elements have been removed from this SelectionInList's List/ListModel. |
protected void |
fireListChanged(int oldLastIndex,
int newLastIndex)
Notifies all registered ListDataListeners that this ListModel has changed from an old list to a new list content. |
Object |
getElementAt(int index)
Returns the value at the specified index. |
List |
getList()
Returns the contents of the list holder. |
ListDataListener[] |
getListDataListeners()
Returns an array of all the list data listeners registered on this SelectionInList . |
ValueModel |
getListHolder()
Returns the ValueModel that holds the List we delegate to. |
int |
getSize()
Returns the length of the list, 0 if the list
is null . |
protected int |
getSize(List aListOrNull)
Returns the lists size or 0 if the list is null. |
boolean |
isEmpty()
Checks and answers if the list is empty or null . |
void |
removeListDataListener(ListDataListener l)
Removes a listener from the list that's notified each time a change to the data model occurs. |
void |
setList(List newList)
Sets the given List as value of the list holder. |
void |
setListHolder(ValueModel newListHolder)
Sets a new List holder. |
protected void |
updateList(List oldList,
List newList)
Fires a property change for list and a ListModel contents change event. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PROPERTYNAME_LIST
public static final String PROPERTYNAME_LIST_HOLDER
protected List list
null
as old value, but this ListModelHolder
must know about the old and the new List.
Constructor Detail |
---|
public ListHolder()
public ListHolder(List list)
list
- the initial Listpublic ListHolder(ValueModel listHolder)
listHolder
- provides the List
NullPointerException
- if the listHolder is null
ClassCastException
- if the listHolder contents is
not an instance of ListMethod Detail |
---|
public final List getList()
setList(List)
public final void setList(List newList)
newList
- the List to be set as new list contentgetList()
public final ValueModel getListHolder()
public final void setListHolder(ValueModel newListHolder)
newListHolder
- the list holder to be set
NullPointerException
- if the new list holder is null
ClassCastException
- if the new list holder's value is not a Listpublic final boolean isEmpty()
null
.
null
, false otherwisepublic final int getSize()
0
if the list
is null
.
getSize
in interface ListModel
0
if the list is
null
public final Object getElementAt(int index)
getElementAt
in interface ListModel
index
- the requested index
index
.
NullPointerException
- if the list holder's content is nullpublic final void addListDataListener(ListDataListener l)
addListDataListener
in interface ListModel
l
- the ListDataListener
to be addedpublic final void removeListDataListener(ListDataListener l)
removeListDataListener
in interface ListModel
l
- the ListDataListener
to be removedpublic final ListDataListener[] getListDataListeners()
SelectionInList
.
ListDataListener
s,
or an empty array if no list data listeners
are currently registeredaddListDataListener(ListDataListener)
,
removeListDataListener(ListDataListener)
public final void fireContentsChanged(int index0, int index1)
index0
- one end of the new intervalindex1
- the other end of the new intervalListModel
,
ListDataListener
,
ListDataEvent
public final void fireIntervalAdded(int index0, int index1)
index0
- one end of the new intervalindex1
- the other end of the new intervalListModel
,
ListDataListener
,
ListDataEvent
public final void fireIntervalRemoved(int index0, int index1)
index0
and index1
are the end points
of the interval that's been removed. Note that index0
need not be less than or equal to index1
.
index0
- one end of the removed interval,
including index0
index1
- the other end of the removed interval,
including index1
ListModel
,
ListDataListener
,
ListDataEvent
protected void updateList(List oldList, List newList)
oldList
- the old ListnewList
- the new Listprotected final void fireListChanged(int oldLastIndex, int newLastIndex)
This method is invoked by #updateList during the transition from an old List(Model) to a new List(Model).
oldLastIndex
- the last index of the old listnewLastIndex
- the last index of the new listprotected final int getSize(List aListOrNull)
aListOrNull
- a List or null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |