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.html;
017:
018: import org.directwebremoting.ScriptBuffer;
019: import org.directwebremoting.proxy.ScriptProxy;
020: import org.directwebremoting.proxy.io.Context;
021:
022: /**
023: * Represents an HTML element that occupies a rectangle of the screen.
024:
025: This class is available only when the Charting add-in is enabled.
026: * @author Joe Walker [joe at getahead dot org]
027: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
028: */
029: public class BlockTag extends jsx3.html.Tag {
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 BlockTag(Context context, String extension,
036: ScriptProxy scriptProxy) {
037: super (context, extension, scriptProxy);
038: }
039:
040: /**
041: * The instance initializer.
042: * @param strTagNS
043: * @param strTagName
044: * @param left left position (in pixels) of the object relative to its parent container
045: * @param top top position (in pixels) of the object relative to its parent container
046: * @param width width (in pixels) of the object
047: * @param height height (in pixels) of the object
048: */
049: public BlockTag(String strTagNS, String strTagName, int left,
050: int top, int width, int height) {
051: super ((Context) null, (String) null, (ScriptProxy) null);
052: ScriptBuffer script = new ScriptBuffer();
053: script.appendCall("new BlockTag", strTagNS, strTagName, left,
054: top, width, height);
055: setInitScript(script);
056: }
057:
058: /**
059: * Returns the left field.
060: * @param callback left
061: */
062: @SuppressWarnings("unchecked")
063: public void getLeft(
064: org.directwebremoting.proxy.Callback<Integer> callback) {
065: ScriptBuffer script = new ScriptBuffer();
066: String callbackPrefix = "";
067:
068: if (callback != null) {
069: callbackPrefix = "var reply = ";
070: }
071:
072: script
073: .appendCall(callbackPrefix + getContextPath()
074: + "getLeft");
075:
076: if (callback != null) {
077: String key = org.directwebremoting.extend.CallbackHelper
078: .saveCallback(callback, Integer.class);
079: script
080: .appendCall("__System.activateCallback", key,
081: "reply");
082: }
083:
084: getScriptProxy().addScript(script);
085: }
086:
087: /**
088: * Sets the left field.
089: * @param left the new value for left
090: */
091: public void setLeft(int left) {
092: ScriptBuffer script = new ScriptBuffer();
093: script.appendCall(getContextPath() + "setLeft", left);
094: getScriptProxy().addScript(script);
095: }
096:
097: /**
098: * Returns the top field.
099: * @param callback top
100: */
101: @SuppressWarnings("unchecked")
102: public void getTop(
103: org.directwebremoting.proxy.Callback<Integer> callback) {
104: ScriptBuffer script = new ScriptBuffer();
105: String callbackPrefix = "";
106:
107: if (callback != null) {
108: callbackPrefix = "var reply = ";
109: }
110:
111: script.appendCall(callbackPrefix + getContextPath() + "getTop");
112:
113: if (callback != null) {
114: String key = org.directwebremoting.extend.CallbackHelper
115: .saveCallback(callback, Integer.class);
116: script
117: .appendCall("__System.activateCallback", key,
118: "reply");
119: }
120:
121: getScriptProxy().addScript(script);
122: }
123:
124: /**
125: * Sets the top field.
126: * @param top the new value for top
127: */
128: public void setTop(int top) {
129: ScriptBuffer script = new ScriptBuffer();
130: script.appendCall(getContextPath() + "setTop", top);
131: getScriptProxy().addScript(script);
132: }
133:
134: /**
135: * Returns the width field.
136: * @param callback width
137: */
138: @SuppressWarnings("unchecked")
139: public void getWidth(
140: org.directwebremoting.proxy.Callback<Integer> callback) {
141: ScriptBuffer script = new ScriptBuffer();
142: String callbackPrefix = "";
143:
144: if (callback != null) {
145: callbackPrefix = "var reply = ";
146: }
147:
148: script.appendCall(callbackPrefix + getContextPath()
149: + "getWidth");
150:
151: if (callback != null) {
152: String key = org.directwebremoting.extend.CallbackHelper
153: .saveCallback(callback, Integer.class);
154: script
155: .appendCall("__System.activateCallback", key,
156: "reply");
157: }
158:
159: getScriptProxy().addScript(script);
160: }
161:
162: /**
163: * Sets the width field.
164: * @param width the new value for width
165: */
166: public void setWidth(int width) {
167: ScriptBuffer script = new ScriptBuffer();
168: script.appendCall(getContextPath() + "setWidth", width);
169: getScriptProxy().addScript(script);
170: }
171:
172: /**
173: * Returns the height field.
174: * @param callback height
175: */
176: @SuppressWarnings("unchecked")
177: public void getHeight(
178: org.directwebremoting.proxy.Callback<Integer> callback) {
179: ScriptBuffer script = new ScriptBuffer();
180: String callbackPrefix = "";
181:
182: if (callback != null) {
183: callbackPrefix = "var reply = ";
184: }
185:
186: script.appendCall(callbackPrefix + getContextPath()
187: + "getHeight");
188:
189: if (callback != null) {
190: String key = org.directwebremoting.extend.CallbackHelper
191: .saveCallback(callback, Integer.class);
192: script
193: .appendCall("__System.activateCallback", key,
194: "reply");
195: }
196:
197: getScriptProxy().addScript(script);
198: }
199:
200: /**
201: * Sets the height field.
202: * @param height the new value for height
203: */
204: public void setHeight(int height) {
205: ScriptBuffer script = new ScriptBuffer();
206: script.appendCall(getContextPath() + "setHeight", height);
207: getScriptProxy().addScript(script);
208: }
209:
210: /**
211: * Returns the margin field, as set by setMargin().
212: * @param callback margin
213: */
214: @SuppressWarnings("unchecked")
215: public void getMargin(
216: org.directwebremoting.proxy.Callback<String> callback) {
217: ScriptBuffer script = new ScriptBuffer();
218: String callbackPrefix = "";
219:
220: if (callback != null) {
221: callbackPrefix = "var reply = ";
222: }
223:
224: script.appendCall(callbackPrefix + getContextPath()
225: + "getMargin");
226:
227: if (callback != null) {
228: String key = org.directwebremoting.extend.CallbackHelper
229: .saveCallback(callback, String.class);
230: script
231: .appendCall("__System.activateCallback", key,
232: "reply");
233: }
234:
235: getScriptProxy().addScript(script);
236: }
237:
238: /**
239: * Sets the margin field, can be a single value or four values separated by space that correspond to top, right, bottom, and left.
240: * @param margin the new value for margin
241: */
242: public void setMargin(String margin) {
243: ScriptBuffer script = new ScriptBuffer();
244: script.appendCall(getContextPath() + "setMargin", margin);
245: getScriptProxy().addScript(script);
246: }
247:
248: /**
249: * Returns the padding field, as set by setPadding().
250: * @param callback padding
251: */
252: @SuppressWarnings("unchecked")
253: public void getPadding(
254: org.directwebremoting.proxy.Callback<String> callback) {
255: ScriptBuffer script = new ScriptBuffer();
256: String callbackPrefix = "";
257:
258: if (callback != null) {
259: callbackPrefix = "var reply = ";
260: }
261:
262: script.appendCall(callbackPrefix + getContextPath()
263: + "getPadding");
264:
265: if (callback != null) {
266: String key = org.directwebremoting.extend.CallbackHelper
267: .saveCallback(callback, String.class);
268: script
269: .appendCall("__System.activateCallback", key,
270: "reply");
271: }
272:
273: getScriptProxy().addScript(script);
274: }
275:
276: /**
277: * Sets the padding field, can be a single value or four values separated by space that correspond to top, right, bottom, and left.
278: * @param padding the new value for padding
279: */
280: public void setPadding(String padding) {
281: ScriptBuffer script = new ScriptBuffer();
282: script.appendCall(getContextPath() + "setPadding", padding);
283: getScriptProxy().addScript(script);
284: }
285:
286: /**
287: * Returns the position field.
288: * @param callback position
289: */
290: @SuppressWarnings("unchecked")
291: public void getPosition(
292: org.directwebremoting.proxy.Callback<String> callback) {
293: ScriptBuffer script = new ScriptBuffer();
294: String callbackPrefix = "";
295:
296: if (callback != null) {
297: callbackPrefix = "var reply = ";
298: }
299:
300: script.appendCall(callbackPrefix + getContextPath()
301: + "getPosition");
302:
303: if (callback != null) {
304: String key = org.directwebremoting.extend.CallbackHelper
305: .saveCallback(callback, String.class);
306: script
307: .appendCall("__System.activateCallback", key,
308: "reply");
309: }
310:
311: getScriptProxy().addScript(script);
312: }
313:
314: /**
315: * Sets the position field, can be 'absolute' or 'relative'.
316: * @param position the new value for position
317: */
318: public void setPosition(String position) {
319: ScriptBuffer script = new ScriptBuffer();
320: script.appendCall(getContextPath() + "setPosition", position);
321: getScriptProxy().addScript(script);
322: }
323:
324: /**
325: * Returns the zIndex field.
326: * @param callback zIndex
327: */
328: @SuppressWarnings("unchecked")
329: public void getZIndex(
330: org.directwebremoting.proxy.Callback<Integer> callback) {
331: ScriptBuffer script = new ScriptBuffer();
332: String callbackPrefix = "";
333:
334: if (callback != null) {
335: callbackPrefix = "var reply = ";
336: }
337:
338: script.appendCall(callbackPrefix + getContextPath()
339: + "getZIndex");
340:
341: if (callback != null) {
342: String key = org.directwebremoting.extend.CallbackHelper
343: .saveCallback(callback, Integer.class);
344: script
345: .appendCall("__System.activateCallback", key,
346: "reply");
347: }
348:
349: getScriptProxy().addScript(script);
350: }
351:
352: /**
353: * Sets the zIndex field.
354: * @param zIndex the new value for zIndex
355: */
356: public void setZIndex(int zIndex) {
357: ScriptBuffer script = new ScriptBuffer();
358: script.appendCall(getContextPath() + "setZIndex", zIndex);
359: getScriptProxy().addScript(script);
360: }
361:
362: /**
363: * Returns the bgcolor field.
364: * @param callback bgcolor
365: */
366: @SuppressWarnings("unchecked")
367: public void getBackgroundColor(
368: org.directwebremoting.proxy.Callback<String> callback) {
369: ScriptBuffer script = new ScriptBuffer();
370: String callbackPrefix = "";
371:
372: if (callback != null) {
373: callbackPrefix = "var reply = ";
374: }
375:
376: script.appendCall(callbackPrefix + getContextPath()
377: + "getBackgroundColor");
378:
379: if (callback != null) {
380: String key = org.directwebremoting.extend.CallbackHelper
381: .saveCallback(callback, String.class);
382: script
383: .appendCall("__System.activateCallback", key,
384: "reply");
385: }
386:
387: getScriptProxy().addScript(script);
388: }
389:
390: /**
391: * Sets the bgcolor field.
392: * @param bgcolor the new value for bgcolor
393: */
394: public void setBackgroundColor(String bgcolor) {
395: ScriptBuffer script = new ScriptBuffer();
396: script.appendCall(getContextPath() + "setBackgroundColor",
397: bgcolor);
398: getScriptProxy().addScript(script);
399: }
400:
401: /**
402: * parses the margin field into an array of four int values
403: * @param callback [top,right,bottom,left]
404: */
405: @SuppressWarnings("unchecked")
406: public void getMarginDimensions(
407: org.directwebremoting.proxy.Callback<Object[]> callback) {
408: ScriptBuffer script = new ScriptBuffer();
409: String callbackPrefix = "";
410:
411: if (callback != null) {
412: callbackPrefix = "var reply = ";
413: }
414:
415: script.appendCall(callbackPrefix + getContextPath()
416: + "getMarginDimensions");
417:
418: if (callback != null) {
419: String key = org.directwebremoting.extend.CallbackHelper
420: .saveCallback(callback, Object[].class);
421: script
422: .appendCall("__System.activateCallback", key,
423: "reply");
424: }
425:
426: getScriptProxy().addScript(script);
427: }
428:
429: /**
430: * parses the padding field into an array of four int values
431: * @param callback [top,right,bottom,left]
432: */
433: @SuppressWarnings("unchecked")
434: public void getPaddingDimensions(
435: org.directwebremoting.proxy.Callback<Object[]> callback) {
436: ScriptBuffer script = new ScriptBuffer();
437: String callbackPrefix = "";
438:
439: if (callback != null) {
440: callbackPrefix = "var reply = ";
441: }
442:
443: script.appendCall(callbackPrefix + getContextPath()
444: + "getPaddingDimensions");
445:
446: if (callback != null) {
447: String key = org.directwebremoting.extend.CallbackHelper
448: .saveCallback(callback, Object[].class);
449: script
450: .appendCall("__System.activateCallback", key,
451: "reply");
452: }
453:
454: getScriptProxy().addScript(script);
455: }
456:
457: /**
458: * Returns the dimensions in an array of four int values
459: * @param callback [left,top,width,height]
460: */
461: @SuppressWarnings("unchecked")
462: public void getDimensions(
463: org.directwebremoting.proxy.Callback<Object[]> callback) {
464: ScriptBuffer script = new ScriptBuffer();
465: String callbackPrefix = "";
466:
467: if (callback != null) {
468: callbackPrefix = "var reply = ";
469: }
470:
471: script.appendCall(callbackPrefix + getContextPath()
472: + "getDimensions");
473:
474: if (callback != null) {
475: String key = org.directwebremoting.extend.CallbackHelper
476: .saveCallback(callback, Object[].class);
477: script
478: .appendCall("__System.activateCallback", key,
479: "reply");
480: }
481:
482: getScriptProxy().addScript(script);
483: }
484:
485: /**
486: * Sets all four dimensions at once.
487: * @param left the new left value or an array containing all four new values
488: * @param top the new top value
489: * @param width the new width value
490: * @param height the new height value
491: */
492: public void setDimensions(int left, int top, int width, int height) {
493: ScriptBuffer script = new ScriptBuffer();
494: script.appendCall(getContextPath() + "setDimensions", left,
495: top, width, height);
496: getScriptProxy().addScript(script);
497: }
498:
499: /**
500: * Sets all four dimensions at once.
501: * @param left the new left value or an array containing all four new values
502: * @param top the new top value
503: * @param width the new width value
504: * @param height the new height value
505: */
506: public void setDimensions(Object[] left, int top, int width,
507: int height) {
508: ScriptBuffer script = new ScriptBuffer();
509: script.appendCall(getContextPath() + "setDimensions", left,
510: top, width, height);
511: getScriptProxy().addScript(script);
512: }
513:
514: }
|