|
JIDE 2.8.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTable
com.jidesoft.grid.JideTable
com.jidesoft.grid.ContextSensitiveTable
public class ContextSensitiveTable
ContextSensitiveTable is a JTable which supports EditorContext. If you pass a regular TableModel, it just acts like JTable. However if the model is ContextSensitiveTableModel, it will use the editor context information to get the correct cell renderer and cell editor from CellRendererManager and CellEditorManager respectively. Please note cell editor/renderer assigned to table column has a higher priority. Only when the cell editor/renderer on the table column is null, the renderer/editor on CellRendererManager or CellEditorManager will then be used.
By default, we use combobox as the cell editor for boolean. If you prefer to use the check box as in regular Swing table, you can call the code below when your application starts. It will affect all your tables. If you prefer to just change one table, you would need to return BooleanCheckBoxCellEditor.CONTEXT in ContextSensitiveTableModel#getEditorContextAt method for the paticular boolean column.
CellEditorManager.initDefaultEditor();
final CellEditorFactory cellEditorFactory = new CellEditorFactory() {
public CellEditor create() {
return new BooleanCheckBoxCellEditor();
}
};
CellEditorManager.registerEditor(Boolean.class, cellEditorFactory);
CellEditorManager.registerEditor(boolean.class, cellEditorFactory);
CellRendererManager.initDefaultRenderer();
BooleanCheckBoxCellRenderer booleanCheckBoxCellRenderer = new BooleanCheckBoxCellRenderer();
CellRendererManager.registerRenderer(Boolean.class, booleanCheckBoxCellRenderer);
CellRendererManager.registerRenderer(boolean.class, booleanCheckBoxCellRenderer);
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.jidesoft.grid.JideTable |
|---|
JideTable.NonContiguousTransferHandler |
| Nested classes/interfaces inherited from class javax.swing.JTable |
|---|
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintMode |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary |
|---|
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
ContextSensitiveTable()
|
|
ContextSensitiveTable(int numRows,
int numColumns)
|
|
ContextSensitiveTable(Object[][] rowData,
Object[] columnNames)
|
|
ContextSensitiveTable(TableModel dm)
|
|
ContextSensitiveTable(TableModel dm,
TableColumnModel cm)
|
|
ContextSensitiveTable(TableModel dm,
TableColumnModel cm,
ListSelectionModel sm)
|
|
ContextSensitiveTable(Vector<?> rowData,
Vector<?> columnNames)
|
|
| Method Summary | |
|---|---|
protected String |
convertElementToString(Object value,
int row,
int column)
Get the displayed string of the specified value in designated row and column. |
Class<?> |
getCellClassAt(int row,
int column)
Gets the cell class at the cell. |
TableCellEditor |
getCellEditor(int row,
int column)
Returns an appropriate cell editor for the cell specified by this row and column. |
protected TableCellEditor |
getCellEditorFromManager(int row,
int column)
Gets the cell editor from the CellEditorManager based on the values returned from getCellClassAt and getEditorContextAt. |
TableCellRenderer |
getCellRenderer(int row,
int column)
Returns an appropriate renderer for the cell specified by this row and column. |
protected TableCellRenderer |
getCellRendererFromManager(int row,
int column)
Gets the cell editor from the CellRendererManager based on the values returned from getCellClassAt and getEditorContextAt. |
ConverterContext |
getConverterContextAt(int row,
int column)
Gets the ConverterContext at the cell. |
TableCellRenderer |
getDefaultCellRenderer()
Gets the default cell renderer. |
EditorContext |
getEditorContextAt(int row,
int column)
Gets the EditorContext at the cell. |
void |
invalidateCellRendererCache()
For the performance consideration, we cached the cell renderers after getting it from CellRendererManager. |
boolean |
isCellEditorManagerEnabled()
Checks if CellEditorManager is in enabled. |
boolean |
isCellRendererManagerEnabled()
Checks if CellRendererManager is in enabled. |
void |
resetTransferHandler()
ContextSensitiveTable will use its own transfer handler called ContextSensitiveTableTransferHandler
which understands the ObjectConverter. |
void |
setCellEditorManagerEnabled(boolean cellEditorManagerEnabled)
By default, ContextSensitiveTable will use cell editors that are registered in CellEditorManager if the
model is ContextSensitiveTableModel. |
void |
setCellRendererManagerEnabled(boolean cellRendererManagerEnabled)
By default, ContextSensitiveTable will use cell renderers that are registered in CellRendererManager if
the model is ContextSensitiveTableModel. |
void |
setDefaultCellRenderer(TableCellRenderer defaultCellRenderer)
Sets the default cell renderer. |
void |
updateUI()
Resets the UI property to a value from the current look and feel. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.jidesoft.grid.TableAdapter |
|---|
getCellSelectionEnabled, getColumnClass, getColumnCount, getColumnName, getColumnSelectionAllowed, getRowCount, getRowSelectionAllowed, getValueAt, isCellEditable, setCellSelectionEnabled, setValueAt |
| Constructor Detail |
|---|
public ContextSensitiveTable()
public ContextSensitiveTable(int numRows,
int numColumns)
public ContextSensitiveTable(TableModel dm)
public ContextSensitiveTable(Object[][] rowData,
Object[] columnNames)
public ContextSensitiveTable(Vector<?> rowData,
Vector<?> columnNames)
public ContextSensitiveTable(TableModel dm,
TableColumnModel cm)
public ContextSensitiveTable(TableModel dm,
TableColumnModel cm,
ListSelectionModel sm)
| Method Detail |
|---|
public void resetTransferHandler()
ContextSensitiveTable will use its own transfer handler called ContextSensitiveTableTransferHandler
which understands the ObjectConverter. So the string value copied to the clipboard is after the the conversion by
the converters. If you want to copy the raw value without conversion, you call this method to reset the transfer
handler to the default one created by JTable which doesn't use the converters.
public TableCellRenderer getCellRenderer(int row,
int column)
getDefaultCellRenderer() method. If null, it will check is isCellRendererManagerEnabled() is true. If true, it will look for the cell renderer that assigned to the
specific column. Only if the renderer is still null, it will use the EditorContext information from
ContextSensitiveTableModel and get the correct CellRedenerer from the CellRendererManager. In any case, if we
can't determine a cell renderer, we will call super.getCellRenderer(row, column) just like regular JTable.
getCellRenderer in class JTablerow - the row of the cell to render, where 0 is the first rowcolumn - the column of the cell to render, where 0 is the first column
protected TableCellRenderer getCellRendererFromManager(int row,
int column)
row - the row index.column - the column index.
public void invalidateCellRendererCache()
CellRendererManager. Since usually CellRendererManagerdoesn't change dynamically in the
life span of a table, it should be fine. However if for whatever reason you have to change
CellRendererManager on fly, you can call this method to invalidate the cache.
public void updateUI()
JideTable
updateUI in class JideTableJComponent.updateUI()
public TableCellEditor getCellEditor(int row,
int column)
isCellEditorManagerEnabled() is true. If true, it will look for the cell editor that assigned to the specific
column. Only if the editor is still null, it will use the EditorContext information from
ContextSensitiveTableModel and get the correct CellEditorfrom the CellRendererManager. In any case, if we can't
determine a cell editor, we will call super.getCellEditor(row, column) just like regular JTable.
getCellEditor in class JTablerow - the row of the cell to edit, where 0 is the first rowcolumn - the column of the cell to edit, where 0 is the first column
TableCellEditor that does the editingJTable.cellEditor
protected TableCellEditor getCellEditorFromManager(int row,
int column)
row - the row index.column - the column index.
public boolean isCellEditorManagerEnabled()
CellEditorManager is in enabled. Default is true.
public void setCellEditorManagerEnabled(boolean cellEditorManagerEnabled)
CellEditorManager if the
model is ContextSensitiveTableModel. However if for some reason you don't want this feature, you can call
this method to enable or disable it.
cellEditorManagerEnabled - true to enable CellEditorManager. False to disable it.public boolean isCellRendererManagerEnabled()
CellRendererManager is in enabled. Default is true.
public void setCellRendererManagerEnabled(boolean cellRendererManagerEnabled)
CellRendererManager if
the model is ContextSensitiveTableModel. However if for some reason you don't want this feature, you can
call this method to enable or disable it.
cellRendererManagerEnabled - true to enable CellRendererManager. False to disable it.public TableCellRenderer getDefaultCellRenderer()
getCellRenderer(int,int) will look for.
In the other word, if you ever set it using setDefaultCellRenderer(javax.swing.table.TableCellRenderer),
it will be guaranteed to be used (unless subclass of it overrides getCellRenderer(int,int) to return
something else).
public void setDefaultCellRenderer(TableCellRenderer defaultCellRenderer)
defaultCellRenderer - the default cell renderer. This renderer will be used by all cells.getDefaultCellRenderer()
public ConverterContext getConverterContextAt(int row,
int column)
row - the row index. It is the view row index.column - the column index. It is the view column index.
public EditorContext getEditorContextAt(int row,
int column)
row - the row index. It is the view row index.column - the column index. It is the view column index.
public Class<?> getCellClassAt(int row,
int column)
row - the row index. It is the view row index.column - the column index. It is the view column index.
protected String convertElementToString(Object value,
int row,
int column)
JideTable
convertElementToString in class JideTablevalue - the cell valuerow - the row of the cellcolumn - the column of the cell
|
JIDE 2.8.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||