|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JTable com.jidesoft.grid.JideTable com.jidesoft.grid.ContextSensitiveTable com.jidesoft.grid.NavigableTable com.jidesoft.grid.CellStyleTable com.jidesoft.grid.CellSpanTable
public class CellSpanTable
CellSpanTable
introduces cell spans to table. As long as the table model implements SpanModel
and its SpanModel.isCellSpanOn()
returns true, CellSpanTable
will use the CellSpan
that is returned from SpanModel.getCellSpanAt(int, int)
to span the cell. The span could be across several
rows or several columns. If you know the table data and cell span beforehand, you can use
DefaultSpanTableModel
. If the table data is dynamic so is the cell span, you should use
AbstractSpanTableModel
.
Nested Class Summary | |
---|---|
protected static class |
CellSpanTable.DelegateAction
|
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 | |
---|---|
static int |
AUTO_CELL_MERGE_COLUMNS
|
static int |
AUTO_CELL_MERGE_COLUMNS_LIMITED
|
static int |
AUTO_CELL_MERGE_OFF
|
static int |
AUTO_CELL_MERGE_ROWS
|
static int |
AUTO_CELL_MERGE_ROWS_LIMITED
|
static String |
PROPERTY_AUTO_CONVERT_CELL_SPAN
|
static String |
PROPERTY_PAINT_CELL_SPAN_AS_SELECTED
|
Fields inherited from class com.jidesoft.grid.CellStyleTable |
---|
_cellStyleList, PROPERTY_FILLS_SELECTION, PROPERTY_FILLS_VIEWPORT_WITH_STRIPE |
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 | |
---|---|
CellSpanTable()
|
|
CellSpanTable(int numRows,
int numColumns)
|
|
CellSpanTable(Object[][] rowData,
Object[] columnNames)
|
|
CellSpanTable(TableModel dm)
|
|
CellSpanTable(TableModel dm,
TableColumnModel cm)
|
|
CellSpanTable(TableModel dm,
TableColumnModel cm,
ListSelectionModel sm)
|
|
CellSpanTable(Vector<?> rowData,
Vector<?> columnNames)
|
Method Summary | |
---|---|
protected CellSpan |
binarySearch(List<CellSpan> cache,
int row,
int column)
Search the CellSpan from the cache based on the row and column. |
protected int |
calculateRowHeight(int row)
The method calculates the height for the row based on the content in the row. |
void |
calculateRowHeight(int row,
boolean doWholeSpan)
Calculate the height of a rows based on the preferred size of contents in each of its cells. |
void |
calculateRowHeights()
Calculate the height of all rows based on the preferred size of contents in each of a row's cells. |
void |
columnAdded(TableColumnModelEvent e)
|
int |
columnAtPoint(Point point)
|
void |
columnMoved(TableColumnModelEvent e)
|
void |
columnRemoved(TableColumnModelEvent e)
|
CellSpan |
convertModelCellSpanToView(CellSpan span)
Converts the cell span from table model to the cell span from the view. |
CellSpan |
convertViewCellSpanToModel(CellSpan span)
Converts the cell span from view to the cell span from the table model. |
protected List<CellSpan> |
createCellSpanCache()
Create the CellSpan cache. |
protected Action |
createDelegateAction(Action action,
KeyStroke keyStroke)
|
boolean |
editCellAt(int row,
int column,
EventObject o)
|
int |
getActualRowHeight(int row)
Get actual row height of a row. |
String |
getActualUIClassID()
|
int |
getAutoCellMerge()
Gets the autoCellMerge mode. |
protected List<CellSpan> |
getCache()
|
protected Set<com.jidesoft.grid.CellSpanTable.Cell> |
getCacheEmpty()
|
TableCellEditor |
getCellEditor(int row,
int column)
Returns an appropriate cell editor for the cell specified by this row and column. |
Rectangle |
getCellRect(int row,
int column,
boolean includeSpacing)
|
TableCellRenderer |
getCellRenderer(int row,
int column)
Returns an appropriate renderer for the cell specified by this row and column. |
CellSpan |
getCellSpanAt(int row,
int column)
Gets the cell span at the specified cell. |
CellSpan |
getCellSpanAt(SpanModel spanModel,
int row,
int column)
Gets the cell span at the specified cells. |
protected CellSpan |
getCellSpanFromAutoCellMerge(int row,
int column)
|
protected CellSpan |
getCellSpanFromSpanModel(int row,
int column)
|
protected Rectangle |
getDirtyRegion(int firstRow,
int firstColumn,
int lastRow,
int lastColumn)
Gets the dirty region from the first row, first column and last row, last column considering CellSpan. |
int |
getScrollableUnitIncrement(Rectangle visibleRect,
int orientation,
int direction)
Overrides the method in JTable in order provide a smooth vertical scrolling. |
TableModel |
getSpanModel()
Gets span model. |
Object |
getValueAt(int row,
int column)
Returns the cell value at row and column . |
void |
invalidateCellSpanCache()
Invalidates the cell span cache. |
boolean |
isAutoConvertCellSpan()
Check the autoConvertCellSpan flag. |
protected boolean |
isCellFocused(int rowIndex,
int columnIndex)
Check if the cell is a focused cell inside the table. |
boolean |
isCellSelected(int row,
int column)
Returns true if the specified indices are in the valid range of rows and columns and the cell at the specified position is selected. |
boolean |
isCellSpanCacheEnabled()
Get the flag indicating if the cache for cell span is enabled. |
boolean |
isCellSpanOn()
Checks if the cell span is on. |
boolean |
isKeepColumnAtPoint()
Checks if columnAtPoint(java.awt.Point) method will return the actual column index without considering
the cell spans. |
boolean |
isKeepRowAtPoint()
Checks if rowAtPoint(java.awt.Point) method will return the actual row index without considering the
cell spans. |
boolean |
isPaintCellSpanAsSelected()
Check the paintCellSpanAsSelected flag. |
protected void |
muteDefaultKeyStroke()
|
int |
originalColumnAtPoint(Point point)
The columnAtPoint method without considering the cell spans. |
Rectangle |
originalGetCellRect(int row,
int column,
boolean includeSpacing)
Gets the original cell rect of the cell at row and column without considering the cell spans. |
int |
originalRowAtPoint(Point point)
The rowAtPoint method without considering the cell spans. |
Component |
prepareEditor(TableCellEditor editor,
int row,
int column)
Override this method to get the style from CellStyle defined by StyleModel and set it to component return from super.prepareEditor(). |
protected void |
replaceAction(KeyStroke keyStroke)
Registers an action for the KeyStroke. |
protected void |
replaceAction(KeyStroke keyStroke,
int condition)
Registers an action for the KeyStroke. |
protected void |
restoreAction(KeyStroke keyStroke)
Restores the action registered using replaceAction(javax.swing.KeyStroke) . |
protected void |
restoreAction(KeyStroke keyStroke,
int condition)
Restores the action registered using replaceAction(javax.swing.KeyStroke, int) . |
boolean |
rolloverCellAt(int row,
int column)
Makes the cell enters editing mode without forcing the other cell editor, if any, to stop editing. |
int |
rowAtPoint(Point point)
Returns the index of the row that point lies in, or -1 if the result is not in the range [0,
getRowCount() -1]. |
void |
setAutoCellMerge(int autoCellMerge)
Sets the autoCellMerge mode. |
void |
setAutoConvertCellSpan(boolean autoConvertCellSpan)
By default, we will automatically convert CellSpan from model to view and vice verse in order to consider the case of hidden columns. |
void |
setCellSpanCacheEnabled(boolean cellSpanCacheEnabled)
Set the flag indicating if the cache for cell span is enabled. |
void |
setKeepColumnAtPoint(boolean keepColumnAtPoint)
CellSpanTable overrides columnAtPoint(java.awt.Point) method to consider the cell span. |
void |
setKeepRowAtPoint(boolean keepRowAtPoint)
CellSpanTable overrides rowAtPoint(java.awt.Point) method to consider the cell span. |
void |
setPaintCellSpanAsSelected(boolean paintCellSpanAsSelected)
By default, we will paint the whole cell span as selected when the cell is indeed selected. |
protected boolean |
shouldCellBePaintedAsFocused(int row,
int column)
Subclass can override this method to determine if the cell should be painted as focused cell when it is a focused cell. |
protected boolean |
shouldCellBePaintedAsSelected(int row,
int column)
Subclass can override this method to determine if the cell should be painted as selected when selected. |
void |
tableChanged(TableModelEvent e)
Invoked when this table's TableModel generates a TableModelEvent . |
void |
valueChanged(ListSelectionEvent e)
|
static boolean |
verifyCellSpan(CellSpanTable table)
This is a method for debugging purpose. |
static boolean |
verifyCellSpan(SpanModel spanModel)
This is a method for debugging purpose. |
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, isCellEditable, setCellSelectionEnabled, setValueAt |
Field Detail |
---|
public static final int AUTO_CELL_MERGE_OFF
public static final int AUTO_CELL_MERGE_ROWS
public static final int AUTO_CELL_MERGE_COLUMNS
public static final int AUTO_CELL_MERGE_ROWS_LIMITED
public static final int AUTO_CELL_MERGE_COLUMNS_LIMITED
public static final String PROPERTY_AUTO_CONVERT_CELL_SPAN
public static final String PROPERTY_PAINT_CELL_SPAN_AS_SELECTED
Constructor Detail |
---|
public CellSpanTable()
public CellSpanTable(int numRows, int numColumns)
public CellSpanTable(TableModel dm)
public CellSpanTable(Object[][] rowData, Object[] columnNames)
public CellSpanTable(Vector<?> rowData, Vector<?> columnNames)
public CellSpanTable(TableModel dm, TableColumnModel cm)
public CellSpanTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
Method Detail |
---|
public void columnAdded(TableColumnModelEvent e)
columnAdded
in interface TableColumnModelListener
columnAdded
in class JTable
public void columnRemoved(TableColumnModelEvent e)
columnRemoved
in interface TableColumnModelListener
columnRemoved
in class JTable
public void columnMoved(TableColumnModelEvent e)
columnMoved
in interface TableColumnModelListener
columnMoved
in class JTable
public String getActualUIClassID()
getActualUIClassID
in class JideTable
public TableModel getSpanModel()
TableModelWrapperUtils.getActualTableModel(javax.swing.table.TableModel, Class)
to find an
instance of SpanModel. If it can finds one, it will return that one. Otherwise, getModel() is returned as fall
back.
public CellSpan getCellSpanAt(SpanModel spanModel, int row, int column)
convertModelCellSpanToView(CellSpan)
to do auto conversion from model to view if isAutoConvertCellSpan()
is true. If isAutoConvertCellSpan()
is false, this method is the same as
tableModel.getCellSpanAt(row, column).
Please note, you should use getCellSpanAt(int, int)
method instead of using this method directly in most
cases because this method will not look at isCellSpanOn()
value when returning the cell span. In the
other word, even if isCellSpanOn()
returns false, this method could still return a valid cell span. In
comparison, getCellSpanAt(int, int)
will always return null if isCellSpanOn()
returns false.
spanModel
- the SpanModelrow
- the row indexcolumn
- the column index
public CellSpan convertModelCellSpanToView(CellSpan span)
span
- the CellSpan
public CellSpan convertViewCellSpanToModel(CellSpan span)
span
- the CellSpan
public boolean isAutoConvertCellSpan()
setAutoConvertCellSpan(boolean)
public void setAutoConvertCellSpan(boolean autoConvertCellSpan)
autoConvertCellSpan
- true or false.public boolean isPaintCellSpanAsSelected()
setPaintCellSpanAsSelected(boolean)
public void setPaintCellSpanAsSelected(boolean paintCellSpanAsSelected)
paintCellSpanAsSelected
- true or false.public boolean isKeepColumnAtPoint()
columnAtPoint(java.awt.Point)
method will return the actual column index without considering
the cell spans.
columnAtPoint(java.awt.Point)
method will return the actual column index without
considering the cell spans. Otherwise, false.setKeepColumnAtPoint(boolean)
public void setKeepColumnAtPoint(boolean keepColumnAtPoint)
columnAtPoint(java.awt.Point)
method to consider the cell span. When the point
passed to columnAtPoint() is in a cell span, it will return the anchor column index of that cell span instead of
the column index the actual obscured cell. However sometimes it is still useful to know the actual column index.
If you call this method and set it to true, columnAtPoint(java.awt.Point)
will return the actual column
index without considering the cell spans.
keepColumnAtPoint
- true or false.public boolean isKeepRowAtPoint()
rowAtPoint(java.awt.Point)
method will return the actual row index without considering the
cell spans.
rowAtPoint(java.awt.Point)
method will return the actual row index without considering
the cell spans. Otherwise, false.public void setKeepRowAtPoint(boolean keepRowAtPoint)
rowAtPoint(java.awt.Point)
method to consider the cell span. When the point
passed to rowAtPoint() is in a cell span, it will return the anchor row index of that cell span instead of the
row index the actual obscured cell. However sometimes it is still useful to know the actual row index. IF you
call this method and set it to true, rowAtPoint(java.awt.Point)
will return the actual row index without
considering the cell spans.
keepRowAtPoint
- true or false.public Rectangle originalGetCellRect(int row, int column, boolean includeSpacing)
row
- the row index.column
- the column index.includeSpacing
- if false, return the true cell bounds - computed by subtracting the inter cell spacing from
the height and widths of the column and row models
public Rectangle getCellRect(int row, int column, boolean includeSpacing)
getCellRect
in class JideTable
public int originalRowAtPoint(Point point)
point
- the location of the interest.
point
lies in, or -1 if the result is not in the range [0,
getRowCount()
-1]public int originalColumnAtPoint(Point point)
point
- the location of the interest.
point
lies in, or -1 if the result is not in the range [0,
getColumnCount()
-1]public int rowAtPoint(Point point)
JideTable
point
lies in, or -1 if the result is not in the range [0,
getRowCount()
-1].
rowAtPoint
in class JideTable
point
- the location of interest
point
lies in, or -1 if the result is not in the range [0,
getRowCount()
-1]JTable.columnAtPoint(java.awt.Point)
public int columnAtPoint(Point point)
columnAtPoint
in class JTable
public boolean rolloverCellAt(int row, int column)
JideTable
rolloverCellAt
in class JideTable
row
- the row index.column
- the column index.
public boolean editCellAt(int row, int column, EventObject o)
editCellAt
in class JideTable
protected boolean shouldCellBePaintedAsFocused(int row, int column)
JideTable
shouldCellBePaintedAsFocused
in class JideTable
row
- the row index.column
- the column index
protected boolean shouldCellBePaintedAsSelected(int row, int column)
JideTable
shouldCellBePaintedAsSelected
in class JideTable
row
- the row index.column
- the column index
public boolean isCellSelected(int row, int column)
TableAdapter
isCellSelected
in interface TableAdapter
isCellSelected
in class JideTable
row
- the row being queriedcolumn
- the column being queried
row
and column
are valid indices and the cell at index (row,
column)
is selected, where the first row and first column are at index 0public TableCellEditor getCellEditor(int row, int column)
ContextSensitiveTable
ContextSensitiveTable.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 ContextSensitiveTable
row
- 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
public TableCellRenderer getCellRenderer(int row, int column)
ContextSensitiveTable
ContextSensitiveTable.getDefaultCellRenderer()
method. If null, it will check is ContextSensitiveTable.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 ContextSensitiveTable
row
- 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
public Component prepareEditor(TableCellEditor editor, int row, int column)
CellStyleTable
prepareEditor
in class CellStyleTable
editor
- the cell editor.row
- the row index.column
- the column index.
public Object getValueAt(int row, int column)
TableAdapter
row
and column
.
Note: The column is specified in the table view's display order, and not in the TableModel
's
column order. This is an important distinction because as the user rearranges the columns in the table, the
column at a given index in the view will change. Meanwhile the user's actions never affect the model's column
ordering.
getValueAt
in interface TableAdapter
getValueAt
in class JideTable
row
- the row whose value is to be queriedcolumn
- the column whose value is to be queried
protected boolean isCellFocused(int rowIndex, int columnIndex)
JideTable
isCellFocused
in class JideTable
rowIndex
- the row index of the cellcolumnIndex
- the column index of the cell
protected Rectangle getDirtyRegion(int firstRow, int firstColumn, int lastRow, int lastColumn)
getDirtyRegion
in class JideTable
firstRow
- the first rowfirstColumn
- the first columnlastRow
- the last rowlastColumn
- the last column
public boolean isCellSpanOn()
getAutoCellMerge()
while another
is from SpanModel
.
public CellSpan getCellSpanAt(int row, int column)
convertModelCellSpanToView(CellSpan)
to do auto conversion from model to view if isAutoConvertCellSpan()
is true. If isAutoConvertCellSpan()
is false, this method is the same as
tableModel.getCellSpanAt(row, column). If isCellSpanOn()
returns false, this method will always return
null.
row
- the row indexcolumn
- the column index
protected List<CellSpan> createCellSpanCache()
protected CellSpan binarySearch(List<CellSpan> cache, int row, int column)
cache
- the CellSpan cacherow
- the row indexcolumn
- the column index
protected CellSpan getCellSpanFromAutoCellMerge(int row, int column)
protected CellSpan getCellSpanFromSpanModel(int row, int column)
public void valueChanged(ListSelectionEvent e)
valueChanged
in interface ListSelectionListener
valueChanged
in class JideTable
public void tableChanged(TableModelEvent e)
JideTable
TableModel
generates a TableModelEvent
. The
TableModelEvent
should be constructed in the coordinate system of the model; the appropriate mapping
to the view coordinate system is performed by this JTable
when it receives the event.
Application code will not use these methods explicitly, they are used internally by JTable
.
tableChanged
in interface TableModelListener
tableChanged
in class JideTable
public void invalidateCellSpanCache()
protected void muteDefaultKeyStroke()
protected Action createDelegateAction(Action action, KeyStroke keyStroke)
public boolean isCellSpanCacheEnabled()
public void setCellSpanCacheEnabled(boolean cellSpanCacheEnabled)
cellSpanCacheEnabled
- the flagisCellSpanCacheEnabled()
protected void replaceAction(KeyStroke keyStroke)
keyStroke
- the KeyStroke.protected void replaceAction(KeyStroke keyStroke, int condition)
keyStroke
- the KeyStroke.condition
- the condition. Valid values are JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
JComponent.WHEN_FOCUSED and JComponent.WHEN_IN_FOCUSED_WINDOW.protected void restoreAction(KeyStroke keyStroke)
replaceAction(javax.swing.KeyStroke)
.
keyStroke
- the KeyStroke.protected void restoreAction(KeyStroke keyStroke, int condition)
replaceAction(javax.swing.KeyStroke, int)
.
keyStroke
- the KeyStroke.condition
- the condition. Valid values are JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
JComponent.WHEN_FOCUSED and JComponent.WHEN_IN_FOCUSED_WINDOW.public void calculateRowHeights()
public void calculateRowHeight(int row, boolean doWholeSpan)
row
- intdoWholeSpan
- boolean indicates whether to check all the rows in a span, if any, that the given row might
belong to. If false, height of none of the rows that might belong to the same spans as the
given row would be recalculated.protected int calculateRowHeight(int row)
JideTable
calculateRowHeight
in class JideTable
row
- the row to be calculated
public static boolean verifyCellSpan(SpanModel spanModel)
spanModel
- the SpanModel.
public static boolean verifyCellSpan(CellSpanTable table)
table
- the CellSpanTable.
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
getScrollableUnitIncrement
in interface Scrollable
getScrollableUnitIncrement
in class JTable
visibleRect
- the view area visible within the viewportorientation
- either SwingConstants.VERTICAL
or SwingConstants.HORIZONTAL
direction
- less than zero to scroll up/left, greater than zero for down/right
public int getActualRowHeight(int row)
row
- the row index
protected List<CellSpan> getCache()
protected Set<com.jidesoft.grid.CellSpanTable.Cell> getCacheEmpty()
public int getAutoCellMerge()
AUTO_CELL_MERGE_OFF
, AUTO_CELL_MERGE_ROWS
or AUTO_CELL_MERGE_COLUMNS
, AUTO_CELL_MERGE_ROWS_LIMITED
and AUTO_CELL_MERGE_COLUMNS_LIMITED
. If
on, the cell spans will be created automatically for the adjacent cells that have the same value on the same row
or on the same column.
public void setAutoCellMerge(int autoCellMerge)
autoCellMerge
- the new value for the autoCellMerge mode. Valid values are AUTO_CELL_MERGE_OFF
,
AUTO_CELL_MERGE_ROWS
, AUTO_CELL_MERGE_COLUMNS
, AUTO_CELL_MERGE_ROWS_LIMITED
and AUTO_CELL_MERGE_COLUMNS_LIMITED
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |