18 package org.turro.jpa.model;
20 import java.util.Comparator;
21 import java.util.List;
22 import org.turro.jpa.entity.EntityCollections;
23 import org.turro.jpa.entity.IDaoEntity;
24 import org.zkoss.zul.Grid;
25 import org.zkoss.zul.GroupsModel;
26 import org.zkoss.zul.event.GroupsDataEvent;
27 import org.zkoss.zul.event.GroupsDataListener;
28 import org.zkoss.zul.ext.GroupsSortableModel;
37 private final Comparator _comparator;
38 private final Grid _grid;
39 private final List _list;
42 this._comparator = comparator;
51 _grid.setModel(_grid.getGroupsModel());
52 fireEvent(GroupsDataEvent.GROUPS_CHANGED,-1,-1,-1);
58 _grid.setModel(_grid.getGroupsModel());
59 fireEvent(GroupsDataEvent.GROUPS_CHANGED,-1,-1,-1);
65 _grid.setModel(_grid.getGroupsModel());
66 fireEvent(GroupsDataEvent.GROUPS_CHANGED,-1,-1,-1);
73 _model.removeGroupsDataListener(l);
78 _model.addGroupsDataListener(l);
82 public void sort(Comparator cmpr,
boolean ascending,
int col) {
83 _model.sort(cmpr, ascending, col);
88 return _model.addOpenGroup(groupIndex);
93 return _model.removeOpenGroup(groupIndex);
98 return _model.isGroupOpened(groupIndex);
103 return _model.hasGroupfoot(groupIndex);
107 public void group(Comparator cmpr,
boolean ascending,
int col) {
108 _model.group(cmpr, ascending, col);
113 return _model.getGroupfoot(groupIndex);
118 return _model.getGroupCount();
123 return _model.getGroup(groupIndex);
128 return _model.getChildCount(groupIndex);
132 public Object
getChild(
int groupIndex,
int index) {
133 return _model.getChild(groupIndex, index);
136 protected void fireEvent(
int type,
int groupIndex,
int index0,
int index1) {
137 _model.
fireEvent(type, groupIndex, index0, index1);
152 private void createModel() {
155 protected boolean createGroupOpen(Object[] groupdata,
int index,
int col) {
160 protected Object
createGroupFoot(Object[] groupdata,
int index,
int col) {
161 Object result = super.createGroupFoot(groupdata, index, col);
165 protected Object
createGroupHead(Object[] groupdata,
int index,
int col) {
166 Object result = super.createGroupHead(groupdata, index, col);
172 private boolean doCreateGroupOpen(Object[] groupdata,
int index,
int col,
boolean result) {
174 return _result || result;
177 private Object doCreateGroupFoot(Object[] groupdata,
int index,
int col, Object result) {
179 return _result !=
null ? _result : result;
182 private Object doCreateGroupHead(Object[] groupdata,
int index,
int col, Object result) {
184 return _result !=
null ? _result : result;
static EntityCollections entities(Collection values)
boolean remove(IDaoEntity entity)
boolean replace(IDaoEntity o)
void fireEvent(int type, int groupIndex, int index0, int index1)
boolean createGroupOpen(Object[] groupdata, int index, int col)
Object createGroupHead(Object[] groupdata, int index, int col)
void replaceItem(IDaoEntity object)
boolean hasGroupfoot(int groupIndex)
void removeGroupsDataListener(GroupsDataListener l)
Object createGroupFoot(Object[] groupdata, int index, int col)
Object getGroup(int groupIndex)
boolean removeOpenGroup(int groupIndex)
void sort(Comparator cmpr, boolean ascending, int col)
int getChildCount(int groupIndex)
boolean addOpenGroup(int groupIndex)
GroupModelManager(List list, Comparator comparator, Grid grid)
Object getChild(int groupIndex, int index)
void addItem(IDaoEntity object)
void group(Comparator cmpr, boolean ascending, int col)
boolean createGroupClose(Object[] groupdata, int index, int col)
void removeItem(IDaoEntity object)
Object getGroupfoot(int groupIndex)
boolean isGroupOpened(int groupIndex)
void addGroupsDataListener(GroupsDataListener l)
void fireEvent(int type, int groupIndex, int index0, int index1)