JIDE 3.5.15

com.jidesoft.grid
Class PagedTablePane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.jidesoft.grid.PagedTablePane
All Implemented Interfaces:
TableAdapter, ImageObserver, MenuContainer, Serializable, Accessible

public class PagedTablePane
extends JPanel
implements TableAdapter

PagedTablePane is a panel that displays several tables side by side so that more rows are visible at the same time. A perfect use case is to display a table with not many columns but many rows in a very wide area. If we only display one table in the area, you may only see 20 rows at a time but if you use PagedTablePane, you can see 40 or 60 rows at a time.

PagedTablePane must work together with PagedTablePaneNavigationBar. You may choose not to display the PagedTablePaneNavigationBar but you must create one using new PagedTablePaneNavigationBar(a PagedTablePane) to enable the page navigation in the tables.

See Also:
Serialized Form

Nested Class Summary
static class PagedTablePane.TablePosition
          A class that define a table, a row index and a column index.
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
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
protected  boolean _columnSelectionAllowed
          True if column selection is allowed in this table.
protected  boolean _nonContiguousCellSelectionAllowed
          True if non-contiguous selection is allowed in this table.
protected  boolean _rowSelectionAllowed
          True if row selection is allowed in this table scroll pane.
 
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
PagedTablePane(TableModel tableModel)
          Creates a PagedTablePane with two tables side by side.
PagedTablePane(TableModel tableModel, int column)
           
 
Method Summary
 void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend)
          Updates the selection models of the table, depending on the state of the two flags: toggle and extend.
 void clearSelection()
          Deselects all selected columns and rows.
 int convertColumnIndexToModel(int viewIndex)
          Convert the view column index in the entire TableScrollPane to model index.
 int convertColumnIndexToView(int modelIndex)
          Convert the view column index in the entire TableScrollPane to model index.
protected  JTable createTable(TableModel model)
          Overrides to create your own table.
 boolean getCellSelectionEnabled()
          Returns true if both row and column selection models are enabled.
 Class<?> getColumnClass(int column)
          Returns the type of the column appearing in the view at column position column.
 int getColumnCount()
          Gets the total column count of TableScrollPane.
 String getColumnName(int column)
          Returns the name of the column appearing in the view at column position column.
 boolean getColumnSelectionAllowed()
          Returns true if columns can be selected.
 TableModel getModel()
           
 int getRowCount()
          Gets the total row count of TableScrollPane.
 boolean getRowSelectionAllowed()
          Returns true if rows can be selected.
 int getSelectedColumn()
          Returns the index of the first selected column, -1 if no column is selected.
 int getSelectedColumnCount()
          Returns the number of selected columns.
 int[] getSelectedColumns()
          Returns the indices of all selected columns.
 int getSelectedRow()
          Returns the index of the first selected row, -1 if no row is selected.
 int getSelectedRowCount()
          Returns the number of selected rows.
 int[] getSelectedRows()
          Returns the indices of all selected rows.
 PagedTablePane.TablePosition getTableAtCell(int row, int column)
          Gets the table as the specified row and column index.
 PagedTablePane.TablePosition getTableAtRow(int row)
          Gets the table as the specified row index.
 JTable[] getTables()
           
 Object getValueAt(int row, int column)
          Returns the cell value at row and column.
 boolean isCellEditable(int row, int column)
          Returns true if the cell at row and column is editable.
 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 isColumnSelected(int column)
          Returns true if the specified index is in the valid range of columns, and the column at that index is selected.
 boolean isNonContiguousCellSelectionAllowed()
          Returns true if non-contiguous cell selection can be selected.
 boolean isRowSelected(int row)
          Returns true if the specified index is in the valid range of rows, and the row at that index is selected.
protected  void resynchronizeTablesSelection()
           
 void setCellSelectionEnabled(boolean cellSelectionEnabled)
          Sets whether this table allows both a column selection and a row selection to exist simultaneously.
 void setColumnSelectionAllowed(boolean columnSelectionAllowed)
          Sets whether the columns in this model can be selected.
 void setModel(TableModel tableModel)
           
 void setNonContiguousCellSelectionAllowed(boolean nonContiguousCellSelectionAllowed)
          Sets whether non-contiguous cell selection in this model can be selected.
 void setRowSelectionAllowed(boolean rowSelectionAllowed)
          Sets whether the rows in this model can be selected.
 void setValueAt(Object aValue, int row, int column)
          Sets the value for the cell in the table model at row and column.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_rowSelectionAllowed

protected boolean _rowSelectionAllowed
True if row selection is allowed in this table scroll pane.


_columnSelectionAllowed

protected boolean _columnSelectionAllowed
True if column selection is allowed in this table.


_nonContiguousCellSelectionAllowed

protected boolean _nonContiguousCellSelectionAllowed
True if non-contiguous selection is allowed in this table.

Constructor Detail

PagedTablePane

public PagedTablePane(TableModel tableModel)
Creates a PagedTablePane with two tables side by side.

Parameters:
tableModel - the table model.

PagedTablePane

public PagedTablePane(TableModel tableModel,
                      int column)
Method Detail

setModel

public void setModel(TableModel tableModel)

getModel

public TableModel getModel()

createTable

protected JTable createTable(TableModel model)
Overrides to create your own table. By default, we will create a SortableTable.

Parameters:
model - the model
Returns:
the table

getTables

public JTable[] getTables()

setRowSelectionAllowed

public void setRowSelectionAllowed(boolean rowSelectionAllowed)
Sets whether the rows in this model can be selected.

Specified by:
setRowSelectionAllowed in interface TableAdapter
Parameters:
rowSelectionAllowed - true if this model will allow row selection
See Also:
getRowSelectionAllowed()

getRowSelectionAllowed

public boolean getRowSelectionAllowed()
Returns true if rows can be selected.

Specified by:
getRowSelectionAllowed in interface TableAdapter
Returns:
true if rows can be selected, otherwise false
See Also:
setRowSelectionAllowed(boolean)

setColumnSelectionAllowed

public void setColumnSelectionAllowed(boolean columnSelectionAllowed)
Sets whether the columns in this model can be selected.

Specified by:
setColumnSelectionAllowed in interface TableAdapter
Parameters:
columnSelectionAllowed - true if this model will allow column selection
See Also:
getColumnSelectionAllowed()

getColumnSelectionAllowed

public boolean getColumnSelectionAllowed()
Returns true if columns can be selected.

Specified by:
getColumnSelectionAllowed in interface TableAdapter
Returns:
true if columns can be selected, otherwise false
See Also:
setColumnSelectionAllowed(boolean)

setCellSelectionEnabled

public void setCellSelectionEnabled(boolean cellSelectionEnabled)
Sets whether this table allows both a column selection and a row selection to exist simultaneously. When set, the table treats the intersection of the row and column selection models as the selected cells. Override isCellSelected to change this default behavior. This method is equivalent to setting both the rowSelectionAllowed property and columnSelectionAllowed property of the columnModel to the supplied value.

Specified by:
setCellSelectionEnabled in interface TableAdapter
Parameters:
cellSelectionEnabled - true if simultaneous row and column selection is allowed
See Also:
getCellSelectionEnabled()

getCellSelectionEnabled

public boolean getCellSelectionEnabled()
Returns true if both row and column selection models are enabled. Equivalent to getRowSelectionAllowed() && getColumnSelectionAllowed().

Specified by:
getCellSelectionEnabled in interface TableAdapter
Returns:
true if both row and column selection models are enabled
See Also:
setCellSelectionEnabled(boolean)

setNonContiguousCellSelectionAllowed

public void setNonContiguousCellSelectionAllowed(boolean nonContiguousCellSelectionAllowed)
Sets whether non-contiguous cell selection in this model can be selected. Please note, non-contiguous cell selection is a feature in JideTable so you have to use JideTable or its subclasses in order to use this option. Also please note, due to limitation of TableScrollPane, only one table can be selected at a time. In the other words, you can't select a few cells in header table and a few cells in the main table.

Parameters:
nonContiguousCellSelectionAllowed - true if this model will allow non-contiguous cell selection
See Also:
isNonContiguousCellSelectionAllowed()

isNonContiguousCellSelectionAllowed

public boolean isNonContiguousCellSelectionAllowed()
Returns true if non-contiguous cell selection can be selected.

Returns:
true if -contiguous cell selection is enabled, otherwise false
See Also:
setNonContiguousCellSelectionAllowed(boolean)

resynchronizeTablesSelection

protected void resynchronizeTablesSelection()

getRowCount

public int getRowCount()
Gets the total row count of TableScrollPane.

Specified by:
getRowCount in interface TableAdapter
Returns:
the total row count of TableScrollPane.

getColumnCount

public int getColumnCount()
Gets the total column count of TableScrollPane.

Specified by:
getColumnCount in interface TableAdapter
Returns:
the total column count of TableScrollPane.

getTableAtRow

public PagedTablePane.TablePosition getTableAtRow(int row)
Gets the table as the specified row index.

Parameters:
row - the row index related to TableScrollPane.
Returns:
a TablePosition. The table field in TablePosition is the child table and the row field is the converted row index relative to the child table. The column field is always -1. Because the column index is not specified, the table could only be the main table or the column footer table. It will never be the row header tables or the row footer table.

getTableAtCell

public PagedTablePane.TablePosition getTableAtCell(int row,
                                                   int column)
Gets the table as the specified row and column index.

Parameters:
row - the row index related to TableScrollPane.
column - the column index related to TableScrollPane.
Returns:
a TablePosition. The table field in TablePosition is the child table, the column field is the converted column index relative to the child table and the row field is the converted row index relative to the child table.

getColumnName

public String getColumnName(int column)
Returns the name of the column appearing in the view at column position column.

Specified by:
getColumnName in interface TableAdapter
Parameters:
column - the column in the view being queried
Returns:
the name of the column at position column in the view where the first column is column 0

getColumnClass

public Class<?> getColumnClass(int column)
Returns the type of the column appearing in the view at column position column.

Specified by:
getColumnClass in interface TableAdapter
Parameters:
column - the column in the view being queried
Returns:
the type of the column at position column in the view where the first column is column 0

getValueAt

public Object getValueAt(int row,
                         int column)
Returns the cell value at 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.

Specified by:
getValueAt in interface TableAdapter
Parameters:
row - the row whose value is to be queried
column - the column whose value is to be queried
Returns:
the Object at the specified cell

setValueAt

public void setValueAt(Object aValue,
                       int row,
                       int column)
Sets the value for the cell in the table model at 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.

aValue is the new value.

Specified by:
setValueAt in interface TableAdapter
Parameters:
aValue - the new value
row - the row of the cell to be changed
column - the column of the cell to be changed
See Also:
getValueAt(int, int)

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Returns true if the cell at row and column is editable. Otherwise, invoking setValueAt on the cell will have no effect.

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.

Specified by:
isCellEditable in interface TableAdapter
Parameters:
row - the row whose value is to be queried
column - the column whose value is to be queried
Returns:
true if the cell is editable
See Also:
setValueAt(java.lang.Object, int, int)

getSelectedRow

public int getSelectedRow()
Returns the index of the first selected row, -1 if no row is selected.

Specified by:
getSelectedRow in interface TableAdapter
Returns:
the index of the first selected row

getSelectedColumn

public int getSelectedColumn()
Returns the index of the first selected column, -1 if no column is selected.

Specified by:
getSelectedColumn in interface TableAdapter
Returns:
the index of the first selected column

getSelectedRows

public int[] getSelectedRows()
Returns the indices of all selected rows.

Specified by:
getSelectedRows in interface TableAdapter
Returns:
an array of integers containing the indices of all selected rows, or an empty array if no row is selected
See Also:
getSelectedRow()

convertColumnIndexToView

public int convertColumnIndexToView(int modelIndex)
Convert the view column index in the entire TableScrollPane to model index.

Parameters:
modelIndex - the model column index
Returns:
the view index

convertColumnIndexToModel

public int convertColumnIndexToModel(int viewIndex)
Convert the view column index in the entire TableScrollPane to model index.

Parameters:
viewIndex - the view column index counting from 0 including row header table, main table and row footer table
Returns:
the model index.

getSelectedColumns

public int[] getSelectedColumns()
Returns the indices of all selected columns.

Specified by:
getSelectedColumns in interface TableAdapter
Returns:
an array of integers containing the indices of all selected columns, or an empty array if no column is selected
See Also:
getSelectedColumn()

getSelectedRowCount

public int getSelectedRowCount()
Returns the number of selected rows.

Specified by:
getSelectedRowCount in interface TableAdapter
Returns:
the number of selected rows, 0 if no rows are selected

getSelectedColumnCount

public int getSelectedColumnCount()
Returns the number of selected columns.

Specified by:
getSelectedColumnCount in interface TableAdapter
Returns:
the number of selected columns, 0 if no columns are selected

isRowSelected

public boolean isRowSelected(int row)
Returns true if the specified index is in the valid range of rows, and the row at that index is selected.

Specified by:
isRowSelected in interface TableAdapter
Parameters:
row - the row index
Returns:
true if row is a valid index and the row at that index is selected (where 0 is the first row)

isColumnSelected

public boolean isColumnSelected(int column)
Returns true if the specified index is in the valid range of columns, and the column at that index is selected.

Specified by:
isColumnSelected in interface TableAdapter
Parameters:
column - the column in the column model
Returns:
true if column is a valid index and the column at that index is selected (where 0 is the first column)

isCellSelected

public 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.

Specified by:
isCellSelected in interface TableAdapter
Parameters:
row - the row being queried
column - the column being queried
Returns:
true if 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 0

clearSelection

public void clearSelection()
Deselects all selected columns and rows.


changeSelection

public void changeSelection(int rowIndex,
                            int columnIndex,
                            boolean toggle,
                            boolean extend)
Description copied from interface: TableAdapter
Updates the selection models of the table, depending on the state of the two flags: toggle and extend. Most changes to the selection that are the result of keyboard or mouse events received by the UI are channeled through this method so that the behavior may be overridden by a subclass. Some UIs may need more functionality than this method provides, such as when manipulating the lead for discontiguous selection, and may not call into this method for some selection changes.

This implementation uses the following conventions:

Specified by:
changeSelection in interface TableAdapter
Parameters:
rowIndex - affects the selection at row
columnIndex - affects the selection at column
toggle - see description above
extend - if true, extend the current selection

JIDE 3.5.15