01: /* Columns.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Tue Oct 25 16:00:29 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: import org.zkoss.zul.impl.HeadersElement;
24:
25: /**
26: * Defines the columns of a grid.
27: * Each child of a columns element should be a {@link Column} element.
28: *
29: * @author tomyeh
30: */
31: public class Columns extends HeadersElement {
32:
33: /** Returns the grid that it belongs to.
34: * <p>It is the same as {@link #getParent}.
35: */
36: public Grid getGrid() {
37: return (Grid) getParent();
38: }
39:
40: //-- Component --//
41: public void setParent(Component parent) {
42: if (parent != null && !(parent instanceof Grid))
43: throw new UiException("Unsupported parent for columns: "
44: + parent);
45: super .setParent(parent);
46: }
47:
48: public boolean setVisible(boolean visible) {
49: final boolean vis = super .setVisible(visible);
50: final Grid grid = getGrid();
51: if (grid != null)
52: grid.invalidate();
53: return vis;
54: }
55:
56: public boolean insertBefore(Component child, Component insertBefore) {
57: if (!(child instanceof Column))
58: throw new UiException("Unsupported child for columns: "
59: + child);
60: return super.insertBefore(child, insertBefore);
61: }
62: }
|