pivot.wtk
Class TableView

java.lang.Object
  extended by pivot.wtk.Component
      extended by 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.

Author:
gbrown

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 class TableView.RowComparator
          Compares two rows.
static interface TableView.RowEditor
          Table row editor interface.
static class TableView.SelectMode
          Enumeration defining supported selection modes.
static interface TableView.Skin
          Table view skin interface.
static class TableView.SortHandler
          Default sort handler class.
 
Nested classes/interfaces inherited from class pivot.wtk.Component
Component.Attributes, Component.ComponentDictionary, Component.DecoratorSequence, Component.StyleDictionary, Component.UserDataDictionary
 
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
 void addSelectedIndex(int index)
          Adds a single index to the selection.
 void addSelectedRange(int rangeStart, int rangeEnd)
          Adds a range of indexes to the selection.
 void addSelectedRange(Span range)
          Adds a range of indexes to the selection.
 void clearSelection()
          Clears the selection.
 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.
 Sequence<Integer> getDisabledIndexes()
           
 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<Object> getSelectedRows()
           
 TableView.SelectMode getSelectMode()
          Returns the current selection mode.
 List<?> getTableData()
          Returns the table data.
 ListenerList<TableViewColumnListener> getTableViewColumnListeners()
           
 ListenerList<TableViewListener> getTableViewListeners()
           
 ListenerList<TableViewRowListener> getTableViewRowListeners()
           
 ListenerList<TableViewRowStateListener> getTableViewRowStateListeners()
           
 ListenerList<TableViewSelectionListener> getTableViewSelectionListeners()
           
 boolean isRangeSelected(int rangeStart, int rangeEnd)
          Returns the selection state of a given range.
 boolean isRangeSelected(Span range)
          Returns the selection state of a given range.
 boolean isRowDisabled(int index)
          Returns the disabled state of a given row.
 boolean isRowSelected(int index)
          Returns the selection state of a given index.
 void removeSelectedIndex(int index)
          Removes a single index from the selection.
 void removeSelectedRange(int rangeStart, int rangeEnd)
          Removes a range of indexes from the selection.
 void removeSelectedRange(Span range)
          Removes a range of indexes from the selection.
 void setRowDisabled(int index, boolean disabled)
          Sets the disabled state of a row.
 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 setSelectedRanges(Sequence<Span> selectedRanges)
          Sets the selection to the given span 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.
 void setTableData(List<?> tableData)
          Sets the table data.
 void setTableData(String tableData)
          Sets the table data.
 
Methods inherited from class pivot.wtk.Component
clearFocus, clearFocus, finalize, getAttributes, getBounds, getComponentClassListeners, getComponentDataListeners, getComponentDecoratorListeners, getComponentDragDropListeners, getComponentKeyListeners, getComponentLayoutListeners, getComponentListeners, getComponentMouseButtonListeners, getComponentMouseListeners, getComponentMouseWheelListeners, getComponents, getComponentStateListeners, getCursor, getDecoratedBounds, getDecorators, getDisplay, getDragSource, getDropTarget, getFocusedComponent, getGraphics, getHandle, getHeight, getLocation, getParent, getPreferredHeight, getPreferredHeight, getPreferredSize, getPreferredWidth, getPreferredWidth, getSize, getSkin, getStyles, getTooltipText, getUserData, getVisibleArea, getVisibleArea, getVisibleArea, getWidth, getWindow, getX, getY, installSkin, invalidate, isBlocked, isDisplayable, isEnabled, isFocusable, isFocused, isMouseOver, isOpaque, isPreferredHeightSet, isPreferredSizeSet, isPreferredWidthSet, isShowing, isValid, isVisible, keyPressed, keyReleased, keyTyped, load, load, mapPointFromAncestor, mapPointToAncestor, mouseClick, mouseDown, mouseMove, mouseOut, mouseOver, mouseUp, mouseWheel, paint, repaint, repaint, repaint, repaint, repaint, repaint, requestFocus, requestFocus, scrollAreaToVisible, scrollAreaToVisible, setAttributes, setCursor, setCursor, setDisplayable, setDragSource, setDropTarget, setEnabled, setFocused, setHeight, setLocation, setLocation, setParent, setPreferredHeight, setPreferredSize, setPreferredSize, setPreferredWidth, setSize, setSize, setStyles, setStyles, setStyles, setTooltipText, setVisible, setWidth, setX, setY, store, store, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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. Clears any existing selection state.

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

setTableData

public void setTableData(String tableData)
Sets the table data. Clears any existing selection state.

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

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.

getSelectedRanges

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


setSelectedRanges

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

Parameters:
selectedRanges - The new selection

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 void addSelectedIndex(int index)
Adds a single index to the selection.

Parameters:
index - The index to add.

addSelectedRange

public void addSelectedRange(int rangeStart,
                             int rangeEnd)
Adds a range of indexes to the selection.

Parameters:
rangeStart - The first index in the range.
rangeEnd - The last index in the range.

addSelectedRange

public void addSelectedRange(Span range)
Adds a range of indexes to the selection.

Parameters:
range - The range to add.

removeSelectedIndex

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

Parameters:
index - The index to remove.

removeSelectedRange

public void removeSelectedRange(int rangeStart,
                                int rangeEnd)
Removes a range of indexes from the selection.

Parameters:
rangeStart - The start of the range to remove.
rangeEnd - The end of the range to remove.

removeSelectedRange

public void removeSelectedRange(Span range)
Removes a range of indexes from the selection.

Parameters:
range - The range to remove.

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.

isRangeSelected

public boolean isRangeSelected(int rangeStart,
                               int rangeEnd)
Returns the selection state of a given range.

Parameters:
rangeStart - The first index in the range.
rangeEnd - The last index in the range.
Returns:
true if the entire range is selected; false, otherwise.

isRangeSelected

public boolean isRangeSelected(Span range)
Returns the selection state of a given range.

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

getSelectedRow

public Object getSelectedRow()

getSelectedRows

public Sequence<Object> 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)

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.

setRowDisabled

public void setRowDisabled(int index,
                           boolean disabled)
Sets the disabled state of a row.

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

getDisabledIndexes

public Sequence<Integer> getDisabledIndexes()

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()

getTableViewRowStateListeners

public ListenerList<TableViewRowStateListener> getTableViewRowStateListeners()

getTableViewSelectionListeners

public ListenerList<TableViewSelectionListener> getTableViewSelectionListeners()