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