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: * GUI utility class that provides a way to display HTML content on-screen in an HTML equivalent of a heavyweight container.
024: Instances of this class are often used to display menu lists, select lists, spyglass, and focus-rectangles.
025: An instance of this class cannot be serialized, it is merely a run-time construct similar to an alert or input box.
026: * @author Joe Walker [joe at getahead dot org]
027: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
028: */
029: public class Heavyweight extends jsx3.lang.Object {
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 Heavyweight(Context context, String extension,
036: ScriptProxy scriptProxy) {
037: super (context, extension, scriptProxy);
038: }
039:
040: /**
041: * instance initializer
042: * @param strId id to identify this HW instance among all others; this id will be used by both jsx3.gui.Heavyweight (to index it in the hash) and by the browser as the HTML tag's "id" attribute. If no ID is passed, a unique ID will be assigned by the system and is available by calling, [object].getId();
043: * @param objOwner
044: */
045: public Heavyweight(String strId, jsx3.gui.Painted objOwner) {
046: super ((Context) null, (String) null, (ScriptProxy) null);
047: ScriptBuffer script = new ScriptBuffer();
048: script.appendCall("new Heavyweight", strId, objOwner);
049: setInitScript(script);
050: }
051:
052: /**
053: * 32000
054: */
055: public static final int DEFAULTZINDEX = 32000;
056:
057: /**
058: * Returns the instance of the heavyweight object with the given ID; to get the on-screen HTML instance call: jsx3.gui.Heavyweight.GO([id]).getRendered()
059: * @param strId unique ID for the heavyweight instance
060: */
061: @SuppressWarnings("unchecked")
062: public jsx3.gui.Heavyweight GO(String strId) {
063: String extension = "GO(\"" + strId + "\").";
064: try {
065: java.lang.reflect.Constructor<jsx3.gui.Heavyweight> ctor = jsx3.gui.Heavyweight.class
066: .getConstructor(Context.class, String.class,
067: ScriptProxy.class);
068: return ctor.newInstance(this , extension, getScriptProxy());
069: } catch (Exception ex) {
070: throw new IllegalArgumentException("Unsupported type: "
071: + jsx3.gui.Heavyweight.class.getName());
072: }
073: }
074:
075: /**
076: * Sets the text/HTML for the control to be displayed on-screen; returns reference to self to facilitate method chaining;
077: * @param bDisplay true if null; if true, the heavyweight container is positioned and displayed immediately; if false, the container is painted on-screen, but its CSS 'visibility' property is set to 'hidden', allowing the developer to adjust as needed (via 2-pass, etc) before actually displaying;
078: */
079: public void show(boolean bDisplay) {
080: ScriptBuffer script = new ScriptBuffer();
081: script.appendCall(getContextPath() + "show", bDisplay);
082: getScriptProxy().addScript(script);
083: }
084:
085: /**
086: * can be called if show() has been called; resets the ratio (width/total) of the VIEW to be that of [object].getRatio()
087: */
088: public void applyRatio() {
089: ScriptBuffer script = new ScriptBuffer();
090: script.appendCall(getContextPath() + "applyRatio");
091: getScriptProxy().addScript(script);
092: }
093:
094: /**
095: * can be called if show() has been called; allows an existing HW window to re-apply its rules (used for complex layouts requiring a multi-pass)
096: * @param strAxis character (string) representing whether the rule is for the X or Y axis. Rememeber to capitalize!
097: * @param intSize
098: */
099: public void applyRules(String strAxis, int intSize) {
100: ScriptBuffer script = new ScriptBuffer();
101: script.appendCall(getContextPath() + "applyRules", strAxis,
102: intSize);
103: getScriptProxy().addScript(script);
104: }
105:
106: /**
107: * destorys the on-screen VIEW for the HW container; Hide() only affects the VIEW; this is not the same as setting visibility to "hidden", which doesn't actually destroy the VIEW
108: */
109: public void hide() {
110: ScriptBuffer script = new ScriptBuffer();
111: script.appendCall(getContextPath() + "hide");
112: getScriptProxy().addScript(script);
113: }
114:
115: /**
116: * destroy's the on-screen VIEW for the HW container AND removes any reference to the instance from the hash; Destroy() affects the MODEL and the VIEW
117: */
118: public void destroy() {
119: ScriptBuffer script = new ScriptBuffer();
120: script.appendCall(getContextPath() + "destroy");
121: getScriptProxy().addScript(script);
122: }
123:
124: /**
125: * Returns handle/reference to the Heavyweight Object's on-screen counterpartÑbasically a handle to a DHTML SPAN;
126: * @param objGUI optional argument improves efficiency if provided.
127: * @param callback Browser-Native DHTML object
128: */
129: @SuppressWarnings("unchecked")
130: public void getRendered(jsx3.gui.Event objGUI,
131: org.directwebremoting.proxy.Callback<String> callback) {
132: ScriptBuffer script = new ScriptBuffer();
133: String callbackPrefix = "";
134:
135: if (callback != null) {
136: callbackPrefix = "var reply = ";
137: }
138:
139: script.appendCall(callbackPrefix + getContextPath()
140: + "getRendered", objGUI);
141:
142: if (callback != null) {
143: String key = org.directwebremoting.extend.CallbackHelper
144: .saveCallback(callback, String.class);
145: script
146: .appendCall("__System.activateCallback", key,
147: "reply");
148: }
149:
150: getScriptProxy().addScript(script);
151: }
152:
153: /**
154: * Returns handle/reference to the Heavyweight Object's on-screen counterpartÑbasically a handle to a DHTML SPAN;
155: * @param objGUI optional argument improves efficiency if provided.
156: * @param callback Browser-Native DHTML object
157: */
158: @SuppressWarnings("unchecked")
159: public void getRendered(String objGUI,
160: org.directwebremoting.proxy.Callback<String> callback) {
161: ScriptBuffer script = new ScriptBuffer();
162: String callbackPrefix = "";
163:
164: if (callback != null) {
165: callbackPrefix = "var reply = ";
166: }
167:
168: script.appendCall(callbackPrefix + getContextPath()
169: + "getRendered", objGUI);
170:
171: if (callback != null) {
172: String key = org.directwebremoting.extend.CallbackHelper
173: .saveCallback(callback, String.class);
174: script
175: .appendCall("__System.activateCallback", key,
176: "reply");
177: }
178:
179: getScriptProxy().addScript(script);
180: }
181:
182: /**
183: * Returns the unique id for this heavyweight instance
184: */
185: @SuppressWarnings("unchecked")
186: public void getId(
187: org.directwebremoting.proxy.Callback<String> callback) {
188: ScriptBuffer script = new ScriptBuffer();
189: String callbackPrefix = "";
190:
191: if (callback != null) {
192: callbackPrefix = "var reply = ";
193: }
194:
195: script.appendCall(callbackPrefix + getContextPath() + "getId");
196:
197: if (callback != null) {
198: String key = org.directwebremoting.extend.CallbackHelper
199: .saveCallback(callback, String.class);
200: script
201: .appendCall("__System.activateCallback", key,
202: "reply");
203: }
204:
205: getScriptProxy().addScript(script);
206: }
207:
208: /**
209: * Returns the HTML content to display inside the HW instance on-screen
210: */
211: @SuppressWarnings("unchecked")
212: public void getHTML(
213: org.directwebremoting.proxy.Callback<String> callback) {
214: ScriptBuffer script = new ScriptBuffer();
215: String callbackPrefix = "";
216:
217: if (callback != null) {
218: callbackPrefix = "var reply = ";
219: }
220:
221: script
222: .appendCall(callbackPrefix + getContextPath()
223: + "getHTML");
224:
225: if (callback != null) {
226: String key = org.directwebremoting.extend.CallbackHelper
227: .saveCallback(callback, String.class);
228: script
229: .appendCall("__System.activateCallback", key,
230: "reply");
231: }
232:
233: getScriptProxy().addScript(script);
234: }
235:
236: /**
237: * Sets the HTML content to display inside the HW instance on-screen; returns ref to self
238: * @param strHTML HTML
239: * @param bRepaint
240: * @return this
241: */
242: public jsx3.gui.Heavyweight setHTML(String strHTML, boolean bRepaint) {
243: ScriptBuffer script = new ScriptBuffer();
244: script.appendCall(getContextPath() + "setHTML", strHTML,
245: bRepaint);
246: getScriptProxy().addScript(script);
247: return this ;
248: }
249:
250: /**
251: * Returns an object reference to the Browser Element parent to be used; if none specified, the browser BODY will be used
252: */
253: @SuppressWarnings("unchecked")
254: public void getDomParent(
255: org.directwebremoting.proxy.Callback<String> callback) {
256: ScriptBuffer script = new ScriptBuffer();
257: String callbackPrefix = "";
258:
259: if (callback != null) {
260: callbackPrefix = "var reply = ";
261: }
262:
263: script.appendCall(callbackPrefix + getContextPath()
264: + "getDomParent");
265:
266: if (callback != null) {
267: String key = org.directwebremoting.extend.CallbackHelper
268: .saveCallback(callback, String.class);
269: script
270: .appendCall("__System.activateCallback", key,
271: "reply");
272: }
273:
274: getScriptProxy().addScript(script);
275: }
276:
277: /**
278: * Sets an object reference to the Browser Element parent to be used; if none specified, the browser BODY will be used.
279: Note that this method must be called before setting any point rules for the hW instance, so those functions know the true origin from which to calculate left/top positions; returns ref to self
280: * @param objGUI HTML element in the browser
281: * @return this
282: */
283: public jsx3.gui.Heavyweight setDomParent(String objGUI) {
284: ScriptBuffer script = new ScriptBuffer();
285: script.appendCall(getContextPath() + "setDomParent", objGUI);
286: getScriptProxy().addScript(script);
287: return this ;
288: }
289:
290: /**
291: * Returns the ratio (a decimal between .01 and .99) to multiply the "Rise + Run" by. When applied by the 'show'
292: command during a double-pass, a width to height ratio can be established to provide a consistent L&F for
293: the text content. For example, a value of .8 would mean that the width of the heavyweight container would
294: represent 80% and the height would represent 20% of the total perimiter
295: */
296: @SuppressWarnings("unchecked")
297: public void getRatio(
298: org.directwebremoting.proxy.Callback<Integer> callback) {
299: ScriptBuffer script = new ScriptBuffer();
300: String callbackPrefix = "";
301:
302: if (callback != null) {
303: callbackPrefix = "var reply = ";
304: }
305:
306: script.appendCall(callbackPrefix + getContextPath()
307: + "getRatio");
308:
309: if (callback != null) {
310: String key = org.directwebremoting.extend.CallbackHelper
311: .saveCallback(callback, Integer.class);
312: script
313: .appendCall("__System.activateCallback", key,
314: "reply");
315: }
316:
317: getScriptProxy().addScript(script);
318: }
319:
320: /**
321: * Sets the ratio (a decimal between .01 and .99) to multiply the "Rise + Run" by. When applied by the 'show' command during a double-pass, a width to height ratio can be established to provide a consistent L&F for the text content. For example, a value of .8 would mean that the width of the heavyweight container would represent 80% and the height would represent 20% of the total perimiter;
322: returns a ref to self
323: * @param vntRatio any value between .01 and .99
324: * @return this
325: */
326: public jsx3.gui.Heavyweight setRatio(Integer vntRatio) {
327: ScriptBuffer script = new ScriptBuffer();
328: script.appendCall(getContextPath() + "setRatio", vntRatio);
329: getScriptProxy().addScript(script);
330: return this ;
331: }
332:
333: /**
334: * Returns the overflow property for CONTENTS of the HW container; it is assumed that anytime a perfect fit cannot occur that the content will have its overflow property set to 'auto' unless specified otherwise
335: * @param callback [jsx3.gui.Block.OVERFLOWSCROLL, jsx3.gui.Block.OVERFLOWHIDDEN, jsx3.gui.Block.OVERFLOWEXPAND]
336: */
337: @SuppressWarnings("unchecked")
338: public void getOverflow(
339: org.directwebremoting.proxy.Callback<String> callback) {
340: ScriptBuffer script = new ScriptBuffer();
341: String callbackPrefix = "";
342:
343: if (callback != null) {
344: callbackPrefix = "var reply = ";
345: }
346:
347: script.appendCall(callbackPrefix + getContextPath()
348: + "getOverflow");
349:
350: if (callback != null) {
351: String key = org.directwebremoting.extend.CallbackHelper
352: .saveCallback(callback, String.class);
353: script
354: .appendCall("__System.activateCallback", key,
355: "reply");
356: }
357:
358: getScriptProxy().addScript(script);
359: }
360:
361: /**
362: * Sets the overflow property for CONTENTS of the HW container; it is assumed that anytime a perfect fit cannot occur that the content will have its overflow property set to 'auto' unless specified otherwise
363: returns reference to self to facilitate method chaining;
364: * @param strOverflow [jsx3.gui.Block.OVERFLOWSCROLL, jsx3.gui.Block.OVERFLOWHIDDEN, jsx3.gui.Block.OVERFLOWEXPAND]
365: * @return this object
366: */
367: public jsx3.gui.Heavyweight setOverflow(String strOverflow) {
368: ScriptBuffer script = new ScriptBuffer();
369: script
370: .appendCall(getContextPath() + "setOverflow",
371: strOverflow);
372: getScriptProxy().addScript(script);
373: return this ;
374: }
375:
376: /**
377: * if the HW instance has an on-screen VIEW, this method can be used to toggle its visibility; it has no effect on the MODEL; it is most commonly used when "[object].show(false);" is called, allowing the developer to manually adjust layout before actually showing the HW instance.
378: returns a ref to self for method chaining
379: * @param strVisibility [jsx3.gui.Block.VISIBILITYVISIBLE, jsx3.gui.Block.VISIBILITYHIDDEN]
380: * @return this object
381: */
382: public jsx3.gui.Heavyweight setVisibility(String strVisibility) {
383: ScriptBuffer script = new ScriptBuffer();
384: script.appendCall(getContextPath() + "setVisibility",
385: strVisibility);
386: getScriptProxy().addScript(script);
387: return this ;
388: }
389:
390: /**
391: * Returns the z-index property; assumes jsx3.gui.Heavyweight.DEFAULTZINDEX if none supplied
392: */
393: @SuppressWarnings("unchecked")
394: public void getZIndex(
395: org.directwebremoting.proxy.Callback<Integer> callback) {
396: ScriptBuffer script = new ScriptBuffer();
397: String callbackPrefix = "";
398:
399: if (callback != null) {
400: callbackPrefix = "var reply = ";
401: }
402:
403: script.appendCall(callbackPrefix + getContextPath()
404: + "getZIndex");
405:
406: if (callback != null) {
407: String key = org.directwebremoting.extend.CallbackHelper
408: .saveCallback(callback, Integer.class);
409: script
410: .appendCall("__System.activateCallback", key,
411: "reply");
412: }
413:
414: getScriptProxy().addScript(script);
415: }
416:
417: /**
418: * Sets the CSS z-index for the object; if null, is passed, jsx3.gui.Heavyweight.DEFAULTZINDEX will be used as the default value
419: * @param intZIndex z-index value
420: */
421: public void setZIndex(int intZIndex) {
422: ScriptBuffer script = new ScriptBuffer();
423: script.appendCall(getContextPath() + "setZIndex", intZIndex);
424: getScriptProxy().addScript(script);
425: }
426:
427: /**
428: * Returns the CSS width property (in pixels); if this value is set, it is assumed that the Heavyweight container will not have its width lessened to fit on-screen.
429: * @param callback width (in pixels)
430: */
431: @SuppressWarnings("unchecked")
432: public void getWidth(
433: org.directwebremoting.proxy.Callback<Integer> callback) {
434: ScriptBuffer script = new ScriptBuffer();
435: String callbackPrefix = "";
436:
437: if (callback != null) {
438: callbackPrefix = "var reply = ";
439: }
440:
441: script.appendCall(callbackPrefix + getContextPath()
442: + "getWidth");
443:
444: if (callback != null) {
445: String key = org.directwebremoting.extend.CallbackHelper
446: .saveCallback(callback, Integer.class);
447: script
448: .appendCall("__System.activateCallback", key,
449: "reply");
450: }
451:
452: getScriptProxy().addScript(script);
453: }
454:
455: /**
456: * Sets the CSS width property (in pixels); if this value is set, it is assumed that the Heavyweight container will not have its width lessened to fit on-screen.
457: * @param intWidth width (in pixels)
458: */
459: public void setWidth(int intWidth) {
460: ScriptBuffer script = new ScriptBuffer();
461: script.appendCall(getContextPath() + "setWidth", intWidth);
462: getScriptProxy().addScript(script);
463: }
464:
465: /**
466: * Returns the CSS height property (in pixels); if this value is set, it is assumed that the Heavyweight container will not have its height lessened to fit on-screen.
467: * @param callback height (in pixels)
468: */
469: @SuppressWarnings("unchecked")
470: public void getHeight(
471: org.directwebremoting.proxy.Callback<Integer> callback) {
472: ScriptBuffer script = new ScriptBuffer();
473: String callbackPrefix = "";
474:
475: if (callback != null) {
476: callbackPrefix = "var reply = ";
477: }
478:
479: script.appendCall(callbackPrefix + getContextPath()
480: + "getHeight");
481:
482: if (callback != null) {
483: String key = org.directwebremoting.extend.CallbackHelper
484: .saveCallback(callback, Integer.class);
485: script
486: .appendCall("__System.activateCallback", key,
487: "reply");
488: }
489:
490: getScriptProxy().addScript(script);
491: }
492:
493: /**
494: * Sets the CSS height property (in pixels); if this value is set, it is assumed that the Heavyweight container will not have its height lessened to fit on-screen.
495: returns reference to self to facilitate method chaining;
496: * @param intHeight height (in pixels)
497: * @return this object
498: */
499: public jsx3.gui.Heavyweight setHeight(int intHeight) {
500: ScriptBuffer script = new ScriptBuffer();
501: script.appendCall(getContextPath() + "setHeight", intHeight);
502: getScriptProxy().addScript(script);
503: return this ;
504: }
505:
506: /**
507: * adds a POSITION RULE ruleset (X value) (a simple structure/hash) to the array of position rules; Note that POSITION RULE objects are used by the show() method to determine the best possible location for a heavyweight item
508: * @param objAnchor Either an event, or an on-screen HTML element
509: * @param strAnchorPoint REQUIRED if @objAnchor is an HTML element; when used, defines one of the valid 9 compass points: 4 primary: (N, S, E, W); 4 secondary: (NE, SE, SW, NW); and origin: (O). Note that it
510: is from this point (on @objAnchor) that the heavyweight item will try to position itself
511: * @param strPoint Defines one of the valid 9 compass points: 4 primary: (N, S, E, W); 4 secondary: (NE, SE, SW, NW); and origin: (O). Note that it
512: is from this point (on the Heavyweight instance) that the heavyweight item will try to position itself
513: * @param intOff offset (in pixels) by which to nudge the horizontal placement of the HW instance before displaying (useful for submenus, for example, where their left has a -10px offset to overlay the parent menu item)
514: * @return this object (this)
515: */
516: @SuppressWarnings("unchecked")
517: public jsx3.gui.Heavyweight addXRule(jsx3.gui.Event objAnchor,
518: String strAnchorPoint, String strPoint, int intOff) {
519: String extension = "addXRule(\"" + objAnchor + "\", \""
520: + strAnchorPoint + "\", \"" + strPoint + "\", \""
521: + intOff + "\").";
522: try {
523: java.lang.reflect.Constructor<jsx3.gui.Heavyweight> ctor = jsx3.gui.Heavyweight.class
524: .getConstructor(Context.class, String.class,
525: ScriptProxy.class);
526: return ctor.newInstance(this , extension, getScriptProxy());
527: } catch (Exception ex) {
528: throw new IllegalArgumentException("Unsupported type: "
529: + jsx3.gui.Heavyweight.class.getName());
530: }
531: }
532:
533: /**
534: * adds a POSITION RULE ruleset (X value) (a simple structure/hash) to the array of position rules; Note that POSITION RULE objects are used by the show() method to determine the best possible location for a heavyweight item
535: * @param objAnchor Either an event, or an on-screen HTML element
536: * @param strAnchorPoint REQUIRED if @objAnchor is an HTML element; when used, defines one of the valid 9 compass points: 4 primary: (N, S, E, W); 4 secondary: (NE, SE, SW, NW); and origin: (O). Note that it
537: is from this point (on @objAnchor) that the heavyweight item will try to position itself
538: * @param strPoint Defines one of the valid 9 compass points: 4 primary: (N, S, E, W); 4 secondary: (NE, SE, SW, NW); and origin: (O). Note that it
539: is from this point (on the Heavyweight instance) that the heavyweight item will try to position itself
540: * @param intOff offset (in pixels) by which to nudge the horizontal placement of the HW instance before displaying (useful for submenus, for example, where their left has a -10px offset to overlay the parent menu item)
541: * @return this object (this)
542: */
543: @SuppressWarnings("unchecked")
544: public jsx3.gui.Heavyweight addXRule(jsx3.lang.Object objAnchor,
545: String strAnchorPoint, String strPoint, int intOff) {
546: String extension = "addXRule(\"" + objAnchor + "\", \""
547: + strAnchorPoint + "\", \"" + strPoint + "\", \""
548: + intOff + "\").";
549: try {
550: java.lang.reflect.Constructor<jsx3.gui.Heavyweight> ctor = jsx3.gui.Heavyweight.class
551: .getConstructor(Context.class, String.class,
552: ScriptProxy.class);
553: return ctor.newInstance(this , extension, getScriptProxy());
554: } catch (Exception ex) {
555: throw new IllegalArgumentException("Unsupported type: "
556: + jsx3.gui.Heavyweight.class.getName());
557: }
558: }
559:
560: /**
561: * adds a POSITION RULE ruleset (Y value) (a simple structure/hash) to the array of position rules; Note that POSITION RULE objects are used by the show() method to determine the best possible location for a heavyweight item
562: * @param objAnchor Either an event or an on-screen HTML element
563: * @param strAnchorPoint REQUIRED if @objAnchor is an HTML element; when used, defines one of the valid 9 compass points: 4 primary: (N, S, E, W); 4 secondary: (NE, SE, SW, NW); and origin: (O). Note that it
564: is from this point (on @objAnchor) that the heavyweight item will try to position itself
565: * @param strPoint Defines one of the valid 9 compass points: 4 primary: (N, S, E, W); 4 secondary: (NE, SE, SW, NW); and origin: (O). Note that it
566: is from this point (on the Heavyweight instance) that the heavyweight item will try to position itself
567: * @param intOff offset (in pixels) by which to nudge the vertical placement of the HW instance before displaying (useful for submenus, for example, where their left has a -10px offset to overlay the parent menu item)
568: * @return this object (this)
569: */
570: @SuppressWarnings("unchecked")
571: public jsx3.gui.Heavyweight addYRule(jsx3.lang.Object objAnchor,
572: String strAnchorPoint, String strPoint, int intOff) {
573: String extension = "addYRule(\"" + objAnchor + "\", \""
574: + strAnchorPoint + "\", \"" + strPoint + "\", \""
575: + intOff + "\").";
576: try {
577: java.lang.reflect.Constructor<jsx3.gui.Heavyweight> ctor = jsx3.gui.Heavyweight.class
578: .getConstructor(Context.class, String.class,
579: ScriptProxy.class);
580: return ctor.newInstance(this , extension, getScriptProxy());
581: } catch (Exception ex) {
582: throw new IllegalArgumentException("Unsupported type: "
583: + jsx3.gui.Heavyweight.class.getName());
584: }
585: }
586:
587: /**
588: * adds a POSITION RULE ruleset (Y value) (a simple structure/hash) to the array of position rules; Note that POSITION RULE objects are used by the show() method to determine the best possible location for a heavyweight item
589: * @param objAnchor Either an event or an on-screen HTML element
590: * @param strAnchorPoint REQUIRED if @objAnchor is an HTML element; when used, defines one of the valid 9 compass points: 4 primary: (N, S, E, W); 4 secondary: (NE, SE, SW, NW); and origin: (O). Note that it
591: is from this point (on @objAnchor) that the heavyweight item will try to position itself
592: * @param strPoint Defines one of the valid 9 compass points: 4 primary: (N, S, E, W); 4 secondary: (NE, SE, SW, NW); and origin: (O). Note that it
593: is from this point (on the Heavyweight instance) that the heavyweight item will try to position itself
594: * @param intOff offset (in pixels) by which to nudge the vertical placement of the HW instance before displaying (useful for submenus, for example, where their left has a -10px offset to overlay the parent menu item)
595: * @return this object (this)
596: */
597: @SuppressWarnings("unchecked")
598: public jsx3.gui.Heavyweight addYRule(jsx3.gui.Event objAnchor,
599: String strAnchorPoint, String strPoint, int intOff) {
600: String extension = "addYRule(\"" + objAnchor + "\", \""
601: + strAnchorPoint + "\", \"" + strPoint + "\", \""
602: + intOff + "\").";
603: try {
604: java.lang.reflect.Constructor<jsx3.gui.Heavyweight> ctor = jsx3.gui.Heavyweight.class
605: .getConstructor(Context.class, String.class,
606: ScriptProxy.class);
607: return ctor.newInstance(this , extension, getScriptProxy());
608: } catch (Exception ex) {
609: throw new IllegalArgumentException("Unsupported type: "
610: + jsx3.gui.Heavyweight.class.getName());
611: }
612: }
613:
614: /**
615: * adds a POSITION RULE ruleset (a simple structure/hash) to the array of position rules; Note that POSITION RULE objects are used by the show() method to determine the best possible location for a heavyweight item
616: * @param intPixel left position (in pixels) for the anchorpoint the heavyweight instance will try to layout in context of
617: * @param strPoint Defines one of the valid 9 compass points: 4 primary: (N, S, E, W); 4 secondary: (NE, SE, SW, NW); and origin: (O). Note that it
618: is from this point (on the Heavyweight instance) that the heavyweight item will try to position itself
619: * @param intOff offset (in pixels) by which to nudge the vertical placement of the HW instance before displaying (useful for submenus, for example, where their left has a -10px offset to overlay the parent menu item)
620: * @param strAxis character (string) representing whether the rule is for the X or Y axis. Rememeber to capitalize!
621: * @return this object (this)
622: */
623: @SuppressWarnings("unchecked")
624: public jsx3.gui.Heavyweight addRule(int intPixel, String strPoint,
625: int intOff, String strAxis) {
626: String extension = "addRule(\"" + intPixel + "\", \""
627: + strPoint + "\", \"" + intOff + "\", \"" + strAxis
628: + "\").";
629: try {
630: java.lang.reflect.Constructor<jsx3.gui.Heavyweight> ctor = jsx3.gui.Heavyweight.class
631: .getConstructor(Context.class, String.class,
632: ScriptProxy.class);
633: return ctor.newInstance(this , extension, getScriptProxy());
634: } catch (Exception ex) {
635: throw new IllegalArgumentException("Unsupported type: "
636: + jsx3.gui.Heavyweight.class.getName());
637: }
638: }
639:
640: /**
641: * Returns a POSITION RULE object at the given index; Note that POSITION RULE objects are JavaScript objects that implement the following 3 properties: _pixel (the on-screen point around which to pivot/place), _offset (amount to nudge the placement), _point (compass direction)
642: * @param intIndex the index (in rank order of execution) of the POSITION RULEing rule set to apply (it is assumed that at least one POSITION RULE ruleset exists)
643: * @param strAxis character (string) representing whether the rule is for the X or Y axis. Rememeber to capitalize!
644: */
645: @SuppressWarnings("unchecked")
646: public void getPositionRule(int intIndex, String strAxis,
647: org.directwebremoting.proxy.Callback<String> callback) {
648: ScriptBuffer script = new ScriptBuffer();
649: String callbackPrefix = "";
650:
651: if (callback != null) {
652: callbackPrefix = "var reply = ";
653: }
654:
655: script.appendCall(callbackPrefix + getContextPath()
656: + "getPositionRule", intIndex, strAxis);
657:
658: if (callback != null) {
659: String key = org.directwebremoting.extend.CallbackHelper
660: .saveCallback(callback, String.class);
661: script
662: .appendCall("__System.activateCallback", key,
663: "reply");
664: }
665:
666: getScriptProxy().addScript(script);
667: }
668:
669: /**
670: * Returns a JavaScript object array (hash). This hash contains the Y rules and the X rules for positioning the object
671: */
672: @SuppressWarnings("unchecked")
673: public jsx3.lang.Object getPositionRules() {
674: String extension = "getPositionRules().";
675: try {
676: java.lang.reflect.Constructor<jsx3.lang.Object> ctor = jsx3.lang.Object.class
677: .getConstructor(Context.class, String.class,
678: ScriptProxy.class);
679: return ctor.newInstance(this , extension, getScriptProxy());
680: } catch (Exception ex) {
681: throw new IllegalArgumentException("Unsupported type: "
682: + jsx3.lang.Object.class.getName());
683: }
684: }
685:
686: /**
687: * Returns a JavaScript object array (hash). This hash contains the Y rules and the X rules for positioning the object
688: * @param returnType The expected return type
689: */
690: @SuppressWarnings("unchecked")
691: public <T> T getPositionRules(Class<T> returnType) {
692: String extension = "getPositionRules().";
693: try {
694: java.lang.reflect.Constructor<T> ctor = returnType
695: .getConstructor(Context.class, String.class,
696: ScriptProxy.class);
697: return ctor.newInstance(this , extension, getScriptProxy());
698: } catch (Exception ex) {
699: throw new IllegalArgumentException(
700: "Unsupported return type: " + returnType.getName());
701: }
702: }
703:
704: /**
705: * Returns a JavaScript object with properties: X,Y (Left and Top); relating to the 4 primary (N, S, E, W), 4 secondary (NE, SE, SW, NW), and origin (O) compass positions for O
706: * @param objGUI GUI object in the browser DOM (typically an HTML element such as a DIV or SPAN) for which to provide the X,Y for
707: * @param strPoint a character denoting one of the valid 9 compass points: 4 primary: (N, S, E, W); 4 secondary: (NE, SE, SW, NW); and origin: (O)
708: */
709: public void getPoint(int objGUI, String strPoint) {
710: ScriptBuffer script = new ScriptBuffer();
711: script.appendCall(getContextPath() + "getPoint", objGUI,
712: strPoint);
713: getScriptProxy().addScript(script);
714: }
715:
716: /**
717: * Returns a JavaScript object with properties: X,Y (Left and Top); relating to the 4 primary (N, S, E, W), 4 secondary (NE, SE, SW, NW), and origin (O) compass positions for O
718: * @param objGUI GUI object in the browser DOM (typically an HTML element such as a DIV or SPAN) for which to provide the X,Y for
719: * @param strPoint a character denoting one of the valid 9 compass points: 4 primary: (N, S, E, W); 4 secondary: (NE, SE, SW, NW); and origin: (O)
720: */
721: public void getPoint(jsx3.gui.Block objGUI, String strPoint) {
722: ScriptBuffer script = new ScriptBuffer();
723: script.appendCall(getContextPath() + "getPoint", objGUI,
724: strPoint);
725: getScriptProxy().addScript(script);
726: }
727:
728: /**
729: * Returns a JavaScript object with properties: X,Y (Left and Top); relating to the 4 primary (N, S, E, W), 4 secondary (NE, SE, SW, NW), and origin (O) compass positions for O
730: * @param objGUI GUI object in the browser DOM (typically an HTML element such as a DIV or SPAN) for which to provide the X,Y for
731: * @param strPoint a character denoting one of the valid 9 compass points: 4 primary: (N, S, E, W); 4 secondary: (NE, SE, SW, NW); and origin: (O)
732: */
733: public void getPoint(String objGUI, String strPoint) {
734: ScriptBuffer script = new ScriptBuffer();
735: script.appendCall(getContextPath() + "getPoint", objGUI,
736: strPoint);
737: getScriptProxy().addScript(script);
738: }
739:
740: }
|