Class AbstractListModel<E>
- All Implemented Interfaces:
Serializable,Pageable,Selectable<E>,ListModel<E>,PageableModel
- Direct Known Subclasses:
GroupsListModel,ListModelArray,ListModelList,ListModelMap,ListModelSet,SimpleListModel
ListModel and Selectable- Author:
- tomyeh
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA default selection control implementation forAbstractListModel, by default it assumes all elements are selectable. -
Field Summary
FieldsFields inherited from interface org.zkoss.zul.PageableModel
INTERNAL_EVENT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener to the list that's notified each time a change to the data model occurs.voidAdds a listener to the list of listeners to be notified when a PagingEvent happens outside of standard Paging componentbooleanaddToSelection(E obj) Add the specified object into selection.voidChange the selection to the empty set.clone()protected voidfireEvent(int type, int index0, int index1) Fires aListDataEventfor all registered listener (thruaddListDataListener(org.zkoss.zul.event.ListDataListener).protected voidSelectable's implementor use only.intReturns the active page (starting from 0).Returns all listeners.intReturns the number of pages.intReturns the number of items per page.Returns the current selection.Returns the selection control for the selection model, if any.intReturns the total number of items.booleanReturns whether the current selection mode is multiple.booleanisSelected(Object obj) Returns whether an object is selected.booleanReturns true if the selection is currently empty.Instantiation an empty set of the section.protected voidReads back_selection.protected voidremoveAllSelection(Collection<?> c) Removes the selection of the given collection.booleanRemove the specified object from selection.voidRemoves a listener from the list that's notified each time a change to the data model occurs.voidRemoves a listener from the list of listeners to be notified when a PagingEvent happens outside of standard Paging componentprotected voidretainAllSelection(Collection<?> c) Removes the selection that doesn't belong to the given collection.voidsetActivePage(int pg) Sets the active page (starting from 0).voidsetMultiple(boolean multiple) Sets the selection mode to be multiple.voidsetPageSize(int size) Sets the number of items per page.voidsetSelection(Collection<? extends E> selection) Replace the current selection with the given set.voidSets the selection control for the selection modelprotected voidWrites_selection.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.zkoss.zul.ListModel
getElementAt, getSize
-
Field Details
-
_selection
The current selection.
-
-
Constructor Details
-
AbstractListModel
protected AbstractListModel()
-
-
Method Details
-
getListDataListeners
Description copied from interface:ListModelReturns all listeners.- Specified by:
getListDataListenersin interfaceListModel<E>
-
fireEvent
protected void fireEvent(int type, int index0, int index1) Fires aListDataEventfor all registered listener (thruaddListDataListener(org.zkoss.zul.event.ListDataListener).Note: you can invoke this method only in an event listener.
-
addListDataListener
Adds a listener to the list that's notified each time a change to the data model occurs.- Specified by:
addListDataListenerin interfaceListModel<E>
-
removeListDataListener
Removes a listener from the list that's notified each time a change to the data model occurs.- Specified by:
removeListDataListenerin interfaceListModel<E>
-
getSelection
Returns the current selection. It is readonly. Don't modify it directly- Specified by:
getSelectionin interfaceSelectable<E>- Returns:
- the current selection.
-
setSelection
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<E>
-
isSelected
Returns whether an object is selected.- Specified by:
isSelectedin interfaceSelectable<E>
-
isSelectionEmpty
public boolean isSelectionEmpty()Returns true if the selection is currently empty.- Specified by:
isSelectionEmptyin interfaceSelectable<E>
-
addToSelection
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<E>- 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
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<E>- 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<E>
-
fireSelectionEvent
Selectable's implementor use only.Fires a selection event for component to scroll into view. The override subclass must put the index0 of
fireEvent(int, int, int)as the view index to scroll. By default, the value -1 is assumed which means no scroll into view.The method is invoked when both methods are invoked.
addToSelection(Object)andsetSelection(Collection).- Parameters:
e- selected object.
-
removeAllSelection
Removes the selection of the given collection. -
retainAllSelection
Removes the selection that doesn't belong to the given collection. -
isMultiple
public boolean isMultiple()Returns whether the current selection mode is multiple.- Specified by:
isMultiplein interfaceSelectable<E>- See Also:
-
setMultiple
public void setMultiple(boolean multiple) Sets the selection mode to be multiple.- Specified by:
setMultiplein interfaceSelectable<E>
-
setSelectionControl
Description copied from interface:SelectableSets the selection control for the selection model- Specified by:
setSelectionControlin interfaceSelectable<E>
-
getSelectionControl
Description copied from interface:SelectableReturns the selection control for the selection model, if any.- Specified by:
getSelectionControlin interfaceSelectable<E>
-
newEmptySelection
Instantiation an empty set of the section. It is used to initialize_selection.By default, it instantiates an instance of LinkedHashSet. The deriving class might override to instantiate a different class.
-
writeSelection
Writes_selection.Default: write it directly. Override it if E is not serializable.
- Throws:
IOException
-
readSelection
Reads back_selection.Default: write it directly. Override it if E is not serializable.
- Throws:
IOExceptionClassNotFoundException
-
clone
-
getPageSize
public int getPageSize()Description copied from interface:PageableReturns the number of items per page.Default: 20.
- Specified by:
getPageSizein interfacePageable
-
getTotalSize
public int getTotalSize()Description copied from interface:PageableModelReturns the total number of items.- Specified by:
getTotalSizein interfacePageableModel
-
setPageSize
public void setPageSize(int size) throws org.zkoss.zk.ui.WrongValueException Description copied from interface:PageableSets the number of items per page.- Specified by:
setPageSizein interfacePageable- Throws:
org.zkoss.zk.ui.WrongValueException
-
getPageCount
public int getPageCount()Description copied from interface:PageableReturns the number of pages. Note: there is at least one page even no item at all.- Specified by:
getPageCountin interfacePageable
-
getActivePage
public int getActivePage()Description copied from interface:PageableReturns the active page (starting from 0).- Specified by:
getActivePagein interfacePageable
-
setActivePage
public void setActivePage(int pg) throws org.zkoss.zk.ui.WrongValueException Description copied from interface:PageableSets the active page (starting from 0).- Specified by:
setActivePagein interfacePageable- Throws:
org.zkoss.zk.ui.WrongValueException
-
addPagingEventListener
Description copied from interface:PageableModelAdds a listener to the list of listeners to be notified when a PagingEvent happens outside of standard Paging component- Specified by:
addPagingEventListenerin interfacePageableModel
-
removePagingEventListener
Description copied from interface:PageableModelRemoves a listener from the list of listeners to be notified when a PagingEvent happens outside of standard Paging component- Specified by:
removePagingEventListenerin interfacePageableModel
-