torero.gui
Class TraversalModel

java.lang.Object
  |
  +--javax.swing.AbstractListModel
        |
        +--torero.gui.TraversalModel
All Implemented Interfaces:
ComboBoxModel, ListModel, Serializable

public class TraversalModel
extends AbstractListModel
implements ComboBoxModel

ListModel used by the ComboBoxes in the TraversalTool. Contained objects are sorted according to their compareTo methods with the Collection.sort() method.

See Also:
TraversalTool, Serialized Form

Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
TraversalModel()
           
 
Method Summary
 void fire()
          Causes the displaying JList to refresh its content.
 Object getElementAt(int at)
          Get the Element at the given position.
 int getIndexOf(Object o)
          Get the index of the given traversal.
 Object getSelectedItem()
          Get the selected item.
 int getSize()
          Get the number of traversals in this model.
 void reload()
          Reloads the lístmodel's content from the actual GrammarModel.
 void setSelectedItem(Object o)
          Sets the selected item.
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, 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
 

Constructor Detail

TraversalModel

public TraversalModel()
Method Detail

reload

public void reload()
Reloads the lístmodel's content from the actual GrammarModel.

getSize

public int getSize()
Get the number of traversals in this model.
Specified by:
getSize in interface ListModel
Overrides:
getSize in class AbstractListModel
Returns:
number of traversals in this model.

getElementAt

public Object getElementAt(int at)
Get the Element at the given position.
Specified by:
getElementAt in interface ListModel
Overrides:
getElementAt in class AbstractListModel
Parameters:
at - index of the traversal
Returns:
traversal at the given index at.

getIndexOf

public int getIndexOf(Object o)
Get the index of the given traversal.
Parameters:
at - traversal
Returns:
the index of the given traversal.

getSelectedItem

public Object getSelectedItem()
Get the selected item.
Specified by:
getSelectedItem in interface ComboBoxModel
Returns:
the selected attribute.

setSelectedItem

public void setSelectedItem(Object o)
Sets the selected item.
Specified by:
setSelectedItem in interface ComboBoxModel
Parameters:
o - set the selected item to o.

fire

public void fire()
Causes the displaying JList to refresh its content. Due to a Swing bug there are some situations where the JList doesn't recognize that the underlying model has changed. Therefore this method should be called after reload().