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: * This class manages layouts by providing a container that will paint its first two child GUI objects separated
024: by a 'splitter' (either vertical or horizontal). Split panes can contain any number of object types, but most
025: commonly contain JSXBlock elements to aid in layout feautures such as padding, borders, etc.
026: * @author Joe Walker [joe at getahead dot org]
027: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
028: */
029: public class Splitter extends jsx3.gui.Block {
030: /**
031: * All reverse ajax proxies need context to work from
032: * @param scriptProxy The place we are writing scripts to
033: * @param context The script that got us to where we are now
034: */
035: public Splitter(Context context, String extension,
036: ScriptProxy scriptProxy) {
037: super (context, extension, scriptProxy);
038: }
039:
040: /**
041: * instance initializer
042: * @param strName unique name distinguishing this object from all other JSX GUI objects in the JSX application
043: * @param ORIENTATION constant; either jsx3.gui.Splitter.ORIENTATIONH or jsx3.gui.Splitter.ORIENTATIONV; if none provided the default (horizontal layout) or vertical (stacked) layout)
044: */
045: public Splitter(String strName, int ORIENTATION) {
046: super ((Context) null, (String) null, (ScriptProxy) null);
047: ScriptBuffer script = new ScriptBuffer();
048: script.appendCall("new Splitter", strName, ORIENTATION);
049: setInitScript(script);
050: }
051:
052: /**
053: *
054: */
055: public static final int ORIENTATIONH = 0;
056:
057: /**
058: *
059: */
060: public static final int ORIENTATIONV = 1;
061:
062: /**
063: * Returns a valid percentage (e.g., 100.00% 23.567%) that will be applied to the on-screen element as its CSS width/height percentage
064: */
065: @SuppressWarnings("unchecked")
066: public void getSubcontainer1Pct(
067: org.directwebremoting.proxy.Callback<String> callback) {
068: ScriptBuffer script = new ScriptBuffer();
069: String callbackPrefix = "";
070:
071: if (callback != null) {
072: callbackPrefix = "var reply = ";
073: }
074:
075: script.appendCall(callbackPrefix + getContextPath()
076: + "getSubcontainer1Pct");
077:
078: if (callback != null) {
079: String key = org.directwebremoting.extend.CallbackHelper
080: .saveCallback(callback, String.class);
081: script
082: .appendCall("__System.activateCallback", key,
083: "reply");
084: }
085:
086: getScriptProxy().addScript(script);
087: }
088:
089: /**
090: * Sets a valid percentage (e.g., 100.00% 23.567%) that will be applied to the on-screen element as its CSS width/height percentage
091: * @param strSubcontainerPct valid CSS width property as a percentage (e.g., 34.56%)
092: * @param bView false if null; if true the view is updated automatically without a repaint
093: * @return this object
094: */
095: public jsx3.gui.Splitter setSubcontainer1Pct(
096: String strSubcontainerPct, boolean bView) {
097: ScriptBuffer script = new ScriptBuffer();
098: script.appendCall(getContextPath() + "setSubcontainer1Pct",
099: strSubcontainerPct, bView);
100: getScriptProxy().addScript(script);
101: return this ;
102: }
103:
104: /**
105: * Returns a valid integer representing the minimum size in pixels for the container; the default minimum is 1
106: */
107: @SuppressWarnings("unchecked")
108: public void getSubcontainer1Min(
109: org.directwebremoting.proxy.Callback<Integer> callback) {
110: ScriptBuffer script = new ScriptBuffer();
111: String callbackPrefix = "";
112:
113: if (callback != null) {
114: callbackPrefix = "var reply = ";
115: }
116:
117: script.appendCall(callbackPrefix + getContextPath()
118: + "getSubcontainer1Min");
119:
120: if (callback != null) {
121: String key = org.directwebremoting.extend.CallbackHelper
122: .saveCallback(callback, Integer.class);
123: script
124: .appendCall("__System.activateCallback", key,
125: "reply");
126: }
127:
128: getScriptProxy().addScript(script);
129: }
130:
131: /**
132: * Sets the minimum size in pixels for the container; the default minimum is 1;
133: returns reference to self to facilitate method chaining
134: * @param intMin integer value represnting the minimum size in pixels for the container
135: * @return this object
136: */
137: public jsx3.gui.Splitter setSubcontainer1Min(int intMin) {
138: ScriptBuffer script = new ScriptBuffer();
139: script.appendCall(getContextPath() + "setSubcontainer1Min",
140: intMin);
141: getScriptProxy().addScript(script);
142: return this ;
143: }
144:
145: /**
146: * Returns a valid integer representing the minimum size in pixels for the container; the default minimum is 8
147: */
148: @SuppressWarnings("unchecked")
149: public void getSubcontainer2Min(
150: org.directwebremoting.proxy.Callback<Integer> callback) {
151: ScriptBuffer script = new ScriptBuffer();
152: String callbackPrefix = "";
153:
154: if (callback != null) {
155: callbackPrefix = "var reply = ";
156: }
157:
158: script.appendCall(callbackPrefix + getContextPath()
159: + "getSubcontainer2Min");
160:
161: if (callback != null) {
162: String key = org.directwebremoting.extend.CallbackHelper
163: .saveCallback(callback, Integer.class);
164: script
165: .appendCall("__System.activateCallback", key,
166: "reply");
167: }
168:
169: getScriptProxy().addScript(script);
170: }
171:
172: /**
173: * Sets the minimum size in pixels for the container; the default minimum is 8;
174: returns reference to self to facilitate method chaining
175: * @param intMin integer value represnting the minimum size in pixels for the container
176: * @return this object
177: */
178: public jsx3.gui.Splitter setSubcontainer2Min(int intMin) {
179: ScriptBuffer script = new ScriptBuffer();
180: script.appendCall(getContextPath() + "setSubcontainer2Min",
181: intMin);
182: getScriptProxy().addScript(script);
183: return this ;
184: }
185:
186: /**
187: * *Returns whether the splitter layout is top-over (--) or side-by-side (|).
188: */
189: @SuppressWarnings("unchecked")
190: public void getOrientation(
191: org.directwebremoting.proxy.Callback<Integer> callback) {
192: ScriptBuffer script = new ScriptBuffer();
193: String callbackPrefix = "";
194:
195: if (callback != null) {
196: callbackPrefix = "var reply = ";
197: }
198:
199: script.appendCall(callbackPrefix + getContextPath()
200: + "getOrientation");
201:
202: if (callback != null) {
203: String key = org.directwebremoting.extend.CallbackHelper
204: .saveCallback(callback, Integer.class);
205: script
206: .appendCall("__System.activateCallback", key,
207: "reply");
208: }
209:
210: getScriptProxy().addScript(script);
211: }
212:
213: /**
214: * Returns whether the splitter layout is top-over (--) or side-by-side (|);
215: returns reference to self to facilitate method chaining
216: * @param ORIENTATION constant; either jsx3.gui.Splitter.ORIENTATIONH or jsx3.gui.Splitter.ORIENTATIONV
217: * @return this object
218: */
219: public jsx3.gui.Splitter setOrientation(int ORIENTATION) {
220: ScriptBuffer script = new ScriptBuffer();
221: script.appendCall(getContextPath() + "setOrientation",
222: ORIENTATION);
223: getScriptProxy().addScript(script);
224: return this ;
225: }
226:
227: /**
228: * Returns the URL for the image to use for the splitter handle when the splitter is rendered top over bottom (--). When not set, Splitter.VSPLITIMAGE will be used when painted on-screen.
229: */
230: @SuppressWarnings("unchecked")
231: public void getVSplitImage(
232: org.directwebremoting.proxy.Callback<String> callback) {
233: ScriptBuffer script = new ScriptBuffer();
234: String callbackPrefix = "";
235:
236: if (callback != null) {
237: callbackPrefix = "var reply = ";
238: }
239:
240: script.appendCall(callbackPrefix + getContextPath()
241: + "getVSplitImage");
242:
243: if (callback != null) {
244: String key = org.directwebremoting.extend.CallbackHelper
245: .saveCallback(callback, String.class);
246: script
247: .appendCall("__System.activateCallback", key,
248: "reply");
249: }
250:
251: getScriptProxy().addScript(script);
252: }
253:
254: /**
255: * Sets the URL for the image to use for the splitter handle when the splitter is rendered top over bottom (--).
256: * @param strURL valid URL. If no background image is wanted, pass an empty string. The resize bar for a top-over-bottom orientation is 8 pixels hight with a variable width; the image will be placed at background position, 'center center', and will not repeat.
257: * @return this object
258: */
259: public jsx3.gui.Splitter setVSplitImage(String strURL) {
260: ScriptBuffer script = new ScriptBuffer();
261: script.appendCall(getContextPath() + "setVSplitImage", strURL);
262: getScriptProxy().addScript(script);
263: return this ;
264: }
265:
266: /**
267: * Returns the URL for the image to use for the splitter handle when the splitter is rendered side by side ( | ). When not set, Splitter.HSPLITIMAGE will be used when painted on-screen.
268: */
269: @SuppressWarnings("unchecked")
270: public void getHSplitImage(
271: org.directwebremoting.proxy.Callback<String> callback) {
272: ScriptBuffer script = new ScriptBuffer();
273: String callbackPrefix = "";
274:
275: if (callback != null) {
276: callbackPrefix = "var reply = ";
277: }
278:
279: script.appendCall(callbackPrefix + getContextPath()
280: + "getHSplitImage");
281:
282: if (callback != null) {
283: String key = org.directwebremoting.extend.CallbackHelper
284: .saveCallback(callback, String.class);
285: script
286: .appendCall("__System.activateCallback", key,
287: "reply");
288: }
289:
290: getScriptProxy().addScript(script);
291: }
292:
293: /**
294: * Sets the URL for the image to use for the splitter handle when the splitter is rendered side by side ( | ).
295: * @param strURL valid URL. If no background image is wanted, pass an empty string. The resize bar for a side-by-side orientation is 8 pixels wide with a variable height; the image will be placed at background position, 'center center', and will not repeat.
296: * @return this object
297: */
298: public jsx3.gui.Splitter setHSplitImage(String strURL) {
299: ScriptBuffer script = new ScriptBuffer();
300: script.appendCall(getContextPath() + "setHSplitImage", strURL);
301: getScriptProxy().addScript(script);
302: return this;
303: }
304:
305: }
|