Package jadex.base.gui.idtree
Class IdTableModel<T,E>
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- javax.swing.table.DefaultTableModel
-
- jadex.base.gui.idtree.IdTableModel<T,E>
-
- All Implemented Interfaces:
java.io.Serializable
,javax.swing.table.TableModel
public class IdTableModel<T,E> extends javax.swing.table.DefaultTableModel
Table model for list of objects.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Class<?>[]
coltypes
The column types.protected java.lang.String[]
columns
The column names.protected java.util.Map<T,E>
obs
The known (id->ob).protected javax.swing.ListSelectionModel
selmodel
The selection model.protected java.util.List<E>
sels
The selected elems.protected javax.swing.JTable
table
The table.
-
Constructor Summary
Constructors Constructor Description IdTableModel(java.lang.String[] columns, java.lang.Class<?>[] coltypes, javax.swing.JTable table)
Create a new table model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addObject(T id, E obj)
Add a new object.void
addTableModelListener(javax.swing.event.TableModelListener l)
java.lang.Class<?>
getColumnClass(int i)
Get the column class.int
getColumnCount()
Get the column count.java.lang.String
getColumnName(int i)
Get the column name.E
getObject(java.lang.String id)
Get an object for an id.java.util.Collection<E>
getObjects()
Get the objects.int
getRowCount()
Get the row count.java.lang.Object
getValueAt(int row, int column)
Get the value at each row.java.lang.Object
getValueAt(E obj, int column)
Get the cell value.java.util.List<E>
getValues()
Get the obs.boolean
isCellEditable(int row, int column)
Test if cell is editable (default is false).void
refresh()
void
removeAll()
Remove all objects.void
removeObject(T id)
Remove an object.void
removeTableModelListener(javax.swing.event.TableModelListener l)
protected void
restoreUserSelection()
Restore the current user selection.protected void
saveUserSelection()
Save the current user selectionvoid
setObs(java.util.Map<T,E> obs)
Set the obs.void
setValueAt(java.lang.Object val, int row, int column)
-
Methods inherited from class javax.swing.table.DefaultTableModel
addColumn, addColumn, addColumn, addRow, addRow, convertToVector, convertToVector, getDataVector, insertRow, insertRow, moveRow, newDataAvailable, newRowsAdded, removeRow, rowsRemoved, setColumnCount, setColumnIdentifiers, setColumnIdentifiers, setDataVector, setDataVector, setNumRows, setRowCount
-
-
-
-
Field Detail
-
columns
protected java.lang.String[] columns
The column names.
-
coltypes
protected java.lang.Class<?>[] coltypes
The column types.
-
sels
protected java.util.List<E> sels
The selected elems.
-
selmodel
protected javax.swing.ListSelectionModel selmodel
The selection model.
-
table
protected javax.swing.JTable table
The table.
-
-
Method Detail
-
getColumnCount
public int getColumnCount()
Get the column count.- Specified by:
getColumnCount
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnCount
in classjavax.swing.table.DefaultTableModel
- Returns:
- The number of columns.
-
getColumnName
public java.lang.String getColumnName(int i)
Get the column name.- Specified by:
getColumnName
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnName
in classjavax.swing.table.DefaultTableModel
- Parameters:
i
- The index.
-
getColumnClass
public java.lang.Class<?> getColumnClass(int i)
Get the column class.- Specified by:
getColumnClass
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnClass
in classjavax.swing.table.AbstractTableModel
- Returns:
- The column class.
-
getRowCount
public int getRowCount()
Get the row count.- Specified by:
getRowCount
in interfacejavax.swing.table.TableModel
- Overrides:
getRowCount
in classjavax.swing.table.DefaultTableModel
- Returns:
- The row count.
-
getValueAt
public java.lang.Object getValueAt(int row, int column)
Get the value at each row.- Specified by:
getValueAt
in interfacejavax.swing.table.TableModel
- Overrides:
getValueAt
in classjavax.swing.table.DefaultTableModel
-
getValueAt
public java.lang.Object getValueAt(E obj, int column)
Get the cell value. Override to get specific value out of the object.
-
getValues
public java.util.List<E> getValues()
Get the obs.- Returns:
- The obs.
-
isCellEditable
public boolean isCellEditable(int row, int column)
Test if cell is editable (default is false).- Specified by:
isCellEditable
in interfacejavax.swing.table.TableModel
- Overrides:
isCellEditable
in classjavax.swing.table.DefaultTableModel
-
getObject
public E getObject(java.lang.String id)
Get an object for an id.- Parameters:
id
- The id.- Returns:
- The object.
-
getObjects
public java.util.Collection<E> getObjects()
Get the objects.
-
addObject
public void addObject(T id, E obj)
Add a new object.- Parameters:
id
- The id.obj
- The object.
-
removeObject
public void removeObject(T id)
Remove an object.- Parameters:
id
- The id.
-
removeAll
public void removeAll()
Remove all objects.
-
setValueAt
public void setValueAt(java.lang.Object val, int row, int column)
- Specified by:
setValueAt
in interfacejavax.swing.table.TableModel
- Overrides:
setValueAt
in classjavax.swing.table.DefaultTableModel
-
addTableModelListener
public void addTableModelListener(javax.swing.event.TableModelListener l)
- Specified by:
addTableModelListener
in interfacejavax.swing.table.TableModel
- Overrides:
addTableModelListener
in classjavax.swing.table.AbstractTableModel
-
removeTableModelListener
public void removeTableModelListener(javax.swing.event.TableModelListener l)
- Specified by:
removeTableModelListener
in interfacejavax.swing.table.TableModel
- Overrides:
removeTableModelListener
in classjavax.swing.table.AbstractTableModel
-
saveUserSelection
protected void saveUserSelection()
Save the current user selection
-
restoreUserSelection
protected void restoreUserSelection()
Restore the current user selection.
-
refresh
public void refresh()
-
-