Package jpa.tools.swing
Class EntityDataModel<T>
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- jpa.tools.swing.EntityDataModel<T>
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<T>
,javax.swing.table.TableModel
public class EntityDataModel<T> extends javax.swing.table.AbstractTableModel implements javax.swing.table.TableModel, java.lang.Iterable<T>
A data model for a tabular view of a list of persistent entities. The data supplied by this model can be filtered to display field values of basic type or single-valued or multi-valued relationships.
The meta-information about the attributes of the entity are supplied by newly definedmeta-model API
of JPA 2.0 specification.- Author:
- Pinaki Poddar
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
ALL_ATTR
Constant designates to include all fields.static int
ASSOCIATION_ATTR
Constant designates to include single-valued relation fields.static int
BASIC_ATTR
Constant designates to include non-relation fields.static int
PLURAL_ATTR
Constant designates to include multi-valued relation fields.static int
ROW_COUNT
Constant designates to show a row count field at the first column.
-
Constructor Summary
Constructors Constructor Description EntityDataModel(java.lang.Class<T> cls, java.util.List<T> data, jakarta.persistence.metamodel.Metamodel meta, int styleBits)
Attributes of the entity are reordered with basic attributes, followed by singular association followed by the many-valued attributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description jakarta.persistence.metamodel.Attribute<?,?>
getAttribute(int columnIndex)
Gets the attribute at a given column index.java.lang.Class<?>
getColumnClass(int columnIndex)
int
getColumnCount()
java.lang.String
getColumnName(int columnIndex)
T
getRow(int row)
Gets the entity represented in the given row.int
getRowCount()
java.lang.Object
getValueAt(int rowIndex, int columnIndex)
boolean
isCellEditable(int rowIndex, int columnIndex)
java.util.Iterator<T>
iterator()
void
setValueAt(java.lang.Object value, int rowIndex, int columnIndex)
void
updateData(java.util.List<T> newData)
-
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
-
-
-
-
Field Detail
-
BASIC_ATTR
public static int BASIC_ATTR
Constant designates to include non-relation fields.
-
ASSOCIATION_ATTR
public static int ASSOCIATION_ATTR
Constant designates to include single-valued relation fields.
-
PLURAL_ATTR
public static int PLURAL_ATTR
Constant designates to include multi-valued relation fields.
-
ALL_ATTR
public static int ALL_ATTR
Constant designates to include all fields.
-
ROW_COUNT
public static int ROW_COUNT
Constant designates to show a row count field at the first column.
-
-
Method Detail
-
getAttribute
public jakarta.persistence.metamodel.Attribute<?,?> getAttribute(int columnIndex)
Gets the attribute at a given column index. Can be null for 0-th index if row count is being shown.
-
getRow
public T getRow(int row)
Gets the entity represented in the given row.
-
getColumnClass
public java.lang.Class<?> getColumnClass(int columnIndex)
- Specified by:
getColumnClass
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnClass
in classjavax.swing.table.AbstractTableModel
-
getColumnCount
public int getColumnCount()
- Specified by:
getColumnCount
in interfacejavax.swing.table.TableModel
-
getColumnName
public java.lang.String getColumnName(int columnIndex)
- Specified by:
getColumnName
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnName
in classjavax.swing.table.AbstractTableModel
-
getRowCount
public int getRowCount()
- Specified by:
getRowCount
in interfacejavax.swing.table.TableModel
-
getValueAt
public java.lang.Object getValueAt(int rowIndex, int columnIndex)
- Specified by:
getValueAt
in interfacejavax.swing.table.TableModel
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex)
- Specified by:
isCellEditable
in interfacejavax.swing.table.TableModel
- Overrides:
isCellEditable
in classjavax.swing.table.AbstractTableModel
-
setValueAt
public void setValueAt(java.lang.Object value, int rowIndex, int columnIndex)
- Specified by:
setValueAt
in interfacejavax.swing.table.TableModel
- Overrides:
setValueAt
in classjavax.swing.table.AbstractTableModel
-
updateData
public void updateData(java.util.List<T> newData)
-
-