kawigi.config
Class TagLibEditorModel

java.lang.Object
  |
  +--kawigi.config.TagLibEditorModel
All Implemented Interfaces:
javax.swing.ComboBoxModel, javax.swing.ListModel, javax.swing.MutableComboBoxModel

public class TagLibEditorModel
extends java.lang.Object
implements javax.swing.MutableComboBoxModel

A class that maps a TagLibrary to a JComboBox. This is used by the editor to provide editing functionality.


Field Summary
protected  kawigi.template.TagLibrary taglib
          The currently opened TagLibrary.
 
Constructor Summary
TagLibEditorModel(kawigi.template.TagLibrary taglib)
          Creates a TagLibEditorModel instance mapping to the given TagLibrary.
 
Method Summary
 void addElement(java.lang.Object obj)
          Adds a new MethodInfo to the TagLibrary.
 void addListDataListener(javax.swing.event.ListDataListener l)
          Adds the ListDataListener to the list of listeners that will be notified of changes to this model.
protected  void fireEvent()
          Fires a CONTENTS_CHANGED event to all the listeners to this model.
 java.lang.Object getElementAt(int index)
          Returns the element in the list at the given index.
 java.lang.Object getSelectedItem()
          Returns the object designated as being selected.
 int getSize()
          Returns the number of elements to be rendered in the JComboBox, which is one more than the number of Tags in the TagLibrary.
 kawigi.template.TagLibrary getTagLibrary()
          Returns the TagLibrary that is mapped from this editor model.
 void insertElementAt(java.lang.Object obj, int index)
          Adds a new MethodInfo to the TagLibrary.
 void removeElement(java.lang.Object obj)
          Removes a MethodInfo from the TagLibrary.
 void removeElementAt(int index)
          Removes the indexth element from the TagLibrary, as mapped to the JComboBox.
 void removeListDataListener(javax.swing.event.ListDataListener l)
          Removes a ListDataListener so that it will no longer receive change events from this model.
 void setSelectedItem(java.lang.Object anItem)
          Changes which object is designated as being selected.
 void setTagLibrary(kawigi.template.TagLibrary lib)
          Changes the TagLibrary represented by this TagLibEditorModel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

taglib

protected kawigi.template.TagLibrary taglib
The currently opened TagLibrary.

Constructor Detail

TagLibEditorModel

public TagLibEditorModel(kawigi.template.TagLibrary taglib)
Creates a TagLibEditorModel instance mapping to the given TagLibrary.

Method Detail

getTagLibrary

public kawigi.template.TagLibrary getTagLibrary()
Returns the TagLibrary that is mapped from this editor model.


setTagLibrary

public void setTagLibrary(kawigi.template.TagLibrary lib)
Changes the TagLibrary represented by this TagLibEditorModel.


addElement

public void addElement(java.lang.Object obj)
Adds a new MethodInfo to the TagLibrary. obj should be an instance of MethodInfo, or else it won't be added.

Specified by:
addElement in interface javax.swing.MutableComboBoxModel

insertElementAt

public void insertElementAt(java.lang.Object obj,
                            int index)
Adds a new MethodInfo to the TagLibrary. It does this by calling addElement. obj should be an instance of MethodInfo, or nothing will happen. index is completely disregarded - you don't get to choose where a new element is added to the TagLibrary. They are added by name into a TreeMap, so they are always inserted into their lexicographical ordering.

Specified by:
insertElementAt in interface javax.swing.MutableComboBoxModel

removeElement

public void removeElement(java.lang.Object obj)
Removes a MethodInfo from the TagLibrary. Does nothing if obj is not a MethodInfo defined by the current TagLibrary.

Specified by:
removeElement in interface javax.swing.MutableComboBoxModel

removeElementAt

public void removeElementAt(int index)
Removes the indexth element from the TagLibrary, as mapped to the JComboBox. Ignores requests to remove element 0, because that is where the <New Tag> thing is.

Specified by:
removeElementAt in interface javax.swing.MutableComboBoxModel

getSelectedItem

public java.lang.Object getSelectedItem()
Returns the object designated as being selected.

Specified by:
getSelectedItem in interface javax.swing.ComboBoxModel

setSelectedItem

public void setSelectedItem(java.lang.Object anItem)
Changes which object is designated as being selected.

Specified by:
setSelectedItem in interface javax.swing.ComboBoxModel

addListDataListener

public void addListDataListener(javax.swing.event.ListDataListener l)
Adds the ListDataListener to the list of listeners that will be notified of changes to this model.

Specified by:
addListDataListener in interface javax.swing.ListModel

getElementAt

public java.lang.Object getElementAt(int index)
Returns the element in the list at the given index. Returns the string, "<New Tag>" for index 0, otherwise returns the MethodInfo from the TagLibrary at position index-1.

Specified by:
getElementAt in interface javax.swing.ListModel

getSize

public int getSize()
Returns the number of elements to be rendered in the JComboBox, which is one more than the number of Tags in the TagLibrary.

Specified by:
getSize in interface javax.swing.ListModel

removeListDataListener

public void removeListDataListener(javax.swing.event.ListDataListener l)
Removes a ListDataListener so that it will no longer receive change events from this model.

Specified by:
removeListDataListener in interface javax.swing.ListModel

fireEvent

protected void fireEvent()
Fires a CONTENTS_CHANGED event to all the listeners to this model.