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 toolbar button.
024: Normal, check, and radio type buttons are supported. All buttons support 16x16 pixel icons.
025: When rendered, buttons are 22 pixels wide by 22 pixels high (unless a text label is used or a menu is bound,
026: in which case the button is wider).
027:
028: This class publishes the following model events:
029:
030:
031: EXECUTE Ð when the user clicks on the enabled button, when the button has focus and the user presses the
032: space or enter key, or when doExecute() is called on the button.
033:
034: CHANGE Ð when the state of a check or radio type button changes through user interaction or when
035: setState() is called under the deprecated 3.0 model event protocol.
036:
037: MENU Ð on a mouseup event with the right button when the button has a bound context menu.
038: * @author Joe Walker [joe at getahead dot org]
039: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
040: */
041: public class ToolbarButton extends jsx3.gui.Block {
042: /**
043: * All reverse ajax proxies need context to work from
044: * @param scriptProxy The place we are writing scripts to
045: * @param context The script that got us to where we are now
046: */
047: public ToolbarButton(Context context, String extension,
048: ScriptProxy scriptProxy) {
049: super (context, extension, scriptProxy);
050: }
051:
052: /**
053: * The instance initializer.
054: * @param strName unique name distinguishing this object from all other JSX GUI objects in the JSX application
055: * @param intType the type of button to create: <code>TYPENORMAL</code>, or <code>TYPECHECK</code>,
056: <code>TYPERADIO</code>.
057: * @param strTip the tooltip text for the button.
058: */
059: public ToolbarButton(String strName, int intType, String strTip) {
060: super ((Context) null, (String) null, (ScriptProxy) null);
061: ScriptBuffer script = new ScriptBuffer();
062: script
063: .appendCall("new ToolbarButton", strName, intType,
064: strTip);
065: setInitScript(script);
066: }
067:
068: /**
069: * Value of the type field indicating a normal (stateless) button.
070: */
071: public static final int TYPENORMAL = 0;
072:
073: /**
074: * Value of the type field indicating a check button. A check button is a two-state button with
075: a down state (on) and an up state (off).
076: */
077: public static final int TYPECHECK = 1;
078:
079: /**
080: * Value of the type field indicating a radio button. A radio button is a two-state button that exists as
081: a member of a set of radio buttons. Only one radio button is a set may be in a down state at one time.
082: */
083: public static final int TYPERADIO = 2;
084:
085: /**
086: * Value of the state field indicating the up/off state. A normal button is always off.
087: */
088: public static final int STATEOFF = 0;
089:
090: /**
091: * Value of the state field indicating the down/on state. Check and radio buttons may be on.
092: */
093: public static final int STATEON = 1;
094:
095: /**
096: * Returns the URL of the image to use when this button is disabled.
097: */
098: @SuppressWarnings("unchecked")
099: public void getDisabledImage(
100: org.directwebremoting.proxy.Callback<String> callback) {
101: ScriptBuffer script = new ScriptBuffer();
102: String callbackPrefix = "";
103:
104: if (callback != null) {
105: callbackPrefix = "var reply = ";
106: }
107:
108: script.appendCall(callbackPrefix + getContextPath()
109: + "getDisabledImage");
110:
111: if (callback != null) {
112: String key = org.directwebremoting.extend.CallbackHelper
113: .saveCallback(callback, String.class);
114: script
115: .appendCall("__System.activateCallback", key,
116: "reply");
117: }
118:
119: getScriptProxy().addScript(script);
120: }
121:
122: /**
123: * Sets the URL of the image to use when this button is disabled. If no disabled image is set the normal image is
124: used instead.
125: * @param strURL the URL of an image file, 16px by 16px.
126: * @return this object.
127: */
128: public jsx3.gui.ToolbarButton setDisabledImage(String strURL) {
129: ScriptBuffer script = new ScriptBuffer();
130: script
131: .appendCall(getContextPath() + "setDisabledImage",
132: strURL);
133: getScriptProxy().addScript(script);
134: return this ;
135: }
136:
137: /**
138: * Validates this button based on the type of button and whether this control is required. Normal buttons are always
139: valid because they have no state. Radio and check buttons are valid if they are on or if they are not required.
140: * @param callback <code>jsx3.gui.Form.STATEVALID</code> or <code>jsx3.gui.Form.STATEINVALID</code>.
141: */
142: @SuppressWarnings("unchecked")
143: public void doValidate(
144: org.directwebremoting.proxy.Callback<Integer> callback) {
145: ScriptBuffer script = new ScriptBuffer();
146: String callbackPrefix = "";
147:
148: if (callback != null) {
149: callbackPrefix = "var reply = ";
150: }
151:
152: script.appendCall(callbackPrefix + getContextPath()
153: + "doValidate");
154:
155: if (callback != null) {
156: String key = org.directwebremoting.extend.CallbackHelper
157: .saveCallback(callback, Integer.class);
158: script
159: .appendCall("__System.activateCallback", key,
160: "reply");
161: }
162:
163: getScriptProxy().addScript(script);
164: }
165:
166: /**
167: * Returns the URL of the image to use to render this button.
168: */
169: @SuppressWarnings("unchecked")
170: public void getImage(
171: org.directwebremoting.proxy.Callback<String> callback) {
172: ScriptBuffer script = new ScriptBuffer();
173: String callbackPrefix = "";
174:
175: if (callback != null) {
176: callbackPrefix = "var reply = ";
177: }
178:
179: script.appendCall(callbackPrefix + getContextPath()
180: + "getImage");
181:
182: if (callback != null) {
183: String key = org.directwebremoting.extend.CallbackHelper
184: .saveCallback(callback, String.class);
185: script
186: .appendCall("__System.activateCallback", key,
187: "reply");
188: }
189:
190: getScriptProxy().addScript(script);
191: }
192:
193: /**
194: * Sets the URL of the image to use to render this button. The URL is resolved by the URI resolver of this button
195: before it is rendered to HTML.
196: * @param strURL the URL of an image file, 16px by 16px.
197: * @return this object.
198: */
199: public jsx3.gui.ToolbarButton setImage(String strURL) {
200: ScriptBuffer script = new ScriptBuffer();
201: script.appendCall(getContextPath() + "setImage", strURL);
202: getScriptProxy().addScript(script);
203: return this ;
204: }
205:
206: /**
207: * Returns the type of this button.
208: * @param callback <code>TYPENORMAL</code>, or <code>TYPECHECK</code>, or <code>TYPERADIO</code>.
209: */
210: @SuppressWarnings("unchecked")
211: public void getType(
212: org.directwebremoting.proxy.Callback<Integer> callback) {
213: ScriptBuffer script = new ScriptBuffer();
214: String callbackPrefix = "";
215:
216: if (callback != null) {
217: callbackPrefix = "var reply = ";
218: }
219:
220: script
221: .appendCall(callbackPrefix + getContextPath()
222: + "getType");
223:
224: if (callback != null) {
225: String key = org.directwebremoting.extend.CallbackHelper
226: .saveCallback(callback, Integer.class);
227: script
228: .appendCall("__System.activateCallback", key,
229: "reply");
230: }
231:
232: getScriptProxy().addScript(script);
233: }
234:
235: /**
236: * Sets the type of this button.
237: * @param TYPE <code>TYPENORMAL</code>, or <code>TYPECHECK</code>, <code>TYPERADIO</code>.
238: * @return this object.
239: */
240: public jsx3.gui.ToolbarButton setType(int TYPE) {
241: ScriptBuffer script = new ScriptBuffer();
242: script.appendCall(getContextPath() + "setType", TYPE);
243: getScriptProxy().addScript(script);
244: return this ;
245: }
246:
247: /**
248: * Invokes the EXECUTE model event of this toolbar button. Note that because the model event is invoked
249: programmatically rather than by user interaction the objEVENT event parameter will be
250: null if the objEvent parameter is undefined. If this is a radio button its state is
251: set to on. If this is a check button, its state is toggled.
252: * @param objEvent the browser event that caused the execution of this button. This argument is
253: optional and should only be provided if the execution of this button is the result of a browser event. This
254: parameter will be passed along to the model event as <code>objEVENT</code>.
255: */
256: public void doExecute(jsx3.gui.Event objEvent) {
257: ScriptBuffer script = new ScriptBuffer();
258: script.appendCall(getContextPath() + "doExecute", objEvent);
259: getScriptProxy().addScript(script);
260: }
261:
262: /**
263: * Returns the name of the group to which this radio button belongs. This method returns null if this
264: button is not a radio button.
265: */
266: @SuppressWarnings("unchecked")
267: public void getGroupName(
268: org.directwebremoting.proxy.Callback<String> callback) {
269: ScriptBuffer script = new ScriptBuffer();
270: String callbackPrefix = "";
271:
272: if (callback != null) {
273: callbackPrefix = "var reply = ";
274: }
275:
276: script.appendCall(callbackPrefix + getContextPath()
277: + "getGroupName");
278:
279: if (callback != null) {
280: String key = org.directwebremoting.extend.CallbackHelper
281: .saveCallback(callback, String.class);
282: script
283: .appendCall("__System.activateCallback", key,
284: "reply");
285: }
286:
287: getScriptProxy().addScript(script);
288: }
289:
290: /**
291: * Sets the name of the group to which this radio button belongs. This method only applies to radio buttons.
292: * @param strGroupName the name of button group.
293: * @return this object.
294: */
295: public jsx3.gui.ToolbarButton setGroupName(String strGroupName) {
296: ScriptBuffer script = new ScriptBuffer();
297: script.appendCall(getContextPath() + "setGroupName",
298: strGroupName);
299: getScriptProxy().addScript(script);
300: return this ;
301: }
302:
303: /**
304: * Returns whether this toolbar button renders a visual divider on its left side.
305: * @param callback <code>jsx3.Boolean.TRUE</code> or <code>jsx3.Boolean.FALSE</code>.
306: */
307: @SuppressWarnings("unchecked")
308: public void getDivider(
309: org.directwebremoting.proxy.Callback<Integer> callback) {
310: ScriptBuffer script = new ScriptBuffer();
311: String callbackPrefix = "";
312:
313: if (callback != null) {
314: callbackPrefix = "var reply = ";
315: }
316:
317: script.appendCall(callbackPrefix + getContextPath()
318: + "getDivider");
319:
320: if (callback != null) {
321: String key = org.directwebremoting.extend.CallbackHelper
322: .saveCallback(callback, Integer.class);
323: script
324: .appendCall("__System.activateCallback", key,
325: "reply");
326: }
327:
328: getScriptProxy().addScript(script);
329: }
330:
331: /**
332: * Sets whether this toolbar button renders a visual divider on its left side. The divider is useful for
333: visually separating this toolbar button from the next toolbar button to the left.
334: * @param intDivider <code>jsx3.Boolean.TRUE</code> or <code>jsx3.Boolean.FALSE</code>.
335: * @param bRecalc
336: * @return this object.
337: */
338: public jsx3.gui.ToolbarButton setDivider(int intDivider,
339: boolean bRecalc) {
340: ScriptBuffer script = new ScriptBuffer();
341: script.appendCall(getContextPath() + "setDivider", intDivider,
342: bRecalc);
343: getScriptProxy().addScript(script);
344: return this ;
345: }
346:
347: /**
348: * Returns the state of this button. A normal button always returns STATEOFF. Radio and check
349: buttons may return STATEOFF or STATEON.
350: * @param callback <code>STATEON</code> or <code>STATEOFF</code>.
351: */
352: @SuppressWarnings("unchecked")
353: public void getState(
354: org.directwebremoting.proxy.Callback<Integer> callback) {
355: ScriptBuffer script = new ScriptBuffer();
356: String callbackPrefix = "";
357:
358: if (callback != null) {
359: callbackPrefix = "var reply = ";
360: }
361:
362: script.appendCall(callbackPrefix + getContextPath()
363: + "getState");
364:
365: if (callback != null) {
366: String key = org.directwebremoting.extend.CallbackHelper
367: .saveCallback(callback, Integer.class);
368: script
369: .appendCall("__System.activateCallback", key,
370: "reply");
371: }
372:
373: getScriptProxy().addScript(script);
374: }
375:
376: /**
377: * Sets the state of this button. This method effects both the model and the view immediately. This method invokes
378: the CHANGE model event only under the deprecated 3.0 model event protocol.
379: * @param intState <code>STATEON</code> or <code>STATEOFF</code>.
380: * @return this object.
381: */
382: public jsx3.gui.ToolbarButton setState(int intState) {
383: ScriptBuffer script = new ScriptBuffer();
384: script.appendCall(getContextPath() + "setState", intState);
385: getScriptProxy().addScript(script);
386: return this ;
387: }
388:
389: /**
390: * Binds the given key sequence to a callback function. Any object that has a key binding (specified with
391: setKeyBinding()) will call this method when painted to register the key sequence with an appropriate
392: ancestor of this form control. Any key down event that bubbles up to the ancestor without being intercepted
393: and matches the given key sequence will invoke the given callback function.
394:
395: As of 3.2: The hot key will be registered with the first ancestor found that is either a
396: jsx3.gui.Window, a jsx3.gui.Dialog, or the root block of a jsx3.app.Server.
397: * @param fctCallback JavaScript function to execute when the given sequence is keyed by the user.
398: * @param strKeys a plus-delimited ('+') key sequence such as <code>ctrl+s</code> or
399: <code>ctrl+shift+alt+h</code> or <code>shift+a</code>, etc. Any combination of shift, ctrl, and alt are
400: supported, including none. Also supported as the final token are <code>enter</code>, <code>esc</code>,
401: <code>tab</code>, <code>del</code>, and <code>space</code>. To specify the final token as a key code, the
402: last token can be the key code contained in brackets, <code>[13]</code>.
403: * @return the registered hot key.
404: */
405: @SuppressWarnings("unchecked")
406: public jsx3.gui.HotKey doKeyBinding(
407: org.directwebremoting.proxy.CodeBlock fctCallback,
408: String strKeys) {
409: String extension = "doKeyBinding(\"" + fctCallback + "\", \""
410: + strKeys + "\").";
411: try {
412: java.lang.reflect.Constructor<jsx3.gui.HotKey> ctor = jsx3.gui.HotKey.class
413: .getConstructor(Context.class, String.class,
414: ScriptProxy.class);
415: return ctor.newInstance(this , extension, getScriptProxy());
416: } catch (Exception ex) {
417: throw new IllegalArgumentException("Unsupported type: "
418: + jsx3.gui.HotKey.class.getName());
419: }
420: }
421:
422: /**
423: * Resets the validation state of this control.
424: * @return this object.
425: */
426: @SuppressWarnings("unchecked")
427: public jsx3.gui.Form doReset() {
428: String extension = "doReset().";
429: try {
430: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
431: .getConstructor(Context.class, String.class,
432: ScriptProxy.class);
433: return ctor.newInstance(this , extension, getScriptProxy());
434: } catch (Exception ex) {
435: throw new IllegalArgumentException("Unsupported type: "
436: + jsx3.gui.Form.class.getName());
437: }
438: }
439:
440: /**
441: * Resets the validation state of this control.
442: * @param returnType The expected return type
443: * @return this object.
444: */
445: @SuppressWarnings("unchecked")
446: public <T> T doReset(Class<T> returnType) {
447: String extension = "doReset().";
448: try {
449: java.lang.reflect.Constructor<T> ctor = returnType
450: .getConstructor(Context.class, String.class,
451: ScriptProxy.class);
452: return ctor.newInstance(this , extension, getScriptProxy());
453: } catch (Exception ex) {
454: throw new IllegalArgumentException(
455: "Unsupported return type: " + returnType.getName());
456: }
457: }
458:
459: /**
460: * Returns the background color of this control when it is disabled.
461: * @param callback valid CSS property value, (i.e., red, #ff0000)
462: */
463: @SuppressWarnings("unchecked")
464: public void getDisabledBackgroundColor(
465: org.directwebremoting.proxy.Callback<String> callback) {
466: ScriptBuffer script = new ScriptBuffer();
467: String callbackPrefix = "";
468:
469: if (callback != null) {
470: callbackPrefix = "var reply = ";
471: }
472:
473: script.appendCall(callbackPrefix + getContextPath()
474: + "getDisabledBackgroundColor");
475:
476: if (callback != null) {
477: String key = org.directwebremoting.extend.CallbackHelper
478: .saveCallback(callback, String.class);
479: script
480: .appendCall("__System.activateCallback", key,
481: "reply");
482: }
483:
484: getScriptProxy().addScript(script);
485: }
486:
487: /**
488: * Returns the font color to use when this control is disabled.
489: * @param callback valid CSS property value, (i.e., red, #ff0000)
490: */
491: @SuppressWarnings("unchecked")
492: public void getDisabledColor(
493: org.directwebremoting.proxy.Callback<String> callback) {
494: ScriptBuffer script = new ScriptBuffer();
495: String callbackPrefix = "";
496:
497: if (callback != null) {
498: callbackPrefix = "var reply = ";
499: }
500:
501: script.appendCall(callbackPrefix + getContextPath()
502: + "getDisabledColor");
503:
504: if (callback != null) {
505: String key = org.directwebremoting.extend.CallbackHelper
506: .saveCallback(callback, String.class);
507: script
508: .appendCall("__System.activateCallback", key,
509: "reply");
510: }
511:
512: getScriptProxy().addScript(script);
513: }
514:
515: /**
516: * Returns the state for the form field control. If no enabled state is set, this method returns
517: STATEENABLED.
518: * @param callback <code>STATEDISABLED</code> or <code>STATEENABLED</code>.
519: */
520: @SuppressWarnings("unchecked")
521: public void getEnabled(
522: org.directwebremoting.proxy.Callback<Integer> callback) {
523: ScriptBuffer script = new ScriptBuffer();
524: String callbackPrefix = "";
525:
526: if (callback != null) {
527: callbackPrefix = "var reply = ";
528: }
529:
530: script.appendCall(callbackPrefix + getContextPath()
531: + "getEnabled");
532:
533: if (callback != null) {
534: String key = org.directwebremoting.extend.CallbackHelper
535: .saveCallback(callback, Integer.class);
536: script
537: .appendCall("__System.activateCallback", key,
538: "reply");
539: }
540:
541: getScriptProxy().addScript(script);
542: }
543:
544: /**
545: * Returns the key binding that when keyed will fire the execute event for this control.
546: * @param callback plus-delimited (e.g.,'+') key sequence such as ctrl+s or ctrl+shift+alt+h or shift+a, etc
547: */
548: @SuppressWarnings("unchecked")
549: public void getKeyBinding(
550: org.directwebremoting.proxy.Callback<String> callback) {
551: ScriptBuffer script = new ScriptBuffer();
552: String callbackPrefix = "";
553:
554: if (callback != null) {
555: callbackPrefix = "var reply = ";
556: }
557:
558: script.appendCall(callbackPrefix + getContextPath()
559: + "getKeyBinding");
560:
561: if (callback != null) {
562: String key = org.directwebremoting.extend.CallbackHelper
563: .saveCallback(callback, String.class);
564: script
565: .appendCall("__System.activateCallback", key,
566: "reply");
567: }
568:
569: getScriptProxy().addScript(script);
570: }
571:
572: /**
573: * Returns whether or not this control is required. If the required property has never been set, this method returns
574: OPTIONAL.
575: * @param callback <code>REQUIRED</code> or <code>OPTIONAL</code>.
576: */
577: @SuppressWarnings("unchecked")
578: public void getRequired(
579: org.directwebremoting.proxy.Callback<Integer> callback) {
580: ScriptBuffer script = new ScriptBuffer();
581: String callbackPrefix = "";
582:
583: if (callback != null) {
584: callbackPrefix = "var reply = ";
585: }
586:
587: script.appendCall(callbackPrefix + getContextPath()
588: + "getRequired");
589:
590: if (callback != null) {
591: String key = org.directwebremoting.extend.CallbackHelper
592: .saveCallback(callback, Integer.class);
593: script
594: .appendCall("__System.activateCallback", key,
595: "reply");
596: }
597:
598: getScriptProxy().addScript(script);
599: }
600:
601: /**
602: * Returns the validation state of this control. If the validationState property has never been set, this method returns
603: STATEVALID.
604: * @param callback <code>STATEINVALID</code> or <code>STATEVALID</code>.
605: */
606: @SuppressWarnings("unchecked")
607: public void getValidationState(
608: org.directwebremoting.proxy.Callback<Integer> callback) {
609: ScriptBuffer script = new ScriptBuffer();
610: String callbackPrefix = "";
611:
612: if (callback != null) {
613: callbackPrefix = "var reply = ";
614: }
615:
616: script.appendCall(callbackPrefix + getContextPath()
617: + "getValidationState");
618:
619: if (callback != null) {
620: String key = org.directwebremoting.extend.CallbackHelper
621: .saveCallback(callback, Integer.class);
622: script
623: .appendCall("__System.activateCallback", key,
624: "reply");
625: }
626:
627: getScriptProxy().addScript(script);
628: }
629:
630: /**
631: * Returns the value of this control.
632: */
633: @SuppressWarnings("unchecked")
634: public void getValue(
635: org.directwebremoting.proxy.Callback<Integer> callback) {
636: ScriptBuffer script = new ScriptBuffer();
637: String callbackPrefix = "";
638:
639: if (callback != null) {
640: callbackPrefix = "var reply = ";
641: }
642:
643: script.appendCall(callbackPrefix + getContextPath()
644: + "getValue");
645:
646: if (callback != null) {
647: String key = org.directwebremoting.extend.CallbackHelper
648: .saveCallback(callback, Integer.class);
649: script
650: .appendCall("__System.activateCallback", key,
651: "reply");
652: }
653:
654: getScriptProxy().addScript(script);
655: }
656:
657: /**
658: * Sets the background color of this form control when it is disabled.
659: * @param strColor valid CSS property value, (i.e., red, #ff0000)
660: * @return this object.
661: */
662: @SuppressWarnings("unchecked")
663: public jsx3.gui.Form setDisabledBackgroundColor(String strColor) {
664: String extension = "setDisabledBackgroundColor(\"" + strColor
665: + "\").";
666: try {
667: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
668: .getConstructor(Context.class, String.class,
669: ScriptProxy.class);
670: return ctor.newInstance(this , extension, getScriptProxy());
671: } catch (Exception ex) {
672: throw new IllegalArgumentException("Unsupported type: "
673: + jsx3.gui.Form.class.getName());
674: }
675: }
676:
677: /**
678: * Sets the background color of this form control when it is disabled.
679: * @param strColor valid CSS property value, (i.e., red, #ff0000)
680: * @param returnType The expected return type
681: * @return this object.
682: */
683: @SuppressWarnings("unchecked")
684: public <T> T setDisabledBackgroundColor(String strColor,
685: Class<T> returnType) {
686: String extension = "setDisabledBackgroundColor(\"" + strColor
687: + "\").";
688: try {
689: java.lang.reflect.Constructor<T> ctor = returnType
690: .getConstructor(Context.class, String.class,
691: ScriptProxy.class);
692: return ctor.newInstance(this , extension, getScriptProxy());
693: } catch (Exception ex) {
694: throw new IllegalArgumentException(
695: "Unsupported return type: " + returnType.getName());
696: }
697: }
698:
699: /**
700: * Sets the font color to use when this control is disabled.
701: * @param strColor valid CSS property value, (i.e., red, #ff0000)
702: * @return this object.
703: */
704: @SuppressWarnings("unchecked")
705: public jsx3.gui.Form setDisabledColor(String strColor) {
706: String extension = "setDisabledColor(\"" + strColor + "\").";
707: try {
708: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
709: .getConstructor(Context.class, String.class,
710: ScriptProxy.class);
711: return ctor.newInstance(this , extension, getScriptProxy());
712: } catch (Exception ex) {
713: throw new IllegalArgumentException("Unsupported type: "
714: + jsx3.gui.Form.class.getName());
715: }
716: }
717:
718: /**
719: * Sets the font color to use when this control is disabled.
720: * @param strColor valid CSS property value, (i.e., red, #ff0000)
721: * @param returnType The expected return type
722: * @return this object.
723: */
724: @SuppressWarnings("unchecked")
725: public <T> T setDisabledColor(String strColor, Class<T> returnType) {
726: String extension = "setDisabledColor(\"" + strColor + "\").";
727: try {
728: java.lang.reflect.Constructor<T> ctor = returnType
729: .getConstructor(Context.class, String.class,
730: ScriptProxy.class);
731: return ctor.newInstance(this , extension, getScriptProxy());
732: } catch (Exception ex) {
733: throw new IllegalArgumentException(
734: "Unsupported return type: " + returnType.getName());
735: }
736: }
737:
738: /**
739: * Sets whether this control is enabled. Disabled controls do not respond to user interaction.
740: * @param intEnabled <code>STATEDISABLED</code> or <code>STATEENABLED</code>. <code>null</code> is
741: equivalent to <code>STATEENABLED</code>.
742: * @param bRepaint if <code>true</code> this control is immediately repainted to reflect the new setting.
743: */
744: public void setEnabled(int intEnabled, boolean bRepaint) {
745: ScriptBuffer script = new ScriptBuffer();
746: script.appendCall(getContextPath() + "setEnabled", intEnabled,
747: bRepaint);
748: getScriptProxy().addScript(script);
749: }
750:
751: /**
752: * Sets the key binding that when keyed will fire the bound execute (jsx3.gui.Interactive.EXECUTE)
753: event for this control.
754: * @param strSequence plus-delimited (e.g.,'+') key sequence such as ctrl+s or ctrl+shift+alt+h or shift+a, etc
755: * @return this object.
756: */
757: @SuppressWarnings("unchecked")
758: public jsx3.gui.Form setKeyBinding(String strSequence) {
759: String extension = "setKeyBinding(\"" + strSequence + "\").";
760: try {
761: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
762: .getConstructor(Context.class, String.class,
763: ScriptProxy.class);
764: return ctor.newInstance(this , extension, getScriptProxy());
765: } catch (Exception ex) {
766: throw new IllegalArgumentException("Unsupported type: "
767: + jsx3.gui.Form.class.getName());
768: }
769: }
770:
771: /**
772: * Sets the key binding that when keyed will fire the bound execute (jsx3.gui.Interactive.EXECUTE)
773: event for this control.
774: * @param strSequence plus-delimited (e.g.,'+') key sequence such as ctrl+s or ctrl+shift+alt+h or shift+a, etc
775: * @param returnType The expected return type
776: * @return this object.
777: */
778: @SuppressWarnings("unchecked")
779: public <T> T setKeyBinding(String strSequence, Class<T> returnType) {
780: String extension = "setKeyBinding(\"" + strSequence + "\").";
781: try {
782: java.lang.reflect.Constructor<T> ctor = returnType
783: .getConstructor(Context.class, String.class,
784: ScriptProxy.class);
785: return ctor.newInstance(this , extension, getScriptProxy());
786: } catch (Exception ex) {
787: throw new IllegalArgumentException(
788: "Unsupported return type: " + returnType.getName());
789: }
790: }
791:
792: /**
793: * Sets whether or not this control is required.
794: * @param required {int} <code>REQUIRED</code> or <code>OPTIONAL</code>.
795: * @return this object.
796: */
797: @SuppressWarnings("unchecked")
798: public jsx3.gui.Form setRequired(int required) {
799: String extension = "setRequired(\"" + required + "\").";
800: try {
801: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
802: .getConstructor(Context.class, String.class,
803: ScriptProxy.class);
804: return ctor.newInstance(this , extension, getScriptProxy());
805: } catch (Exception ex) {
806: throw new IllegalArgumentException("Unsupported type: "
807: + jsx3.gui.Form.class.getName());
808: }
809: }
810:
811: /**
812: * Sets whether or not this control is required.
813: * @param required {int} <code>REQUIRED</code> or <code>OPTIONAL</code>.
814: * @param returnType The expected return type
815: * @return this object.
816: */
817: @SuppressWarnings("unchecked")
818: public <T> T setRequired(int required, Class<T> returnType) {
819: String extension = "setRequired(\"" + required + "\").";
820: try {
821: java.lang.reflect.Constructor<T> ctor = returnType
822: .getConstructor(Context.class, String.class,
823: ScriptProxy.class);
824: return ctor.newInstance(this , extension, getScriptProxy());
825: } catch (Exception ex) {
826: throw new IllegalArgumentException(
827: "Unsupported return type: " + returnType.getName());
828: }
829: }
830:
831: /**
832: * Sets the validation state of this control. The validation state of a control is not serialized.
833: * @param intState <code>STATEINVALID</code> or <code>STATEVALID</code>.
834: * @return this object.
835: */
836: @SuppressWarnings("unchecked")
837: public jsx3.gui.Form setValidationState(int intState) {
838: String extension = "setValidationState(\"" + intState + "\").";
839: try {
840: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
841: .getConstructor(Context.class, String.class,
842: ScriptProxy.class);
843: return ctor.newInstance(this , extension, getScriptProxy());
844: } catch (Exception ex) {
845: throw new IllegalArgumentException("Unsupported type: "
846: + jsx3.gui.Form.class.getName());
847: }
848: }
849:
850: /**
851: * Sets the validation state of this control. The validation state of a control is not serialized.
852: * @param intState <code>STATEINVALID</code> or <code>STATEVALID</code>.
853: * @param returnType The expected return type
854: * @return this object.
855: */
856: @SuppressWarnings("unchecked")
857: public <T> T setValidationState(int intState, Class<T> returnType) {
858: String extension = "setValidationState(\"" + intState + "\").";
859: try {
860: java.lang.reflect.Constructor<T> ctor = returnType
861: .getConstructor(Context.class, String.class,
862: ScriptProxy.class);
863: return ctor.newInstance(this , extension, getScriptProxy());
864: } catch (Exception ex) {
865: throw new IllegalArgumentException(
866: "Unsupported return type: " + returnType.getName());
867: }
868: }
869:
870: /**
871: * Sets the value of this control.
872: * @param vntValue string/int value for the component
873: * @return this object.
874: */
875: @SuppressWarnings("unchecked")
876: public jsx3.gui.Form setValue(String vntValue) {
877: String extension = "setValue(\"" + vntValue + "\").";
878: try {
879: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
880: .getConstructor(Context.class, String.class,
881: ScriptProxy.class);
882: return ctor.newInstance(this , extension, getScriptProxy());
883: } catch (Exception ex) {
884: throw new IllegalArgumentException("Unsupported type: "
885: + jsx3.gui.Form.class.getName());
886: }
887: }
888:
889: /**
890: * Sets the value of this control.
891: * @param vntValue string/int value for the component
892: * @param returnType The expected return type
893: * @return this object.
894: */
895: @SuppressWarnings("unchecked")
896: public <T> T setValue(String vntValue, Class<T> returnType) {
897: String extension = "setValue(\"" + vntValue + "\").";
898: try {
899: java.lang.reflect.Constructor<T> ctor = returnType
900: .getConstructor(Context.class, String.class,
901: ScriptProxy.class);
902: return ctor.newInstance(this , extension, getScriptProxy());
903: } catch (Exception ex) {
904: throw new IllegalArgumentException(
905: "Unsupported return type: " + returnType.getName());
906: }
907: }
908:
909: /**
910: * Sets the value of this control.
911: * @param vntValue string/int value for the component
912: * @return this object.
913: */
914: @SuppressWarnings("unchecked")
915: public jsx3.gui.Form setValue(Integer vntValue) {
916: String extension = "setValue(\"" + vntValue + "\").";
917: try {
918: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
919: .getConstructor(Context.class, String.class,
920: ScriptProxy.class);
921: return ctor.newInstance(this , extension, getScriptProxy());
922: } catch (Exception ex) {
923: throw new IllegalArgumentException("Unsupported type: "
924: + jsx3.gui.Form.class.getName());
925: }
926: }
927:
928: /**
929: * Sets the value of this control.
930: * @param vntValue string/int value for the component
931: * @param returnType The expected return type
932: * @return this object.
933: */
934: @SuppressWarnings("unchecked")
935: public <T> T setValue(Integer vntValue, Class<T> returnType) {
936: String extension = "setValue(\"" + vntValue + "\").";
937: try {
938: java.lang.reflect.Constructor<T> ctor = returnType
939: .getConstructor(Context.class, String.class,
940: ScriptProxy.class);
941: return ctor.newInstance(this , extension, getScriptProxy());
942: } catch (Exception ex) {
943: throw new IllegalArgumentException(
944: "Unsupported return type: " + returnType.getName());
945: }
946: }
947:
948: }
|