Package jadex.commons.gui.jtable
Class ObjectTableModel
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- jadex.commons.gui.jtable.ObjectTableModel
-
- All Implemented Interfaces:
java.io.Serializable,javax.swing.table.TableModel
public class ObjectTableModel extends javax.swing.table.AbstractTableModelThe object table model has associated an object with each row.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashMapcolumnclassesThe classes of the columns.protected java.util.VectorcolumnsThe data.protected java.util.HashSetcolumseditableThe editable colums.protected java.util.VectordataThe data.
-
Constructor Summary
Constructors Constructor Description ObjectTableModel()Create a new object table model.ObjectTableModel(java.lang.String[] colnames)Create a new object table model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRow(java.lang.Object[] row, java.lang.Object object)Add a row to the model.voidaddRow(java.lang.Object row, java.lang.Object object)Add a row to the model.voidaddRow(java.util.ArrayList row, java.lang.Object object)Add a row to the model.java.lang.ClassgetColumnClass(int idx)Get the class of the column.intgetColumnCount()java.lang.StringgetColumnName(int column)Get a column namejava.lang.ObjectgetObjectForRow(int rowcnt)Get the associated object for a row.intgetRowCount()java.lang.ObjectgetValueAt(int row, int column)Get the value from a field.voidinsertRow(int rowcnt, java.lang.Object[] row, java.lang.Object object)Insert a row at a position.voidinsertRow(int rowcnt, java.util.List row, java.lang.Object object)Insert a row at a position.booleanisCellEditable(int rowIndex, int columnIndex)Returns false.voidmodifyData(java.lang.Object val, int rowcnt, int columncnt)Modify a row at a position.voidremoveAllRows()Remove all rows from the model.voidremoveRow(int cnt)Remove a row from the model.voidremoveRow(java.lang.Object object)Remove a row from the model.voidsetColumnClass(java.lang.Class clazz, int idx)Set the class of the column.voidsetColumnEditable(boolean editable, int col)Set if a column is editable.-
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener, setValueAt
-
-
-
-
Method Detail
-
addRow
public void addRow(java.lang.Object row, java.lang.Object object)Add a row to the model.- Parameters:
row- The row data.object- The associated object.
-
addRow
public void addRow(java.util.ArrayList row, java.lang.Object object)Add a row to the model.- Parameters:
row- The row data.object- The associated object.
-
addRow
public void addRow(java.lang.Object[] row, java.lang.Object object)Add a row to the model.- Parameters:
row- The row data.object- The associated object.
-
insertRow
public void insertRow(int rowcnt, java.lang.Object[] row, java.lang.Object object)Insert a row at a position.- Parameters:
rowcnt- The row cnt.row- The row data.object- The object.
-
insertRow
public void insertRow(int rowcnt, java.util.List row, java.lang.Object object)Insert a row at a position.- Parameters:
rowcnt- The row cnt.row- The row data.object- The object.
-
removeRow
public void removeRow(java.lang.Object object)
Remove a row from the model.- Parameters:
object- The associated object.
-
removeRow
public void removeRow(int cnt)
Remove a row from the model.- Parameters:
cnt- The row number.
-
removeAllRows
public void removeAllRows()
Remove all rows from the model.
-
modifyData
public void modifyData(java.lang.Object val, int rowcnt, int columncnt)Modify a row at a position.- Parameters:
val- The value.rowcnt- The row.columncnt- The column.
-
getObjectForRow
public java.lang.Object getObjectForRow(int rowcnt)
Get the associated object for a row.- Parameters:
rowcnt- The row ccount.- Returns:
- The object.
-
getColumnName
public java.lang.String getColumnName(int column)
Get a column name- Specified by:
getColumnNamein interfacejavax.swing.table.TableModel- Overrides:
getColumnNamein classjavax.swing.table.AbstractTableModel- Parameters:
column- The number of the column.- Returns:
- The column name.
-
getColumnClass
public java.lang.Class getColumnClass(int idx)
Get the class of the column.- Specified by:
getColumnClassin interfacejavax.swing.table.TableModel- Overrides:
getColumnClassin classjavax.swing.table.AbstractTableModel- Parameters:
idx- the column being queried- Returns:
- the Object.class
-
setColumnClass
public void setColumnClass(java.lang.Class clazz, int idx)Set the class of the column.- Parameters:
clazz- The class.idx- the column being queried
-
setColumnEditable
public void setColumnEditable(boolean editable, int col)Set if a column is editable.- Parameters:
editable- True, for editable.col- The column.
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex)Returns false. This is the default implementation for all cells.- Specified by:
isCellEditablein interfacejavax.swing.table.TableModel- Overrides:
isCellEditablein classjavax.swing.table.AbstractTableModel- Parameters:
rowIndex- the row being queriedcolumnIndex- the column being queried- Returns:
- false
-
getRowCount
public int getRowCount()
- Returns:
- The row count.
-
getColumnCount
public int getColumnCount()
- Returns:
- The column count.
-
getValueAt
public java.lang.Object getValueAt(int row, int column)Get the value from a field.- Parameters:
row- The row index.column- The column index.- Returns:
- The value.
-
-