com.nqadmin.swingSet.formatting.helpers
Class SelectorComboBoxModel

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by com.nqadmin.swingSet.formatting.helpers.SelectorComboBoxModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.ComboBoxModel, javax.swing.ListModel

public class SelectorComboBoxModel
extends javax.swing.AbstractListModel
implements javax.swing.ComboBoxModel

Author:
dags
See Also:
Serialized Form

Field Summary
 BasicEventList data
           
 FilterList filtered_data
           
 java.util.Map<java.lang.String,java.lang.Long> itemMap
           
protected  java.lang.String seperator
          Separateor for the second display column
 TextComponentMatcherEditor text_match
           
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
SelectorComboBoxModel()
          Creates a new instance of SelectorListModel
SelectorComboBoxModel(SSConnection ssConnection, java.lang.String query, java.lang.String primaryKeyColumn, java.lang.String displayColumn)
          Creates an object of SelectorComboBoxModel with the specified values.
 
Method Summary
 void addElement(java.lang.Object ob)
          Adds an element to the data
 void addListDataListener(javax.swing.event.ListDataListener l)
           
 void addListEventListener(ListEventListener listChangeListener)
          Adds the event listener for the filtered list
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Adds a PropertyChangeListener to the listener list.
 void createFilteredData()
          Creates filtered data based on the actual data
 void execute()
          This will execute the query and fetch the information from database and updates the model with the new data fetched from the database
 java.lang.String getDisplayColumn()
          Getter for property displayColumn.
 java.lang.Object getElementAt(int index)
           
 javax.swing.JTextField getFilterEdit()
          Returns the text field used as the filter.
 java.lang.String getPrimaryKeyColumn()
          Getter for property primaryKeyColumn.
 java.lang.Object getSelectedBoundData(int index)
          Returns the value corresponding to the item at the specified index.
 java.lang.Object getSelectedItem()
           
 java.lang.String getSelectText()
          Getter for property selectText.
 int getSize()
           
 SSConnection getSsConnection()
          Getter for property ssConnection.
protected  java.lang.String getStringValue(java.sql.ResultSet _rs, java.lang.String _columnName)
           
 void refresh()
          This function refetches the information from the database.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Removes a PropertyChangeListener from the listener list.
 void setDisplayColumn(java.lang.String displayColumn)
          Setter for property displayColumn.
 void setFilterEdit(javax.swing.JTextField filter)
          Sets the JTextField to be used as the filter field.
 void setFilterText(java.lang.String[] newFilter)
          Sets the text to be used to filter items in the list
 void setPrimaryKeyColumn(java.lang.String primaryKeyColumn)
          Setter for property primaryKeyColumn.
 void setQuery(java.lang.String _query)
          Sets the query used to display items in the combo box.
 void setSecondDisplayColumn(java.lang.String secondDisplayColumn)
          Setter for property displayColumn.
 void setSelectedItem(java.lang.Object anItem)
           
 void setSelectText(java.lang.String selectText)
          Setter for property selectText.
 void setSeparator(java.lang.String separator)
           
 void setSSConnection(SSConnection ssConnection)
          Setter for property ssConnection.
 
Methods inherited from class javax.swing.AbstractListModel
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
removeListDataListener
 

Field Detail

data

public BasicEventList data

filtered_data

public FilterList filtered_data

text_match

public TextComponentMatcherEditor text_match

seperator

protected java.lang.String seperator
Separateor for the second display column


itemMap

public java.util.Map<java.lang.String,java.lang.Long> itemMap
Constructor Detail

SelectorComboBoxModel

public SelectorComboBoxModel()
Creates a new instance of SelectorListModel


SelectorComboBoxModel

public SelectorComboBoxModel(SSConnection ssConnection,
                             java.lang.String query,
                             java.lang.String primaryKeyColumn,
                             java.lang.String displayColumn)
Creates an object of SelectorComboBoxModel with the specified values.

Parameters:
ssConnection - - connection object to be used for running the query
query - - name of the query to be used
primaryKeyColumn - - column name whose values should be used as underlying values
displayColumn - - column name whose values shoudl be used for displaying
Method Detail

refresh

public void refresh()
This function refetches the information from the database.


getSelectedBoundData

public java.lang.Object getSelectedBoundData(int index)
Returns the value corresponding to the item at the specified index.

Parameters:
index - - index of the item whose value should be returned.
Returns:
returns the value of the item at the specified index

setSeparator

public void setSeparator(java.lang.String separator)

setFilterText

public void setFilterText(java.lang.String[] newFilter)
Sets the text to be used to filter items in the list

Parameters:
newFilter - - text to be used to filter item in the list

getStringValue

protected java.lang.String getStringValue(java.sql.ResultSet _rs,
                                          java.lang.String _columnName)

addElement

public void addElement(java.lang.Object ob)
Adds an element to the data

Parameters:
ob - - object to be added to the data

createFilteredData

public void createFilteredData()
Creates filtered data based on the actual data


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a PropertyChangeListener to the listener list.

Parameters:
l - The listener to add.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes a PropertyChangeListener from the listener list.

Parameters:
l - The listener to remove.

getPrimaryKeyColumn

public java.lang.String getPrimaryKeyColumn()
Getter for property primaryKeyColumn.

Returns:
Value of property primaryKeyColumn.

setPrimaryKeyColumn

public void setPrimaryKeyColumn(java.lang.String primaryKeyColumn)
Setter for property primaryKeyColumn.

Parameters:
primaryKeyColumn - New value of property primaryKeyColumn.

getDisplayColumn

public java.lang.String getDisplayColumn()
Getter for property displayColumn.

Returns:
Value of property displayColumn.

setDisplayColumn

public void setDisplayColumn(java.lang.String displayColumn)
Setter for property displayColumn.

Parameters:
displayColumn - New value of property displayColumn.

setSecondDisplayColumn

public void setSecondDisplayColumn(java.lang.String secondDisplayColumn)
Setter for property displayColumn.

Parameters:
displayColumn - New value of property displayColumn.

getSelectText

public java.lang.String getSelectText()
Getter for property selectText.

Returns:
Value of property selectText.

setSelectText

public void setSelectText(java.lang.String selectText)
Setter for property selectText.

Parameters:
selectText - New value of property selectText.

execute

public void execute()
This will execute the query and fetch the information from database and updates the model with the new data fetched from the database


getSsConnection

public SSConnection getSsConnection()
Getter for property ssConnection.

Returns:
Value of property ssConnection.

setSSConnection

public void setSSConnection(SSConnection ssConnection)
Setter for property ssConnection.

Parameters:
ssConnection - New value of property ssConnection.

getElementAt

public java.lang.Object getElementAt(int index)
Specified by:
getElementAt in interface javax.swing.ListModel

getSize

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

getFilterEdit

public javax.swing.JTextField getFilterEdit()
Returns the text field used as the filter.

Returns:
- returns the text field used as the filter text field.

setQuery

public void setQuery(java.lang.String _query)
Sets the query used to display items in the combo box.

Parameters:
_query - query to be used to get values from database (to display combo box items)

setFilterEdit

public void setFilterEdit(javax.swing.JTextField filter)
Sets the JTextField to be used as the filter field.

Parameters:
filter - - JTextField to be used to get the filter text.

addListEventListener

public void addListEventListener(ListEventListener listChangeListener)
Adds the event listener for the filtered list

Parameters:
listChangeListener - - list listener to be added to filtered list

addListDataListener

public void addListDataListener(javax.swing.event.ListDataListener l)
Specified by:
addListDataListener in interface javax.swing.ListModel
Overrides:
addListDataListener in class javax.swing.AbstractListModel

setSelectedItem

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

getSelectedItem

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