com.sas.swing.models
Class TableModelInsertRowSupport

com.sas.swing.models.TableModelInsertRowSupport

public class TableModelInsertRowSupport

The TableModelInsertRowSupport aids implementors of InsertRowInterface with inserting a row into a table. The TableModelInsertRowSupport creates an uncommitted (fake) row until the row is actually committed into the table.


Constructor Summary
TableModelInsertRowSupport()
          Constructor
 
Method Summary
 void cancelUncommittedRow(javax.swing.table.TableModel model)
          Removes the "fake" row from the model, effectively performing a cancel.
 java.lang.Object[] commitUncommittedRow(javax.swing.table.TableModel model)
          Commits the data in the row to the underlying model.
 int getAdjustedRowNumber(int row)
          Takes a row number (from the viewers perspective) and adjusts it based on whether a "fake" row had been added without being committed or cancelled.
static java.lang.Object[] getDefaultRowValues(javax.swing.table.TableModel model)
          Gets the default values of a row as an object array for a given TableModel based upon a new instance of each column's class or null if the class is java.lang.Object.
 int getUncommittedRowNumber()
          Returns the index of the uncommitted row.
 java.lang.Object getValueAt(int columnIndex)
          Returns the value for the cell of the uncomitted row at columnIndex.
 void insertUncommittedRow(javax.swing.table.TableModel model, int row)
          Adds a "fake" row to the table model at the specified location.
 boolean isUncommittedRowPresent()
          Indicates whether an uncommitted row exists.
 void setValueAt(java.lang.Object value, int columnIndex)
          Sets the value in the cell of the uncommitted row at columnIndex to value.
 

Constructor Detail

TableModelInsertRowSupport

public TableModelInsertRowSupport()
Constructor

Method Detail

insertUncommittedRow

public void insertUncommittedRow(javax.swing.table.TableModel model,
                                 int row)
                          throws com.sas.util.UncheckedException
Adds a "fake" row to the table model at the specified location.

Parameters:
row - The row to add the "fake" row before.
Throws:
com.sas.util.UncheckedException - Provides a catch-all for all Exceptions.

commitUncommittedRow

public java.lang.Object[] commitUncommittedRow(javax.swing.table.TableModel model)
                                        throws com.sas.util.UncheckedException
Commits the data in the row to the underlying model.

Returns:
the array of data for the "fake" row
Throws:
com.sas.util.UncheckedException

cancelUncommittedRow

public void cancelUncommittedRow(javax.swing.table.TableModel model)
                          throws com.sas.util.UncheckedException
Removes the "fake" row from the model, effectively performing a cancel.

Throws:
com.sas.util.UncheckedException

isUncommittedRowPresent

public boolean isUncommittedRowPresent()
Indicates whether an uncommitted row exists.

Returns:
true if an uncommitted row exists

getUncommittedRowNumber

public int getUncommittedRowNumber()
Returns the index of the uncommitted row. Returns -1 if there is no uncommitted row.

Returns:
the index of the uncommitted row

getValueAt

public java.lang.Object getValueAt(int columnIndex)
Returns the value for the cell of the uncomitted row at columnIndex.

Parameters:
columnIndex - the column whose value is to be queried
Returns:
the value Object at the specified cell

setValueAt

public void setValueAt(java.lang.Object value,
                       int columnIndex)
Sets the value in the cell of the uncommitted row at columnIndex to value.

Parameters:
value - the new value
columnIndex - the column whose value is to be changed

getAdjustedRowNumber

public int getAdjustedRowNumber(int row)
Takes a row number (from the viewers perspective) and adjusts it based on whether a "fake" row had been added without being committed or cancelled.


getDefaultRowValues

public static java.lang.Object[] getDefaultRowValues(javax.swing.table.TableModel model)
Gets the default values of a row as an object array for a given TableModel based upon a new instance of each column's class or null if the class is java.lang.Object.

Parameters:
model - the TableModel to get the column's classes from
Returns:
an Object array of default values with the size equal to the number of columns



Copyright © 2009 SAS Institute Inc. All Rights Reserved.