com.nqadmin.swingSet.formatting.helpers
Class SelectorListModel

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

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

Author:
dags
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
SelectorListModel()
          Creates a new instance of SelectorListModel
SelectorListModel(SSConnection ssConnection, java.lang.String table, java.lang.String dataColumn, java.lang.String listColumn, java.lang.String orderBy)
          Creates an object of SelectorListModel with the given data
SelectorListModel(java.lang.String table, java.lang.String dataColumn, java.lang.String listColumn)
          Creates an object of SelectorListModel with the given data
SelectorListModel(java.lang.String table, java.lang.String dataColumn, java.lang.String listColumn, java.lang.String orderBy)
          Creates an object of SelectorListModel with the given data
 
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 getDataColumn()
          Getter for property dataColumn.
 java.lang.Object getElementAt(int index)
           
 javax.swing.JTextField getFilterEdit()
          Returns the text field used as the filter.
 java.lang.String getListColumn()
          Getter for property listColumn.
 java.lang.String getOrderBy()
          Returns the column names based on which items are ordered
 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.
 java.lang.String getTable()
          Getter for property table.
 int indexOf(java.lang.Object object)
          Returns the index of the specified object in the actual data (unfiltered list)
 void refresh()
          This function re-fetches the information from the database.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Removes a PropertyChangeListener from the listener list.
 void setDataColumn(java.lang.String dataColumn)
          Setter for property dataColumn.
 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 setListColumn(java.lang.String listColumn)
          Setter for property listColumn.
 void setOrderBy(java.lang.String orderBy)
          Setter for property orderBy.
 void setSelectedItem(java.lang.Object anItem)
           
 void setSelectText(java.lang.String selectText)
          Setter for property selectText.
 void setSsConnection(SSConnection ssConnection)
          Setter for property ssConnection.
 void setTable(java.lang.String table)
          Setter for property table.
 
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
 

Constructor Detail

SelectorListModel

public SelectorListModel()
Creates a new instance of SelectorListModel


SelectorListModel

public SelectorListModel(java.lang.String table,
                         java.lang.String dataColumn,
                         java.lang.String listColumn)
Creates an object of SelectorListModel with the given data

Parameters:
table - - database table name
dataColumn - - name of the column containing the values of the items displayed in the list
listColumn - - column names whose values should be displayed in the list

SelectorListModel

public SelectorListModel(java.lang.String table,
                         java.lang.String dataColumn,
                         java.lang.String listColumn,
                         java.lang.String orderBy)
Creates an object of SelectorListModel with the given data

Parameters:
table - - database table name
dataColumn - - name of the column containing the values of the items displayed in the list
listColumn - - column names whose values should be displayed in the list
orderBy - - column name based on which the list items should be ordered

SelectorListModel

public SelectorListModel(SSConnection ssConnection,
                         java.lang.String table,
                         java.lang.String dataColumn,
                         java.lang.String listColumn,
                         java.lang.String orderBy)
Creates an object of SelectorListModel with the given data

Parameters:
ssConnection - - connection to be used for querying the database
table - - database table name
dataColumn - - name of the column containing the values of the items displayed in the list
listColumn - - column names whose values should be displayed in the list
orderBy - - column name based on which the list items should be ordered
Method Detail

indexOf

public int indexOf(java.lang.Object object)
Returns the index of the specified object in the actual data (unfiltered list)

Parameters:
object - - object whose index should be returned
Returns:
- returns the index of the specified object (in unfiltered list)

refresh

public void refresh()
This function re-fetches 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

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

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.

getDataColumn

public java.lang.String getDataColumn()
Getter for property dataColumn.

Returns:
Value of property dataColumn.

setDataColumn

public void setDataColumn(java.lang.String dataColumn)
Setter for property dataColumn.

Parameters:
dataColumn - New value of property dataColumn.

getListColumn

public java.lang.String getListColumn()
Getter for property listColumn.

Returns:
Value of property listColumn.

setListColumn

public void setListColumn(java.lang.String listColumn)
Setter for property listColumn.

Parameters:
listColumn - New value of property listColumn.

getTable

public java.lang.String getTable()
Getter for property table.

Returns:
Value of property table.

setTable

public void setTable(java.lang.String table)
Setter for property table.

Parameters:
table - New value of property table.

setOrderBy

public void setOrderBy(java.lang.String orderBy)
Setter for property orderBy.

Parameters:
orderBy - New value of orderBy property

getOrderBy

public java.lang.String getOrderBy()
Returns the column names based on which items are ordered

Returns:
returns the column names based on which items are ordered

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.

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