|
QJCC homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object biz.chitec.quarterback.swing.MapListTableCellManager
Managing class for cell renderers and editors in tables which are driven by a MapListTableModel. In tables which are drive by a list-of-maps model, renderers are likely to be assigned by map key names. Unfortunately, the model cannot force the table to use certain renderers for the job. This additional manager class is attached to a table. As soon as the table gets a MapListTableModel, it waits for structural table changes which affect the header (i.e. the header might have changed. In this case, it reassigns renderers to the columns of the table according to the column renderer or editor settings in the model. There are two ways how the cell manager knows which renderer or editor to use for which column: (a) the MapListTableModel contains ResourceBundle-driven entries for renderer and editor class name. If such a name is given, MapListTableCellManager creates an instance of the referenced class and uses it. (b) Renderer and editor instances can be given directly to the manager, either one by one or in a Map. This is the only way to use renderer or editor classes which take parameters in their initializer. Directly given instances do always override ResourceBundle entries. Note that all renderer and editors are cached. Every class is instantiated only once.
Field Summary | |
private java.util.Map |
editorcache
|
private javax.swing.JTable |
jt
|
private MapListTableModel |
mltm
|
private java.util.Map |
renderercache
|
private javax.swing.table.TableColumnModel |
tcm
|
Constructor Summary | |
MapListTableCellManager()
Initialize an empty cell manager |
|
MapListTableCellManager(javax.swing.JTable jtx)
Initialize empty cell manager and bind it to table. |
Method Summary | |
void |
addEditor(java.util.Map editors)
Add multiple editors directly to the manager. |
void |
addEditor(java.lang.String key,
javax.swing.table.TableCellEditor tce)
Add one editor directly to the manager. |
void |
addRenderer(java.util.Map renderers)
Add multiple renderers directly to the manager. |
void |
addRenderer(java.lang.String key,
javax.swing.table.TableCellRenderer tcr)
Add one renderer directly to the manager. |
void |
addTo(javax.swing.JTable jtx)
Attaches the cell manager to a JTable instance. |
static void |
addTo(javax.swing.JTable jt,
java.lang.Object[] renderers)
Convenience method to setup a cell manager with one line of code. |
static void |
addTo(javax.swing.JTable jt,
java.lang.String name1,
javax.swing.table.TableCellRenderer tcr1)
Convenience method to setup a cell manager with one special column renderer with one line of code. |
protected void |
assignRendererAndEditors()
Assigns renderers and editors to column models |
protected void |
assignRendererAndEditorToColumn(int i)
|
void |
columnAdded(javax.swing.event.TableColumnModelEvent e)
From TableColumnModelListener to the JTable's TableColumnModel. |
void |
columnMarginChanged(javax.swing.event.ChangeEvent e)
From TableColumnModelListener to the JTable's TableColumnModel. |
void |
columnMoved(javax.swing.event.TableColumnModelEvent e)
From TableColumnModelListener to the JTable's TableColumnModel. |
void |
columnRemoved(javax.swing.event.TableColumnModelEvent e)
From TableColumnModelListener to the JTable's TableColumnModel. |
void |
columnSelectionChanged(javax.swing.event.ListSelectionEvent e)
From TableColumnModelListener to the JTable's TableColumnModel. |
void |
propertyChange(java.beans.PropertyChangeEvent evt)
From PropertyChangeListener to the JTable. |
protected void |
rebindToModel()
Binds the cell manager to the table's model. |
void |
setRenderers(java.lang.Object[] renderers)
Sets the renderers from an array list. |
void |
tableChanged(javax.swing.event.TableModelEvent e)
From TableModelListener: If headerstructure changes, re-assign all renderers and editors |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private javax.swing.JTable jt
private javax.swing.table.TableColumnModel tcm
private MapListTableModel mltm
private java.util.Map renderercache
private java.util.Map editorcache
Constructor Detail |
public MapListTableCellManager()
public MapListTableCellManager(javax.swing.JTable jtx)
Method Detail |
public void addTo(javax.swing.JTable jtx)
jtx
- JTable to assign to.public void addRenderer(java.lang.String key, javax.swing.table.TableCellRenderer tcr)
key
- Key in the underlying maps of the column in question.tcr
- Renderer to use for this columnpublic void addRenderer(java.util.Map renderers)
renderers
- Map with renderers of type Mappublic void setRenderers(java.lang.Object[] renderers)
renderers
- List of column names and renderers.public void addEditor(java.lang.String key, javax.swing.table.TableCellEditor tce)
key
- Key in the underlying maps of the column in question.tce
- Editor to use for this columnpublic void addEditor(java.util.Map editors)
editors
- Map with editors of type Mapprotected void rebindToModel()
protected void assignRendererAndEditorToColumn(int i)
protected void assignRendererAndEditors()
public void tableChanged(javax.swing.event.TableModelEvent e)
tableChanged
in interface javax.swing.event.TableModelListener
public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange
in interface java.beans.PropertyChangeListener
public void columnMarginChanged(javax.swing.event.ChangeEvent e)
columnMarginChanged
in interface javax.swing.event.TableColumnModelListener
public void columnSelectionChanged(javax.swing.event.ListSelectionEvent e)
columnSelectionChanged
in interface javax.swing.event.TableColumnModelListener
public void columnAdded(javax.swing.event.TableColumnModelEvent e)
columnAdded
in interface javax.swing.event.TableColumnModelListener
public void columnMoved(javax.swing.event.TableColumnModelEvent e)
columnMoved
in interface javax.swing.event.TableColumnModelListener
public void columnRemoved(javax.swing.event.TableColumnModelEvent e)
columnRemoved
in interface javax.swing.event.TableColumnModelListener
public static void addTo(javax.swing.JTable jt, java.lang.Object[] renderers)
jt
- Tablerenderers
- Renderers in form of alternating String and TableCellRenderer objects.public static void addTo(javax.swing.JTable jt, java.lang.String name1, javax.swing.table.TableCellRenderer tcr1)
jt
- Tablename1
- Name of column which should get special renderertcr1
- Renderer for column in question
|
QJCC homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |