|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.zkoss.zul.AbstractGroupsModel
org.zkoss.zul.ArrayGroupsModel
public class ArrayGroupsModel
An array implementation of GroupsModel
.
This implementation supports regroup array to groups depends on Comparator
and GroupComparator
.
GroupsModel
,
SimpleGroupsModel
Field Summary | |
---|---|
protected boolean[] |
_closes
member field to store group close status |
protected java.util.Comparator |
_comparator
member field to store Comparator for initial grouping. |
protected java.lang.Object[][] |
_data
member field to store group data |
protected java.lang.Object[] |
_foots
member field to store group foot data |
protected java.lang.Object[] |
_heads
member field to store group head data |
protected java.lang.Object[] |
_nativedata
member field to store native array data |
Constructor Summary | |
---|---|
ArrayGroupsModel(java.lang.Object[] data,
java.util.Comparator cmpr)
Constructor |
|
ArrayGroupsModel(java.lang.Object[] data,
java.util.Comparator cmpr,
int col)
|
Method Summary | |
---|---|
protected boolean |
createGroupClose(java.lang.Object[] groupdata,
int index,
int col)
create group close status, default implementation return false, which means open the group. |
protected java.lang.Object |
createGroupFoot(java.lang.Object[] groupdata,
int index,
int col)
create group foot Object, default implementation return null, which means no foot . |
protected java.lang.Object |
createGroupHead(java.lang.Object[] groupdata,
int index,
int col)
create group head Object, default implementation return first element of groupdata. |
java.lang.Object |
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 group value at the specified index. |
int |
getGroupCount()
Returns the number of groups. |
java.lang.Object |
getGroupfoot(int groupIndex)
Returns the foot value of the specified group. |
void |
group(java.util.Comparator cmpr,
boolean ascending,
int col)
Groups and sorts the data by the specified column. |
boolean |
hasGroupfoot(int groupIndex)
Returns if the specified group has a foot value. |
boolean |
isClose(int groupIndex)
Whether the group is close at the specified index. |
protected void |
organizeGroup(java.util.Comparator cmpr,
int col)
Organizes groups based sorted data. |
void |
setClose(int groupIndex,
boolean close)
Sets whether the group is close at the specified index. |
void |
sort(java.util.Comparator cmpr,
boolean ascending,
int col)
It called when Listbox or Grid has to sort
the content. |
protected void |
sortDataInGroupOrder(java.util.Comparator cmpr,
boolean ascending,
int colIndex)
Sorts the native data in the group order. |
protected void |
sortGroupData(java.lang.Object group,
java.lang.Object[] groupdata,
java.util.Comparator cmpr,
boolean ascending,
int col)
Sorts data within a group. |
Methods inherited from class org.zkoss.zul.AbstractGroupsModel |
---|
addGroupsDataListener, fireEvent, removeGroupsDataListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.Object[] _nativedata
protected java.util.Comparator _comparator
protected java.lang.Object[][] _data
protected java.lang.Object[] _heads
protected java.lang.Object[] _foots
protected boolean[] _closes
Constructor Detail |
---|
public ArrayGroupsModel(java.lang.Object[] data, java.util.Comparator cmpr)
data
- an array data to be grouping.cmpr
- a comparator implementation help group the data. you could implements GroupComparator
to do more grouping control.Comparator.compare(Object, Object)
or GroupComparator.compareGroup(Object, Object)
to sort the data.Comparator.compare(Object, Object)
or GroupComparator.compareGroup(Object, Object)
to decide which data belong to which group.
In this phase it also invoke createGroupHead(Object[], int, int)
and createGroupFoot(Object[], int, int)
to create head of foot Object of each group.Comparator.compare(Object, Object)
to sort data in each group.public ArrayGroupsModel(java.lang.Object[] data, java.util.Comparator cmpr, int col)
data
- an array data to be grouping.cmpr
- a comparator implementation help group the data. you could implements GroupComparator
to do more grouping control.Comparator.compare(Object, Object)
or GroupComparator.compareGroup(Object, Object)
to sort the data.Comparator.compare(Object, Object)
or GroupComparator.compareGroup(Object, Object)
to decide which data belong to which group.
In this phase it also invoke createGroupHead(Object[], int, int)
and createGroupFoot(Object[], int, int)
to create head of foot Object of each group.Comparator.compare(Object, Object)
to sort data in each group.col
- column index associate with cmpr.Method Detail |
---|
public java.lang.Object getChild(int groupIndex, int index)
GroupsModel
getChild
in interface GroupsModel
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 groot foot (GroupsModel.getGroupfoot(int)
).
getChildCount
in interface GroupsModel
groupIndex
- the index of the group.public java.lang.Object getGroup(int groupIndex)
GroupsModel
Group
and Listgroup
.
getGroup
in interface GroupsModel
groupIndex
- the index of the group.public int getGroupCount()
GroupsModel
getGroupCount
in interface GroupsModel
public java.lang.Object getGroupfoot(int groupIndex)
GroupsModel
Groupfoot
and Listgroupfoot
.
Note: it is ignored if GroupsModel.hasGroupfoot(int)
returns false.
getGroupfoot
in interface GroupsModel
groupIndex
- the index of the group.public boolean hasGroupfoot(int groupIndex)
GroupsModel
hasGroupfoot
in interface GroupsModel
groupIndex
- the index of the group.public void sort(java.util.Comparator cmpr, boolean ascending, int col)
GroupsModelExt
Listbox
or Grid
has to sort
the content.
After sorting, this model shall notify the instances of
ListDataListener
(registered thru ListModel.addListDataListener(org.zkoss.zul.event.ListDataListener)
)
to update the content.
Typically you have to notify with
new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, -1, -1)
to denote all data are changed (and reloading is required).
The comparator assigned to, say, Listheader.setSortAscending(java.util.Comparator)
is passed to method as the cmpr argument.
Thus, developers could use it as a tag to know which column
or what kind of order to sort.
sort
in interface GroupsModelExt
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.ascending
- whether to sort in the ascending order (or in
the descending order)col
- the index of the columnpublic void group(java.util.Comparator cmpr, boolean ascending, int col)
GroupsModelExt
Listbox
or Grid
has the sort function.
group
in interface GroupsModelExt
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)col
- the index of the columnpublic boolean isClose(int groupIndex)
GroupsModel
Group
and Listgroup
.
isClose
in interface GroupsModel
groupIndex
- the index of the group.public void setClose(int groupIndex, boolean close)
GroupsModel
Group
and Listgroup
.
setClose
in interface GroupsModel
groupIndex
- the index of the group.close
- true to close the Group.protected void sortGroupData(java.lang.Object group, java.lang.Object[] groupdata, java.util.Comparator cmpr, boolean ascending, int col)
There are three steps to re-group data:
sortDataInGroupOrder(java.util.Comparator, boolean, int)
, organizeGroup(java.util.Comparator, int)
and then
sortGroupData(java.lang.Object, java.lang.Object[], java.util.Comparator, boolean, int)
.
It is the last step of grouping. It sorts data in the specified group.
protected void organizeGroup(java.util.Comparator cmpr, int col)
There are three steps to re-group data:
sortDataInGroupOrder(java.util.Comparator, boolean, int)
, organizeGroup(java.util.Comparator, int)
and then
sortGroupData(java.lang.Object, java.lang.Object[], java.util.Comparator, boolean, int)
.
It is the second step of grouping. It creates group data
based on the data sorted in the group order by
sortDataInGroupOrder(java.util.Comparator, boolean, int)
.
cmpr
- the comparator used to compare data in the group order.
Notice that the comparator is never an instance of GroupComparator
.
The implementation just uses Comparator.compare(java.lang.Object, java.lang.Object)
to sort
the data.col
- column indexprotected java.lang.Object createGroupHead(java.lang.Object[] groupdata, int index, int col)
groupdata
- data the already in a group.index
- group indexcol
- column to groupprotected java.lang.Object createGroupFoot(java.lang.Object[] groupdata, int index, int col)
groupdata
- data the already in a group.index
- group indexcol
- column to groupprotected void sortDataInGroupOrder(java.util.Comparator cmpr, boolean ascending, int colIndex)
There are three steps to re-group data:
sortDataInGroupOrder(java.util.Comparator, boolean, int)
, organizeGroup(java.util.Comparator, int)
and then
sortGroupData(java.lang.Object, java.lang.Object[], java.util.Comparator, boolean, int)
.
cmpr
- the comparator used to compare data in the group order.
Notice that the comparator is never an instance of GroupComparator
.
The implementation just uses Comparator.compare(java.lang.Object, java.lang.Object)
to sort
the data.protected boolean createGroupClose(java.lang.Object[] groupdata, int index, int col)
groupdata
- data the already in a group.index
- group indexcol
- column to group
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |