01: /* Listhead.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Fri Aug 5 13:06:38 2005, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2005 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.zul;
20:
21: import org.zkoss.zk.ui.Component;
22: import org.zkoss.zk.ui.UiException;
23:
24: import org.zkoss.zul.impl.HeadersElement;
25:
26: /**
27: * A list headers used to define multi-columns and/or headers.
28: *
29: * <p>Difference from XUL:
30: * <ol>
31: * <li>There is no listcols in ZUL because it is merged into {@link Listhead}.
32: * Reason: easier to write Listbox.</li>
33: * </ol>
34: *
35: * @author tomyeh
36: */
37: public class Listhead extends HeadersElement {
38: /** Returns the list box that it belongs to.
39: * <p>It is the same as {@link #getParent}.
40: */
41: public Listbox getListbox() {
42: return (Listbox) getParent();
43: }
44:
45: public boolean setVisible(boolean visible) {
46: final boolean vis = super .setVisible(visible);
47: final Listbox listbox = getListbox();
48: if (listbox != null)
49: listbox.invalidate();
50: return vis;
51: }
52:
53: //-- Component --//
54: public void setParent(Component parent) {
55: if (parent != null && !(parent instanceof Listbox))
56: throw new UiException("Wrong parent: " + parent);
57: super .setParent(parent);
58: }
59:
60: public boolean insertBefore(Component child, Component insertBefore) {
61: if (!(child instanceof Listheader))
62: throw new UiException("Unsupported child for listhead: "
63: + child);
64: return super.insertBefore(child, insertBefore);
65: }
66: }
|