JIDE 3.5.15

com.jidesoft.list
Class DefaultListModelWrapper

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by com.jidesoft.list.DefaultListModelWrapper
All Implemented Interfaces:
IndexChangeEventGenerator, EventFireListModel, ListModelWrapper, Serializable, EventListener, ListDataListener, ListModel
Direct Known Subclasses:
FilterableListModel, SortableListModel

public class DefaultListModelWrapper
extends AbstractListModel
implements ListModelWrapper, ListDataListener, EventFireListModel, IndexChangeEventGenerator

The default implementation of ListModelWrapper.

See Also:
Serialized Form

Field Summary
protected  int[] _adjustingIndexes
           
protected  int[] _indexes
           
protected  ListModel _model
           
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
DefaultListModelWrapper()
           
DefaultListModelWrapper(ListModel model)
          Creates a DefaultListModelWrapper from any list model.
 
Method Summary
 void addIndexChangeListener(IndexChangeListener l)
          Add IndexChangelistener.
 void contentsChanged(ListDataEvent e)
           
protected  CompoundListDataEvent createCompoundListDataEvent()
           
protected  void fireEvents(int[] oldIndexes, int[] newIndexes)
          Fires the exact events when index changed.
protected  void fireIndexChanged(int eventSerialNumber)
           
 void fireListDataEvent(ListDataEvent event)
          Fires a ListDataEvent.
 int getActualIndexAt(int row)
          Gets the actual row.
 ListModel getActualModel()
          Gets the actual list model.
 Object getElementAt(int row)
           
 int getIndexAt(int actualRow)
          Gets the visual row.
 IndexChangeListener[] getIndexChangeListeners()
          Returns an array of all the IndexChangeListeners
 int[] getIndexes()
          Gets the indexes that maps from the visual row index to the actual row index.
 int getSize()
           
 void intervalAdded(ListDataEvent e)
           
 void intervalRemoved(ListDataEvent e)
           
 void reallocateIndexes()
          Resets the index mapping.
 void removeIndexChangeListener(IndexChangeListener l)
          Remove IndexChangelistener.
 void setActualModel(ListModel model)
          Sets the actual list model.
 void setIndexes(int[] indexes)
          Sets the indexes of the row mapping.
 
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, toString, wait, wait, wait
 

Field Detail

_model

protected ListModel _model

_indexes

protected int[] _indexes

_adjustingIndexes

protected transient int[] _adjustingIndexes
Constructor Detail

DefaultListModelWrapper

public DefaultListModelWrapper()

DefaultListModelWrapper

public DefaultListModelWrapper(ListModel model)
Creates a DefaultListModelWrapper from any list model.

Parameters:
model - the wrapped list model
Method Detail

setActualModel

public void setActualModel(ListModel model)
Sets the actual list model.

Specified by:
setActualModel in interface ListModelWrapper
Parameters:
model - the list model.

getActualModel

public ListModel getActualModel()
Gets the actual list model. Since ListModelWrapper is just a wrapper around another list model, this method will return you the actual list model.

Specified by:
getActualModel in interface ListModelWrapper
Returns:
the actual list model.

getActualIndexAt

public int getActualIndexAt(int row)
Gets the actual row.

Specified by:
getActualIndexAt in interface ListModelWrapper
Parameters:
row - the row on the UI.
Returns:
the actual row in the actual model. It will throw IllegalArgumentException if the row is out of range.

getIndexAt

public int getIndexAt(int actualRow)
Gets the visual row.

Specified by:
getIndexAt in interface ListModelWrapper
Parameters:
actualRow - the actual row in actual model.
Returns:
the row on UI. -1 if cannot find the row.

getElementAt

public Object getElementAt(int row)
Specified by:
getElementAt in interface ListModel

getSize

public int getSize()
Specified by:
getSize in interface ListModel

reallocateIndexes

public void reallocateIndexes()
Resets the index mapping.


getIndexes

public int[] getIndexes()
Gets the indexes that maps from the visual row index to the actual row index.

Specified by:
getIndexes in interface ListModelWrapper
Returns:
the indexes.

setIndexes

public void setIndexes(int[] indexes)
Sets the indexes of the row mapping. We exposed this method to allow quick access to the underlying indexes. The method won't fire any list data events. So once you change the indexes, you need to fire corresponding list data event so that table can update itself.

Specified by:
setIndexes in interface ListModelWrapper
Parameters:
indexes - the new indices

fireEvents

protected void fireEvents(int[] oldIndexes,
                          int[] newIndexes)
Fires the exact events when index changed.

Please be noted that, customers should not invoke this method directly.

Parameters:
oldIndexes - the index array before filtering.
newIndexes - the index array after filtering.

createCompoundListDataEvent

protected CompoundListDataEvent createCompoundListDataEvent()

intervalAdded

public void intervalAdded(ListDataEvent e)
Specified by:
intervalAdded in interface ListDataListener

intervalRemoved

public void intervalRemoved(ListDataEvent e)
Specified by:
intervalRemoved in interface ListDataListener

contentsChanged

public void contentsChanged(ListDataEvent e)
Specified by:
contentsChanged in interface ListDataListener

fireListDataEvent

public void fireListDataEvent(ListDataEvent event)
Description copied from interface: EventFireListModel
Fires a ListDataEvent.

Specified by:
fireListDataEvent in interface EventFireListModel
Parameters:
event - the event

fireIndexChanged

protected void fireIndexChanged(int eventSerialNumber)

addIndexChangeListener

public void addIndexChangeListener(IndexChangeListener l)
Description copied from interface: IndexChangeEventGenerator
Add IndexChangelistener.

Specified by:
addIndexChangeListener in interface IndexChangeEventGenerator
Parameters:
l - the listener

removeIndexChangeListener

public void removeIndexChangeListener(IndexChangeListener l)
Description copied from interface: IndexChangeEventGenerator
Remove IndexChangelistener.

Specified by:
removeIndexChangeListener in interface IndexChangeEventGenerator
Parameters:
l - the listener

getIndexChangeListeners

public IndexChangeListener[] getIndexChangeListeners()
Description copied from interface: IndexChangeEventGenerator
Returns an array of all the IndexChangeListeners

Specified by:
getIndexChangeListeners in interface IndexChangeEventGenerator
Returns:
all of the IndexChangeListeners added or an empty array if no listeners have been added
See Also:
IndexChangeEventGenerator.addIndexChangeListener(com.jidesoft.grid.IndexChangeListener)

JIDE 3.5.15