Package org.apache.pivot.wtk
Class TableView
- java.lang.Object
-
- org.apache.pivot.wtk.Component
-
- org.apache.pivot.wtk.TableView
-
- All Implemented Interfaces:
ConstrainedVisual,Visual
@DefaultProperty("tableData") public class TableView extends Component
Component that displays a sequence of rows partitioned into columns, optionally allowing a user to select one or more rows.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceTableView.CellRendererRendererinterface to customize the appearance of a cell in a TableView.static classTableView.ColumnContains information about a table column.classTableView.ColumnSequenceColumn sequence implementation.static interfaceTableView.HeaderDataRendererRendererinterface to customize the appearance of the header of a TableView.static interfaceTableView.RowEditorTable view row editor interface.static interfaceTableView.SelectedRowBindMappingTranslates between selection and bind context data during data binding.static classTableView.SelectModeEnumeration defining supported selection modes.static interfaceTableView.SkinTable view skin interface.classTableView.SortDictionarySort dictionary implementation.static interfaceTableView.TableDataBindMappingTranslates between table and bind context data during data binding.-
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Component
Component.DecoratorSequence, Component.StyleDictionary, Component.UserDataDictionary
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCOLUMN_NAME_KEYstatic java.lang.StringSORT_DIRECTION_KEY
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddSelectedIndex(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.voidclear()Clears any bound values in the component.voidclearSelection()Clears the selection.voidclearSort()Clears the sort.BoundsgetCellBounds(int rowIndex, int columnIndex)Returns the bounding area of a given cell.intgetColumnAt(int x)Returns the index of the column at a given location.BoundsgetColumnBounds(int columnIndex)Returns the bounding area of a given column.TableView.ColumnSequencegetColumns()Returns the table column sequence.TableViewgetColumnSource()Filter<?>getDisabledRowFilter()Returns the disabled row filter.intgetFirstSelectedIndex()Returns the first selected index.intgetLastSelectedIndex()Returns the last selected index.intgetRowAt(int y)Returns the index of the row at a given location.BoundsgetRowBounds(int rowIndex)Returns the bounding area of a given row.TableView.RowEditorgetRowEditor()Returns the editor used to edit rows in this table.intgetSelectedIndex()Returns the currently selected index, even when in multi-select mode.ImmutableList<Span>getSelectedRanges()Returns the currently selected ranges.java.lang.ObjectgetSelectedRow()TableView.SelectedRowBindMappinggetSelectedRowBindMapping()BindTypegetSelectedRowBindType()java.lang.StringgetSelectedRowKey()Sequence<?>getSelectedRows()TableView.SelectedRowBindMappinggetSelectedRowsBindMapping()BindTypegetSelectedRowsBindType()java.lang.StringgetSelectedRowsKey()TableView.SelectModegetSelectMode()TableView.SortDictionarygetSort()List<?>getTableData()Returns the table data.TableView.TableDataBindMappinggetTableDataBindMapping()BindTypegetTableDataBindType()java.lang.StringgetTableDataKey()ListenerList<TableViewBindingListener>getTableViewBindingListeners()ListenerList<TableViewColumnListener>getTableViewColumnListeners()ListenerList<TableViewListener>getTableViewListeners()ListenerList<TableViewRowListener>getTableViewRowListeners()ListenerList<TableViewSelectionListener>getTableViewSelectionListeners()ListenerList<TableViewSortListener>getTableViewSortListeners()booleanisRowDisabled(int index)Returns the disabled state of a given row.booleanisRowSelected(int index)Returns the selection state of a given index.voidload(java.lang.Object context)Copies bound values from the bind context to the component.booleanremoveSelectedIndex(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.voidselectAll()Selects all rows in the table.voidsetColumnSource(TableView columnSource)voidsetDisabledRowFilter(Filter<?> disabledRowFilter)Sets the disabled row filter.voidsetRowEditor(TableView.RowEditor rowEditor)Sets the editor used to edit rows in this table.voidsetSelectedIndex(int index)Sets the selection to a single index.voidsetSelectedRange(int start, int end)Sets the selection to a single range.Sequence<Span>setSelectedRanges(java.lang.String selectedRanges)Sets the selection to the given range sequence.Sequence<Span>setSelectedRanges(Sequence<Span> selectedRanges)Sets the selection to the given range sequence.voidsetSelectedRow(java.lang.Object row)voidsetSelectedRowBindMapping(TableView.SelectedRowBindMapping selectedRowBindMapping)voidsetSelectedRowBindType(BindType selectedRowBindType)voidsetSelectedRowKey(java.lang.String selectedRowKey)voidsetSelectedRows(Sequence<java.lang.Object> rows)voidsetSelectedRowsBindMapping(TableView.SelectedRowBindMapping selectedRowsBindMapping)voidsetSelectedRowsBindType(BindType selectedRowsBindType)voidsetSelectedRowsKey(java.lang.String selectedRowsKey)voidsetSelectMode(TableView.SelectMode selectMode)Sets the selection mode.protected voidsetSkin(Skin skin)Sets the skin, replacing any previous skin.Dictionary<java.lang.String,SortDirection>setSort(java.lang.String sort)Sets the table view's sort.Dictionary<java.lang.String,SortDirection>setSort(java.lang.String columnName, SortDirection sortDirection)Sets the table view's sort.Dictionary<java.lang.String,SortDirection>setSort(Sequence<Dictionary.Pair<java.lang.String,SortDirection>> sort)Sets the table view's sort.voidsetTableData(java.lang.String tableData)Sets the table data.voidsetTableData(java.net.URL tableData)Sets the table data.voidsetTableData(List<?> tableData)Sets the table data.voidsetTableDataBindMapping(TableView.TableDataBindMapping tableDataBindMapping)voidsetTableDataBindType(BindType tableDataBindType)voidsetTableDataKey(java.lang.String tableDataKey)voidstore(java.lang.Object context)Copies bound values from the component to the bind context.-
Methods inherited from class org.apache.pivot.wtk.Component
checkSkin, clearFocus, contains, copyStyle, copyStyle, getAncestor, getAncestor, getAttribute, getAutomationID, getBaseline, getBaseline, getBounds, getComponentClassListeners, getComponentDataListeners, getComponentDecoratorListeners, getComponentKeyListeners, getComponentListeners, getComponentMouseButtonListeners, getComponentMouseListeners, getComponentMouseWheelListeners, getComponentStateListeners, getComponentStyleListeners, getComponentTooltipListeners, getCursor, getDecoratedBounds, getDecorators, getDisplay, getDragSource, getDropTarget, getFocusedComponent, getGraphics, getHeight, getHeightLimits, getLocation, getMaximumHeight, getMaximumWidth, getMenuHandler, getMinimumHeight, getMinimumWidth, getMouseLocation, getName, getNamedStyles, getParent, getPreferredHeight, getPreferredHeight, getPreferredSize, getPreferredWidth, getPreferredWidth, getScreenBounds, getSize, getSkin, getStyle, getStyle, getStyleBoolean, getStyleBoolean, getStyleColor, getStyleColor, getStyleFont, getStyleFont, getStyleInt, getStyleInt, getStyles, getTextInputMethodListener, getTooltipDelay, getTooltipText, getTooltipWrapText, getTypedStyles, getUserData, getVisibleArea, getVisibleArea, getVisibleArea, getWidth, getWidthLimits, getWindow, getX, getY, indexBoundsCheck, installSkin, invalidate, isBlocked, isEnabled, isFocusable, isFocused, isMouseOver, isOpaque, isPreferredHeightSet, isPreferredSizeSet, isPreferredWidthSet, isShowing, isValid, isVisible, keyPressed, keyReleased, keyTyped, layout, mapPointFromAncestor, mapPointFromAncestor, mapPointToAncestor, mapPointToAncestor, mouseClick, mouseDown, mouseMove, mouseOut, mouseOver, mouseUp, mouseWheel, offsetToScreen, paint, putStyle, putStyle, reenterMouse, repaint, repaint, repaint, repaint, repaint, repaint, requestFocus, scrollAreaToVisible, scrollAreaToVisible, setAttribute, setAutomationID, setAutomationID, setCursor, setDragSource, setDropTarget, setEnabled, setFocused, setHeight, setHeightLimits, setHeightLimits, setLocation, setLocation, setMaximumHeight, setMaximumWidth, setMenuHandler, setMinimumHeight, setMinimumWidth, setName, setParent, setPreferredHeight, setPreferredSize, setPreferredSize, setPreferredWidth, setSize, setSize, setStyleName, setStyleNames, setStyleNames, setStyles, setStyles, setTooltipDelay, setTooltipText, setTooltipWrapText, setVisible, setWidth, setWidthLimits, setWidthLimits, setX, setY, toString, transferFocus, validate
-
-
-
-
Field Detail
-
COLUMN_NAME_KEY
public static final java.lang.String COLUMN_NAME_KEY
- See Also:
- Constant Field Values
-
SORT_DIRECTION_KEY
public static final java.lang.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- The initial data for this table view.
-
-
Method Detail
-
setSkin
protected void setSkin(Skin skin)
Description copied from class:ComponentSets the skin, replacing any previous 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(java.lang.String tableData)
Sets the table data.- Parameters:
tableData- A JSON string (must begin with[and end with], denoting a list) which will be the data to be presented by the table view.
-
setTableData
public void setTableData(java.net.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
nullif 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()
Returns the currently selected index, even when in multi-select mode.- 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-1to clear the selection.
-
setSelectedRange
public void setSelectedRange(int start, int end)Sets the selection to a single range.- Parameters:
start- The start of the selection range.end- The end of the range.
-
getSelectedRanges
public ImmutableList<Span> getSelectedRanges()
Returns the currently selected ranges.- Returns:
- An immutable list containing the currently selected ranges. Note that the returned list is a wrapper around the actual selection, not a copy. Any changes made to the selection state will be reflected in the list, but events will not be fired.
-
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- The new sequence of selected ranges.- Returns:
- The ranges that were actually set.
-
setSelectedRanges
public final Sequence<Span> setSelectedRanges(java.lang.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
-1if nothing is selected.
-
getLastSelectedIndex
public int getLastSelectedIndex()
Returns the last selected index.- Returns:
- The last selected index, or
-1if nothing is selected.
-
addSelectedIndex
public boolean addSelectedIndex(int index)
Adds a single index to the selection.- Parameters:
index- The index to add.- Returns:
trueif 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:
trueif 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:
trueif the index is selected;false, otherwise.
-
getSelectedRow
public java.lang.Object getSelectedRow()
-
setSelectedRow
public void setSelectedRow(java.lang.Object row)
-
getSelectedRows
public Sequence<?> getSelectedRows()
-
setSelectedRows
public void setSelectedRows(Sequence<java.lang.Object> rows)
-
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.
-
getSort
public TableView.SortDictionary getSort()
- Returns:
- The table view's sort dictionary.
-
setSort
public Dictionary<java.lang.String,SortDirection> setSort(java.lang.String columnName, SortDirection sortDirection)
Sets the table view's sort.- Parameters:
columnName- The column name to sort on.sortDirection- Whether ascending or descending sort on that column.- Returns:
- The new sort criteria.
-
setSort
public Dictionary<java.lang.String,SortDirection> setSort(Sequence<Dictionary.Pair<java.lang.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.- Returns:
- The new sort criteria.
- Throws:
java.lang.IllegalArgumentException- if the sort parameter isnull.
-
setSort
public final Dictionary<java.lang.String,SortDirection> setSort(java.lang.String sort)
Sets the table view's sort.- Parameters:
sort- A JSON list containing JSON objects representing the sort.- Returns:
- The new sort criteria.
- Throws:
java.lang.IllegalArgumentException- if the sort parameter isnullor can't be parsed from the JSON input.- 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:
trueif the row is disabled;false, otherwise.
-
getDisabledRowFilter
public Filter<?> getDisabledRowFilter()
Returns the disabled row filter.- Returns:
- The disabled row filter, or
nullif no disabled row filter is set.
-
setDisabledRowFilter
public void setDisabledRowFilter(Filter<?> disabledRowFilter)
Sets the disabled row filter.- Parameters:
disabledRowFilter- The disabled row filter, ornullfor no disabled row filter.
-
getTableDataKey
public java.lang.String getTableDataKey()
-
setTableDataKey
public void setTableDataKey(java.lang.String tableDataKey)
-
getTableDataBindType
public BindType getTableDataBindType()
-
setTableDataBindType
public void setTableDataBindType(BindType tableDataBindType)
-
getTableDataBindMapping
public TableView.TableDataBindMapping getTableDataBindMapping()
-
setTableDataBindMapping
public void setTableDataBindMapping(TableView.TableDataBindMapping tableDataBindMapping)
-
getSelectedRowKey
public java.lang.String getSelectedRowKey()
-
setSelectedRowKey
public void setSelectedRowKey(java.lang.String selectedRowKey)
-
getSelectedRowBindType
public BindType getSelectedRowBindType()
-
setSelectedRowBindType
public void setSelectedRowBindType(BindType selectedRowBindType)
-
getSelectedRowBindMapping
public TableView.SelectedRowBindMapping getSelectedRowBindMapping()
-
setSelectedRowBindMapping
public void setSelectedRowBindMapping(TableView.SelectedRowBindMapping selectedRowBindMapping)
-
getSelectedRowsKey
public java.lang.String getSelectedRowsKey()
-
setSelectedRowsKey
public void setSelectedRowsKey(java.lang.String selectedRowsKey)
-
getSelectedRowsBindType
public BindType getSelectedRowsBindType()
-
setSelectedRowsBindType
public void setSelectedRowsBindType(BindType selectedRowsBindType)
-
getSelectedRowsBindMapping
public TableView.SelectedRowBindMapping getSelectedRowsBindMapping()
-
setSelectedRowsBindMapping
public void setSelectedRowsBindMapping(TableView.SelectedRowBindMapping selectedRowsBindMapping)
-
load
public void load(java.lang.Object context)
Description copied from class:ComponentCopies bound values from the bind context to the component. This functionality must be provided by the subclass; the base implementation is a no-op.
-
store
public void store(java.lang.Object context)
Description copied from class:ComponentCopies bound values from the component to the bind context. This functionality must be provided by the subclass; the base implementation is a no-op.
-
clear
public void clear()
Description copied from class:ComponentClears any bound values in the component. This functionality must be provided by the subclass; the base implementation is a no-op.
-
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
-1if 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
-1if 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()
-
getTableViewBindingListeners
public ListenerList<TableViewBindingListener> getTableViewBindingListeners()
-
-