001: /*
002: * Copyright 2005 Joe Walker
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package jsx3.gui;
017:
018: import org.directwebremoting.ScriptBuffer;
019: import org.directwebremoting.proxy.ScriptProxy;
020: import org.directwebremoting.proxy.io.Context;
021:
022: /**
023: * Renders a tabbed pane, which consists of a set of tabs, only one of which is visible at a time.
024: * @author Joe Walker [joe at getahead dot org]
025: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
026: */
027: public class TabbedPane extends jsx3.gui.Block {
028: /**
029: * All reverse ajax proxies need context to work from
030: * @param scriptProxy The place we are writing scripts to
031: * @param context The script that got us to where we are now
032: */
033: public TabbedPane(Context context, String extension,
034: ScriptProxy scriptProxy) {
035: super (context, extension, scriptProxy);
036: }
037:
038: /**
039: * instance initializer
040: * @param strName unique name distinguishing this object from all other JSX GUI objects in the JSX application
041: */
042: public TabbedPane(String strName) {
043: super ((Context) null, (String) null, (ScriptProxy) null);
044: ScriptBuffer script = new ScriptBuffer();
045: script.appendCall("new TabbedPane", strName);
046: setInitScript(script);
047: }
048:
049: /**
050: * 50
051: */
052: public static final int AUTO_SCROLL_INTERVAL = 50;
053:
054: /**
055: * jsx:///images/tab/l.png
056: */
057: public static final String LSCROLLER = null;
058:
059: /**
060: * jsx:///images/tab/r.png
061: */
062: public static final String RSCROLLER = null;
063:
064: /**
065: * 20 (default)
066: */
067: public static final int DEFAULTTABHEIGHT = 20;
068:
069: /**
070: * Returns the zero-based child index of the active child tab.
071: */
072: @SuppressWarnings("unchecked")
073: public void getSelectedIndex(
074: org.directwebremoting.proxy.Callback<Integer> callback) {
075: ScriptBuffer script = new ScriptBuffer();
076: String callbackPrefix = "";
077:
078: if (callback != null) {
079: callbackPrefix = "var reply = ";
080: }
081:
082: script.appendCall(callbackPrefix + getContextPath()
083: + "getSelectedIndex");
084:
085: if (callback != null) {
086: String key = org.directwebremoting.extend.CallbackHelper
087: .saveCallback(callback, Integer.class);
088: script
089: .appendCall("__System.activateCallback", key,
090: "reply");
091: }
092:
093: getScriptProxy().addScript(script);
094: }
095:
096: /**
097: * Sets the active tab of this tabbed pane. Pass either the zero-based child index of the tab to activate or
098: the tab itself.
099: * @param intIndex
100: * @param bRepaint if <code>true</code>, immediately updates the view to reflect the new active tab.
101: * @return this object.
102: */
103: public jsx3.gui.TabbedPane setSelectedIndex(jsx3.gui.Tab intIndex,
104: boolean bRepaint) {
105: ScriptBuffer script = new ScriptBuffer();
106: script.appendCall(getContextPath() + "setSelectedIndex",
107: intIndex, bRepaint);
108: getScriptProxy().addScript(script);
109: return this ;
110: }
111:
112: /**
113: * Sets the active tab of this tabbed pane. Pass either the zero-based child index of the tab to activate or
114: the tab itself.
115: * @param intIndex
116: * @param bRepaint if <code>true</code>, immediately updates the view to reflect the new active tab.
117: * @return this object.
118: */
119: public jsx3.gui.TabbedPane setSelectedIndex(int intIndex,
120: boolean bRepaint) {
121: ScriptBuffer script = new ScriptBuffer();
122: script.appendCall(getContextPath() + "setSelectedIndex",
123: intIndex, bRepaint);
124: getScriptProxy().addScript(script);
125: return this ;
126: }
127:
128: /**
129: * Returns the CSS height property (in pixels) for child tabs
130: * @param callback height (in pixels)
131: */
132: @SuppressWarnings("unchecked")
133: public void getTabHeight(
134: org.directwebremoting.proxy.Callback<Integer> callback) {
135: ScriptBuffer script = new ScriptBuffer();
136: String callbackPrefix = "";
137:
138: if (callback != null) {
139: callbackPrefix = "var reply = ";
140: }
141:
142: script.appendCall(callbackPrefix + getContextPath()
143: + "getTabHeight");
144:
145: if (callback != null) {
146: String key = org.directwebremoting.extend.CallbackHelper
147: .saveCallback(callback, Integer.class);
148: script
149: .appendCall("__System.activateCallback", key,
150: "reply");
151: }
152:
153: getScriptProxy().addScript(script);
154: }
155:
156: /**
157: * Sets the CSS height property for the object (in pixels) for child tabs;
158: returns reference to self to facilitate method chaining
159: * @param intTabHeight height (in pixels)
160: * @return this object
161: */
162: public jsx3.gui.TabbedPane setTabHeight(int intTabHeight) {
163: ScriptBuffer script = new ScriptBuffer();
164: script.appendCall(getContextPath() + "setTabHeight",
165: intTabHeight);
166: getScriptProxy().addScript(script);
167: return this ;
168: }
169:
170: /**
171: * whether or not to show the tabs of the tabbed pane. if false then only the content of each tab is drawn.
172: */
173: public void getShowTabs() {
174: ScriptBuffer script = new ScriptBuffer();
175: script.appendCall(getContextPath() + "getShowTabs");
176: getScriptProxy().addScript(script);
177: }
178:
179: /**
180: * whether or not to show the tabs of the tabbed pane. if false then only the content of each tab is drawn.
181: * @param intShowTabs
182: */
183: public void setShowTabs(int intShowTabs) {
184: ScriptBuffer script = new ScriptBuffer();
185: script
186: .appendCall(getContextPath() + "setShowTabs",
187: intShowTabs);
188: getScriptProxy().addScript(script);
189: }
190:
191: }
|