0001: /*
0002: * Copyright 2005 Joe Walker
0003: *
0004: * Licensed under the Apache License, Version 2.0 (the "License");
0005: * you may not use this file except in compliance with the License.
0006: * You may obtain a copy of the License at
0007: *
0008: * http://www.apache.org/licenses/LICENSE-2.0
0009: *
0010: * Unless required by applicable law or agreed to in writing, software
0011: * distributed under the License is distributed on an "AS IS" BASIS,
0012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013: * See the License for the specific language governing permissions and
0014: * limitations under the License.
0015: */
0016: package jsx3.gui;
0017:
0018: import org.directwebremoting.ScriptBuffer;
0019: import org.directwebremoting.proxy.ScriptProxy;
0020: import org.directwebremoting.proxy.io.Context;
0021:
0022: /**
0023: * An object-oriented interface onto a GUI button made of various image files. The class allows for an image file
0024: for the following states:
0025:
0026: Normal/Off
0027: Mouse Over
0028: Mouse Down
0029: Selected/On
0030: Disabled
0031:
0032: The following model events are published:
0033:
0034: EXECUTE (click)
0035: TOGGLE (click when type is TYPE_TOGGLE)
0036: MENU
0037: * @author Joe Walker [joe at getahead dot org]
0038: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
0039: */
0040: public class ImageButton extends jsx3.gui.Block {
0041: /**
0042: * All reverse ajax proxies need context to work from
0043: * @param scriptProxy The place we are writing scripts to
0044: * @param context The script that got us to where we are now
0045: */
0046: public ImageButton(Context context, String extension,
0047: ScriptProxy scriptProxy) {
0048: super (context, extension, scriptProxy);
0049: }
0050:
0051: /**
0052: * The instance initializer.
0053: * @param strName the JSX name
0054: * @param vntLeft either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
0055: * @param vntTop either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
0056: * @param vntWidth
0057: * @param vntHeight
0058: */
0059: public ImageButton(String strName, int vntLeft, String vntTop,
0060: int vntWidth, int vntHeight) {
0061: super ((Context) null, (String) null, (ScriptProxy) null);
0062: ScriptBuffer script = new ScriptBuffer();
0063: script.appendCall("new ImageButton", strName, vntLeft, vntTop,
0064: vntWidth, vntHeight);
0065: setInitScript(script);
0066: }
0067:
0068: /**
0069: * The instance initializer.
0070: * @param strName the JSX name
0071: * @param vntLeft either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
0072: * @param vntTop either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
0073: * @param vntWidth
0074: * @param vntHeight
0075: */
0076: public ImageButton(String strName, int vntLeft, int vntTop,
0077: int vntWidth, int vntHeight) {
0078: super ((Context) null, (String) null, (ScriptProxy) null);
0079: ScriptBuffer script = new ScriptBuffer();
0080: script.appendCall("new ImageButton", strName, vntLeft, vntTop,
0081: vntWidth, vntHeight);
0082: setInitScript(script);
0083: }
0084:
0085: /**
0086: * The instance initializer.
0087: * @param strName the JSX name
0088: * @param vntLeft either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
0089: * @param vntTop either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
0090: * @param vntWidth
0091: * @param vntHeight
0092: */
0093: public ImageButton(String strName, String vntLeft, String vntTop,
0094: int vntWidth, int vntHeight) {
0095: super ((Context) null, (String) null, (ScriptProxy) null);
0096: ScriptBuffer script = new ScriptBuffer();
0097: script.appendCall("new ImageButton", strName, vntLeft, vntTop,
0098: vntWidth, vntHeight);
0099: setInitScript(script);
0100: }
0101:
0102: /**
0103: * The instance initializer.
0104: * @param strName the JSX name
0105: * @param vntLeft either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
0106: * @param vntTop either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
0107: * @param vntWidth
0108: * @param vntHeight
0109: */
0110: public ImageButton(String strName, String vntLeft, int vntTop,
0111: int vntWidth, int vntHeight) {
0112: super ((Context) null, (String) null, (ScriptProxy) null);
0113: ScriptBuffer script = new ScriptBuffer();
0114: script.appendCall("new ImageButton", strName, vntLeft, vntTop,
0115: vntWidth, vntHeight);
0116: setInitScript(script);
0117: }
0118:
0119: /**
0120: * Value for the type field indicating a normal button.
0121: */
0122: public static final int TYPE_NORMAL = 0;
0123:
0124: /**
0125: * Value for the type field indicating a toggle (2-state) button.
0126: */
0127: public static final int TYPE_TOGGLE = 1;
0128:
0129: /**
0130: * Value for the state field indicating that the toggle button is off.
0131: */
0132: public static final int STATE_OFF = 0;
0133:
0134: /**
0135: * Value for the state field indicating that the toggle button is on.
0136: */
0137: public static final int STATE_ON = 1;
0138:
0139: /**
0140: * Returns the URI of the image of this image button.
0141: */
0142: @SuppressWarnings("unchecked")
0143: public void getImage(
0144: org.directwebremoting.proxy.Callback<String> callback) {
0145: ScriptBuffer script = new ScriptBuffer();
0146: String callbackPrefix = "";
0147:
0148: if (callback != null) {
0149: callbackPrefix = "var reply = ";
0150: }
0151:
0152: script.appendCall(callbackPrefix + getContextPath()
0153: + "getImage");
0154:
0155: if (callback != null) {
0156: String key = org.directwebremoting.extend.CallbackHelper
0157: .saveCallback(callback, String.class);
0158: script
0159: .appendCall("__System.activateCallback", key,
0160: "reply");
0161: }
0162:
0163: getScriptProxy().addScript(script);
0164: }
0165:
0166: /**
0167: * Sets the URI of the image of this image button. This is the default image that is displayed if the button
0168: is off or if the button is in a state for which no image URI is specified.
0169: * @param strImage
0170: * @return this object
0171: */
0172: public jsx3.gui.ImageButton setImage(String strImage) {
0173: ScriptBuffer script = new ScriptBuffer();
0174: script.appendCall(getContextPath() + "setImage", strImage);
0175: getScriptProxy().addScript(script);
0176: return this ;
0177: }
0178:
0179: /**
0180: * Returns the URI of the over image of this image button.
0181: */
0182: @SuppressWarnings("unchecked")
0183: public void getOverImage(
0184: org.directwebremoting.proxy.Callback<String> callback) {
0185: ScriptBuffer script = new ScriptBuffer();
0186: String callbackPrefix = "";
0187:
0188: if (callback != null) {
0189: callbackPrefix = "var reply = ";
0190: }
0191:
0192: script.appendCall(callbackPrefix + getContextPath()
0193: + "getOverImage");
0194:
0195: if (callback != null) {
0196: String key = org.directwebremoting.extend.CallbackHelper
0197: .saveCallback(callback, String.class);
0198: script
0199: .appendCall("__System.activateCallback", key,
0200: "reply");
0201: }
0202:
0203: getScriptProxy().addScript(script);
0204: }
0205:
0206: /**
0207: * Sets the URI of the over image of this image button. This is the image that is displayed when the mouse moves
0208: over the image button.
0209: * @param strImage
0210: * @return this object
0211: */
0212: public jsx3.gui.ImageButton setOverImage(String strImage) {
0213: ScriptBuffer script = new ScriptBuffer();
0214: script.appendCall(getContextPath() + "setOverImage", strImage);
0215: getScriptProxy().addScript(script);
0216: return this ;
0217: }
0218:
0219: /**
0220: * Returns the URI of the down image of this image button.
0221: */
0222: @SuppressWarnings("unchecked")
0223: public void getDownImage(
0224: org.directwebremoting.proxy.Callback<String> callback) {
0225: ScriptBuffer script = new ScriptBuffer();
0226: String callbackPrefix = "";
0227:
0228: if (callback != null) {
0229: callbackPrefix = "var reply = ";
0230: }
0231:
0232: script.appendCall(callbackPrefix + getContextPath()
0233: + "getDownImage");
0234:
0235: if (callback != null) {
0236: String key = org.directwebremoting.extend.CallbackHelper
0237: .saveCallback(callback, String.class);
0238: script
0239: .appendCall("__System.activateCallback", key,
0240: "reply");
0241: }
0242:
0243: getScriptProxy().addScript(script);
0244: }
0245:
0246: /**
0247: * Sets the URI of the down image of this image button. This is the image that is displayed when the mouse is down
0248: over the image button.
0249: * @param strImage
0250: * @return this object
0251: */
0252: public jsx3.gui.ImageButton setDownImage(String strImage) {
0253: ScriptBuffer script = new ScriptBuffer();
0254: script.appendCall(getContextPath() + "setDownImage", strImage);
0255: getScriptProxy().addScript(script);
0256: return this ;
0257: }
0258:
0259: /**
0260: * Returns the URI of the on image of this image button.
0261: */
0262: @SuppressWarnings("unchecked")
0263: public void getOnImage(
0264: org.directwebremoting.proxy.Callback<String> callback) {
0265: ScriptBuffer script = new ScriptBuffer();
0266: String callbackPrefix = "";
0267:
0268: if (callback != null) {
0269: callbackPrefix = "var reply = ";
0270: }
0271:
0272: script.appendCall(callbackPrefix + getContextPath()
0273: + "getOnImage");
0274:
0275: if (callback != null) {
0276: String key = org.directwebremoting.extend.CallbackHelper
0277: .saveCallback(callback, String.class);
0278: script
0279: .appendCall("__System.activateCallback", key,
0280: "reply");
0281: }
0282:
0283: getScriptProxy().addScript(script);
0284: }
0285:
0286: /**
0287: * Sets the URI of the on image of this image button. This is the image that is displayed when this image button is
0288: of type TYPE_TOGGLE and its state is STATE_ON.
0289: * @param strImage
0290: * @return this object
0291: */
0292: public jsx3.gui.ImageButton setOnImage(String strImage) {
0293: ScriptBuffer script = new ScriptBuffer();
0294: script.appendCall(getContextPath() + "setOnImage", strImage);
0295: getScriptProxy().addScript(script);
0296: return this ;
0297: }
0298:
0299: /**
0300: * Returns the URI of the disabled image of this image button.
0301: */
0302: @SuppressWarnings("unchecked")
0303: public void getDisabledImage(
0304: org.directwebremoting.proxy.Callback<String> callback) {
0305: ScriptBuffer script = new ScriptBuffer();
0306: String callbackPrefix = "";
0307:
0308: if (callback != null) {
0309: callbackPrefix = "var reply = ";
0310: }
0311:
0312: script.appendCall(callbackPrefix + getContextPath()
0313: + "getDisabledImage");
0314:
0315: if (callback != null) {
0316: String key = org.directwebremoting.extend.CallbackHelper
0317: .saveCallback(callback, String.class);
0318: script
0319: .appendCall("__System.activateCallback", key,
0320: "reply");
0321: }
0322:
0323: getScriptProxy().addScript(script);
0324: }
0325:
0326: /**
0327: * Sets the URI of the disabled image of this image button. This is the image that is displayed when this image
0328: button disabled.
0329: * @param strImage
0330: * @return this object
0331: */
0332: public jsx3.gui.ImageButton setDisabledImage(String strImage) {
0333: ScriptBuffer script = new ScriptBuffer();
0334: script.appendCall(getContextPath() + "setDisabledImage",
0335: strImage);
0336: getScriptProxy().addScript(script);
0337: return this ;
0338: }
0339:
0340: /**
0341: * Returns the current state of this image button.
0342: * @param callback <code>STATE_OFF</code> or <code>STATE_ON</code>
0343: */
0344: @SuppressWarnings("unchecked")
0345: public void getState(
0346: org.directwebremoting.proxy.Callback<Integer> callback) {
0347: ScriptBuffer script = new ScriptBuffer();
0348: String callbackPrefix = "";
0349:
0350: if (callback != null) {
0351: callbackPrefix = "var reply = ";
0352: }
0353:
0354: script.appendCall(callbackPrefix + getContextPath()
0355: + "getState");
0356:
0357: if (callback != null) {
0358: String key = org.directwebremoting.extend.CallbackHelper
0359: .saveCallback(callback, Integer.class);
0360: script
0361: .appendCall("__System.activateCallback", key,
0362: "reply");
0363: }
0364:
0365: getScriptProxy().addScript(script);
0366: }
0367:
0368: /**
0369: * Sets the current state of this image button and updates the displayed image accordingly.
0370: * @param intState <code>STATE_OFF</code> or <code>STATE_ON</code>
0371: * @return this object
0372: */
0373: public jsx3.gui.ImageButton setState(int intState) {
0374: ScriptBuffer script = new ScriptBuffer();
0375: script.appendCall(getContextPath() + "setState", intState);
0376: getScriptProxy().addScript(script);
0377: return this ;
0378: }
0379:
0380: /**
0381: * Returns the type of this image button.
0382: * @param callback <code>TYPE_NORMAL</code> or <code>TYPE_TOGGLE</code>
0383: */
0384: @SuppressWarnings("unchecked")
0385: public void getType(
0386: org.directwebremoting.proxy.Callback<Integer> callback) {
0387: ScriptBuffer script = new ScriptBuffer();
0388: String callbackPrefix = "";
0389:
0390: if (callback != null) {
0391: callbackPrefix = "var reply = ";
0392: }
0393:
0394: script
0395: .appendCall(callbackPrefix + getContextPath()
0396: + "getType");
0397:
0398: if (callback != null) {
0399: String key = org.directwebremoting.extend.CallbackHelper
0400: .saveCallback(callback, Integer.class);
0401: script
0402: .appendCall("__System.activateCallback", key,
0403: "reply");
0404: }
0405:
0406: getScriptProxy().addScript(script);
0407: }
0408:
0409: /**
0410: * Sets the type of this image button.
0411: * @param intType <code>TYPE_NORMAL</code> or <code>TYPE_TOGGLE</code>
0412: * @return this object
0413: */
0414: public jsx3.gui.ImageButton setType(int intType) {
0415: ScriptBuffer script = new ScriptBuffer();
0416: script.appendCall(getContextPath() + "setType", intType);
0417: getScriptProxy().addScript(script);
0418: return this ;
0419: }
0420:
0421: /**
0422: * Returns true if the images of this image button are pre-fetched.
0423: */
0424: @SuppressWarnings("unchecked")
0425: public void isPreFetch(
0426: org.directwebremoting.proxy.Callback<Boolean> callback) {
0427: ScriptBuffer script = new ScriptBuffer();
0428: String callbackPrefix = "";
0429:
0430: if (callback != null) {
0431: callbackPrefix = "var reply = ";
0432: }
0433:
0434: script.appendCall(callbackPrefix + getContextPath()
0435: + "isPreFetch");
0436:
0437: if (callback != null) {
0438: String key = org.directwebremoting.extend.CallbackHelper
0439: .saveCallback(callback, Boolean.class);
0440: script
0441: .appendCall("__System.activateCallback", key,
0442: "reply");
0443: }
0444:
0445: getScriptProxy().addScript(script);
0446: }
0447:
0448: /**
0449: * Sets whether if the images of this image button are pre-fetched. Pre-fetching allows for better responsiveness
0450: the first time a state image is displayed.
0451: * @param bFetch
0452: * @return this object
0453: */
0454: public jsx3.gui.ImageButton setPreFetch(boolean bFetch) {
0455: ScriptBuffer script = new ScriptBuffer();
0456: script.appendCall(getContextPath() + "setPreFetch", bFetch);
0457: getScriptProxy().addScript(script);
0458: return this ;
0459: }
0460:
0461: /**
0462: * If this image button is of type TYPE_TOGGLE, then the state must be either STATE_ON
0463: or required must be OPTIONAL to pass validation.
0464: */
0465: @SuppressWarnings("unchecked")
0466: public void doValidate(
0467: org.directwebremoting.proxy.Callback<Integer> callback) {
0468: ScriptBuffer script = new ScriptBuffer();
0469: String callbackPrefix = "";
0470:
0471: if (callback != null) {
0472: callbackPrefix = "var reply = ";
0473: }
0474:
0475: script.appendCall(callbackPrefix + getContextPath()
0476: + "doValidate");
0477:
0478: if (callback != null) {
0479: String key = org.directwebremoting.extend.CallbackHelper
0480: .saveCallback(callback, Integer.class);
0481: script
0482: .appendCall("__System.activateCallback", key,
0483: "reply");
0484: }
0485:
0486: getScriptProxy().addScript(script);
0487: }
0488:
0489: /**
0490: * Binds the given key sequence to a callback function. Any object that has a key binding (specified with
0491: setKeyBinding()) will call this method when painted to register the key sequence with an appropriate
0492: ancestor of this form control. Any key down event that bubbles up to the ancestor without being intercepted
0493: and matches the given key sequence will invoke the given callback function.
0494:
0495: As of 3.2: The hot key will be registered with the first ancestor found that is either a
0496: jsx3.gui.Window, a jsx3.gui.Dialog, or the root block of a jsx3.app.Server.
0497: * @param fctCallback JavaScript function to execute when the given sequence is keyed by the user.
0498: * @param strKeys a plus-delimited ('+') key sequence such as <code>ctrl+s</code> or
0499: <code>ctrl+shift+alt+h</code> or <code>shift+a</code>, etc. Any combination of shift, ctrl, and alt are
0500: supported, including none. Also supported as the final token are <code>enter</code>, <code>esc</code>,
0501: <code>tab</code>, <code>del</code>, and <code>space</code>. To specify the final token as a key code, the
0502: last token can be the key code contained in brackets, <code>[13]</code>.
0503: * @return the registered hot key.
0504: */
0505: @SuppressWarnings("unchecked")
0506: public jsx3.gui.HotKey doKeyBinding(
0507: org.directwebremoting.proxy.CodeBlock fctCallback,
0508: String strKeys) {
0509: String extension = "doKeyBinding(\"" + fctCallback + "\", \""
0510: + strKeys + "\").";
0511: try {
0512: java.lang.reflect.Constructor<jsx3.gui.HotKey> ctor = jsx3.gui.HotKey.class
0513: .getConstructor(Context.class, String.class,
0514: ScriptProxy.class);
0515: return ctor.newInstance(this , extension, getScriptProxy());
0516: } catch (Exception ex) {
0517: throw new IllegalArgumentException("Unsupported type: "
0518: + jsx3.gui.HotKey.class.getName());
0519: }
0520: }
0521:
0522: /**
0523: * Resets the validation state of this control.
0524: * @return this object.
0525: */
0526: @SuppressWarnings("unchecked")
0527: public jsx3.gui.Form doReset() {
0528: String extension = "doReset().";
0529: try {
0530: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
0531: .getConstructor(Context.class, String.class,
0532: ScriptProxy.class);
0533: return ctor.newInstance(this , extension, getScriptProxy());
0534: } catch (Exception ex) {
0535: throw new IllegalArgumentException("Unsupported type: "
0536: + jsx3.gui.Form.class.getName());
0537: }
0538: }
0539:
0540: /**
0541: * Resets the validation state of this control.
0542: * @param returnType The expected return type
0543: * @return this object.
0544: */
0545: @SuppressWarnings("unchecked")
0546: public <T> T doReset(Class<T> returnType) {
0547: String extension = "doReset().";
0548: try {
0549: java.lang.reflect.Constructor<T> ctor = returnType
0550: .getConstructor(Context.class, String.class,
0551: ScriptProxy.class);
0552: return ctor.newInstance(this , extension, getScriptProxy());
0553: } catch (Exception ex) {
0554: throw new IllegalArgumentException(
0555: "Unsupported return type: " + returnType.getName());
0556: }
0557: }
0558:
0559: /**
0560: * Returns the background color of this control when it is disabled.
0561: * @param callback valid CSS property value, (i.e., red, #ff0000)
0562: */
0563: @SuppressWarnings("unchecked")
0564: public void getDisabledBackgroundColor(
0565: org.directwebremoting.proxy.Callback<String> callback) {
0566: ScriptBuffer script = new ScriptBuffer();
0567: String callbackPrefix = "";
0568:
0569: if (callback != null) {
0570: callbackPrefix = "var reply = ";
0571: }
0572:
0573: script.appendCall(callbackPrefix + getContextPath()
0574: + "getDisabledBackgroundColor");
0575:
0576: if (callback != null) {
0577: String key = org.directwebremoting.extend.CallbackHelper
0578: .saveCallback(callback, String.class);
0579: script
0580: .appendCall("__System.activateCallback", key,
0581: "reply");
0582: }
0583:
0584: getScriptProxy().addScript(script);
0585: }
0586:
0587: /**
0588: * Returns the font color to use when this control is disabled.
0589: * @param callback valid CSS property value, (i.e., red, #ff0000)
0590: */
0591: @SuppressWarnings("unchecked")
0592: public void getDisabledColor(
0593: org.directwebremoting.proxy.Callback<String> callback) {
0594: ScriptBuffer script = new ScriptBuffer();
0595: String callbackPrefix = "";
0596:
0597: if (callback != null) {
0598: callbackPrefix = "var reply = ";
0599: }
0600:
0601: script.appendCall(callbackPrefix + getContextPath()
0602: + "getDisabledColor");
0603:
0604: if (callback != null) {
0605: String key = org.directwebremoting.extend.CallbackHelper
0606: .saveCallback(callback, String.class);
0607: script
0608: .appendCall("__System.activateCallback", key,
0609: "reply");
0610: }
0611:
0612: getScriptProxy().addScript(script);
0613: }
0614:
0615: /**
0616: * Returns the state for the form field control. If no enabled state is set, this method returns
0617: STATEENABLED.
0618: * @param callback <code>STATEDISABLED</code> or <code>STATEENABLED</code>.
0619: */
0620: @SuppressWarnings("unchecked")
0621: public void getEnabled(
0622: org.directwebremoting.proxy.Callback<Integer> callback) {
0623: ScriptBuffer script = new ScriptBuffer();
0624: String callbackPrefix = "";
0625:
0626: if (callback != null) {
0627: callbackPrefix = "var reply = ";
0628: }
0629:
0630: script.appendCall(callbackPrefix + getContextPath()
0631: + "getEnabled");
0632:
0633: if (callback != null) {
0634: String key = org.directwebremoting.extend.CallbackHelper
0635: .saveCallback(callback, Integer.class);
0636: script
0637: .appendCall("__System.activateCallback", key,
0638: "reply");
0639: }
0640:
0641: getScriptProxy().addScript(script);
0642: }
0643:
0644: /**
0645: * Returns the key binding that when keyed will fire the execute event for this control.
0646: * @param callback plus-delimited (e.g.,'+') key sequence such as ctrl+s or ctrl+shift+alt+h or shift+a, etc
0647: */
0648: @SuppressWarnings("unchecked")
0649: public void getKeyBinding(
0650: org.directwebremoting.proxy.Callback<String> callback) {
0651: ScriptBuffer script = new ScriptBuffer();
0652: String callbackPrefix = "";
0653:
0654: if (callback != null) {
0655: callbackPrefix = "var reply = ";
0656: }
0657:
0658: script.appendCall(callbackPrefix + getContextPath()
0659: + "getKeyBinding");
0660:
0661: if (callback != null) {
0662: String key = org.directwebremoting.extend.CallbackHelper
0663: .saveCallback(callback, String.class);
0664: script
0665: .appendCall("__System.activateCallback", key,
0666: "reply");
0667: }
0668:
0669: getScriptProxy().addScript(script);
0670: }
0671:
0672: /**
0673: * Returns whether or not this control is required. If the required property has never been set, this method returns
0674: OPTIONAL.
0675: * @param callback <code>REQUIRED</code> or <code>OPTIONAL</code>.
0676: */
0677: @SuppressWarnings("unchecked")
0678: public void getRequired(
0679: org.directwebremoting.proxy.Callback<Integer> callback) {
0680: ScriptBuffer script = new ScriptBuffer();
0681: String callbackPrefix = "";
0682:
0683: if (callback != null) {
0684: callbackPrefix = "var reply = ";
0685: }
0686:
0687: script.appendCall(callbackPrefix + getContextPath()
0688: + "getRequired");
0689:
0690: if (callback != null) {
0691: String key = org.directwebremoting.extend.CallbackHelper
0692: .saveCallback(callback, Integer.class);
0693: script
0694: .appendCall("__System.activateCallback", key,
0695: "reply");
0696: }
0697:
0698: getScriptProxy().addScript(script);
0699: }
0700:
0701: /**
0702: * Returns the validation state of this control. If the validationState property has never been set, this method returns
0703: STATEVALID.
0704: * @param callback <code>STATEINVALID</code> or <code>STATEVALID</code>.
0705: */
0706: @SuppressWarnings("unchecked")
0707: public void getValidationState(
0708: org.directwebremoting.proxy.Callback<Integer> callback) {
0709: ScriptBuffer script = new ScriptBuffer();
0710: String callbackPrefix = "";
0711:
0712: if (callback != null) {
0713: callbackPrefix = "var reply = ";
0714: }
0715:
0716: script.appendCall(callbackPrefix + getContextPath()
0717: + "getValidationState");
0718:
0719: if (callback != null) {
0720: String key = org.directwebremoting.extend.CallbackHelper
0721: .saveCallback(callback, Integer.class);
0722: script
0723: .appendCall("__System.activateCallback", key,
0724: "reply");
0725: }
0726:
0727: getScriptProxy().addScript(script);
0728: }
0729:
0730: /**
0731: * Returns the value of this control.
0732: */
0733: @SuppressWarnings("unchecked")
0734: public void getValue(
0735: org.directwebremoting.proxy.Callback<Integer> callback) {
0736: ScriptBuffer script = new ScriptBuffer();
0737: String callbackPrefix = "";
0738:
0739: if (callback != null) {
0740: callbackPrefix = "var reply = ";
0741: }
0742:
0743: script.appendCall(callbackPrefix + getContextPath()
0744: + "getValue");
0745:
0746: if (callback != null) {
0747: String key = org.directwebremoting.extend.CallbackHelper
0748: .saveCallback(callback, Integer.class);
0749: script
0750: .appendCall("__System.activateCallback", key,
0751: "reply");
0752: }
0753:
0754: getScriptProxy().addScript(script);
0755: }
0756:
0757: /**
0758: * Sets the background color of this form control when it is disabled.
0759: * @param strColor valid CSS property value, (i.e., red, #ff0000)
0760: * @return this object.
0761: */
0762: @SuppressWarnings("unchecked")
0763: public jsx3.gui.Form setDisabledBackgroundColor(String strColor) {
0764: String extension = "setDisabledBackgroundColor(\"" + strColor
0765: + "\").";
0766: try {
0767: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
0768: .getConstructor(Context.class, String.class,
0769: ScriptProxy.class);
0770: return ctor.newInstance(this , extension, getScriptProxy());
0771: } catch (Exception ex) {
0772: throw new IllegalArgumentException("Unsupported type: "
0773: + jsx3.gui.Form.class.getName());
0774: }
0775: }
0776:
0777: /**
0778: * Sets the background color of this form control when it is disabled.
0779: * @param strColor valid CSS property value, (i.e., red, #ff0000)
0780: * @param returnType The expected return type
0781: * @return this object.
0782: */
0783: @SuppressWarnings("unchecked")
0784: public <T> T setDisabledBackgroundColor(String strColor,
0785: Class<T> returnType) {
0786: String extension = "setDisabledBackgroundColor(\"" + strColor
0787: + "\").";
0788: try {
0789: java.lang.reflect.Constructor<T> ctor = returnType
0790: .getConstructor(Context.class, String.class,
0791: ScriptProxy.class);
0792: return ctor.newInstance(this , extension, getScriptProxy());
0793: } catch (Exception ex) {
0794: throw new IllegalArgumentException(
0795: "Unsupported return type: " + returnType.getName());
0796: }
0797: }
0798:
0799: /**
0800: * Sets the font color to use when this control is disabled.
0801: * @param strColor valid CSS property value, (i.e., red, #ff0000)
0802: * @return this object.
0803: */
0804: @SuppressWarnings("unchecked")
0805: public jsx3.gui.Form setDisabledColor(String strColor) {
0806: String extension = "setDisabledColor(\"" + strColor + "\").";
0807: try {
0808: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
0809: .getConstructor(Context.class, String.class,
0810: ScriptProxy.class);
0811: return ctor.newInstance(this , extension, getScriptProxy());
0812: } catch (Exception ex) {
0813: throw new IllegalArgumentException("Unsupported type: "
0814: + jsx3.gui.Form.class.getName());
0815: }
0816: }
0817:
0818: /**
0819: * Sets the font color to use when this control is disabled.
0820: * @param strColor valid CSS property value, (i.e., red, #ff0000)
0821: * @param returnType The expected return type
0822: * @return this object.
0823: */
0824: @SuppressWarnings("unchecked")
0825: public <T> T setDisabledColor(String strColor, Class<T> returnType) {
0826: String extension = "setDisabledColor(\"" + strColor + "\").";
0827: try {
0828: java.lang.reflect.Constructor<T> ctor = returnType
0829: .getConstructor(Context.class, String.class,
0830: ScriptProxy.class);
0831: return ctor.newInstance(this , extension, getScriptProxy());
0832: } catch (Exception ex) {
0833: throw new IllegalArgumentException(
0834: "Unsupported return type: " + returnType.getName());
0835: }
0836: }
0837:
0838: /**
0839: * Sets whether this control is enabled. Disabled controls do not respond to user interaction.
0840: * @param intEnabled <code>STATEDISABLED</code> or <code>STATEENABLED</code>. <code>null</code> is
0841: equivalent to <code>STATEENABLED</code>.
0842: * @param bRepaint if <code>true</code> this control is immediately repainted to reflect the new setting.
0843: */
0844: public void setEnabled(int intEnabled, boolean bRepaint) {
0845: ScriptBuffer script = new ScriptBuffer();
0846: script.appendCall(getContextPath() + "setEnabled", intEnabled,
0847: bRepaint);
0848: getScriptProxy().addScript(script);
0849: }
0850:
0851: /**
0852: * Sets the key binding that when keyed will fire the bound execute (jsx3.gui.Interactive.EXECUTE)
0853: event for this control.
0854: * @param strSequence plus-delimited (e.g.,'+') key sequence such as ctrl+s or ctrl+shift+alt+h or shift+a, etc
0855: * @return this object.
0856: */
0857: @SuppressWarnings("unchecked")
0858: public jsx3.gui.Form setKeyBinding(String strSequence) {
0859: String extension = "setKeyBinding(\"" + strSequence + "\").";
0860: try {
0861: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
0862: .getConstructor(Context.class, String.class,
0863: ScriptProxy.class);
0864: return ctor.newInstance(this , extension, getScriptProxy());
0865: } catch (Exception ex) {
0866: throw new IllegalArgumentException("Unsupported type: "
0867: + jsx3.gui.Form.class.getName());
0868: }
0869: }
0870:
0871: /**
0872: * Sets the key binding that when keyed will fire the bound execute (jsx3.gui.Interactive.EXECUTE)
0873: event for this control.
0874: * @param strSequence plus-delimited (e.g.,'+') key sequence such as ctrl+s or ctrl+shift+alt+h or shift+a, etc
0875: * @param returnType The expected return type
0876: * @return this object.
0877: */
0878: @SuppressWarnings("unchecked")
0879: public <T> T setKeyBinding(String strSequence, Class<T> returnType) {
0880: String extension = "setKeyBinding(\"" + strSequence + "\").";
0881: try {
0882: java.lang.reflect.Constructor<T> ctor = returnType
0883: .getConstructor(Context.class, String.class,
0884: ScriptProxy.class);
0885: return ctor.newInstance(this , extension, getScriptProxy());
0886: } catch (Exception ex) {
0887: throw new IllegalArgumentException(
0888: "Unsupported return type: " + returnType.getName());
0889: }
0890: }
0891:
0892: /**
0893: * Sets whether or not this control is required.
0894: * @param required {int} <code>REQUIRED</code> or <code>OPTIONAL</code>.
0895: * @return this object.
0896: */
0897: @SuppressWarnings("unchecked")
0898: public jsx3.gui.Form setRequired(int required) {
0899: String extension = "setRequired(\"" + required + "\").";
0900: try {
0901: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
0902: .getConstructor(Context.class, String.class,
0903: ScriptProxy.class);
0904: return ctor.newInstance(this , extension, getScriptProxy());
0905: } catch (Exception ex) {
0906: throw new IllegalArgumentException("Unsupported type: "
0907: + jsx3.gui.Form.class.getName());
0908: }
0909: }
0910:
0911: /**
0912: * Sets whether or not this control is required.
0913: * @param required {int} <code>REQUIRED</code> or <code>OPTIONAL</code>.
0914: * @param returnType The expected return type
0915: * @return this object.
0916: */
0917: @SuppressWarnings("unchecked")
0918: public <T> T setRequired(int required, Class<T> returnType) {
0919: String extension = "setRequired(\"" + required + "\").";
0920: try {
0921: java.lang.reflect.Constructor<T> ctor = returnType
0922: .getConstructor(Context.class, String.class,
0923: ScriptProxy.class);
0924: return ctor.newInstance(this , extension, getScriptProxy());
0925: } catch (Exception ex) {
0926: throw new IllegalArgumentException(
0927: "Unsupported return type: " + returnType.getName());
0928: }
0929: }
0930:
0931: /**
0932: * Sets the validation state of this control. The validation state of a control is not serialized.
0933: * @param intState <code>STATEINVALID</code> or <code>STATEVALID</code>.
0934: * @return this object.
0935: */
0936: @SuppressWarnings("unchecked")
0937: public jsx3.gui.Form setValidationState(int intState) {
0938: String extension = "setValidationState(\"" + intState + "\").";
0939: try {
0940: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
0941: .getConstructor(Context.class, String.class,
0942: ScriptProxy.class);
0943: return ctor.newInstance(this , extension, getScriptProxy());
0944: } catch (Exception ex) {
0945: throw new IllegalArgumentException("Unsupported type: "
0946: + jsx3.gui.Form.class.getName());
0947: }
0948: }
0949:
0950: /**
0951: * Sets the validation state of this control. The validation state of a control is not serialized.
0952: * @param intState <code>STATEINVALID</code> or <code>STATEVALID</code>.
0953: * @param returnType The expected return type
0954: * @return this object.
0955: */
0956: @SuppressWarnings("unchecked")
0957: public <T> T setValidationState(int intState, Class<T> returnType) {
0958: String extension = "setValidationState(\"" + intState + "\").";
0959: try {
0960: java.lang.reflect.Constructor<T> ctor = returnType
0961: .getConstructor(Context.class, String.class,
0962: ScriptProxy.class);
0963: return ctor.newInstance(this , extension, getScriptProxy());
0964: } catch (Exception ex) {
0965: throw new IllegalArgumentException(
0966: "Unsupported return type: " + returnType.getName());
0967: }
0968: }
0969:
0970: /**
0971: * Sets the value of this control.
0972: * @param vntValue string/int value for the component
0973: * @return this object.
0974: */
0975: @SuppressWarnings("unchecked")
0976: public jsx3.gui.Form setValue(Integer vntValue) {
0977: String extension = "setValue(\"" + vntValue + "\").";
0978: try {
0979: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
0980: .getConstructor(Context.class, String.class,
0981: ScriptProxy.class);
0982: return ctor.newInstance(this , extension, getScriptProxy());
0983: } catch (Exception ex) {
0984: throw new IllegalArgumentException("Unsupported type: "
0985: + jsx3.gui.Form.class.getName());
0986: }
0987: }
0988:
0989: /**
0990: * Sets the value of this control.
0991: * @param vntValue string/int value for the component
0992: * @param returnType The expected return type
0993: * @return this object.
0994: */
0995: @SuppressWarnings("unchecked")
0996: public <T> T setValue(Integer vntValue, Class<T> returnType) {
0997: String extension = "setValue(\"" + vntValue + "\").";
0998: try {
0999: java.lang.reflect.Constructor<T> ctor = returnType
1000: .getConstructor(Context.class, String.class,
1001: ScriptProxy.class);
1002: return ctor.newInstance(this , extension, getScriptProxy());
1003: } catch (Exception ex) {
1004: throw new IllegalArgumentException(
1005: "Unsupported return type: " + returnType.getName());
1006: }
1007: }
1008:
1009: /**
1010: * Sets the value of this control.
1011: * @param vntValue string/int value for the component
1012: * @return this object.
1013: */
1014: @SuppressWarnings("unchecked")
1015: public jsx3.gui.Form setValue(String vntValue) {
1016: String extension = "setValue(\"" + vntValue + "\").";
1017: try {
1018: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
1019: .getConstructor(Context.class, String.class,
1020: ScriptProxy.class);
1021: return ctor.newInstance(this , extension, getScriptProxy());
1022: } catch (Exception ex) {
1023: throw new IllegalArgumentException("Unsupported type: "
1024: + jsx3.gui.Form.class.getName());
1025: }
1026: }
1027:
1028: /**
1029: * Sets the value of this control.
1030: * @param vntValue string/int value for the component
1031: * @param returnType The expected return type
1032: * @return this object.
1033: */
1034: @SuppressWarnings("unchecked")
1035: public <T> T setValue(String vntValue, Class<T> returnType) {
1036: String extension = "setValue(\"" + vntValue + "\").";
1037: try {
1038: java.lang.reflect.Constructor<T> ctor = returnType
1039: .getConstructor(Context.class, String.class,
1040: ScriptProxy.class);
1041: return ctor.newInstance(this , extension, getScriptProxy());
1042: } catch (Exception ex) {
1043: throw new IllegalArgumentException(
1044: "Unsupported return type: " + returnType.getName());
1045: }
1046: }
1047:
1048: }
|