01: /* RowCollectionItem.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Jul 31, 2007 3:24:34 PM , Created by jumperchen
10: }}IS_NOTE
11:
12: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.zkplus.databind;
20:
21: import org.zkoss.zk.ui.Component;
22: import org.zkoss.zk.ui.UiException;
23: import org.zkoss.zul.Grid;
24: import org.zkoss.zul.ListModel;
25: import org.zkoss.zul.Row;
26:
27: /* package */class RowCollectionItem implements CollectionItem {
28:
29: public Component getComponentAtIndexByOwner(Component comp,
30: int index) {
31: if (comp instanceof Grid) {
32: final Grid grid = (Grid) comp;
33: return (Component) grid.getRows().getChildren().get(index);
34: } else {
35: throw new UiException(
36: "Unsupported type for RowCollectionItem: " + comp);
37: }
38: }
39:
40: public Component getComponentCollectionOwner(Component comp) {
41: if (comp instanceof Row) {
42: final Row row = (Row) comp;
43: return row.getGrid();
44: } else {
45: throw new UiException(
46: "Unsupported type for RowCollectionItem: " + comp);
47: }
48: }
49:
50: public ListModel getModelByOwner(Component comp) {
51: if (comp instanceof Grid) {
52: final Grid grid = (Grid) comp;
53: return grid.getModel();
54: } else {
55: throw new UiException(
56: "Unsupported type for RowCollectionItem: " + comp);
57: }
58: }
59:
60: public void setupBindingRenderer(Component comp, DataBinder binder) {
61: if (comp instanceof Row) {
62: final Row row = (Row) comp;
63: final Grid grid = row.getGrid();
64: if (grid.getRowRenderer() == null) {
65: grid
66: .setRowRenderer(new BindingRowRenderer(row,
67: binder));
68: }
69: }
70: }
71: }
|