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>
EncapsulatesGroupsModelas an instance ofListModelsuch that it is easier to handle byListboxandGroup.- Since:
- 3.5.0
- Author:
- tomyeh
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGroupsListModel.GroupDataInfoThe 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 protectedGroupsListModel(GroupsModel<D,G,F> model)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddToSelection(java.lang.Object obj)Add the specified object into selection.voidcleanInternalListener()Clean up internal listener, it will be called when components changing model.voidclearSelection()Change the selection to the empty set.java.lang.Objectclone()booleanequals(java.lang.Object o)GroupingInfogetDataInfo(int index)Returns the group info of given indexjava.lang.ObjectgetElementAt(int index)Returns the value at the specified index.intgetGroupOffset(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.SelectionControlgetSelectionControl()Returns the selection control for the selection model, if any.intgetSize()Returns the length of the list.inthashCode()booleanisGroupSelectable()Returns whether the groups are selectablebooleanisMultiple()Returns whether the current selection mode is multiple.booleanisSelected(java.lang.Object obj)Returns whether an object is selected.booleanisSelectionEmpty()Returns true if the selection is currently empty.booleanremoveFromSelection(java.lang.Object obj)Remove the specified object from selection.voidsetGroupSelectable(boolean groupSelectable)Sets the groups are selectablevoidsetMultiple(boolean multiple)Sets the selection mode to be multiple.voidsetSelection(java.util.Collection<?> selection)Replace the current selection with the given set.voidsetSelectionControl(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.StringtoString()-
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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getElementAt
public java.lang.Object getElementAt(int index)
Description copied from interface:ListModelReturns the value at the specified index.- Specified by:
getElementAtin interfaceListModel<D>
-
getSize
public int getSize()
Description copied from interface:ListModelReturns the length of the list.
-
getSelection
public java.util.Set<java.lang.Object> getSelection()
Description copied from class:AbstractListModelReturns the current selection. It is readonly. Don't modify it directly- Specified by:
getSelectionin interfaceSelectable<D>- Overrides:
getSelectionin 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:
setSelectionin interfaceSelectable<D>- Overrides:
setSelectionin classAbstractListModel<java.lang.Object>
-
isSelected
public boolean isSelected(java.lang.Object obj)
Returns whether an object is selected.- Specified by:
isSelectedin interfaceSelectable<D>- Overrides:
isSelectedin classAbstractListModel<java.lang.Object>
-
isSelectionEmpty
public boolean isSelectionEmpty()
Returns true if the selection is currently empty.- Specified by:
isSelectionEmptyin interfaceSelectable<D>- Overrides:
isSelectionEmptyin 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:
addToSelectionin interfaceSelectable<D>- Overrides:
addToSelectionin classAbstractListModel<java.lang.Object>- Parameters:
obj- the object to be as selection.- Returns:
- true if it is added successfully; false if
objis 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:
removeFromSelectionin interfaceSelectable<D>- Overrides:
removeFromSelectionin 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:
clearSelectionin interfaceSelectable<D>- Overrides:
clearSelectionin classAbstractListModel<java.lang.Object>
-
isMultiple
public boolean isMultiple()
Returns whether the current selection mode is multiple.- Specified by:
isMultiplein interfaceSelectable<D>- Overrides:
isMultiplein classAbstractListModel<java.lang.Object>- See Also:
Selectable.setMultiple(boolean)
-
setMultiple
public void setMultiple(boolean multiple)
Sets the selection mode to be multiple.- Specified by:
setMultiplein interfaceSelectable<D>- Overrides:
setMultiplein classAbstractListModel<java.lang.Object>
-
getSelectionControl
public SelectionControl getSelectionControl()
Description copied from interface:SelectableReturns the selection control for the selection model, if any.- Specified by:
getSelectionControlin interfaceSelectable<D>- Overrides:
getSelectionControlin classAbstractListModel<java.lang.Object>
-
setSelectionControl
public void setSelectionControl(SelectionControl ctrl)
Description copied from interface:SelectableSets the selection control for the selection model- Specified by:
setSelectionControlin interfaceSelectable<D>- Overrides:
setSelectionControlin classAbstractListModel<java.lang.Object>
-
clone
public java.lang.Object clone()
- Overrides:
clonein classAbstractListModel<java.lang.Object>
-
setGroupSelectable
public void setGroupSelectable(boolean groupSelectable)
Description copied from interface:GroupsSelectableModelSets the groups are selectable- Specified by:
setGroupSelectablein interfaceGroupsSelectableModel<D>
-
isGroupSelectable
public boolean isGroupSelectable()
Description copied from interface:GroupsSelectableModelReturns whether the groups are selectable- Specified by:
isGroupSelectablein interfaceGroupsSelectableModel<D>
-
-