org.apache.pivot.wtk
Class ListButton

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

@DefaultProperty(value="listData")
public class ListButton
extends Button

Component that allows a user to select one of several list options. The options are hidden until the user pushes the button.


Nested Class Summary
static interface ListButton.Skin
          ListButton skin interface.
 
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Button
Button.ButtonDataBindMapping, Button.DataRenderer, Button.SelectedBindMapping, Button.State, Button.StateBindMapping
 
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Component
Component.DecoratorSequence, Component.StyleDictionary, Component.UserDataDictionary
 
Constructor Summary
ListButton()
          Creates an empty list button.
ListButton(List<?> listData)
          Creates a list button with no button data and the given list data.
ListButton(Object buttonData)
          Creates a list button with the given button data and an empty list.
ListButton(Object buttonData, List<?> listData)
          Creates a list button with the given button and list data.
 
Method Summary
 void clear()
          Clears any bound values in the component.
 void clearSelection()
          Clears the selection.
 Filter<?> getDisabledItemFilter()
          Returns the disabled item filter.
 ListView.ItemRenderer getItemRenderer()
          Returns the renderer used to display items in the list.
 ListenerList<ListButtonBindingListener> getListButtonBindingListeners()
          Returns the list button binding listener list.
 ListenerList<ListButtonItemListener> getListButtonItemListeners()
          Returns the list button item listener list.
 ListenerList<ListButtonListener> getListButtonListeners()
          Returns the list button listener list.
 ListenerList<ListButtonSelectionListener> getListButtonSelectionListeners()
          Returns the list button selection listener list.
 List<?> getListData()
          Returns the list data associated with this list button.
 ListView.ListDataBindMapping getListDataBindMapping()
           
 BindType getListDataBindType()
           
 String getListDataKey()
          Returns name of the key that is used in context binding.
 Window getListPopup()
           
 int getListSize()
          Returns the list size.
 int getSelectedIndex()
          Returns the current selection.
 Object getSelectedItem()
           
 ListView.ItemBindMapping getSelectedItemBindMapping()
           
 BindType getSelectedItemBindType()
           
 String getSelectedItemKey()
           
 boolean isItemDisabled(int index)
          Returns an item's disabled state.
 boolean isRepeatable()
          Returns the list button's repeatable flag.
 void load(Object context)
          Copies bound values from the bind context to the component.
 void setDisabledItemFilter(Filter<?> disabledItemFilter)
          Sets the disabled item filter.
 void setItemRenderer(ListView.ItemRenderer itemRenderer)
          Sets the renderer used to display items in the list.
 void setListData(List<?> listData)
          Sets the list button's list data.
 void setListData(String listData)
          Sets the list button's list data.
 void setListData(URL listData)
          Sets the list button's list data.
 void setListDataBindMapping(ListView.ListDataBindMapping listDataBindMapping)
           
 void setListDataBindType(BindType listDataBindType)
           
 void setListDataKey(String listDataKey)
          Set the name of the key that is used in context binding.
 void setListSize(int listSize)
          Sets the list size.
 void setRepeatable(boolean repeatable)
          Sets the list button's repeatable flag.
 void setSelectedIndex(int selectedIndex)
          Sets the selection.
 void setSelectedItem(Object item)
           
 void setSelectedItemBindMapping(ListView.ItemBindMapping selectedItemBindMapping)
           
 void setSelectedItemBindType(BindType selectedItemBindType)
           
 void setSelectedItemKey(String selectedItemKey)
           
protected  void setSkin(Skin skin)
          Sets the skin, replacing any previous skin.
 void setToggleButton(boolean toggleButton)
          Sets the button's toggle state.
 void store(Object context)
          Copies bound values from the component to the bind context.
 
Methods inherited from class org.apache.pivot.wtk.Button
getAction, getButtonBindingListeners, getButtonData, getButtonDataBindMapping, getButtonDataBindType, getButtonDataKey, getButtonGroup, getButtonListeners, getButtonPressListeners, getButtonStateListeners, getDataRenderer, getSelectedBindMapping, getSelectedBindType, getSelectedKey, getState, getStateBindMapping, getStateBindType, getStateKey, isSelected, isToggleButton, isTriState, press, setAction, setAction, setButtonData, setButtonDataBindMapping, setButtonDataBindType, setButtonDataKey, setButtonGroup, setDataRenderer, setEnabled, setSelected, setSelectedBindMapping, setSelectedBindType, setSelectedKey, setState, setStateBindMapping, setStateBindType, setStateKey, setTriState
 
Methods inherited from class org.apache.pivot.wtk.Component
clearFocus, contains, 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, getSize, getSkin, getStyles, 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, paint, reenterMouse, repaint, repaint, repaint, repaint, repaint, repaint, requestFocus, scrollAreaToVisible, scrollAreaToVisible, setAttribute, setAutomationID, setCursor, setDragSource, setDropTarget, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ListButton

public ListButton()
Creates an empty list button.


ListButton

public ListButton(Object buttonData)
Creates a list button with the given button data and an empty list.

Parameters:
buttonData -

ListButton

public ListButton(List<?> listData)
Creates a list button with no button data and the given list data.

Parameters:
listData -

ListButton

public ListButton(Object buttonData,
                  List<?> listData)
Creates a list button with the given button and list data.

Note that the default renderer uses (as last option) the toString method on list elements, so override it to return whatever you want to display in the ListView, or implement your own custom renderer.

Parameters:
buttonData - The button data.
listData - The data to set.
See Also:
ListButtonDataRenderer, ListViewItemRenderer
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.

getListPopup

public Window getListPopup()
Returns:
the popup window associated with this components skin

setToggleButton

public void setToggleButton(boolean toggleButton)
Description copied from class: Button
Sets the button's toggle state.

Overrides:
setToggleButton in class Button
Throws:
UnsupportedOperationException - This method is not supported by ListButton.

getListData

public List<?> getListData()
Returns the list data associated with this list button.

Returns:
The list data.

setListData

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

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

setListData

public final void setListData(String listData)
Sets the list button's list data.

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

setListData

public void setListData(URL listData)
Sets the list button's list data.

Parameters:
listData - A URL referring to a JSON file containing the data to be presented by the list button.

getItemRenderer

public ListView.ItemRenderer getItemRenderer()
Returns the renderer used to display items in the list.

Returns:
The item renderer instance.

setItemRenderer

public void setItemRenderer(ListView.ItemRenderer itemRenderer)
Sets the renderer used to display items in the list.

Use Button.setDataRenderer(org.apache.pivot.wtk.Button.DataRenderer) to define the renderer used to draw the button data.

Parameters:
itemRenderer - The item renderer instance.

isRepeatable

public boolean isRepeatable()
Returns the list button's repeatable flag.


setRepeatable

public void setRepeatable(boolean repeatable)
Sets the list button's repeatable flag.

Parameters:
repeatable -

getSelectedIndex

public int getSelectedIndex()
Returns the current selection.

Returns:
The index of the currently selected list item, or -1 if nothing is selected.

setSelectedIndex

public void setSelectedIndex(int selectedIndex)
Sets the selection.

Parameters:
selectedIndex - The index of the list item to select, or -1 to clear the selection.

getSelectedItem

public Object getSelectedItem()

setSelectedItem

public void setSelectedItem(Object item)

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.

getListSize

public int getListSize()
Returns the list size.


setListSize

public void setListSize(int listSize)
Sets the list size. If the number of items in the list exceeds this value, the list will scroll.

Parameters:
listSize -

getListDataKey

public String getListDataKey()
Returns name of the key that is used in context binding.

Returns:
The key.

setListDataKey

public void setListDataKey(String listDataKey)
Set the name of the key that is used in context binding.

Parameters:
listDataKey - The key to set.

getListDataBindType

public BindType getListDataBindType()

setListDataBindType

public void setListDataBindType(BindType listDataBindType)

getListDataBindMapping

public ListView.ListDataBindMapping getListDataBindMapping()

setListDataBindMapping

public void setListDataBindMapping(ListView.ListDataBindMapping listDataBindMapping)

getSelectedItemKey

public String getSelectedItemKey()

setSelectedItemKey

public void setSelectedItemKey(String selectedItemKey)

getSelectedItemBindType

public BindType getSelectedItemBindType()

setSelectedItemBindType

public void setSelectedItemBindType(BindType selectedItemBindType)

getSelectedItemBindMapping

public ListView.ItemBindMapping getSelectedItemBindMapping()

setSelectedItemBindMapping

public void setSelectedItemBindMapping(ListView.ItemBindMapping selectedItemBindMapping)

load

public void load(Object 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 Button

store

public void store(Object 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 Button

clear

public void clear()
Description copied from class: Component
Clears any bound values in the component.

Overrides:
clear in class Button

clearSelection

public void clearSelection()
Clears the selection.


getListButtonListeners

public ListenerList<ListButtonListener> getListButtonListeners()
Returns the list button listener list.


getListButtonItemListeners

public ListenerList<ListButtonItemListener> getListButtonItemListeners()
Returns the list button item listener list.


getListButtonSelectionListeners

public ListenerList<ListButtonSelectionListener> getListButtonSelectionListeners()
Returns the list button selection listener list.


getListButtonBindingListeners

public ListenerList<ListButtonBindingListener> getListButtonBindingListeners()
Returns the list button binding listener list.