Class IChosenboxController<Data>

  • All Implemented Interfaces:
    ItemController<Data,​ListModel<Data>,​IChosenbox,​java.lang.String>

    public class IChosenboxController<Data>
    extends java.lang.Object
    implements ItemController<Data,​ListModel<Data>,​IChosenbox,​java.lang.String>
    An IChosenbox controller to control any operation on the given model.

    Note: this class is not thread-safe, so when it's used in multi-threading environment, the developer should handle the threading issue.

    Author:
    katherine
    • Method Detail

      • of

        public static <D> IChosenboxController<D> of​(IChosenbox owner,
                                                     ListModel<D> model)
        Returns the controller instance with the given chosenbox
        Parameters:
        owner - The controller to control with
        model - The list model to associate with the chosenbox.
      • of

        public static <D> IChosenboxController<D> of​(IChosenbox owner,
                                                     ListModel<D> model,
                                                     CheckedFunction2<D,​java.lang.Integer,​java.lang.String> renderer)
        Returns the controller instance with the given chosenbox
        Parameters:
        owner - The controller to control with
        model - The list model to associate with the chosenbox.
      • getSelectedIndex

        public int getSelectedIndex()
        Returns the index of the selected item (-1 if no one is selected).
      • setSelectedIndex

        public void setSelectedIndex​(int jsel)
        Sets the index of the selected item (-1 if no one is selected). If model already exists, it will update the selection of model.
        Parameters:
        jsel - the index to select.
      • getSelectedObjects

        public <T> java.util.Set<T> getSelectedObjects()
        Returns the selected objects.
      • setSelectedObjects

        public void setSelectedObjects​(java.util.Collection<Data> objects)
        Sets the selected objects.
        Parameters:
        objects - the objects to select.
      • clearSelection

        public void clearSelection()
        Clear all selected objects.
      • addItemToSelection

        public void addItemToSelection​(java.lang.Object o)
        Add an item into selection.
        Parameters:
        o - the object to add.
      • removeItemFromSelection

        public void removeItemFromSelection​(java.lang.Object o)
        Remove an item from selection.
        Parameters:
        o - the object to remove.