info.joseluismartin.gui
Class ListTableModel

java.lang.Object
  extended by info.joseluismartin.gui.ListTableModel
All Implemented Interfaces:
TableModel

public class ListTableModel
extends Object
implements TableModel

TableModel that use a List of Objects to hold data.

Since:
1.0
Author:
Jose Luis Martin - (jlm@joseluismartin.info)
See Also:
PageableTable

Field Summary
static String CELL_RENDERER
           
static String MAX_WIDTH
           
 
Constructor Summary
ListTableModel()
          Creates a new ListTableModel with a empty list model
ListTableModel(List l)
          Creates a new ListTableModel with model set to List l
 
Method Summary
 boolean add(Object o)
          Add a Object to underlaying list
 void addAction(Action action)
          Add an action to action List
 void addTableModelListener(TableModelListener listener)
          
 void check(List<Serializable> keys)
          Check a list of keys
 void checkAll()
          Check all models on list
 int columnToPropertyIndex(int column)
          Convert column model index to property index
 void fireTableCellUpdated(int row, int column)
          Notifies all listeners that the value of the cell at [row, column] has been updated.
 void fireTableChanged()
          Fire a model table changed
 void fireTableChanged(TableModelEvent e)
          Fire a TableModelChanged event
 List<Action> getActions()
           
 List<Serializable> getChecked()
          Get a List with all selected model keys
 Class<?> getColumnClass(int columnIndex)
          
 int getColumnCount()
          
 String getColumnName(int columnIndex)
          Get the column name of an index
 List<String> getColumnNames()
           
 List<ColumnDefinition> getColumns()
           
 TableCellRenderer getDefaultTableCellRenderer()
           
 List<String> getDisplayNames()
           
 Map<String,Boolean> getEditableMap()
           
 List getList()
           
 org.springframework.context.MessageSource getMessageSource()
           
 Class getModelClass()
           
 int getPropertyCount()
           
 String getPropertyName(int index)
          Get a property name from column index, used in PageableTable
 int getRowCount()
          
 String getSortPropertyName(int column)
           
 TableColumnModel getTableColumnModel()
          Create a TableColumnModel for JTable.
 Object getValueAt(int rowIndex, int columnIndex)
          
 List getVisibleChecked()
           
 void init()
          Initialize table.
 boolean isActionColumn(int column)
           
 boolean isCellEditable(int rowIndex, int columnIndex)
          
 boolean isCheckColum(int column)
          Test if index is a check column
 boolean isPropertyColumn(int column)
          Test if index is a property column
 boolean isUsingActions()
           
 boolean isUsingChecks()
           
 boolean isUsingIntrospection()
           
 Iterator<?> iterator()
           
 Object remove(int index)
          Remove a object from underlaying list model
 void remove(Object toRemove)
           
 void removeAll(Collection toRemove)
           
 void removeTableModelListener(TableModelListener l)
          
 void setActions(List<Action> actions)
           
 void setColumnEditable(int columnIndex, boolean value)
           
 void setColumnNames(List<String> columnNames)
           
 void setColumnNames(String[] columnNames)
           
 void setColumns(List<ColumnDefinition> columns)
           
 void setDefaultTableCellRenderer(TableCellRenderer defaultTableCellRenderer)
           
 void setDisplayNames(List<String> displayNames)
           
 void setDisplayNames(String[] displayNames)
           
 void setEditableMap(Map<String,Boolean> editableMap)
           
 void setList(List list)
           
 void setMessageSource(org.springframework.context.MessageSource messageSource)
           
 void setModelClass(Class modelClass)
           
 void setUsingActions(boolean useActions)
           
 void setUsingChecks(boolean useChecks)
           
 void setUsingIntrospection(boolean usingIntrospection)
           
 void setValueAt(Object value, int rowIndex, int columnIndex)
          
 void uncheckAll()
          Uncheck All checks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_WIDTH

public static final String MAX_WIDTH
See Also:
Constant Field Values

CELL_RENDERER

public static final String CELL_RENDERER
See Also:
Constant Field Values
Constructor Detail

ListTableModel

public ListTableModel(List l)
Creates a new ListTableModel with model set to List l

Parameters:
l - the list to set as model

ListTableModel

public ListTableModel()
Creates a new ListTableModel with a empty list model

Method Detail

getColumnName

public String getColumnName(int columnIndex)
Get the column name of an index

Specified by:
getColumnName in interface TableModel
Returns:
String with column name

getColumnClass

public Class<?> getColumnClass(int columnIndex)

Specified by:
getColumnClass in interface TableModel

getRowCount

public int getRowCount()

Specified by:
getRowCount in interface TableModel

getColumnCount

public int getColumnCount()

Specified by:
getColumnCount in interface TableModel

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)

Specified by:
isCellEditable in interface TableModel

getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)

Specified by:
getValueAt in interface TableModel

setValueAt

public void setValueAt(Object value,
                       int rowIndex,
                       int columnIndex)

Specified by:
setValueAt in interface TableModel

fireTableCellUpdated

public void fireTableCellUpdated(int row,
                                 int column)
Notifies all listeners that the value of the cell at [row, column] has been updated.

Parameters:
row - row of cell which has been updated
column - column of cell which has been updated
See Also:
TableModelEvent, EventListenerList

addTableModelListener

public void addTableModelListener(TableModelListener listener)

Specified by:
addTableModelListener in interface TableModel

removeTableModelListener

public void removeTableModelListener(TableModelListener l)

Specified by:
removeTableModelListener in interface TableModel

init

public void init()
Initialize table. Load propertyDescriptors based on columNames or model introspection.


fireTableChanged

public void fireTableChanged(TableModelEvent e)
Fire a TableModelChanged event

Parameters:
e - event to fire

getTableColumnModel

public TableColumnModel getTableColumnModel()
Create a TableColumnModel for JTable. Try to use sizes and cell renderers from property descriptors.

Returns:
a new TableColumnModel based on PropertyDescriptors

add

public boolean add(Object o)
Add a Object to underlaying list

Parameters:
o - the object to add
Returns:
true if added

remove

public Object remove(int index)
Remove a object from underlaying list model

Parameters:
index - column to remove
Returns:
the removed object

isPropertyColumn

public boolean isPropertyColumn(int column)
Test if index is a property column

Parameters:
column - index to check
Returns:
true if index is a property column

isCheckColum

public boolean isCheckColum(int column)
Test if index is a check column

Parameters:
column - column index to check
Returns:
true if index is a check column

isActionColumn

public boolean isActionColumn(int column)

getPropertyName

public String getPropertyName(int index)
Get a property name from column index, used in PageableTable

Parameters:
index - to convert
Returns:
converted index

columnToPropertyIndex

public int columnToPropertyIndex(int column)
Convert column model index to property index

Parameters:
column - the column to convert
Returns:
the property index

fireTableChanged

public void fireTableChanged()
Fire a model table changed


setColumnEditable

public void setColumnEditable(int columnIndex,
                              boolean value)

setEditableMap

public void setEditableMap(Map<String,Boolean> editableMap)

setList

public void setList(List list)

getList

public List getList()

iterator

public Iterator<?> iterator()

isUsingIntrospection

public boolean isUsingIntrospection()

setUsingIntrospection

public void setUsingIntrospection(boolean usingIntrospection)

getColumnNames

public List<String> getColumnNames()

getPropertyCount

public int getPropertyCount()

setColumnNames

public void setColumnNames(List<String> columnNames)

setColumnNames

public void setColumnNames(String[] columnNames)

getDisplayNames

public List<String> getDisplayNames()

setDisplayNames

public void setDisplayNames(List<String> displayNames)

setDisplayNames

public void setDisplayNames(String[] displayNames)

isUsingChecks

public boolean isUsingChecks()

setUsingChecks

public void setUsingChecks(boolean useChecks)

getActions

public List<Action> getActions()

setActions

public void setActions(List<Action> actions)

isUsingActions

public boolean isUsingActions()

setUsingActions

public void setUsingActions(boolean useActions)

getEditableMap

public Map<String,Boolean> getEditableMap()

check

public void check(List<Serializable> keys)
Check a list of keys

Parameters:
keys -

getChecked

public List<Serializable> getChecked()
Get a List with all selected model keys

Returns:
List with checked model keys

getVisibleChecked

public List getVisibleChecked()

uncheckAll

public void uncheckAll()
Uncheck All checks


addAction

public void addAction(Action action)
Add an action to action List

Parameters:
action -

getModelClass

public Class getModelClass()
Returns:
the modelClass

setModelClass

public void setModelClass(Class modelClass)
Parameters:
modelClass - the modelClass to set

getColumns

public List<ColumnDefinition> getColumns()
Returns:
the columns

setColumns

public void setColumns(List<ColumnDefinition> columns)
Parameters:
columns - the columns to set

getDefaultTableCellRenderer

public TableCellRenderer getDefaultTableCellRenderer()
Returns:
the defaultTableCellRenderer

setDefaultTableCellRenderer

public void setDefaultTableCellRenderer(TableCellRenderer defaultTableCellRenderer)
Parameters:
defaultTableCellRenderer - the defaultTableCellRenderer to set

getSortPropertyName

public String getSortPropertyName(int column)
Parameters:
column - column index
Returns:
sort property for column

getMessageSource

public org.springframework.context.MessageSource getMessageSource()
Returns:
the messageSource

setMessageSource

@Autowired
public void setMessageSource(org.springframework.context.MessageSource messageSource)
Parameters:
messageSource - the messageSource to set

checkAll

public void checkAll()
Check all models on list


removeAll

public void removeAll(Collection toRemove)
Parameters:
toRemove -

remove

public void remove(Object toRemove)


Copyright © 2013 JDAL. All Rights Reserved.