es.unex.sextante.parameters
Class FixedTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by es.unex.sextante.parameters.FixedTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class FixedTableModel
extends javax.swing.table.AbstractTableModel

A table model to be used for a fixed table parameter

Author:
volaya
See Also:
ParameterFixedTable, Serialized Form

Constructor Summary
FixedTableModel(java.lang.String[] sColumnNames, int iRows, boolean bIsNumberOfRowsFixed)
          Creates a new table
 
Method Summary
 void addRow()
          Adds a new row to the table, only if possible
 java.lang.String getAsCSV()
          Returns a Comma-Separated Values version of the table
 java.lang.Class getColumnClass(int iField)
          Returns the class of a field
 int getColumnCount()
          Returns the number of columns
 java.lang.String getColumnName(int iCol)
          Returns the name of a column
 java.lang.String[] getColumnNames()
          Returns an array of strings with column names
 java.util.ArrayList[] getData()
           
 java.lang.String getDimensionsAsString()
          Returns the dimensions of the table as a string
 int getRowCount()
          Returns the number of rows
 java.lang.Object getValueAt(int iRow, int iCol)
          Returns the value at a cell
 boolean isCellEditable(int iRow, int iCol)
           
 boolean isNumberOfRowsFixed()
          Returns true if the number of rows in the table is fixed
static FixedTableModel newInstance(FixedTableModel fixedTableModel)
          use this method to clone the table.
 void removeRow(int iRow)
          removes row iRow, if number of rows is not fixed
 boolean setAttributes(java.lang.String[] sColumnNames, java.util.ArrayList[] data, boolean bIsNumberOfRowsFixed)
          Sets the attributes of the table
 boolean setData(java.util.ArrayList[] data)
           
 void setIsNumberOfRowsFixed(boolean bIsNumberOfRowsFixed)
          Sets whether the number of rows can be modified or not
 void setValueAt(java.lang.Object value, int iRow, int iCol)
           
 java.lang.String toString()
           
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FixedTableModel

public FixedTableModel(java.lang.String[] sColumnNames,
                       int iRows,
                       boolean bIsNumberOfRowsFixed)
Creates a new table

Parameters:
sColumnNames - names of columns(fields) in table
iRows - number of rows in table
bIsNumberOfRowsFixed - true if new rows can be added
Method Detail

newInstance

public static FixedTableModel newInstance(FixedTableModel fixedTableModel)
use this method to clone the table.

Parameters:
fixedTableModel -
Returns:
a new instance of fixedTableModel

setAttributes

public boolean setAttributes(java.lang.String[] sColumnNames,
                             java.util.ArrayList[] data,
                             boolean bIsNumberOfRowsFixed)
Sets the attributes of the table

Parameters:
sColumnNames - names of columns(fields)
data - table data
bIsNumberOfRowsFixed - true if new rows can be added
Returns:
true if data is consistent

getColumnCount

public int getColumnCount()
Returns the number of columns

Returns:
Number of columns(fields)

getRowCount

public int getRowCount()
Returns the number of rows

Returns:
Number of rows

getColumnName

public java.lang.String getColumnName(int iCol)
Returns the name of a column

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Parameters:
iCol - the index of the column
Returns:
Name of column iCol

getColumnNames

public java.lang.String[] getColumnNames()
Returns an array of strings with column names

Returns:
An array of strings with column names

getValueAt

public java.lang.Object getValueAt(int iRow,
                                   int iCol)
Returns the value at a cell

Parameters:
iRow - the row
iCol - the column
Returns:
the value at cell [iRow, iCol]

getColumnClass

public java.lang.Class getColumnClass(int iField)
Returns the class of a field

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel
Parameters:
iField - the index of the field
Returns:
the class of the given field

isCellEditable

public boolean isCellEditable(int iRow,
                              int iCol)
Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel

setValueAt

public void setValueAt(java.lang.Object value,
                       int iRow,
                       int iCol)
Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel

addRow

public void addRow()
Adds a new row to the table, only if possible


removeRow

public void removeRow(int iRow)
removes row iRow, if number of rows is not fixed

Parameters:
iRow - the index of the row to remove

getData

public java.util.ArrayList[] getData()

setData

public boolean setData(java.util.ArrayList[] data)

isNumberOfRowsFixed

public boolean isNumberOfRowsFixed()
Returns true if the number of rows in the table is fixed

Returns:
true if the number of rows in the table is fixed

setIsNumberOfRowsFixed

public void setIsNumberOfRowsFixed(boolean bIsNumberOfRowsFixed)
Sets whether the number of rows can be modified or not

Parameters:
bIsNumberOfRowsFixed - indicates whether the number of rows can be modified or not

getDimensionsAsString

public java.lang.String getDimensionsAsString()
Returns the dimensions of the table as a string

Returns:
a String in the form "x by y" with the dimensions of the table

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getAsCSV

public java.lang.String getAsCSV()
Returns a Comma-Separated Values version of the table

Returns:
a Comma-Separated Values version of the table