01: /* ZulFns.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Tue Sep 12 15:19:42 2006, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2006 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: }}IS_RIGHT
16: */
17: package org.zkoss.zul.fn;
18:
19: import org.zkoss.zk.ui.Component;
20: import org.zkoss.zul.Attributes;
21: import org.zkoss.zul.Grid;
22: import org.zkoss.zul.Listbox;
23: import org.zkoss.zul.Row;
24: import org.zkoss.zul.Box;
25:
26: /**
27: * Utilities for using EL.
28: *
29: * @author tomyeh
30: */
31: public class ZulFns {
32: protected ZulFns() {
33: }
34:
35: /** Returns the column attribute of a child of a row by specifying
36: * the index.
37: */
38: public static final String getColAttrs(Row row, int index) {
39: return row.getChildAttrs(index);
40: }
41:
42: /**
43: * Returns the inner attributes used for the cell of the specified child
44: * when it is placed inside of hbox/vbox.
45: */
46: public static final String getBoxChildInnerAttrs(Component child) {
47: return ((Box) child.getParent()).getChildInnerAttrs(child);
48: }
49:
50: /**
51: * Returns the outer attributes used for the cell of the specified child
52: * when it is placed inside of hbox/vbox.
53: */
54: public static final String getBoxChildOuterAttrs(Component child) {
55: return ((Box) child.getParent()).getChildOuterAttrs(child);
56: }
57:
58: /**
59: * Sets the stripe CSS for each row.
60: */
61: public static final void setStripeClass(Component child) {
62: final Component parent = child.getParent();
63: if (child.isVisible()) {
64: final String odd = (String) parent
65: .getAttribute(Attributes.STRIPE_STATE);
66: if (odd == null || !odd.equals("")) {
67: parent.setAttribute(Attributes.STRIPE_STATE, "");
68: } else {
69: if (parent instanceof Listbox)
70: parent.setAttribute(Attributes.STRIPE_STATE,
71: ((Listbox) parent).getOddRowSclass());
72: else
73: parent.setAttribute(Attributes.STRIPE_STATE,
74: ((Grid) parent.getParent())
75: .getOddRowSclass());
76: }
77:
78: }
79: }
80:
81: /**
82: * Resets the stripe CSS for each row.
83: * @since 3.0.3
84: */
85: public static final void resetStripeClass(Component parent) {
86: parent.removeAttribute(Attributes.STRIPE_STATE);
87: }
88: }
|