org.apache.pivot.wtk
Class ListView

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

public class ListView
extends Component

Component that displays a sequence of items, optionally allowing a user to select or check one or more items.


Nested Class Summary
static interface ListView.ItemEditor
          List item editor interface.
static interface ListView.ItemRenderer
          List item renderer interface.
static class ListView.SelectMode
          Enumeration defining supported selection modes.
static interface ListView.Skin
          List view skin interface.
 
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Component
Component.ComponentDictionary, Component.DecoratorSequence, Component.StyleDictionary, Component.UserDataDictionary
 
Constructor Summary
ListView()
          Creates a list view populated with an empty array list.
ListView(List<?> listData)
          Creates a list view populated with the given list 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.
 Sequence<Integer> getCheckedIndexes()
          Returns the indexes of currently checked items.
 boolean getCheckmarksEnabled()
          Returns the current check mode.
 Filter<?> getDisabledItemFilter()
          Returns the disabled item filter.
 int getFirstSelectedIndex()
          Returns the first selected index.
 int getItemAt(int y)
          Returns the index of the item at a given location.
 Bounds getItemBounds(int index)
          Returns the bounding area of a given item.
 ListView.ItemEditor getItemEditor()
          Returns the editor used to edit items in this list.
 int getItemIndent()
          Returns the item indent.
 ListView.ItemRenderer getItemRenderer()
          Returns the item renderer used for items in this list.
 int getLastSelectedIndex()
          Returns the last selected index.
 List<?> getListData()
          Returns the list data.
 ListenerList<ListViewItemListener> getListViewItemListeners()
          Returns the list view item listener list.
 ListenerList<ListViewItemStateListener> getListViewItemStateListeners()
          Returns the list view item state listener list.
 ListenerList<ListViewListener> getListViewListeners()
          Returns the list view listener list.
 ListenerList<ListViewSelectionListener> getListViewSelectionListeners()
          Returns the list view selection detail listener list.
 int getSelectedIndex()
          When in single-select mode, returns the currently selected index.
 Object getSelectedItem()
           
 String getSelectedItemKey()
           
 Sequence<?> getSelectedItems()
           
 String getSelectedItemsKey()
           
 Sequence<Span> getSelectedRanges()
          Returns the list's current selection.
 ListView.SelectMode getSelectMode()
          Returns the current selection mode.
 boolean isItemChecked(int index)
          Returns an item's checked state.
 boolean isItemDisabled(int index)
          Returns an item's disabled state.
 boolean isItemSelected(int index)
          Returns the selection state of a given index.
 void load(Dictionary<String,?> context)
          Copies bound values from the bind context to the component.
 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 items in the list.
 void setCheckmarksEnabled(boolean checkmarksEnabled)
          Enables or disabled checkmarks.
 void setDisabledItemFilter(Filter<?> disabledItemFilter)
          Sets the disabled item filter.
 void setItemChecked(int index, boolean checked)
          Sets an item's checked state.
 void setItemEditor(ListView.ItemEditor itemEditor)
          Sets the editor used to edit items in this list.
 void setItemRenderer(ListView.ItemRenderer itemRenderer)
          Sets the item renderer to be used for items in this list.
 void setListData(List<?> listData)
          Sets the list data.
 void setListData(String listData)
          Sets the list data.
 void setSelectedIndex(int index)
          Sets the selection to a single index.
 void setSelectedItem(Object item)
           
 void setSelectedItemKey(String selectedItemKey)
           
 void setSelectedItems(Sequence<Object> items)
           
 void setSelectedItemsKey(String selectedItemsKey)
           
 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(ListView.SelectMode selectMode)
          Sets the selection mode.
 void setSelectMode(String selectMode)
          Sets the selection mode.
protected  void setSkin(Skin skin)
          Sets the skin, replacing any previous skin.
 void store(Dictionary<String,?> context)
          Copies bound values from the component to the bind context.
 
Methods inherited from class org.apache.pivot.wtk.Component
clearFocus, getAttributes, getBounds, getComponentClassListeners, getComponentDataListeners, getComponentDecoratorListeners, getComponentKeyListeners, getComponentListeners, getComponentMouseButtonListeners, getComponentMouseListeners, getComponentMouseWheelListeners, getComponents, getComponentStateListeners, getCursor, getDecoratedBounds, getDecorators, getDisplay, getDragSource, getDropTarget, getFocusedComponent, getGraphics, getHandle, 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, installSkin, invalidate, isBlocked, isEnabled, isFocusable, isFocused, isMouseOver, isOpaque, isPreferredHeightSet, isPreferredSizeSet, isPreferredWidthSet, isShowing, isValid, isVisible, keyPressed, keyReleased, keyTyped, load, mapPointFromAncestor, mapPointToAncestor, mouseClick, mouseDown, mouseMove, mouseOut, mouseOver, mouseUp, mouseWheel, paint, repaint, repaint, repaint, repaint, repaint, repaint, requestFocus, scrollAreaToVisible, scrollAreaToVisible, setAttributes, 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, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ListView

public ListView()
Creates a list view populated with an empty array list.


ListView

public ListView(List<?> listData)
Creates a list view populated with the given list data.

Parameters:
listData -
Method Detail

getListData

public List<?> getListData()
Returns the list data.

Returns:
The data currently presented by the list view.

setListData

public void setListData(List<?> listData)
Sets the list data.

Parameters:
listData - The data to be presented by the list view.

setListData

public void setListData(String listData)
Sets the list data.

Parameters:
listData - The data to be presented by the list view as a JSON array.

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.

getItemRenderer

public ListView.ItemRenderer getItemRenderer()
Returns the item renderer used for items in this list.


setItemRenderer

public void setItemRenderer(ListView.ItemRenderer itemRenderer)
Sets the item renderer to be used for items in this list.

Parameters:
itemRenderer - The item renderer for the list.

getItemEditor

public ListView.ItemEditor getItemEditor()
Returns the editor used to edit items in this list.

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

setItemEditor

public void setItemEditor(ListView.ItemEditor itemEditor)
Sets the editor used to edit items in this list.

Parameters:
itemEditor - The item 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 list'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 items in the list.


clearSelection

public void clearSelection()
Clears the selection.


isItemSelected

public boolean isItemSelected(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.

getSelectedItem

public Object getSelectedItem()

setSelectedItem

public void setSelectedItem(Object item)

getSelectedItems

public Sequence<?> getSelectedItems()

setSelectedItems

public void setSelectedItems(Sequence<Object> items)

getSelectMode

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


setSelectMode

public void setSelectMode(ListView.SelectMode selectMode)
Sets the selection mode. Clears the selection if the mode has changed (but does not fire a selection change event).

Parameters:
selectMode - The new selection mode.

setSelectMode

public void setSelectMode(String selectMode)
Sets the selection mode.

Parameters:
selectMode -
See Also:
setSelectMode(org.apache.pivot.wtk.ListView.SelectMode)

getCheckmarksEnabled

public boolean getCheckmarksEnabled()
Returns the current check mode.


setCheckmarksEnabled

public void setCheckmarksEnabled(boolean checkmarksEnabled)
Enables or disabled checkmarks. Clears the check state if the check mode has changed (but does not fire any check state change events).

Parameters:
checkmarksEnabled -

isItemChecked

public boolean isItemChecked(int index)
Returns an item's checked state.

Parameters:
index -

setItemChecked

public void setItemChecked(int index,
                           boolean checked)
Sets an item's checked state.

Parameters:
index -
checked -

getCheckedIndexes

public Sequence<Integer> getCheckedIndexes()
Returns the indexes of currently checked items.


isItemDisabled

public boolean isItemDisabled(int index)
Returns an item's disabled state.

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

getDisabledItemFilter

public Filter<?> getDisabledItemFilter()
Returns the disabled item filter.

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

setDisabledItemFilter

public void setDisabledItemFilter(Filter<?> disabledItemFilter)
Sets the disabled item filter.

Parameters:
disabledItemFilter - The disabled item filter, or null for no disabled item filter.

getSelectedItemKey

public String getSelectedItemKey()

setSelectedItemKey

public void setSelectedItemKey(String selectedItemKey)

getSelectedItemsKey

public String getSelectedItemsKey()

setSelectedItemsKey

public void setSelectedItemsKey(String selectedItemsKey)

load

public void load(Dictionary<String,?> context)
Description copied from class: Component
Copies bound values from the bind context to the component. This functionality must be provided by the subclass; the base implementation is a no-op.

Overrides:
load in class Component

store

public void store(Dictionary<String,?> context)
Description copied from class: Component
Copies bound values from the component to the bind context. This functionality must be provided by the subclass; the base implementation is a no-op.

Overrides:
store in class Component

getItemAt

public int getItemAt(int y)
Returns the index of the item at a given location.

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

getItemBounds

public Bounds getItemBounds(int index)
Returns the bounding area of a given item.

Parameters:
index - The item index.
Returns:
The bounding area of the item.

getItemIndent

public int getItemIndent()
Returns the item indent.

Returns:
The horizontal space preceding items in the list.

getListViewListeners

public ListenerList<ListViewListener> getListViewListeners()
Returns the list view listener list.


getListViewItemListeners

public ListenerList<ListViewItemListener> getListViewItemListeners()
Returns the list view item listener list.


getListViewItemStateListeners

public ListenerList<ListViewItemStateListener> getListViewItemStateListeners()
Returns the list view item state listener list.


getListViewSelectionListeners

public ListenerList<ListViewSelectionListener> getListViewSelectionListeners()
Returns the list view selection detail listener list.