01: /* Tabpanels.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Tue Jul 12 10:43:08 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.XulElement;
25:
26: /**
27: * A collection of tab panels.
28: *
29: * <p>Default {@link #getSclass}:
30: * <table border="1" cellspacing="0">
31: * <tr>
32: * <td>sclass</td><td>tabbox's mold</td>
33: * <td>tabbox's orient {@link Tabbox#getOrient}</td>
34: * </tr>
35: * <tr><td>tabpanels</td><td>default</td><td>horizontal</td></tr>
36: * <tr><td>tabpanels-<em>something</em></td><td><em>something</em></td><td>horizontal</td></tr>
37: * <tr><td>vtabpanels</td><td>default</td><td>vertical</td></tr>
38: * <tr><td>vtabpanels-<em>something</em></td><td><em>something</em></td><td>vertical</td></tr>
39: * </table>
40: *
41: * @author tomyeh
42: */
43: public class Tabpanels extends XulElement {
44: public Tabpanels() {
45: }
46:
47: /** Returns the tabbox owns this component.
48: * <p>It is the same as {@link #getParent}.
49: */
50: public Tabbox getTabbox() {
51: return (Tabbox) getParent();
52: }
53:
54: //-- Component --//
55: public void setParent(Component parent) {
56: if (parent != null && !(parent instanceof Tabbox))
57: throw new UiException("Wrong parent: " + parent);
58: super .setParent(parent);
59: }
60:
61: public boolean insertBefore(Component child, Component insertBefore) {
62: if (!(child instanceof Tabpanel))
63: throw new UiException("Unsupported child for tabpanels: "
64: + child);
65: return super .insertBefore(child, insertBefore);
66: }
67:
68: /** Returns the style class.
69: *
70: * <p>The default style class, i.e., the style class is not defined (i.e.,
71: * {@link #setSclass} is not called or called with null or empty):
72: * <table border="1" cellspacing="0">
73: * <tr>
74: * <td>sclass</td><td>tabbox's mold</td>
75: * <td>tabbox's orient {@link Tabbox#getOrient}</td>
76: * </tr>
77: * <tr><td>tabpanels</td><td>default</td><td>horizontal</td></tr>
78: * <tr><td>tabpanels-<em>something</em></td><td><em>something</em></td><td>horizontal</td></tr>
79: * <tr><td>vtabpanels</td><td>default</td><td>vertical</td></tr>
80: * <tr><td>vtabpanels-<em>something</em></td><td><em>something</em></td><td>vertical</td></tr>
81: * </table>
82: *
83: * <p>Note: prior to 3.0.3, the default style class is always "tabpanels".
84: */
85: public String getSclass() {
86: final String scls = super .getSclass();
87: if (scls != null)
88: return scls;
89:
90: final Tabbox tabbox = getTabbox();
91: final boolean vert = tabbox != null && tabbox.isVertical();
92: final String mold = tabbox != null ? tabbox.getMold() : null;
93: return mold == null || "default".equals(mold) ? vert ? "vtabpanels"
94: : "tabpanels"
95: : (vert ? "vtabpanels-" : "tabpanels-") + mold;
96: }
97: }
|