org.norvelle.textcite.gui.adapter
Class ListModelAdapter

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by org.norvelle.textcite.gui.adapter.ListModelAdapter
All Implemented Interfaces:
java.io.Serializable, javax.swing.ComboBoxModel, javax.swing.ListModel, ListModelChangeListener
Direct Known Subclasses:
CategoryListModelAdapter, FilterListModelAdapter

public class ListModelAdapter
extends javax.swing.AbstractListModel
implements javax.swing.ComboBoxModel, ListModelChangeListener

ListModelAdapter An adapter to separate our data model cleanly from the GUI layer. Provides a mapping between the ListModel methods and the methods of our data model objects.

Author:
Erik Norvelle
See Also:
Serialized Form

Field Summary
protected  ListModelAdaptee model
          The data source that will serve as the model for the JList.
protected  java.lang.Object selectedItem
          A data provider to a JList has to maintain state about which item is currently selected.
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
ListModelAdapter(ListModelAdaptee model)
           
 
Method Summary
 void destroy()
          We make sure that the adapted class removes all references to the adaptor, so as not to cause memory leaks.
 void fireContentsChanged(java.lang.Object sender, java.lang.Object data, int pos, int pos2)
          Just hand on the ContentsChanged signal to the JList that we're serving as the model for.
 void fireIntervalAdded(java.lang.Object sender, java.lang.Object data, int pos, int pos2)
          Just hand on the IntervalAdded signal to the JList that we're serving as the model for.
 void fireIntervalRemoved(java.lang.Object sender, java.lang.Object data, int pos, int pos2)
          Just hand on the IntervalRemoved signal to the JList that we're serving as the model for.
 java.lang.Class getAdapteeClass()
          Returns the class of the adapted object.
 java.lang.Object getElementAt(int pos)
           
 java.lang.String getId()
           
 java.lang.Object getSelectedItem()
           
 int getSize()
           
 void setSelectedItem(java.lang.Object selitem)
           
 
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 ListModelAdaptee model
The data source that will serve as the model for the JList.


selectedItem

protected java.lang.Object selectedItem
A data provider to a JList has to maintain state about which item is currently selected. The model itself doesn't need to know about which item is current selected in the GUI, so we handle this issue.

Constructor Detail

ListModelAdapter

public ListModelAdapter(ListModelAdaptee model)
Method Detail

destroy

public void destroy()
We make sure that the adapted class removes all references to the adaptor, so as not to cause memory leaks.


getAdapteeClass

public java.lang.Class getAdapteeClass()
Returns the class of the adapted object.

Returns:
The class of the adapted object.

getElementAt

public java.lang.Object getElementAt(int pos)
                              throws java.lang.ArrayIndexOutOfBoundsException
Specified by:
getElementAt in interface javax.swing.ListModel
Throws:
java.lang.ArrayIndexOutOfBoundsException

getSize

public int getSize()
Specified by:
getSize in interface javax.swing.ListModel

getSelectedItem

public java.lang.Object getSelectedItem()
Specified by:
getSelectedItem in interface javax.swing.ComboBoxModel

setSelectedItem

public void setSelectedItem(java.lang.Object selitem)
Specified by:
setSelectedItem in interface javax.swing.ComboBoxModel

fireContentsChanged

public void fireContentsChanged(java.lang.Object sender,
                                java.lang.Object data,
                                int pos,
                                int pos2)
Just hand on the ContentsChanged signal to the JList that we're serving as the model for.

Specified by:
fireContentsChanged in interface ListModelChangeListener
data - TODO

fireIntervalRemoved

public void fireIntervalRemoved(java.lang.Object sender,
                                java.lang.Object data,
                                int pos,
                                int pos2)
Just hand on the IntervalRemoved signal to the JList that we're serving as the model for.

Specified by:
fireIntervalRemoved in interface ListModelChangeListener
data - TODO

fireIntervalAdded

public void fireIntervalAdded(java.lang.Object sender,
                              java.lang.Object data,
                              int pos,
                              int pos2)
Just hand on the IntervalAdded signal to the JList that we're serving as the model for.

Specified by:
fireIntervalAdded in interface ListModelChangeListener
data - TODO

getId

public java.lang.String getId()