Class ListButton

  • All Implemented Interfaces:
    ConstrainedVisual, Visual

    @DefaultProperty("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.
    • Constructor Detail

      • ListButton

        public ListButton()
        Creates an empty list button.
      • ListButton

        public ListButton​(java.lang.Object buttonData)
        Creates a list button with the given button data and an empty list.
        Parameters:
        buttonData - The button data (that is text and/or icon) for the list button.
      • ListButton

        public ListButton​(List<?> listData)
        Creates a list button with no button data and the given list data.
        Parameters:
        listData - The initial list data for the list button.
      • ListButton

        public ListButton​(java.lang.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
        Parameters:
        toggleButton - Whether or not this should be a toggle button.
        Throws:
        java.lang.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​(java.lang.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.
        Throws:
        java.lang.IllegalArgumentException - if the data string is null or cannot be propertly parsed into a list.
      • setListData

        public void setListData​(java.net.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.
        Throws:
        java.lang.IllegalArgumentException - if the URL is null or the URL data stream cannot be propertly parsed into a list.
      • getItemRenderer

        public ListView.ItemRenderer getItemRenderer()
        Returns the renderer used to display items in the list.
        Returns:
        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 - Whether this list button's action is repeatable (that is, the action can be triggered even if the selection is unchanged).
      • 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 java.lang.Object getSelectedItem()
      • setSelectedItem

        public void setSelectedItem​(java.lang.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 - The number of visible items in the list.
        Throws:
        java.lang.IllegalArgumentException - if the specified size is negative.
      • getListDataKey

        public java.lang.String getListDataKey()
        Returns name of the key that is used in context binding.
        Returns:
        The key.
      • setListDataKey

        public void setListDataKey​(java.lang.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)
      • getSelectedItemKey

        public java.lang.String getSelectedItemKey()
      • setSelectedItemKey

        public void setSelectedItemKey​(java.lang.String selectedItemKey)
      • getSelectedItemBindType

        public BindType getSelectedItemBindType()
      • setSelectedItemBindType

        public void setSelectedItemBindType​(BindType selectedItemBindType)
      • setSelectedItemBindMapping

        public void setSelectedItemBindMapping​(ListView.ItemBindMapping selectedItemBindMapping)
      • load

        public void load​(java.lang.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
        Parameters:
        context - The object to load the bound values from.
      • store

        public void store​(java.lang.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
        Parameters:
        context - The object to store the bound values into.
      • clear

        public void clear()
        Description copied from class: Component
        Clears any bound values in the component. This functionality must be provided by the subclass; the base implementation is a no-op.
        Overrides:
        clear in class Button
      • clearSelection

        public void clearSelection()
        Clears the selection.