public class SimpleGroupsModel<D,H,F,E> extends AbstractGroupsModel<D,java.lang.Object,F,E> implements GroupsSortableModel<D>, ComponentCloneListener, java.lang.Cloneable
GroupsModel
.
This implementation assumes the data is grouped, and the grouping structure
is immutable.
If you allow the user to re-group the content, use GroupsModelArray
instead.
Generics:
For more information, please refer to ZK Developer's Reference: Groups Model
By default, the model support cloneable when the component is cloned. (since 6.0.0)
GroupsModel
,
GroupsModelArray
,
ComponentCloneListener
,
Serialized FormAbstractGroupsModel.DefaultSelectionControl<E>
Modifier and Type | Field and Description |
---|---|
protected java.util.List<java.util.List<D>> |
_data
member field to store group data
|
protected java.util.List<F> |
_foots
member field to store group foot data
|
protected java.util.List<H> |
_heads
member field to store group head data
|
protected boolean[] |
_opens
meMber field to store group close status
|
_selection
Constructor and Description |
---|
SimpleGroupsModel(D[][] data)
Constructs a groups data model with a two-dimensional array of data.
|
SimpleGroupsModel(D[][] data,
H[] heads)
Constructor
When using this constructor ,
getGroup(int) will return the corresponding Object depends on heads. |
SimpleGroupsModel(D[][] data,
H[] heads,
F[] foots)
Constructor
When using this constructor ,
getGroup(int) will return the corresponding Object depends on heads. |
SimpleGroupsModel(D[][] data,
H[] heads,
F[] foots,
boolean[] closes)
Constructor
When using this constructor ,
getGroup(int) will return the corresponding Object depends on heads. |
SimpleGroupsModel(java.util.List<java.util.List<D>> data)
Constructs a groups data model with a two-dimensional list of data.
|
SimpleGroupsModel(java.util.List<java.util.List<D>> data,
java.util.List<H> heads)
Constructor
When using this constructor ,
getGroup(int) will return the corresponding Object depends on heads. |
SimpleGroupsModel(java.util.List<java.util.List<D>> data,
java.util.List<H> heads,
java.util.List<F> foots)
Constructor
When using this constructor ,
getGroup(int) will return the corresponding Object depends on heads. |
SimpleGroupsModel(java.util.List<java.util.List<D>> data,
java.util.List<H> heads,
java.util.List<F> foots,
boolean[] closes)
Constructor
When using this constructor ,
getGroup(int) will return the corresponding Object depends on heads. |
Modifier and Type | Method and Description |
---|---|
boolean |
addOpenGroup(int groupIndex)
Opens the group at the specified index.
|
java.lang.Object |
clone() |
D |
getChild(int groupIndex,
int index)
Returns the child value of the specified group at the specified index.
|
int |
getChildCount(int groupIndex)
Returns the number of children of the specified group.
|
java.lang.Object |
getGroup(int groupIndex)
Returns the data representing the group.
|
int |
getGroupCount()
Returns the number of groups.
|
F |
getGroupfoot(int groupIndex)
Returns the foot value of the specified group, or null if the specified group
does not have any foot.
|
void |
group(java.util.Comparator<D> cmpr,
boolean ascending,
int colIndex)
|
boolean |
hasGroupfoot(int groupIndex)
Returns if the specified group has a foot value.
|
boolean |
isClose(int groupIndex)
Deprecated.
As of release 6.0.0, replace with
isGroupOpened(int) |
boolean |
isGroupOpened(int groupIndex)
Whether the group is open at the specified index.
|
boolean |
removeOpenGroup(int groupIndex)
Closes the group at the specified index.
|
void |
setClose(int groupIndex,
boolean close)
Deprecated.
As of release 6.0.0, replace with
addOpenGroup(int)
and removeOpenGroup(int) . |
boolean |
setOpenGroup0(int groupIndex,
boolean open) |
void |
sort(java.util.Comparator<D> cmpr,
boolean ascending,
int colIndex)
Sort each data in each group by Comparator, developer could override
sortGroupData(Object, List, Comparator, boolean, int) (Since 6.0.1)
to customize. |
protected void |
sortGroupData(java.lang.Object group,
D[] groupdata,
java.util.Comparator<D> cmpr,
boolean ascending,
int colIndex)
Deprecated.
As of release 6.0.1, replaced with
sortGroupData(Object, List, Comparator, boolean, int) . |
protected void |
sortGroupData(java.lang.Object group,
java.util.List<D> groupdata,
java.util.Comparator<D> cmpr,
boolean ascending,
int colIndex)
Sorts a group of data.
|
java.lang.Object |
willClone(Component comp)
Allows the model to clone
|
addGroupsDataListener, addToSelection, clearSelection, fireEvent, fireSelectionEvent, getSelection, getSelectionControl, isGroupSelectable, isMultiple, isSelected, isSelectionEmpty, newEmptySelection, readSelection, removeAllSelection, removeFromSelection, removeGroupsDataListener, retainAllSelection, setGroupSelectable, setMultiple, setSelection, setSelectionControl, writeSelection
protected java.util.List<java.util.List<D>> _data
protected java.util.List<H> _heads
protected java.util.List<F> _foots
protected boolean[] _opens
public SimpleGroupsModel(D[][] data)
This constructor assumes there is no group foot at all.
data
- a two-dimensional array to represent groups data,
where data[0] is the array of element of the first group,
data[1] is of the second group and so on.public SimpleGroupsModel(D[][] data, H[] heads)
getGroup(int)
will return the corresponding Object depends on heads.
hasGroupfoot(int)
will always return falsedata
- a 2 dimension array to represent groups dataheads
- an array to represent head data of grouppublic SimpleGroupsModel(D[][] data, H[] heads, F[] foots)
getGroup(int)
will return the corresponding Object depends on heads.
The return value of hasGroupfoot(int)
and getGroupfoot(int)
are depends on foots.data
- a 2 dimension array to represent groups dataheads
- an array to represent head data of groupfoots
- an array to represent foot data of group, if an element in this array is null, then
hasGroupfoot(int)
will return false in corresponding index.public SimpleGroupsModel(D[][] data, H[] heads, F[] foots, boolean[] closes)
getGroup(int)
will return the corresponding Object depends on heads.
The return value of hasGroupfoot(int)
and getGroupfoot(int)
are depends on foots.
Notice that, for backward compatibility, the last argument is closes
.
data
- a 2 dimension array to represent groups dataheads
- an array to represent head data of groupfoots
- an array to represent foot data of group, if an element in this array is null, then
hasGroupfoot(int)
will return false in corresponding index.closes
- an array of boolean to represent close status of group. If not specified, then
isClose(int)
will return false in corresponding index(i.e. group is default to open)public SimpleGroupsModel(java.util.List<java.util.List<D>> data)
list.get(0)
is the elements of the first group,
list.get(1)
is the elements of the second group, and so on.
Of course, each group might have different number of elements.
This constructor assumes there is no group foot at all.
data
- a two-dimensional list to represent groups data.public SimpleGroupsModel(java.util.List<java.util.List<D>> data, java.util.List<H> heads)
getGroup(int)
will return the corresponding Object depends on heads.
hasGroupfoot(int)
will always return falsedata
- a two dimensional list to represent groups dataheads
- a list to represent head data of grouppublic SimpleGroupsModel(java.util.List<java.util.List<D>> data, java.util.List<H> heads, java.util.List<F> foots)
getGroup(int)
will return the corresponding Object depends on heads.
The return value of hasGroupfoot(int)
and getGroupfoot(int)
are depends on foots.data
- a two dimensional list to represent groups dataheads
- a list to represent head data of groupfoots
- a list to represent foot data of group, if an element in this list is null, then
hasGroupfoot(int)
will return false in corresponding index.public SimpleGroupsModel(java.util.List<java.util.List<D>> data, java.util.List<H> heads, java.util.List<F> foots, boolean[] closes)
getGroup(int)
will return the corresponding Object depends on heads.
The return value of hasGroupfoot(int)
and getGroupfoot(int)
are depends on foots.
Notice that, for backward compatibility, the last argument is closes
.
data
- a two dimensional list to represent groups dataheads
- a list to represent head data of groupfoots
- a list to represent foot data of group, if an element in this list is null, then
hasGroupfoot(int)
will return false in corresponding index.closes
- an array of boolean to represent close status of group. If not specified, then
isClose(int)
will return false in corresponding index(i.e. group is default to open)public D getChild(int groupIndex, int index)
GroupsModel
getChild
in interface GroupsModel<D,java.lang.Object,F>
groupIndex
- the index of the group.index
- the index of the element in the group.public int getChildCount(int groupIndex)
GroupsModel
Note: it does not include the group foot (GroupsModel.getGroupfoot(int)
).
getChildCount
in interface GroupsModel<D,java.lang.Object,F>
groupIndex
- the index of the group.public java.lang.Object getGroup(int groupIndex)
getGroup
in interface GroupsModel<D,java.lang.Object,F>
groupIndex
- the index of the group.public int getGroupCount()
GroupsModel
getGroupCount
in interface GroupsModel<D,java.lang.Object,F>
public F getGroupfoot(int groupIndex)
GroupsModel
Groupfoot
and Listgroupfoot
.
Note: it is ignored if GroupsModel.hasGroupfoot(int)
returns false.
getGroupfoot
in interface GroupsModel<D,java.lang.Object,F>
groupIndex
- the index of the group.public boolean hasGroupfoot(int groupIndex)
GroupsModel
hasGroupfoot
in interface GroupsModel<D,java.lang.Object,F>
groupIndex
- the index of the group.public boolean isClose(int groupIndex)
isGroupOpened(int)
public void setClose(int groupIndex, boolean close)
public boolean isGroupOpened(int groupIndex)
GroupsModel
Group
and Listgroup
.
Default: true
isGroupOpened
in interface GroupsModel<D,java.lang.Object,F>
groupIndex
- the index of the group.public boolean addOpenGroup(int groupIndex)
GroupsModel
addOpenGroup
in interface GroupsModel<D,java.lang.Object,F>
groupIndex
- the index of the group.public boolean removeOpenGroup(int groupIndex)
GroupsModel
removeOpenGroup
in interface GroupsModel<D,java.lang.Object,F>
groupIndex
- the index of the group.public boolean setOpenGroup0(int groupIndex, boolean open)
public void group(java.util.Comparator<D> cmpr, boolean ascending, int colIndex)
_data
,_heads
,_foots
group
in interface GroupsSortableModel<D>
cmpr
- the comparator assigned to Column.setSortAscending(java.util.Comparator<?>)
and other relative methods. If developers didn't assign any one,
the method is returned directly.ascending
- whether to sort in the ascending order (or in
the descending order)colIndex
- the index of the columnpublic void sort(java.util.Comparator<D> cmpr, boolean ascending, int colIndex)
sortGroupData(Object, List, Comparator, boolean, int)
(Since 6.0.1)
to customize.sort
in interface GroupsSortableModel<D>
cmpr
- the comparator assigned to Listheader.setSortAscending(java.util.Comparator)
and other relative methods. If developers didn't assign any one,
the default comparator is used.
Notice that it is capable to sort the data in the correct order,
you could ignore the ascending parameter.ascending
- whether to sort in the ascending order (or in
the descending order, if false). Notice that it is used only to
provide additional information. To sort the data correctly, you could
count on the cmpr parameter only.colIndex
- the index of the columnprotected void sortGroupData(java.lang.Object group, D[] groupdata, java.util.Comparator<D> cmpr, boolean ascending, int colIndex)
sortGroupData(Object, List, Comparator, boolean, int)
.protected void sortGroupData(java.lang.Object group, java.util.List<D> groupdata, java.util.Comparator<D> cmpr, boolean ascending, int colIndex)
Default: Collections.sort(groupdata, cmpr)
group
- the group (the same as getGroup(int)
)groupdata
- the group of data to sortpublic java.lang.Object clone()
clone
in class AbstractGroupsModel<D,java.lang.Object,F,E>
public java.lang.Object willClone(Component comp)
willClone
in interface ComponentCloneListener
comp
- the cloned component (not the original one)Copyright © 2005-2011 Potix Corporation. All Rights Reserved.