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>
EncapsulatesGroupsModel
as an instance ofListModel
such that it is easier to handle byListbox
andGroup
.- 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 bygetDataInfo(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 indexjava.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 selectableboolean
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 selectablevoid
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 modelstatic <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
-
-
-
-
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 classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.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 interfaceListModel<D>
-
getSize
public int getSize()
Description copied from interface:ListModel
Returns the length of the list.
-
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 interfaceSelectable<D>
- Overrides:
getSelection
in classAbstractListModel<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 interfaceSelectable<D>
- Overrides:
setSelection
in classAbstractListModel<java.lang.Object>
-
isSelected
public boolean isSelected(java.lang.Object obj)
Returns whether an object is selected.- Specified by:
isSelected
in interfaceSelectable<D>
- Overrides:
isSelected
in classAbstractListModel<java.lang.Object>
-
isSelectionEmpty
public boolean isSelectionEmpty()
Returns true if the selection is currently empty.- Specified by:
isSelectionEmpty
in interfaceSelectable<D>
- Overrides:
isSelectionEmpty
in classAbstractListModel<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 interfaceSelectable<D>
- Overrides:
addToSelection
in classAbstractListModel<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 interfaceSelectable<D>
- Overrides:
removeFromSelection
in classAbstractListModel<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 interfaceSelectable<D>
- Overrides:
clearSelection
in classAbstractListModel<java.lang.Object>
-
isMultiple
public boolean isMultiple()
Returns whether the current selection mode is multiple.- Specified by:
isMultiple
in interfaceSelectable<D>
- Overrides:
isMultiple
in classAbstractListModel<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 interfaceSelectable<D>
- Overrides:
setMultiple
in classAbstractListModel<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 interfaceSelectable<D>
- Overrides:
getSelectionControl
in classAbstractListModel<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 interfaceSelectable<D>
- Overrides:
setSelectionControl
in classAbstractListModel<java.lang.Object>
-
clone
public java.lang.Object clone()
- Overrides:
clone
in classAbstractListModel<java.lang.Object>
-
setGroupSelectable
public void setGroupSelectable(boolean groupSelectable)
Description copied from interface:GroupsSelectableModel
Sets the groups are selectable- Specified by:
setGroupSelectable
in interfaceGroupsSelectableModel<D>
-
isGroupSelectable
public boolean isGroupSelectable()
Description copied from interface:GroupsSelectableModel
Returns whether the groups are selectable- Specified by:
isGroupSelectable
in interfaceGroupsSelectableModel<D>
-
-