edu.jhu.tmaj.client.tables.data
Class TableData4

java.lang.Object
  extended by edu.jhu.tmaj.client.tables.data.TableData4
Direct Known Subclasses:
DynamicTableData

public class TableData4
extends java.lang.Object

The helper class for the InputPanel.


Field Summary
static java.lang.Object DUMMY_ENUMERATION_OBJECT
           
protected  java.awt.Component parentComponent
           
protected  javax.swing.JScrollPane scrollPane
           
protected  javax.swing.JTable table
           
protected  BeanTableModel tableModel
           
 
Constructor Summary
TableData4(JBean bean)
           
TableData4(JBean bean, boolean useSearchDialogs)
           
TableData4(JBean bean, boolean useSearchDialogs, BeanTableModel tableModel)
          Constructs this object.
 
Method Summary
 void addDefaultValue(DatabaseField columnIdentifier, java.lang.Object defaultValue)
          Sets the default value to be assigned for a column when the user adds a new row
 void addRow()
           
 void addRow(boolean copySelectedColumn)
          Adds a row to the table.
 void addSearchTerm(SearchTerm searchTerm)
          Add a SearchTerm to the list of fields the user can search.
 void clearDefaultValues()
           
 void clearDirtyRows()
          Indicates that no rows have been modified, and thus no rows need to be saved.
 void clearTableData()
          Clears all data in this class.
 void deleteDirtyRows()
          Deletes rows in the table that have been marked by the user.
 void deleteRow()
          Marks a row for deletion.
protected  java.util.List determineColumnIdentifiers()
          Returns a List containing the Column Identifiers for the Bean.
 void disableEditing()
          Sets the tableModel such that the user can not edit the table cells.
 void displayHistory()
           
 void displayHistory(int rowNumber)
           
 void doSearch(Search search)
           
 JBean getBean(int rowNumber)
          Converts a row in the JTable to a JBean.
 java.lang.Object getCellValue(int rowNumber, DatabaseField field)
           
 java.util.List<java.lang.String> getExportList()
          Returns a list of tab-delimited strings that will be written to a file
 JBean getGenericBean()
           
static java.util.Map<DatabaseField,java.lang.Object> getRowMap(int rowNumber, GeneralTableModel tableModel)
          Returns a Map containing ColumnIdentifiers as the key and the Object in the JTable's cell as the value
 javax.swing.JScrollPane getScrollPane()
           
 java.util.List<SearchTerm> getSearchTerms()
          A Convenience method for getSearchTermsForBean(bean)
 java.util.List<java.lang.Integer> getSelectedColumnIDs(java.lang.Object columnIdentifier)
           
static java.util.List<java.lang.Integer> getSelectedColumnIDs(java.lang.Object columnIdentifier, javax.swing.JTable table, GeneralTableModel tableModel)
           
 java.lang.String getSelectedKeysString(java.lang.Object columnIdentifier)
          Returns a comma-delimited String of the integers found in a specified ColumnIdentifier
 javax.swing.JTable getTable()
           
 BeanTableModel getTableModel()
           
protected  void newTableData()
          Performs the finally initialization of the table after the columns have been determined.
 void save()
          Saves any changes the user has made to the table.
 void search()
          Performs a search on the database and fills the table with the found rows
 void setAllComboBoxes()
          Sets enumerated columns to JComboBoxes containing the proper choices.
 void setCellValue(int rowNumber, DatabaseField field, java.lang.Object aValue)
           
static void setComboBox(javax.swing.JTable table, int columnNumber, java.util.List enumerationList)
          Sets the cell editor of the specified column to a ComboBox containing all the choices in enumerationList.
 void setData(java.util.List beanList, java.util.List columnIdentifiers)
           
static void stopCellEditting(javax.swing.JTable table)
          Stop Table editting, such that if a user is editting a cell, the value typed-in in stored in the TableModel.
static java.util.List translateBeanListToTableList(java.util.List<JBean> beanList, java.util.List<DatabaseField> columnIdentifiers)
          Converts a List of Beans to a List of Lists, making it ready to be inserted into a JTable
 void updateDirtyRows()
          Inserts or Updates any rows that have had their data changed (by the user typing in data on one of the row's cells).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

table

protected final javax.swing.JTable table

scrollPane

protected final javax.swing.JScrollPane scrollPane

tableModel

protected final BeanTableModel tableModel

parentComponent

protected final java.awt.Component parentComponent

DUMMY_ENUMERATION_OBJECT

public static final java.lang.Object DUMMY_ENUMERATION_OBJECT
Constructor Detail

TableData4

public TableData4(JBean bean,
                  boolean useSearchDialogs)

TableData4

public TableData4(JBean bean,
                  boolean useSearchDialogs,
                  BeanTableModel tableModel)
Constructs this object.

Parameters:
bean - the generic bean to use for this InputPanel/TableData
parent_component - a component for whom all dialogs will have as a parent (generally a JTabbedPane)
useSearchDialogs - true if pressing the search button should display a searchDialog. false if the pressing the search button should automatically pull up every record for the bean
tableModel - the BeanTableModel the JTable will use

TableData4

public TableData4(JBean bean)
Method Detail

displayHistory

public void displayHistory()

displayHistory

public void displayHistory(int rowNumber)

getTableModel

public BeanTableModel getTableModel()

getTable

public javax.swing.JTable getTable()

getScrollPane

public javax.swing.JScrollPane getScrollPane()

getSearchTerms

public final java.util.List<SearchTerm> getSearchTerms()
A Convenience method for getSearchTermsForBean(bean)


addSearchTerm

public final void addSearchTerm(SearchTerm searchTerm)
Add a SearchTerm to the list of fields the user can search. See SearchDialog class


save

public void save()
Saves any changes the user has made to the table. Any rows that have changed are updated in the database.


stopCellEditting

public static void stopCellEditting(javax.swing.JTable table)
Stop Table editting, such that if a user is editting a cell, the value typed-in in stored in the TableModel. If a user does a save() and is still editting a cell, the data in that cell will not be recorded yet in the TableModel.


deleteRow

public void deleteRow()
Marks a row for deletion. The row is not actually deleted until the user presses the Save button.


clearTableData

public void clearTableData()
Clears all data in this class.


newTableData

protected void newTableData()
Performs the finally initialization of the table after the columns have been determined.


addRow

public final void addRow()

addRow

public final void addRow(boolean copySelectedColumn)
Adds a row to the table. If there are no columns the method calls determineColumnIdentifiers(). All cells are given an empty String as the initial value, except columns that have a default value.


addDefaultValue

public void addDefaultValue(DatabaseField columnIdentifier,
                            java.lang.Object defaultValue)
Sets the default value to be assigned for a column when the user adds a new row


clearDefaultValues

public void clearDefaultValues()

clearDirtyRows

public void clearDirtyRows()
Indicates that no rows have been modified, and thus no rows need to be saved.


deleteDirtyRows

public void deleteDirtyRows()
Deletes rows in the table that have been marked by the user. Note: This function destabilizes the Maps that contain the row numbers of rows that have been marked for update and deletion since it changes the row-structure of the table by deleting rows.


updateDirtyRows

public void updateDirtyRows()
Inserts or Updates any rows that have had their data changed (by the user typing in data on one of the row's cells). The rowsToUpdate Map contains the row numbers of any rows in which the user changed that data. This method assumes that the first column always represents the primary key, and thus is the first column is empty, an insert is performed; otherwise an update is performed.


setAllComboBoxes

public void setAllComboBoxes()
Sets enumerated columns to JComboBoxes containing the proper choices.


setComboBox

public static void setComboBox(javax.swing.JTable table,
                               int columnNumber,
                               java.util.List enumerationList)
Sets the cell editor of the specified column to a ComboBox containing all the choices in enumerationList.


getBean

public final JBean getBean(int rowNumber)
Converts a row in the JTable to a JBean.


getRowMap

public static java.util.Map<DatabaseField,java.lang.Object> getRowMap(int rowNumber,
                                                                      GeneralTableModel tableModel)
Returns a Map containing ColumnIdentifiers as the key and the Object in the JTable's cell as the value


determineColumnIdentifiers

protected java.util.List determineColumnIdentifiers()
Returns a List containing the Column Identifiers for the Bean. This method is called when the table has no structure (e.g. it was zero rows) and TableData does not know the columnIdentifiers. DynamicTableData will overwrite this method so it can prompt the user to enter a type, which will dynamically determine the columnIdentifiers


search

public final void search()
Performs a search on the database and fills the table with the found rows


doSearch

public final void doSearch(Search search)

setData

public final void setData(java.util.List beanList,
                          java.util.List columnIdentifiers)

setCellValue

public final void setCellValue(int rowNumber,
                               DatabaseField field,
                               java.lang.Object aValue)

getCellValue

public final java.lang.Object getCellValue(int rowNumber,
                                           DatabaseField field)

translateBeanListToTableList

public static java.util.List translateBeanListToTableList(java.util.List<JBean> beanList,
                                                          java.util.List<DatabaseField> columnIdentifiers)
Converts a List of Beans to a List of Lists, making it ready to be inserted into a JTable

Parameters:
beanList - a List of Beans
columnIdentifiers - a List of ColumnIdentifiers. Each element is a column in the table
Returns:
A List of Lists that can be directory put into a DefaultTableModel using setDataList(List)

getSelectedKeysString

public java.lang.String getSelectedKeysString(java.lang.Object columnIdentifier)
Returns a comma-delimited String of the integers found in a specified ColumnIdentifier


getSelectedColumnIDs

public java.util.List<java.lang.Integer> getSelectedColumnIDs(java.lang.Object columnIdentifier)

getSelectedColumnIDs

public static java.util.List<java.lang.Integer> getSelectedColumnIDs(java.lang.Object columnIdentifier,
                                                                     javax.swing.JTable table,
                                                                     GeneralTableModel tableModel)

getExportList

public java.util.List<java.lang.String> getExportList()
Returns a list of tab-delimited strings that will be written to a file


getGenericBean

public final JBean getGenericBean()
Returns:
Returns the genericBean.

disableEditing

public void disableEditing()
Sets the tableModel such that the user can not edit the table cells.