JIDE 3.5.15

com.jidesoft.list
Class DefaultGroupableListModel

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by javax.swing.DefaultListModel
          extended by com.jidesoft.list.DefaultGroupableListModel
All Implemented Interfaces:
GroupableListModel, Serializable, ListModel

public class DefaultGroupableListModel
extends DefaultListModel
implements GroupableListModel

This is a default implementation for GroupableListModel. It added methods such as setGroupAt(Object,int), setGroups(Object[]) and renameGroup(Object,Object) to allow user to change groups directly.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
DefaultGroupableListModel()
          Creates a new instance of DefaultGroupableListModel
 
Method Summary
 void addListGroupChangeListener(ListGroupChangeListener l)
          Adds a listener to the list that's notified each time a change to the groups of the list model occurs.
protected  void fireGroupChanged(Object source)
          AbstractListModel subclasses must call this method after one or more elements are added to the model.
 Object getGroupAt(int index)
          Returns the group close before the element at the specified index.
 Object[] getGroups()
          Returns all groups, which control the order of appearance.
 ListGroupChangeListener[] getListGroupChangeListeners()
          Returns an array of all the list group change listeners registered on this DefaultGroupableListModel.
 void removeListGroupChangeListener(ListGroupChangeListener l)
          Removes a listener from the list that's notified each time a change to the groups of the list model occurs.
 void renameGroup(Object oldGroup, Object newGroup)
          Rename a specified group.
 void setGroupAt(Object group, int index)
          Set the new group for the element at the specified index.
 void setGroups(Object[] groups)
          Set a new array of groups for this DefaultGroupableListModel
 
Methods inherited from class javax.swing.DefaultListModel
add, addElement, capacity, clear, contains, copyInto, elementAt, elements, ensureCapacity, firstElement, get, getElementAt, getSize, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, removeAllElements, removeElement, removeElementAt, removeRange, set, setElementAt, setSize, size, toArray, toString, trimToSize
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.swing.ListModel
addListDataListener, getElementAt, getSize, removeListDataListener
 

Constructor Detail

DefaultGroupableListModel

public DefaultGroupableListModel()
Creates a new instance of DefaultGroupableListModel

Method Detail

setGroupAt

public void setGroupAt(Object group,
                       int index)
Set the new group for the element at the specified index.

Parameters:
index - the index of element
group - a group to be added

setGroups

public void setGroups(Object[] groups)
Set a new array of groups for this DefaultGroupableListModel

Parameters:
groups - the new array of group objects
See Also:
getGroups()

getGroupAt

public Object getGroupAt(int index)
Returns the group close before the element at the specified index.

Specified by:
getGroupAt in interface GroupableListModel
Parameters:
index - the index of element
Returns:
the close before the element at the specified index..
See Also:
GroupableListModel.getGroups()

getGroups

public Object[] getGroups()
Description copied from interface: GroupableListModel
Returns all groups, which control the order of appearance. Besides, if getGroupAt(int) returns a value that doesn't exist in the groups, the value will be arranged after the array.

Specified by:
getGroups in interface GroupableListModel
Returns:
an array of groups in the order of appearance.
See Also:
GroupableListModel.getGroupAt(int)

renameGroup

public void renameGroup(Object oldGroup,
                        Object newGroup)
Rename a specified group.

Parameters:
oldGroup - the old group to be changed
newGroup - the new group object.

addListGroupChangeListener

public void addListGroupChangeListener(ListGroupChangeListener l)
Adds a listener to the list that's notified each time a change to the groups of the list model occurs.

Specified by:
addListGroupChangeListener in interface GroupableListModel
Parameters:
l - the ListGroupChangeListener to be added

removeListGroupChangeListener

public void removeListGroupChangeListener(ListGroupChangeListener l)
Removes a listener from the list that's notified each time a change to the groups of the list model occurs.

Specified by:
removeListGroupChangeListener in interface GroupableListModel
Parameters:
l - the ListGroupChangeListener to be removed

getListGroupChangeListeners

public ListGroupChangeListener[] getListGroupChangeListeners()
Returns an array of all the list group change listeners registered on this DefaultGroupableListModel.

Returns:
all of this model's ListGroupChangeListeners, or an empty array if no list data listeners are currently registered
See Also:
addListGroupChangeListener(com.jidesoft.list.ListGroupChangeListener), removeListGroupChangeListener(com.jidesoft.list.ListGroupChangeListener)

fireGroupChanged

protected void fireGroupChanged(Object source)
AbstractListModel subclasses must call this method after one or more elements are added to the model. The new elements are specified by a closed interval index0, index1 -- the end points are included. Note that index0 need not be less than or equal to index1.

Parameters:
source - the GroupableListModel that changed, typically "this"

JIDE 3.5.15