Class AbstractGroupsModel<D,H,F,E>
- All Implemented Interfaces:
Serializable,GroupsSelectableModel<E>,Selectable<E>,GroupsModel<D,H, F>
- Direct Known Subclasses:
GroupsModelArray,SimpleGroupsModel
GroupsModel.
Implements Selectable interface to handle the selection status.
(Since 6.0.0)
Generics:
- D
- The class of each data
- H
- The class of each group header
- F
- The class of each group footer
- E
- The class of each selection. It is the common base class of D, H, F. In other words, D, H and F must extend from E.
- Since:
- 3.5.0
- Author:
- tomyeh
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA default selection control implementation forAbstractGroupsModel, by default it assumes all elements are selectable. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener to the groups that's notified each time a change to the data model occurs.booleanaddToSelection(E obj) Add the specified object into selection.voidChange the selection to the empty set.clone()protected voidfireEvent(int type, int groupIndex, int index0, int index1) Fires aGroupsDataEventfor all registered listener (thruaddGroupsDataListener(org.zkoss.zul.event.GroupsDataListener).protected voidSelectable's implementor use only.Returns the current selection.Returns the selection control for the selection model, if any.booleanReturns whether the groups are selectablebooleanReturns 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 groups that's notified each time a change to the data model occurs.protected voidretainAllSelection(Collection<?> c) Removes the selection that doesn't belong to the given collection.voidsetGroupSelectable(boolean groupSelectable) Sets the groups are selectablevoidsetMultiple(boolean multiple) Sets the selection mode to be multiple.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.GroupsModel
addOpenGroup, getChild, getChildCount, getGroup, getGroupCount, getGroupfoot, hasGroupfoot, isGroupOpened, removeOpenGroup
-
Field Details
-
_selection
The current selection.
-
-
Constructor Details
-
AbstractGroupsModel
protected AbstractGroupsModel()
-
-
Method Details
-
fireEvent
protected void fireEvent(int type, int groupIndex, int index0, int index1) Fires aGroupsDataEventfor all registered listener (thruaddGroupsDataListener(org.zkoss.zul.event.GroupsDataListener).Note: you can invoke this method only in an event listener.
-
setSelectionControl
Description copied from interface:SelectableSets the selection control for the selection model- Specified by:
setSelectionControlin interfaceSelectable<D>
-
getSelectionControl
Description copied from interface:SelectableReturns the selection control for the selection model, if any.- Specified by:
getSelectionControlin interfaceSelectable<D>
-
addGroupsDataListener
Description copied from interface:GroupsModelAdds a listener to the groups that's notified each time a change to the data model occurs.- Specified by:
addGroupsDataListenerin interfaceGroupsModel<D,H, F>
-
removeGroupsDataListener
Description copied from interface:GroupsModelRemoves a listener from the groups that's notified each time a change to the data model occurs.- Specified by:
removeGroupsDataListenerin interfaceGroupsModel<D,H, F>
-
getSelection
Returns the current selection. It is readonly. Don't modify it directly- Specified by:
getSelectionin interfaceSelectable<D>- 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<D>
-
isSelected
Returns whether an object is selected.- Specified by:
isSelectedin interfaceSelectable<D>
-
isSelectionEmpty
public boolean isSelectionEmpty()Returns true if the selection is currently empty.- Specified by:
isSelectionEmptyin interfaceSelectable<D>
-
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<D>- 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<D>- 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>
-
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, 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<D>- See Also:
-
setMultiple
public void setMultiple(boolean multiple) Sets the selection mode to be multiple.- Specified by:
setMultiplein interfaceSelectable<D>
-
isGroupSelectable
public boolean isGroupSelectable()Description copied from interface:GroupsSelectableModelReturns whether the groups are selectable- Specified by:
isGroupSelectablein interfaceGroupsSelectableModel<D>
-
setGroupSelectable
public void setGroupSelectable(boolean groupSelectable) Description copied from interface:GroupsSelectableModelSets the groups are selectable- Specified by:
setGroupSelectablein interfaceGroupsSelectableModel<D>
-
newEmptySelection
Instantiation an empty set of the section. It is used to initialize_selection.By default, it instantiates an instance of LinkedHashMap. 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
-