Package org.zkoss.zul.impl

## Class GroupsListModel<D,​G,​F>

- java.lang.Object
- - org.zkoss.zul.AbstractListModel<java.lang.Object>
  - - org.zkoss.zul.impl.GroupsListModel<D,​G,​F>

- All Implemented Interfaces:
    `java.io.Serializable`, `GroupsSelectableModel<java.lang.Object>`, `Pageable`, `Selectable<java.lang.Object>`, `ListModel<java.lang.Object>`, `PageableModel`

      public class GroupsListModel<D,​G,​F>
      extends AbstractListModel<java.lang.Object>
      implements GroupsSelectableModel<java.lang.Object>

  Encapsulates `GroupsModel` as an instance of `ListModel` such that it is easier to handle by `Listbox` and `Group`.
  Since:
    3.5.0
  Author:
    tomyeh
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `GroupsListModel.GroupDataInfo` | The group information returned by `getDataInfo(int)`.

    - ### Nested classes/interfaces inherited from class org.zkoss.zul.AbstractListModel

      `AbstractListModel.DefaultSelectionControl<E>`

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected GroupsModel<D,​G,​F>` | `_model` |

    - ### Fields inherited from class org.zkoss.zul.AbstractListModel

      `_selection`

    - ### Fields inherited from interface org.zkoss.zul.PageableModel

      `INTERNAL_EVENT`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `GroupsListModel​(GroupsModel<D,​G,​F> model)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `boolean` | `addToSelection​(java.lang.Object obj)` | Add the specified object into selection.
    `void` | `cleanInternalListener()` | Clean up internal listener, it will be called when components changing model.
    `void` | `clearSelection()` | Change the selection to the empty set.
    `java.lang.Object` | `clone()` |
    `boolean` | `equals​(java.lang.Object o)` |
    `GroupingInfo` | `getDataInfo​(int index)` | Returns the group info of given index
    `java.lang.Object` | `getElementAt​(int index)` | Returns the value at the specified index.
    `int` | `getGroupOffset​(int groupIndex)` | Returns the offset from 0 that a group in this ListModel.
    `java.util.List<int[]>` | `getGroupsInfos()` |
    `GroupsModel<D,​G,​F>` | `getGroupsModel()` |
    `java.util.Set<java.lang.Object>` | `getSelection()` | Returns the current selection.
    `SelectionControl` | `getSelectionControl()` | Returns the selection control for the selection model, if any.
    `int` | `getSize()` | Returns the length of the list.
    `int` | `hashCode()` |
    `boolean` | `isGroupSelectable()` | Returns whether the groups are selectable
    `boolean` | `isMultiple()` | Returns whether the current selection mode is multiple.
    `boolean` | `isSelected​(java.lang.Object obj)` | Returns whether an object is selected.
    `boolean` | `isSelectionEmpty()` | Returns true if the selection is currently empty.
    `boolean` | `removeFromSelection​(java.lang.Object obj)` | Remove the specified object from selection.
    `void` | `setGroupSelectable​(boolean groupSelectable)` | Sets the groups are selectable
    `void` | `setMultiple​(boolean multiple)` | Sets the selection mode to be multiple.
    `void` | `setSelection​(java.util.Collection<?> selection)` | Replace the current selection with the given set.
    `void` | `setSelectionControl​(SelectionControl ctrl)` | Sets the selection control for the selection model
    `static <D,​G,​F> GroupsListModel<D,​G,​F>` | `toListModel​(GroupsModel<D,​G,​F> model)` | Returns the list model (`ListModel`) representing the given groups model.
    `java.lang.String` | `toString()` |

    - ### Methods inherited from class org.zkoss.zul.AbstractListModel

      `addListDataListener, addPagingEventListener, fireEvent, fireSelectionEvent, getActivePage, getListDataListeners, getPageCount, getPageSize, getTotalSize, newEmptySelection, readSelection, removeAllSelection, removeListDataListener, removePagingEventListener, retainAllSelection, setActivePage, setPageSize, writeSelection`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### _model

          protected GroupsModel<D,​G,​F> _model

  - ### Constructor Detail

    - #### GroupsListModel

          protected GroupsListModel​(GroupsModel<D,​G,​F> model)

  - ### Method Detail

    - #### toListModel

          public static <D,​G,​F> GroupsListModel<D,​G,​F> toListModel​(GroupsModel<D,​G,​F> model)

      Returns the list model (`ListModel`) representing the given groups model.
      Since:
        6.0.0

    - #### cleanInternalListener

          public void cleanInternalListener()

      Clean up internal listener, it will be called when components changing model.
      Since:
        8.6.0

    - #### getGroupsInfos

          public java.util.List<int[]> getGroupsInfos()

    - #### getGroupOffset

          public int getGroupOffset​(int groupIndex)

      Returns the offset from 0 that a group in this ListModel.

      For example, _gpofs[2] is the offset of group 2 (the third group) in this ListModel.

      Parameters:
        `groupIndex` - the group index
      Returns:
        the offset from 0 that a group in this ListModel.

    - #### getGroupsModel

          public GroupsModel<D,​G,​F> getGroupsModel()

    - #### getDataInfo

          public GroupingInfo getDataInfo​(int index)

      Returns the group info of given index

    - #### equals

          public boolean equals​(java.lang.Object o)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### getElementAt

          public java.lang.Object getElementAt​(int index)

      Description copied from interface: `ListModel`
      Returns the value at the specified index.
      Specified by:
        `getElementAt` in interface `ListModel<D>`

    - #### getSize

          public int getSize()

      Description copied from interface: `ListModel`
      Returns the length of the list.
      Specified by:
        `getSize` in interface `ListModel<D>`

    - #### getSelection

          public java.util.Set<java.lang.Object> getSelection()

      Description copied from class: `AbstractListModel`
      Returns the current selection. It is readonly. Don't modify it directly
      Specified by:
        `getSelection` in interface `Selectable<D>`
      Overrides:
        `getSelection` in class `AbstractListModel<java.lang.Object>`
      Returns:
        the current selection.

    - #### setSelection

          public void setSelection​(java.util.Collection<?> selection)

      Replace the current selection with the given set.

      If this represents a change to the current selection then notify each ListDataListener, including UI.

      Specified by:
        `setSelection` in interface `Selectable<D>`
      Overrides:
        `setSelection` in class `AbstractListModel<java.lang.Object>`

    - #### isSelected

          public boolean isSelected​(java.lang.Object obj)

      Returns whether an object is selected.
      Specified by:
        `isSelected` in interface `Selectable<D>`
      Overrides:
        `isSelected` in class `AbstractListModel<java.lang.Object>`

    - #### isSelectionEmpty

          public boolean isSelectionEmpty()

      Returns true if the selection is currently empty.
      Specified by:
        `isSelectionEmpty` in interface `Selectable<D>`
      Overrides:
        `isSelectionEmpty` in class `AbstractListModel<java.lang.Object>`

    - #### addToSelection

          public boolean addToSelection​(java.lang.Object obj)

      Add the specified object into selection.

      If this represents a change to the current selection then notify each ListDataListener, including UI.

      Specified by:
        `addToSelection` in interface `Selectable<D>`
      Overrides:
        `addToSelection` in class `AbstractListModel<java.lang.Object>`
      Parameters:
        `obj` - the object to be as selection.
      Returns:
        true if it is added successfully; false if `obj` is not part of the data, or was already selected.

    - #### removeFromSelection

          public boolean removeFromSelection​(java.lang.Object obj)

      Remove the specified object from selection.

      If this represents a change to the current selection then notify each ListDataListener, including UI.

      Specified by:
        `removeFromSelection` in interface `Selectable<D>`
      Overrides:
        `removeFromSelection` in class `AbstractListModel<java.lang.Object>`
      Parameters:
        `obj` - the object to be remove from selection.
      Returns:
        whether it is removed successfully

    - #### clearSelection

          public void clearSelection()

      Change the selection to the empty set.

      If this represents a change to the current selection then notify each ListDataListener, including UI.

      Specified by:
        `clearSelection` in interface `Selectable<D>`
      Overrides:
        `clearSelection` in class `AbstractListModel<java.lang.Object>`

    - #### isMultiple

          public boolean isMultiple()

      Returns whether the current selection mode is multiple.
      Specified by:
        `isMultiple` in interface `Selectable<D>`
      Overrides:
        `isMultiple` in class `AbstractListModel<java.lang.Object>`
      See Also:
        `Selectable.setMultiple(boolean)`

    - #### setMultiple

          public void setMultiple​(boolean multiple)

      Sets the selection mode to be multiple.
      Specified by:
        `setMultiple` in interface `Selectable<D>`
      Overrides:
        `setMultiple` in class `AbstractListModel<java.lang.Object>`

    - #### getSelectionControl

          public SelectionControl getSelectionControl()

      Description copied from interface: `Selectable`
      Returns the selection control for the selection model, if any.
      Specified by:
        `getSelectionControl` in interface `Selectable<D>`
      Overrides:
        `getSelectionControl` in class `AbstractListModel<java.lang.Object>`

    - #### setSelectionControl

          public void setSelectionControl​(SelectionControl ctrl)

      Description copied from interface: `Selectable`
      Sets the selection control for the selection model
      Specified by:
        `setSelectionControl` in interface `Selectable<D>`
      Overrides:
        `setSelectionControl` in class `AbstractListModel<java.lang.Object>`

    - #### clone

          public java.lang.Object clone()

      Overrides:
        `clone` in class `AbstractListModel<java.lang.Object>`

    - #### setGroupSelectable

          public void setGroupSelectable​(boolean groupSelectable)

      Description copied from interface: `GroupsSelectableModel`
      Sets the groups are selectable
      Specified by:
        `setGroupSelectable` in interface `GroupsSelectableModel<D>`

    - #### isGroupSelectable

          public boolean isGroupSelectable()

      Description copied from interface: `GroupsSelectableModel`
      Returns whether the groups are selectable
      Specified by:
        `isGroupSelectable` in interface `GroupsSelectableModel<D>`