Class TableEditorModel
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- org.pentaho.reporting.ui.datasources.table.TableEditorModel
-
- All Implemented Interfaces:
Serializable
,TableModel
public class TableEditorModel extends AbstractTableModel
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
-
Constructor Summary
Constructors Constructor Description TableEditorModel()
Constructs a defaultDefaultTableModel
which is a table of zero columns and zero rows.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addColumn(String name, Class type)
void
addRow()
void
addRow(int idx)
void
clear()
void
copyInto(TableModel model)
TableModel
createModel()
void
fireTableCellUpdated(int row, int column)
Notifies all listeners that the value of the cell at[row, column]
has been updated.void
fireTableChanged(TableModelEvent e)
Forwards the given notification event to allTableModelListeners
that registered themselves as listeners for this table model.void
fireTableDataChanged()
Notifies all listeners that all cell values in the table's rows may have changed.void
fireTableRowsDeleted(int firstRow, int lastRow)
Notifies all listeners that rows in the range[firstRow, lastRow]
, inclusive, have been deleted.void
fireTableRowsInserted(int firstRow, int lastRow)
Notifies all listeners that rows in the range[firstRow, lastRow]
, inclusive, have been inserted.void
fireTableRowsUpdated(int firstRow, int lastRow)
Notifies all listeners that rows in the range[firstRow, lastRow]
, inclusive, have been updated.void
fireTableStructureChanged()
Notifies all listeners that the table's structure has changed.Class<?>
getColumnClass(int columnIndex)
ReturnsObject.class
regardless ofcolumnIndex
.int
getColumnCount()
Returns the number of columns in the model.String
getColumnName(int column)
Returns a default name for the column using spreadsheet conventions: A, B, C, ...int
getRowCount()
Returns the number of rows in the model.Object
getValueAt(int rowIndex, int columnIndex)
Returns the value for the cell atcolumnIndex
androwIndex
.boolean
isCellEditable(int rowIndex, int columnIndex)
Returns false.boolean
isSuspendEvents()
void
removeColumn(int column)
void
removeRow(int row)
void
setColumnClass(int index, Class type)
void
setColumnName(int index, String identifier)
void
setSuspendEvents(boolean suspendEvents)
void
setValueAt(Object aValue, int rowIndex, int columnIndex)
This empty implementation is provided so users don't have to implement this method if their data model is not editable.-
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, getListeners, getTableModelListeners, removeTableModelListener
-
-
-
-
Method Detail
-
setColumnName
public void setColumnName(int index, String identifier)
-
removeColumn
public void removeColumn(int column)
-
removeRow
public void removeRow(int row)
-
addRow
public void addRow()
-
addRow
public void addRow(int idx)
-
getColumnName
public String getColumnName(int column)
Returns a default name for the column using spreadsheet conventions: A, B, C, ... Z, AA, AB, etc. Ifcolumn
cannot be found, returns an empty string.- Specified by:
getColumnName
in interfaceTableModel
- Overrides:
getColumnName
in classAbstractTableModel
- Parameters:
column
- the column being queried- Returns:
- a string containing the default name of
column
-
getColumnClass
public Class<?> getColumnClass(int columnIndex)
ReturnsObject.class
regardless ofcolumnIndex
.- Specified by:
getColumnClass
in interfaceTableModel
- Overrides:
getColumnClass
in classAbstractTableModel
- Parameters:
columnIndex
- the column being queried- Returns:
- the Object.class
-
getRowCount
public int getRowCount()
Returns the number of rows in the model. AJTable
uses this method to determine how many rows it should display. This method should be quick, as it is called frequently during rendering.- Returns:
- the number of rows in the model
- See Also:
getColumnCount()
-
getColumnCount
public int getColumnCount()
Returns the number of columns in the model. AJTable
uses this method to determine how many columns it should create and display by default.- Returns:
- the number of columns in the model
- See Also:
getRowCount()
-
getValueAt
public Object getValueAt(int rowIndex, int columnIndex)
Returns the value for the cell atcolumnIndex
androwIndex
.- Parameters:
rowIndex
- the row whose value is to be queriedcolumnIndex
- the column whose value is to be queried- Returns:
- the value Object at the specified cell
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex)
Returns false. This is the default implementation for all cells.- Specified by:
isCellEditable
in interfaceTableModel
- Overrides:
isCellEditable
in classAbstractTableModel
- Parameters:
rowIndex
- the row being queriedcolumnIndex
- the column being queried- Returns:
- false
-
setValueAt
public void setValueAt(Object aValue, int rowIndex, int columnIndex)
This empty implementation is provided so users don't have to implement this method if their data model is not editable.- Specified by:
setValueAt
in interfaceTableModel
- Overrides:
setValueAt
in classAbstractTableModel
- Parameters:
aValue
- value to assign to cellrowIndex
- row of cellcolumnIndex
- column of cell
-
clear
public void clear()
-
setColumnClass
public void setColumnClass(int index, Class type)
-
fireTableDataChanged
public void fireTableDataChanged()
Notifies all listeners that all cell values in the table's rows may have changed. The number of rows may also have changed and theJTable
should redraw the table from scratch. The structure of the table (as in the order of the columns) is assumed to be the same.- Overrides:
fireTableDataChanged
in classAbstractTableModel
- See Also:
TableModelEvent
,EventListenerList
,JTable.tableChanged(javax.swing.event.TableModelEvent)
-
fireTableStructureChanged
public void fireTableStructureChanged()
Notifies all listeners that the table's structure has changed. The number of columns in the table, and the names and types of the new columns may be different from the previous state. If theJTable
receives this event and itsautoCreateColumnsFromModel
flag is set it discards any table columns that it had and reallocates default columns in the order they appear in the model. This is the same as callingsetModel(TableModel)
on theJTable
.- Overrides:
fireTableStructureChanged
in classAbstractTableModel
- See Also:
TableModelEvent
,EventListenerList
-
fireTableRowsInserted
public void fireTableRowsInserted(int firstRow, int lastRow)
Notifies all listeners that rows in the range[firstRow, lastRow]
, inclusive, have been inserted.- Overrides:
fireTableRowsInserted
in classAbstractTableModel
- Parameters:
firstRow
- the first rowlastRow
- the last row- See Also:
TableModelEvent
,EventListenerList
-
fireTableRowsUpdated
public void fireTableRowsUpdated(int firstRow, int lastRow)
Notifies all listeners that rows in the range[firstRow, lastRow]
, inclusive, have been updated.- Overrides:
fireTableRowsUpdated
in classAbstractTableModel
- Parameters:
firstRow
- the first rowlastRow
- the last row- See Also:
TableModelEvent
,EventListenerList
-
fireTableRowsDeleted
public void fireTableRowsDeleted(int firstRow, int lastRow)
Notifies all listeners that rows in the range[firstRow, lastRow]
, inclusive, have been deleted.- Overrides:
fireTableRowsDeleted
in classAbstractTableModel
- Parameters:
firstRow
- the first rowlastRow
- the last row- See Also:
TableModelEvent
,EventListenerList
-
fireTableCellUpdated
public void fireTableCellUpdated(int row, int column)
Notifies all listeners that the value of the cell at[row, column]
has been updated.- Overrides:
fireTableCellUpdated
in classAbstractTableModel
- Parameters:
row
- row of cell which has been updatedcolumn
- column of cell which has been updated- See Also:
TableModelEvent
,EventListenerList
-
fireTableChanged
public void fireTableChanged(TableModelEvent e)
Forwards the given notification event to allTableModelListeners
that registered themselves as listeners for this table model.- Overrides:
fireTableChanged
in classAbstractTableModel
- Parameters:
e
- the event to be forwarded- See Also:
TableModelEvent
,EventListenerList
-
isSuspendEvents
public boolean isSuspendEvents()
-
setSuspendEvents
public void setSuspendEvents(boolean suspendEvents)
-
copyInto
public void copyInto(TableModel model)
-
createModel
public TableModel createModel()
-
-