JIDE 3.5.15

com.jidesoft.combobox
Class DefaultComboBoxModelWrapper

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by com.jidesoft.combobox.DefaultComboBoxModelWrapper
All Implemented Interfaces:
ComboBoxModelWrapper, Serializable, EventListener, ComboBoxModel, ListDataListener, ListModel
Direct Known Subclasses:
FilterableComboBoxModel, SortableComboBoxModel

public class DefaultComboBoxModelWrapper
extends AbstractListModel
implements ComboBoxModel, ComboBoxModelWrapper, ListDataListener

The default implementation of ComboBoxModelWrapper.

See Also:
Serialized Form

Field Summary
protected  int[] _indexes
           
protected  ComboBoxModel _model
           
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
DefaultComboBoxModelWrapper()
           
DefaultComboBoxModelWrapper(ComboBoxModel model)
          Creates a DefaultComboBoxModelWrapper from any list model.
 
Method Summary
 void contentsChanged(ListDataEvent e)
          The event handler when items are updated in the underlying combo box model.
 int getActualIndexAt(int row)
          Gets the actual row.
 ComboBoxModel getActualModel()
          Gets the actual list model.
 Object getElementAt(int row)
           
 int getIndexAt(int actualRow)
          Gets the visual row.
 int[] getIndexes()
          Gets the indexes that maps from the visual row index to the actual row index.
 Object getSelectedItem()
           
 int getSize()
           
 void intervalAdded(ListDataEvent e)
          The event handler when new items are added in the underlying combo box model.
 void intervalRemoved(ListDataEvent e)
          The event handler when items are removed in the underlying combo box model.
protected  void reallocateIndexes()
          Resets the index mapping.
 void setActualModel(ComboBoxModel model)
          Sets the actual list model.
 void setIndexes(int[] indexes)
          Sets the indexes of the row mapping.
 void setSelectedItem(Object anObject)
          Set the value of the selected item.
 
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
 
Methods inherited from interface javax.swing.ListModel
addListDataListener, removeListDataListener
 

Field Detail

_model

protected ComboBoxModel _model

_indexes

protected int[] _indexes
Constructor Detail

DefaultComboBoxModelWrapper

public DefaultComboBoxModelWrapper()

DefaultComboBoxModelWrapper

public DefaultComboBoxModelWrapper(ComboBoxModel model)
Creates a DefaultComboBoxModelWrapper from any list model.

Parameters:
model - the underlying combo box model
Method Detail

setActualModel

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

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

getActualModel

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

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

getActualIndexAt

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

Specified by:
getActualIndexAt in interface ComboBoxModelWrapper
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 ComboBoxModelWrapper
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

protected 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 ComboBoxModelWrapper
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 ComboBoxModelWrapper
Parameters:
indexes - the indexes

setSelectedItem

public void setSelectedItem(Object anObject)
Set the value of the selected item. The selected item may be null.

Specified by:
setSelectedItem in interface ComboBoxModel
Parameters:
anObject - The combo box value or null for no selection.

getSelectedItem

public Object getSelectedItem()
Specified by:
getSelectedItem in interface ComboBoxModel

intervalAdded

public void intervalAdded(ListDataEvent e)
The event handler when new items are added in the underlying combo box model.

Specified by:
intervalAdded in interface ListDataListener
Parameters:
e - the event
Since:
3.2.2

intervalRemoved

public void intervalRemoved(ListDataEvent e)
The event handler when items are removed in the underlying combo box model.

Specified by:
intervalRemoved in interface ListDataListener
Parameters:
e - the event
Since:
3.2.2

contentsChanged

public void contentsChanged(ListDataEvent e)
The event handler when items are updated in the underlying combo box model.

Specified by:
contentsChanged in interface ListDataListener
Parameters:
e - the event
Since:
3.2.2

JIDE 3.5.15