01: /* ComboitemCollectionItem.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Jan 3, 2008 10:51:34 AM , 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.Combobox;
24: import org.zkoss.zul.Comboitem;
25: import org.zkoss.zul.ListModel;
26:
27: /**
28: * @author jumperchen
29: * @since 3.0.2
30: */
31: /* package */class ComboitemCollectionItem implements CollectionItem {
32:
33: public Component getComponentCollectionOwner(Component comp) {
34: if (comp instanceof Comboitem) {
35: final Comboitem item = (Comboitem) comp;
36: return item.getParent();
37: } else {
38: throw new UiException(
39: "Unsupported type for ComboitemCollectionItem: "
40: + comp);
41: }
42: }
43:
44: public ListModel getModelByOwner(Component comp) {
45: if (comp instanceof Combobox) {
46: final Combobox cbbox = (Combobox) comp;
47: return cbbox.getModel();
48: } else {
49: throw new UiException(
50: "Unsupported type for ComboitemCollectionItem: "
51: + comp);
52: }
53: }
54:
55: public Component getComponentAtIndexByOwner(Component comp,
56: int index) {
57: if (comp instanceof Combobox) {
58: final Combobox cbbox = (Combobox) comp;
59: return cbbox.getItemAtIndex(index);
60: } else {
61: throw new UiException(
62: "Unsupported type for ComboitemCollectionItem: "
63: + comp);
64: }
65: }
66:
67: public void setupBindingRenderer(Component comp, DataBinder binder) {
68: if (comp instanceof Comboitem) {
69: final Comboitem li = (Comboitem) comp;
70: final Combobox cbbox = (Combobox) li.getParent();
71: if (cbbox.getItemRenderer() == null) {
72: cbbox.setItemRenderer(new BindingComboitemRenderer(li,
73: binder));
74: }
75: }
76: }
77:
78: }
|