org.apache.pivot.wtk
Class TableView

java.lang.Object
  extended by org.apache.pivot.wtk.Component
      extended by org.apache.pivot.wtk.TableView
All Implemented Interfaces:
ConstrainedVisual, Visual

public class TableView
extends Component

Component that displays a sequence of items partitioned into columns, optionally allowing a user to select one or more rows.


Nested Class Summary
static interface TableView.CellRenderer
          Table cell renderer interface.
static class TableView.Column
          Contains information about a table column.
 class TableView.ColumnSequence
          Column sequence implementation.
static interface TableView.RowEditor
          Table row editor interface.
static interface TableView.RowEditorListener
          The row editor listener interface.
static class TableView.SelectMode
          Enumeration defining supported selection modes.
static interface TableView.Skin
          Table view skin interface.
 class TableView.SortDictionary
          Sort dictionary implementation.
 
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Component
Component.DecoratorSequence, Component.StyleDictionary, Component.UserDataDictionary
 
Field Summary
static String COLUMN_NAME_KEY
           
static String SORT_DIRECTION_KEY
           
 
Constructor Summary
TableView()
          Creates a new table view populated with an empty array list.
TableView(List<?> tableData)
          Creates a new table view populated with the given table data.
 
Method Summary
 boolean addSelectedIndex(int index)
          Adds a single index to the selection.
 Sequence<Span> addSelectedRange(int start, int end)
          Adds a range of indexes to the selection.
 Sequence<Span> addSelectedRange(Span range)
          Adds a range of indexes to the selection.
 void clearSelection()
          Clears the selection.
 void clearSort()
          Clears the sort.
 Bounds getCellBounds(int rowIndex, int columnIndex)
          Returns the bounding area of a given cell.
 int getColumnAt(int x)
          Returns the index of the column at a given location.
 Bounds getColumnBounds(int columnIndex)
          Returns the bounding area of a given column.
 TableView.ColumnSequence getColumns()
          Returns the table column sequence.
 TableView getColumnSource()
           
 Filter<?> getDisabledRowFilter()
          Returns the disabled row filter.
 int getFirstSelectedIndex()
          Returns the first selected index.
 int getLastSelectedIndex()
          Returns the last selected index.
 int getRowAt(int y)
          Returns the index of the row at a given location.
 Bounds getRowBounds(int rowIndex)
          Returns the bounding area of a given row.
 TableView.RowEditor getRowEditor()
          Returns the editor used to edit rows in this table.
 int getSelectedIndex()
          When in single-select mode, returns the currently selected index.
 Sequence<Span> getSelectedRanges()
          Returns the table's current selection.
 Object getSelectedRow()
           
 Sequence<?> getSelectedRows()
           
 TableView.SelectMode getSelectMode()
          Returns the current selection mode.
 TableView.SortDictionary getSort()
          Returns the table view's sort dictionary.
 List<?> getTableData()
          Returns the table data.
 ListenerList<TableViewColumnListener> getTableViewColumnListeners()
           
 ListenerList<TableViewListener> getTableViewListeners()
           
 ListenerList<TableViewRowListener> getTableViewRowListeners()
           
 ListenerList<TableViewSelectionListener> getTableViewSelectionListeners()
           
 ListenerList<TableViewSortListener> getTableViewSortListeners()
           
 boolean isRowDisabled(int index)
          Returns the disabled state of a given row.
 boolean isRowSelected(int index)
          Returns the selection state of a given index.
 boolean removeSelectedIndex(int index)
          Removes a single index from the selection.
 Sequence<Span> removeSelectedRange(int start, int end)
          Removes a range of indexes from the selection.
 Sequence<Span> removeSelectedRange(Span range)
          Removes a range of indexes from the selection.
 void selectAll()
          Selects all rows in the table.
 void setColumnSource(TableView columnSource)
           
 void setDisabledRowFilter(Filter<?> disabledRowFilter)
          Sets the disabled row filter.
 void setRowEditor(TableView.RowEditor rowEditor)
          Sets the editor used to edit rows in this table.
 void setSelectedIndex(int index)
          Sets the selection to a single index.
 void setSelectedRange(int start, int end)
          Sets the selection to a single range.
 Sequence<Span> setSelectedRanges(Sequence<Span> selectedRanges)
          Sets the selection to the given range sequence.
 Sequence<Span> setSelectedRanges(String selectedRanges)
          Sets the selection to the given range sequence.
 void setSelectMode(String selectMode)
           
 void setSelectMode(TableView.SelectMode selectMode)
          Sets the selection mode.
protected  void setSkin(Skin skin)
          Sets the skin, replacing any previous skin.
 Dictionary<String,SortDirection> setSort(Sequence<Dictionary.Pair<String,SortDirection>> sort)
          Sets the table view's sort.
 Dictionary<String,SortDirection> setSort(String sort)
          Sets the table view's sort.
 Dictionary<String,SortDirection> setSort(String columnName, SortDirection sortDirection)
          Sets the table view's sort.
 void setTableData(List<?> tableData)
          Sets the table data.
 void setTableData(String tableData)
          Sets the table data.
 void setTableData(URL tableData)
          Sets the table data.
 
Methods inherited from class org.apache.pivot.wtk.Component
clear, clearFocus, getAttributes, getAutomationID, getBaseline, getBaseline, getBounds, getComponentClassListeners, getComponentDataListeners, getComponentDecoratorListeners, getComponentKeyListeners, getComponentListeners, getComponentMouseButtonListeners, getComponentMouseListeners, getComponentMouseWheelListeners, getComponentStateListeners, getCursor, getDecoratedBounds, getDecorators, getDisplay, getDragSource, getDropTarget, getFocusedComponent, getGraphics, getHeight, getLocation, getMaximumPreferredHeight, getMaximumPreferredWidth, getMenuHandler, getMinimumPreferredHeight, getMinimumPreferredWidth, getParent, getPreferredHeight, getPreferredHeight, getPreferredHeightLimits, getPreferredSize, getPreferredWidth, getPreferredWidth, getPreferredWidthLimits, getSize, getSkin, getStyles, getTooltipText, getUserData, getVisibleArea, getVisibleArea, getVisibleArea, getWidth, getWindow, getX, getY, installThemeSkin, invalidate, isBlocked, isEnabled, isFocusable, isFocused, isMouseOver, isOpaque, isPreferredHeightSet, isPreferredSizeSet, isPreferredWidthSet, isShowing, isValid, isVisible, keyPressed, keyReleased, keyTyped, layout, load, load, mapPointFromAncestor, mapPointToAncestor, mouseClick, mouseDown, mouseMove, mouseOut, mouseOver, mouseUp, mouseWheel, paint, reenterMouse, repaint, repaint, repaint, repaint, repaint, repaint, requestFocus, scrollAreaToVisible, scrollAreaToVisible, setAttributes, setAutomationID, setCursor, setCursor, setDragSource, setDropTarget, setEnabled, setHeight, setLocation, setLocation, setMaximumPreferredHeight, setMaximumPreferredWidth, setMenuHandler, setMinimumPreferredHeight, setMinimumPreferredWidth, setParent, setPreferredHeight, setPreferredHeightLimits, setPreferredHeightLimits, setPreferredSize, setPreferredSize, setPreferredWidth, setPreferredWidthLimits, setPreferredWidthLimits, setSize, setSize, setStyles, setStyles, setStyles, setTooltipText, setVisible, setWidth, setX, setY, store, store, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COLUMN_NAME_KEY

public static final String COLUMN_NAME_KEY
See Also:
Constant Field Values

SORT_DIRECTION_KEY

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

TableView

public TableView()
Creates a new table view populated with an empty array list.


TableView

public TableView(List<?> tableData)
Creates a new table view populated with the given table data.

Parameters:
tableData -
Method Detail

setSkin

protected void setSkin(Skin skin)
Description copied from class: Component
Sets the skin, replacing any previous skin.

Overrides:
setSkin in class Component
Parameters:
skin - The new skin.

getColumns

public TableView.ColumnSequence getColumns()
Returns the table column sequence.

Returns:
The table column sequence.

getTableData

public List<?> getTableData()
Returns the table data.

Returns:
The data currently presented by the table view.

setTableData

public void setTableData(List<?> tableData)
Sets the table data.

Parameters:
tableData - The data to be presented by the table view.

setTableData

public final void setTableData(String tableData)
Sets the table data.

Parameters:
tableData - A JSON string (must begin with [ and end with ]) denoting the data to be presented by the table view.

setTableData

public void setTableData(URL tableData)
Sets the table data.

Parameters:
tableData - A URL referring to a JSON file containing the data to be presented by the table view.

getColumnSource

public TableView getColumnSource()

setColumnSource

public void setColumnSource(TableView columnSource)

getRowEditor

public TableView.RowEditor getRowEditor()
Returns the editor used to edit rows in this table.

Returns:
The row editor, or null if no editor is installed.

setRowEditor

public void setRowEditor(TableView.RowEditor rowEditor)
Sets the editor used to edit rows in this table.

Parameters:
rowEditor - The row editor for the list.

getSelectedIndex

public int getSelectedIndex()
When in single-select mode, returns the currently selected index.

Returns:
The currently selected index.

setSelectedIndex

public void setSelectedIndex(int index)
Sets the selection to a single index.

Parameters:
index - The index to select, or -1 to clear the selection.

setSelectedRange

public void setSelectedRange(int start,
                             int end)
Sets the selection to a single range.

Parameters:
start -
end -

getSelectedRanges

public Sequence<Span> getSelectedRanges()
Returns the table's current selection.


setSelectedRanges

public Sequence<Span> setSelectedRanges(Sequence<Span> selectedRanges)
Sets the selection to the given range sequence. Any overlapping or connecting ranges will be consolidated, and the resulting selection will be sorted in ascending order.

Parameters:
selectedRanges -
Returns:
The ranges that were actually set.

setSelectedRanges

public final Sequence<Span> setSelectedRanges(String selectedRanges)
Sets the selection to the given range sequence.

Parameters:
selectedRanges - A JSON-formatted string containing the ranges to select.
Returns:
The ranges that were actually set.
See Also:
setSelectedRanges(Sequence)

getFirstSelectedIndex

public int getFirstSelectedIndex()
Returns the first selected index.

Returns:
The first selected index, or -1 if nothing is selected.

getLastSelectedIndex

public int getLastSelectedIndex()
Returns the last selected index.

Returns:
The last selected index, or -1 if nothing is selected.

addSelectedIndex

public boolean addSelectedIndex(int index)
Adds a single index to the selection.

Parameters:
index - The index to add.
Returns:
true if the index was added to the selection; false, otherwise.

addSelectedRange

public Sequence<Span> addSelectedRange(int start,
                                       int end)
Adds a range of indexes to the selection.

Parameters:
start - The first index in the range.
end - The last index in the range.
Returns:
The ranges that were added to the selection.

addSelectedRange

public Sequence<Span> addSelectedRange(Span range)
Adds a range of indexes to the selection.

Parameters:
range - The range to add.
Returns:
The ranges that were added to the selection.

removeSelectedIndex

public boolean removeSelectedIndex(int index)
Removes a single index from the selection.

Parameters:
index - The index to remove.
Returns:
true if the index was removed from the selection; false, otherwise.

removeSelectedRange

public Sequence<Span> removeSelectedRange(int start,
                                          int end)
Removes a range of indexes from the selection.

Parameters:
start - The start of the range to remove.
end - The end of the range to remove.
Returns:
The ranges that were removed from the selection.

removeSelectedRange

public Sequence<Span> removeSelectedRange(Span range)
Removes a range of indexes from the selection.

Parameters:
range - The range to remove.
Returns:
The ranges that were removed from the selection.

selectAll

public void selectAll()
Selects all rows in the table.


clearSelection

public void clearSelection()
Clears the selection.


isRowSelected

public boolean isRowSelected(int index)
Returns the selection state of a given index.

Parameters:
index - The index whose selection state is to be tested.
Returns:
true if the index is selected; false, otherwise.

getSelectedRow

public Object getSelectedRow()

getSelectedRows

public Sequence<?> getSelectedRows()

getSelectMode

public TableView.SelectMode getSelectMode()
Returns the current selection mode.


setSelectMode

public void setSelectMode(TableView.SelectMode selectMode)
Sets the selection mode. Clears the selection if the mode has changed.

Parameters:
selectMode - The new selection mode.

setSelectMode

public void setSelectMode(String selectMode)

getSort

public TableView.SortDictionary getSort()
Returns the table view's sort dictionary.


setSort

public Dictionary<String,SortDirection> setSort(String columnName,
                                                SortDirection sortDirection)
Sets the table view's sort.

Parameters:
columnName -
sortDirection -

setSort

public Dictionary<String,SortDirection> setSort(Sequence<Dictionary.Pair<String,SortDirection>> sort)
Sets the table view's sort.

Parameters:
sort - A sequence of key/value pairs representing the sort. Keys represent column names and values represent sort direction.

setSort

public final Dictionary<String,SortDirection> setSort(String sort)
Sets the table view's sort.

Parameters:
sort - A JSON list containing JSON objects representing the sort.
See Also:
setSort(Sequence)

clearSort

public void clearSort()
Clears the sort.


isRowDisabled

public boolean isRowDisabled(int index)
Returns the disabled state of a given row.

Parameters:
index - The index of the row whose disabled state is to be tested.
Returns:
true if the row is disabled; false, otherwise.

getDisabledRowFilter

public Filter<?> getDisabledRowFilter()
Returns the disabled row filter.

Returns:
The disabled row filter, or null if no disabled row filter is set.

setDisabledRowFilter

public void setDisabledRowFilter(Filter<?> disabledRowFilter)
Sets the disabled row filter.

Parameters:
disabledRowFilter - The disabled row filter, or null for no disabled row filter.

getRowAt

public int getRowAt(int y)
Returns the index of the row at a given location.

Parameters:
y - The y-coordinate of the row to identify.
Returns:
The row index, or -1 if there is no row at the given y-coordinate.

getColumnAt

public int getColumnAt(int x)
Returns the index of the column at a given location.

Parameters:
x - The x-coordinate of the column to identify.
Returns:
The column index, or -1 if there is no column at the given x-coordinate.

getRowBounds

public Bounds getRowBounds(int rowIndex)
Returns the bounding area of a given row.

Parameters:
rowIndex - The row index.
Returns:
The bounding area of the row.

getColumnBounds

public Bounds getColumnBounds(int columnIndex)
Returns the bounding area of a given column.

Parameters:
columnIndex - The column index.
Returns:
The bounding area of the column.

getCellBounds

public Bounds getCellBounds(int rowIndex,
                            int columnIndex)
Returns the bounding area of a given cell.

Parameters:
rowIndex - The row index of the cell.
columnIndex - The column index of the cell.
Returns:
The bounding area of the cell.

getTableViewListeners

public ListenerList<TableViewListener> getTableViewListeners()

getTableViewColumnListeners

public ListenerList<TableViewColumnListener> getTableViewColumnListeners()

getTableViewRowListeners

public ListenerList<TableViewRowListener> getTableViewRowListeners()

getTableViewSelectionListeners

public ListenerList<TableViewSelectionListener> getTableViewSelectionListeners()

getTableViewSortListeners

public ListenerList<TableViewSortListener> getTableViewSortListeners()