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: * Mixin interface. Provides functionality to subclasses of jsx3.gui.Painted that allows them to publish model
0024: events.
0025:
0026: Note that this class requires that implementors of this class extends the jsx3.gui.Painted class and
0027: implement the jsx3.util.EventDispatcher interface
0028: * @author Joe Walker [joe at getahead dot org]
0029: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
0030: */
0031: public class Interactive extends jsx3.lang.Object {
0032: /**
0033: * All reverse ajax proxies need context to work from
0034: * @param scriptProxy The place we are writing scripts to
0035: * @param context The script that got us to where we are now
0036: */
0037: public Interactive(Context context, String extension,
0038: ScriptProxy scriptProxy) {
0039: super (context, extension, scriptProxy);
0040: }
0041:
0042: /**
0043: *
0044: */
0045: public static final String JSXBLUR = "jsxblur";
0046:
0047: /**
0048: *
0049: */
0050: public static final String JSXCHANGE = "jsxchange";
0051:
0052: /**
0053: *
0054: */
0055: public static final String JSXCLICK = "jsxclick";
0056:
0057: /**
0058: *
0059: */
0060: public static final String JSXDOUBLECLICK = "jsxdblclick";
0061:
0062: /**
0063: *
0064: */
0065: public static final String JSXFOCUS = "jsxfocus";
0066:
0067: /**
0068: *
0069: */
0070: public static final String JSXKEYDOWN = "jsxkeydown";
0071:
0072: /**
0073: *
0074: */
0075: public static final String JSXKEYPRESS = "jsxkeypress";
0076:
0077: /**
0078: *
0079: */
0080: public static final String JSXKEYUP = "jsxkeyup";
0081:
0082: /**
0083: *
0084: */
0085: public static final String JSXLOAD = "jsxload";
0086:
0087: /**
0088: *
0089: */
0090: public static final String JSXMOUSEDOWN = "jsxmousedown";
0091:
0092: /**
0093: *
0094: */
0095: public static final String JSXMOUSEOUT = "jsxmouseout";
0096:
0097: /**
0098: *
0099: */
0100: public static final String JSXMOUSEOVER = "jsxmouseover";
0101:
0102: /**
0103: *
0104: */
0105: public static final String JSXMOUSEUP = "jsxmouseup";
0106:
0107: /**
0108: *
0109: */
0110: public static final String JSXMOUSEWHEEL = "jsxmousewheel";
0111:
0112: /**
0113: *
0114: */
0115: public static final String FOCUS_STYLE = "text-decoration:underline";
0116:
0117: /**
0118: *
0119: */
0120: public static final String ADOPT = "jsxadopt";
0121:
0122: /**
0123: *
0124: */
0125: public static final String AFTER_APPEND = "jsxafterappend";
0126:
0127: /**
0128: *
0129: */
0130: public static final String AFTER_COMMIT = "jsxaftercommit";
0131:
0132: /**
0133: *
0134: */
0135: public static final String AFTER_EDIT = "jsxafteredit";
0136:
0137: /**
0138: *
0139: */
0140: public static final String AFTER_MOVE = "jsxaftermove";
0141:
0142: /**
0143: *
0144: */
0145: public static final String AFTER_REORDER = "jsxafterreorder";
0146:
0147: /**
0148: *
0149: */
0150: public static final String AFTER_RESIZE = "jsxafterresize";
0151:
0152: /**
0153: *
0154: */
0155: public static final String AFTER_RESIZE_VIEW = "jsxafterresizeview";
0156:
0157: /**
0158: *
0159: */
0160: public static final String AFTER_SORT = "jsxaftersort";
0161:
0162: /**
0163: *
0164: */
0165: public static final String BEFORE_APPEND = "jsxbeforeappend";
0166:
0167: /**
0168: *
0169: */
0170: public static final String BEFORE_DROP = "jsxbeforedrop";
0171:
0172: /**
0173: *
0174: */
0175: public static final String BEFORE_EDIT = "jsxbeforeedit";
0176:
0177: /**
0178: *
0179: */
0180: public static final String BEFORE_MOVE = "jsxbeforemove";
0181:
0182: /**
0183: *
0184: */
0185: public static final String BEFORE_RESIZE = "jsxbeforeresize";
0186:
0187: /**
0188: *
0189: */
0190: public static final String BEFORE_SELECT = "jsxbeforeselect";
0191:
0192: /**
0193: *
0194: */
0195: public static final String BEFORE_SORT = "jsxbeforesort";
0196:
0197: /**
0198: *
0199: */
0200: public static final String CANCEL_DROP = "jsxcanceldrop";
0201:
0202: /**
0203: *
0204: */
0205: public static final String CHANGE = "jsxchange";
0206:
0207: /**
0208: *
0209: */
0210: public static final String CTRL_DROP = "jsxctrldrop";
0211:
0212: /**
0213: *
0214: */
0215: public static final String DESTROY = "jsxdestroy";
0216:
0217: /**
0218: *
0219: */
0220: public static final String DATA = "jsxdata";
0221:
0222: /**
0223: *
0224: */
0225: public static final String DRAG = "jsxdrag";
0226:
0227: /**
0228: *
0229: */
0230: public static final String DROP = "jsxdrop";
0231:
0232: /**
0233: *
0234: */
0235: public static final String EXECUTE = "jsxexecute";
0236:
0237: /**
0238: *
0239: */
0240: public static final String HIDE = "jsxhide";
0241:
0242: /**
0243: *
0244: */
0245: public static final String INCR_CHANGE = "jsxincchange";
0246:
0247: /**
0248: *
0249: */
0250: public static final String INPUT = "jsxinput";
0251:
0252: /**
0253: *
0254: */
0255: public static final String MENU = "jsxmenu";
0256:
0257: /**
0258: *
0259: */
0260: public static final String SCROLL = "jsxscroll";
0261:
0262: /**
0263: *
0264: */
0265: public static final String SELECT = "jsxselect";
0266:
0267: /**
0268: *
0269: */
0270: public static final String SHOW = "jsxshow";
0271:
0272: /**
0273: *
0274: */
0275: public static final String SPYGLASS = "jsxspy";
0276:
0277: /**
0278: *
0279: */
0280: public static final String TOGGLE = "jsxtoggle";
0281:
0282: /**
0283: * Programmatically sets an event of this instance. Sets the script that will execute when this object publishes
0284: a model event. The script value will be saved in the serialization file of a component. Not all classes that
0285: implement this interface will publish events of every type. Consult the documentation of a class for a
0286: description of the events it publishes.
0287:
0288: For programmatic registering of event handlers when persistence in a serialization file is not required,
0289: consider using jsx3.util.EventDispatcher.subscribe() instead of this method. Whenever a model
0290: event is published, it is published using the EventDispatcher interface as well as by executing
0291: any registered event script.
0292: * @param strScript the actual JavaScript code that will execute when the given event is published.
0293: For example: <code>obj.setEvent("alert('hello.');", jsx3.gui.Interactive.EXECUTE);</code>
0294: * @param strType the event type. Must be one of the model event types defined as static fields in this class
0295: * @return reference to this
0296: */
0297: public jsx3.gui.Interactive setEvent(String strScript,
0298: String strType) {
0299: ScriptBuffer script = new ScriptBuffer();
0300: script.appendCall(getContextPath() + "setEvent", strScript,
0301: strType);
0302: getScriptProxy().addScript(script);
0303: return this ;
0304: }
0305:
0306: /**
0307: * Returns the associative array containing all the registered event script of this object. This method returns
0308: the instance field itself and not a copy.
0309: * @return an associative array mapping event type to event script
0310: */
0311: @SuppressWarnings("unchecked")
0312: public jsx3.lang.Object getEvents() {
0313: String extension = "getEvents().";
0314: try {
0315: java.lang.reflect.Constructor<jsx3.lang.Object> ctor = jsx3.lang.Object.class
0316: .getConstructor(Context.class, String.class,
0317: ScriptProxy.class);
0318: return ctor.newInstance(this , extension, getScriptProxy());
0319: } catch (Exception ex) {
0320: throw new IllegalArgumentException("Unsupported type: "
0321: + jsx3.lang.Object.class.getName());
0322: }
0323: }
0324:
0325: /**
0326: * Returns the associative array containing all the registered event script of this object. This method returns
0327: the instance field itself and not a copy.
0328: * @param returnType The expected return type
0329: * @return an associative array mapping event type to event script
0330: */
0331: @SuppressWarnings("unchecked")
0332: public <T> T getEvents(Class<T> returnType) {
0333: String extension = "getEvents().";
0334: try {
0335: java.lang.reflect.Constructor<T> ctor = returnType
0336: .getConstructor(Context.class, String.class,
0337: ScriptProxy.class);
0338: return ctor.newInstance(this , extension, getScriptProxy());
0339: } catch (Exception ex) {
0340: throw new IllegalArgumentException(
0341: "Unsupported return type: " + returnType.getName());
0342: }
0343: }
0344:
0345: /**
0346: * Returns the event script registered for the given event type. This script could have been set by the
0347: setEvent() method or during component deserialization.
0348: * @param strType the event type, one of the model event types defined as static fields in this class
0349: * @param callback the JavaScript event script
0350: */
0351: @SuppressWarnings("unchecked")
0352: public void getEvent(String strType,
0353: org.directwebremoting.proxy.Callback<String> callback) {
0354: ScriptBuffer script = new ScriptBuffer();
0355: String callbackPrefix = "";
0356:
0357: if (callback != null) {
0358: callbackPrefix = "var reply = ";
0359: }
0360:
0361: script.appendCall(callbackPrefix + getContextPath()
0362: + "getEvent", strType);
0363:
0364: if (callback != null) {
0365: String key = org.directwebremoting.extend.CallbackHelper
0366: .saveCallback(callback, String.class);
0367: script
0368: .appendCall("__System.activateCallback", key,
0369: "reply");
0370: }
0371:
0372: getScriptProxy().addScript(script);
0373: }
0374:
0375: /**
0376: * Returns true if there is a event script registered for the given event type.
0377: * @param strType the event type, one of the model event types defined as static fields in this class
0378: * @param callback the JavaScript event script
0379: */
0380: @SuppressWarnings("unchecked")
0381: public void hasEvent(String strType,
0382: org.directwebremoting.proxy.Callback<String> callback) {
0383: ScriptBuffer script = new ScriptBuffer();
0384: String callbackPrefix = "";
0385:
0386: if (callback != null) {
0387: callbackPrefix = "var reply = ";
0388: }
0389:
0390: script.appendCall(callbackPrefix + getContextPath()
0391: + "hasEvent", strType);
0392:
0393: if (callback != null) {
0394: String key = org.directwebremoting.extend.CallbackHelper
0395: .saveCallback(callback, String.class);
0396: script
0397: .appendCall("__System.activateCallback", key,
0398: "reply");
0399: }
0400:
0401: getScriptProxy().addScript(script);
0402: }
0403:
0404: /**
0405: * Publishes a model event. This method both evaluates any registered event script for the given event type
0406: and publishes the event through the EventDispatcher interface. This method ensures that any
0407: registered event script is executed in isolation to prevent most side effects.
0408: * @param strType the event type, one of the model event types defined as static fields in this class
0409: * @param objContext JavaScript object array with name/value pairs that provide a local
0410: variable stack for the execution of the event script. This argument is also passed as the <code>context</code>
0411: property of the event object that is published through the <code>EventDispatcher</code> interface.
0412: * @return the result of evaluating the event script or <code>null</code> if not event script is registered
0413: */
0414: @SuppressWarnings("unchecked")
0415: public jsx3.lang.Object doEvent(String strType,
0416: jsx3.lang.Object objContext) {
0417: String extension = "doEvent(\"" + strType + "\", \""
0418: + objContext + "\").";
0419: try {
0420: java.lang.reflect.Constructor<jsx3.lang.Object> ctor = jsx3.lang.Object.class
0421: .getConstructor(Context.class, String.class,
0422: ScriptProxy.class);
0423: return ctor.newInstance(this , extension, getScriptProxy());
0424: } catch (Exception ex) {
0425: throw new IllegalArgumentException("Unsupported type: "
0426: + jsx3.lang.Object.class.getName());
0427: }
0428: }
0429:
0430: /**
0431: * Publishes a model event. This method both evaluates any registered event script for the given event type
0432: and publishes the event through the EventDispatcher interface. This method ensures that any
0433: registered event script is executed in isolation to prevent most side effects.
0434: * @param strType the event type, one of the model event types defined as static fields in this class
0435: * @param objContext JavaScript object array with name/value pairs that provide a local
0436: variable stack for the execution of the event script. This argument is also passed as the <code>context</code>
0437: property of the event object that is published through the <code>EventDispatcher</code> interface.
0438: * @param returnType The expected return type
0439: * @return the result of evaluating the event script or <code>null</code> if not event script is registered
0440: */
0441: @SuppressWarnings("unchecked")
0442: public <T> T doEvent(String strType, jsx3.lang.Object objContext,
0443: Class<T> returnType) {
0444: String extension = "doEvent(\"" + strType + "\", \""
0445: + objContext + "\").";
0446: try {
0447: java.lang.reflect.Constructor<T> ctor = returnType
0448: .getConstructor(Context.class, String.class,
0449: ScriptProxy.class);
0450: return ctor.newInstance(this , extension, getScriptProxy());
0451: } catch (Exception ex) {
0452: throw new IllegalArgumentException(
0453: "Unsupported return type: " + returnType.getName());
0454: }
0455: }
0456:
0457: /**
0458: * Removes an event script registered for the given model event type.
0459: * @param strType the event type, one of the model event types defined as static fields in this class
0460: * @return this object
0461: */
0462: @SuppressWarnings("unchecked")
0463: public jsx3.gui.Interactive removeEvent(String strType) {
0464: String extension = "removeEvent(\"" + strType + "\").";
0465: try {
0466: java.lang.reflect.Constructor<jsx3.gui.Interactive> ctor = jsx3.gui.Interactive.class
0467: .getConstructor(Context.class, String.class,
0468: ScriptProxy.class);
0469: return ctor.newInstance(this , extension, getScriptProxy());
0470: } catch (Exception ex) {
0471: throw new IllegalArgumentException("Unsupported type: "
0472: + jsx3.gui.Interactive.class.getName());
0473: }
0474: }
0475:
0476: /**
0477: * Removes an event script registered for the given model event type.
0478: * @param strType the event type, one of the model event types defined as static fields in this class
0479: * @param returnType The expected return type
0480: * @return this object
0481: */
0482: @SuppressWarnings("unchecked")
0483: public <T> T removeEvent(String strType, Class<T> returnType) {
0484: String extension = "removeEvent(\"" + strType + "\").";
0485: try {
0486: java.lang.reflect.Constructor<T> ctor = returnType
0487: .getConstructor(Context.class, String.class,
0488: ScriptProxy.class);
0489: return ctor.newInstance(this , extension, getScriptProxy());
0490: } catch (Exception ex) {
0491: throw new IllegalArgumentException(
0492: "Unsupported return type: " + returnType.getName());
0493: }
0494: }
0495:
0496: /**
0497: * Removes all events scripts registered with this object.
0498: * @return this object
0499: */
0500: @SuppressWarnings("unchecked")
0501: public jsx3.gui.Interactive removeEvents() {
0502: String extension = "removeEvents().";
0503: try {
0504: java.lang.reflect.Constructor<jsx3.gui.Interactive> ctor = jsx3.gui.Interactive.class
0505: .getConstructor(Context.class, String.class,
0506: ScriptProxy.class);
0507: return ctor.newInstance(this , extension, getScriptProxy());
0508: } catch (Exception ex) {
0509: throw new IllegalArgumentException("Unsupported type: "
0510: + jsx3.gui.Interactive.class.getName());
0511: }
0512: }
0513:
0514: /**
0515: * Removes all events scripts registered with this object.
0516: * @param returnType The expected return type
0517: * @return this object
0518: */
0519: @SuppressWarnings("unchecked")
0520: public <T> T removeEvents(Class<T> returnType) {
0521: String extension = "removeEvents().";
0522: try {
0523: java.lang.reflect.Constructor<T> ctor = returnType
0524: .getConstructor(Context.class, String.class,
0525: ScriptProxy.class);
0526: return ctor.newInstance(this , extension, getScriptProxy());
0527: } catch (Exception ex) {
0528: throw new IllegalArgumentException(
0529: "Unsupported return type: " + returnType.getName());
0530: }
0531: }
0532:
0533: /**
0534: * Sets whether is object can be moved around the screen (this is not the same as drag/drop). Implementing classes
0535: can decide whether to consult this value or ignore it.
0536: * @param bMovable <code>jsx3.Boolean.TRUE</code> or <code>jsx3.Boolean.FALSE</code>
0537: * @return this object
0538: */
0539: public jsx3.gui.Interactive setCanMove(int bMovable) {
0540: ScriptBuffer script = new ScriptBuffer();
0541: script.appendCall(getContextPath() + "setCanMove", bMovable);
0542: getScriptProxy().addScript(script);
0543: return this ;
0544: }
0545:
0546: /**
0547: * Returns whether is object can be moved around the screen (this is not the same as drag/drop).
0548: * @param callback <code>jsx3.Boolean.TRUE</code> or <code>jsx3.Boolean.FALSE</code>
0549: */
0550: @SuppressWarnings("unchecked")
0551: public void getCanMove(
0552: org.directwebremoting.proxy.Callback<Integer> callback) {
0553: ScriptBuffer script = new ScriptBuffer();
0554: String callbackPrefix = "";
0555:
0556: if (callback != null) {
0557: callbackPrefix = "var reply = ";
0558: }
0559:
0560: script.appendCall(callbackPrefix + getContextPath()
0561: + "getCanMove");
0562:
0563: if (callback != null) {
0564: String key = org.directwebremoting.extend.CallbackHelper
0565: .saveCallback(callback, Integer.class);
0566: script
0567: .appendCall("__System.activateCallback", key,
0568: "reply");
0569: }
0570:
0571: getScriptProxy().addScript(script);
0572: }
0573:
0574: /**
0575: * Sets whether is object supports programmatic drag, meanining it will allow any contained item to be dragged/dropped.
0576: Implementing classes can decide whether to consult this value or ignore it.
0577: * @param bDrag <code>jsx3.Boolean.TRUE</code> or <code>jsx3.Boolean.FALSE</code>
0578: * @return this object
0579: */
0580: public jsx3.gui.Interactive setCanDrag(int bDrag) {
0581: ScriptBuffer script = new ScriptBuffer();
0582: script.appendCall(getContextPath() + "setCanDrag", bDrag);
0583: getScriptProxy().addScript(script);
0584: return this ;
0585: }
0586:
0587: /**
0588: * Returns whether is object supports programmatic drag, meanining it will allow any contained item to be
0589: dragged and dropped on another container supporting drop.
0590: * @param callback <code>jsx3.Boolean.TRUE</code> or <code>jsx3.Boolean.FALSE</code>
0591: */
0592: @SuppressWarnings("unchecked")
0593: public void getCanDrag(
0594: org.directwebremoting.proxy.Callback<Integer> callback) {
0595: ScriptBuffer script = new ScriptBuffer();
0596: String callbackPrefix = "";
0597:
0598: if (callback != null) {
0599: callbackPrefix = "var reply = ";
0600: }
0601:
0602: script.appendCall(callbackPrefix + getContextPath()
0603: + "getCanDrag");
0604:
0605: if (callback != null) {
0606: String key = org.directwebremoting.extend.CallbackHelper
0607: .saveCallback(callback, Integer.class);
0608: script
0609: .appendCall("__System.activateCallback", key,
0610: "reply");
0611: }
0612:
0613: getScriptProxy().addScript(script);
0614: }
0615:
0616: /**
0617: * Sets whether this object can be the target of a drop event. Implementing classes can decide whether to consult
0618: this value or ignore it.
0619: * @param bDrop <code>jsx3.Boolean.TRUE</code> or <code>jsx3.Boolean.FALSE</code>
0620: * @return this object
0621: */
0622: public jsx3.gui.Interactive setCanDrop(int bDrop) {
0623: ScriptBuffer script = new ScriptBuffer();
0624: script.appendCall(getContextPath() + "setCanDrop", bDrop);
0625: getScriptProxy().addScript(script);
0626: return this ;
0627: }
0628:
0629: /**
0630: * Returns whether this object can be the target of a drop event.
0631: * @param callback <code>jsx3.Boolean.TRUE</code> or <code>jsx3.Boolean.FALSE</code>
0632: */
0633: @SuppressWarnings("unchecked")
0634: public void getCanDrop(
0635: org.directwebremoting.proxy.Callback<Integer> callback) {
0636: ScriptBuffer script = new ScriptBuffer();
0637: String callbackPrefix = "";
0638:
0639: if (callback != null) {
0640: callbackPrefix = "var reply = ";
0641: }
0642:
0643: script.appendCall(callbackPrefix + getContextPath()
0644: + "getCanDrop");
0645:
0646: if (callback != null) {
0647: String key = org.directwebremoting.extend.CallbackHelper
0648: .saveCallback(callback, Integer.class);
0649: script
0650: .appendCall("__System.activateCallback", key,
0651: "reply");
0652: }
0653:
0654: getScriptProxy().addScript(script);
0655: }
0656:
0657: /**
0658: * Sets whether is object can be spyglassed. Implementing classes can decide whether to consult
0659: this value or ignore it.
0660: * @param bSpy <code>jsx3.Boolean.TRUE</code> or <code>jsx3.Boolean.FALSE</code>
0661: * @return this object
0662: */
0663: public jsx3.gui.Interactive setCanSpy(int bSpy) {
0664: ScriptBuffer script = new ScriptBuffer();
0665: script.appendCall(getContextPath() + "setCanSpy", bSpy);
0666: getScriptProxy().addScript(script);
0667: return this ;
0668: }
0669:
0670: /**
0671: * Returns whether is object can be spyglassed.
0672: * @param callback <code>jsx3.Boolean.TRUE</code> or <code>jsx3.Boolean.FALSE</code>
0673: */
0674: @SuppressWarnings("unchecked")
0675: public void getCanSpy(
0676: org.directwebremoting.proxy.Callback<Integer> callback) {
0677: ScriptBuffer script = new ScriptBuffer();
0678: String callbackPrefix = "";
0679:
0680: if (callback != null) {
0681: callbackPrefix = "var reply = ";
0682: }
0683:
0684: script.appendCall(callbackPrefix + getContextPath()
0685: + "getCanSpy");
0686:
0687: if (callback != null) {
0688: String key = org.directwebremoting.extend.CallbackHelper
0689: .saveCallback(callback, Integer.class);
0690: script
0691: .appendCall("__System.activateCallback", key,
0692: "reply");
0693: }
0694:
0695: getScriptProxy().addScript(script);
0696: }
0697:
0698: /**
0699: * Returns the name of the jsx3.gui.Menu instance to display (as a context menu) when a user
0700: clicks on this object with the right button.
0701: */
0702: @SuppressWarnings("unchecked")
0703: public void getMenu(
0704: org.directwebremoting.proxy.Callback<String> callback) {
0705: ScriptBuffer script = new ScriptBuffer();
0706: String callbackPrefix = "";
0707:
0708: if (callback != null) {
0709: callbackPrefix = "var reply = ";
0710: }
0711:
0712: script
0713: .appendCall(callbackPrefix + getContextPath()
0714: + "getMenu");
0715:
0716: if (callback != null) {
0717: String key = org.directwebremoting.extend.CallbackHelper
0718: .saveCallback(callback, String.class);
0719: script
0720: .appendCall("__System.activateCallback", key,
0721: "reply");
0722: }
0723:
0724: getScriptProxy().addScript(script);
0725: }
0726:
0727: /**
0728: * Sets the name of the jsx3.gui.Menu instance to display when a user
0729: clicks on this object with the right button. The name is a pointer by-name to a JSX object in the same server.
0730: * @param strMenu name or id (jsxname or jsxid) of the context menu
0731: * @return this object
0732: */
0733: public jsx3.gui.Interactive setMenu(String strMenu) {
0734: ScriptBuffer script = new ScriptBuffer();
0735: script.appendCall(getContextPath() + "setMenu", strMenu);
0736: getScriptProxy().addScript(script);
0737: return this ;
0738: }
0739:
0740: /**
0741: * called by 'window.setTimeout()' to display the spyglass hover for a given object;
0742: * @param strHTML HTML/text to display in the spyglass; as the spyglass does not define a height/width, this content will
0743: have improved layout if it specifies a preferred width in its in-line-style or referenced-css rule.
0744: * @param intLeft use an integer to specify an on-screen location; otherwise, use a <code>jsx3.gui.Event</code> instance to have the system automatically calculate the x/y position.
0745: * @param intTop use an integer if <code>intLeft</code> also uses an integer. Otherwise, use null.
0746: */
0747: public void showSpy(String strHTML, jsx3.gui.Event intLeft,
0748: int intTop) {
0749: ScriptBuffer script = new ScriptBuffer();
0750: script.appendCall(getContextPath() + "showSpy", strHTML,
0751: intLeft, intTop);
0752: getScriptProxy().addScript(script);
0753: }
0754:
0755: /**
0756: * called by 'window.setTimeout()' to display the spyglass hover for a given object;
0757: * @param strHTML HTML/text to display in the spyglass; as the spyglass does not define a height/width, this content will
0758: have improved layout if it specifies a preferred width in its in-line-style or referenced-css rule.
0759: * @param intLeft use an integer to specify an on-screen location; otherwise, use a <code>jsx3.gui.Event</code> instance to have the system automatically calculate the x/y position.
0760: * @param intTop use an integer if <code>intLeft</code> also uses an integer. Otherwise, use null.
0761: */
0762: public void showSpy(String strHTML, int intLeft, int intTop) {
0763: ScriptBuffer script = new ScriptBuffer();
0764: script.appendCall(getContextPath() + "showSpy", strHTML,
0765: intLeft, intTop);
0766: getScriptProxy().addScript(script);
0767: }
0768:
0769: /**
0770: * Sets the CSS definition to apply to an HTML element when a spyglass is shown for that element
0771: * @param strCSS valid CSS. For example, text-decoration:underline;color:red;
0772: */
0773: public void setSpyStyles(String strCSS) {
0774: ScriptBuffer script = new ScriptBuffer();
0775: script.appendCall(getContextPath() + "setSpyStyles", strCSS);
0776: getScriptProxy().addScript(script);
0777: }
0778:
0779: /**
0780: * Registers a hot key with this JSX model node. All keydown events that bubble up to this object
0781: will be checked against the hot key. If an event matches, the callback function will execute and the event
0782: bubble will be canceled.
0783:
0784: If the four parameters vntKey, bShift, bControl, and bAlt
0785: match a previously registered hot key, the previous hot key is clobbered by the new one. Only one hot key callback
0786: function (the most recently registered) will be executed by a single keydown event.
0787: * @param vntCallback either a function, or the name of a method bound to this object.
0788: When a keydown event bubbles up to this object that matches the hot key created by this method, this function
0789: is called on this object. If this function returns <code>false</code> then this hot key will not cancel the
0790: key event. This parameter can also be an instance of <code>HotKey</code>, in which case all
0791: other parameters are ignored.
0792: * @param vntKey if this parameter is a String, the hot key matches that key (the keycode to match is
0793: determined by <code>HotKey.keyDownCharToCode()</code>). If it is an integer, the hot key will match that
0794: keycode value.
0795: * @param bShift if not <code>null</code> the shift key state of the keydown event must match this value
0796: to invoke the hot key.
0797: * @param bControl if not <code>null</code> the control key state of the keydown event must match this value
0798: to invoke the hot key.
0799: * @param bAlt if not <code>null</code> the alt key state of the keydown event must match this value
0800: to invoke the hot key.
0801: * @return the registered hot key.
0802: */
0803: @SuppressWarnings("unchecked")
0804: public jsx3.gui.HotKey registerHotKey(
0805: org.directwebremoting.proxy.CodeBlock vntCallback,
0806: String vntKey, boolean bShift, boolean bControl,
0807: boolean bAlt) {
0808: String extension = "registerHotKey(\"" + vntCallback + "\", \""
0809: + vntKey + "\", \"" + bShift + "\", \"" + bControl
0810: + "\", \"" + bAlt + "\").";
0811: try {
0812: java.lang.reflect.Constructor<jsx3.gui.HotKey> ctor = jsx3.gui.HotKey.class
0813: .getConstructor(Context.class, String.class,
0814: ScriptProxy.class);
0815: return ctor.newInstance(this , extension, getScriptProxy());
0816: } catch (Exception ex) {
0817: throw new IllegalArgumentException("Unsupported type: "
0818: + jsx3.gui.HotKey.class.getName());
0819: }
0820: }
0821:
0822: /**
0823: * Registers a hot key with this JSX model node. All keydown events that bubble up to this object
0824: will be checked against the hot key. If an event matches, the callback function will execute and the event
0825: bubble will be canceled.
0826:
0827: If the four parameters vntKey, bShift, bControl, and bAlt
0828: match a previously registered hot key, the previous hot key is clobbered by the new one. Only one hot key callback
0829: function (the most recently registered) will be executed by a single keydown event.
0830: * @param vntCallback either a function, or the name of a method bound to this object.
0831: When a keydown event bubbles up to this object that matches the hot key created by this method, this function
0832: is called on this object. If this function returns <code>false</code> then this hot key will not cancel the
0833: key event. This parameter can also be an instance of <code>HotKey</code>, in which case all
0834: other parameters are ignored.
0835: * @param vntKey if this parameter is a String, the hot key matches that key (the keycode to match is
0836: determined by <code>HotKey.keyDownCharToCode()</code>). If it is an integer, the hot key will match that
0837: keycode value.
0838: * @param bShift if not <code>null</code> the shift key state of the keydown event must match this value
0839: to invoke the hot key.
0840: * @param bControl if not <code>null</code> the control key state of the keydown event must match this value
0841: to invoke the hot key.
0842: * @param bAlt if not <code>null</code> the alt key state of the keydown event must match this value
0843: to invoke the hot key.
0844: * @return the registered hot key.
0845: */
0846: @SuppressWarnings("unchecked")
0847: public jsx3.gui.HotKey registerHotKey(jsx3.gui.HotKey vntCallback,
0848: String vntKey, boolean bShift, boolean bControl,
0849: boolean bAlt) {
0850: String extension = "registerHotKey(\"" + vntCallback + "\", \""
0851: + vntKey + "\", \"" + bShift + "\", \"" + bControl
0852: + "\", \"" + bAlt + "\").";
0853: try {
0854: java.lang.reflect.Constructor<jsx3.gui.HotKey> ctor = jsx3.gui.HotKey.class
0855: .getConstructor(Context.class, String.class,
0856: ScriptProxy.class);
0857: return ctor.newInstance(this , extension, getScriptProxy());
0858: } catch (Exception ex) {
0859: throw new IllegalArgumentException("Unsupported type: "
0860: + jsx3.gui.HotKey.class.getName());
0861: }
0862: }
0863:
0864: /**
0865: * Registers a hot key with this JSX model node. All keydown events that bubble up to this object
0866: will be checked against the hot key. If an event matches, the callback function will execute and the event
0867: bubble will be canceled.
0868:
0869: If the four parameters vntKey, bShift, bControl, and bAlt
0870: match a previously registered hot key, the previous hot key is clobbered by the new one. Only one hot key callback
0871: function (the most recently registered) will be executed by a single keydown event.
0872: * @param vntCallback either a function, or the name of a method bound to this object.
0873: When a keydown event bubbles up to this object that matches the hot key created by this method, this function
0874: is called on this object. If this function returns <code>false</code> then this hot key will not cancel the
0875: key event. This parameter can also be an instance of <code>HotKey</code>, in which case all
0876: other parameters are ignored.
0877: * @param vntKey if this parameter is a String, the hot key matches that key (the keycode to match is
0878: determined by <code>HotKey.keyDownCharToCode()</code>). If it is an integer, the hot key will match that
0879: keycode value.
0880: * @param bShift if not <code>null</code> the shift key state of the keydown event must match this value
0881: to invoke the hot key.
0882: * @param bControl if not <code>null</code> the control key state of the keydown event must match this value
0883: to invoke the hot key.
0884: * @param bAlt if not <code>null</code> the alt key state of the keydown event must match this value
0885: to invoke the hot key.
0886: * @return the registered hot key.
0887: */
0888: @SuppressWarnings("unchecked")
0889: public jsx3.gui.HotKey registerHotKey(jsx3.gui.HotKey vntCallback,
0890: int vntKey, boolean bShift, boolean bControl, boolean bAlt) {
0891: String extension = "registerHotKey(\"" + vntCallback + "\", \""
0892: + vntKey + "\", \"" + bShift + "\", \"" + bControl
0893: + "\", \"" + bAlt + "\").";
0894: try {
0895: java.lang.reflect.Constructor<jsx3.gui.HotKey> ctor = jsx3.gui.HotKey.class
0896: .getConstructor(Context.class, String.class,
0897: ScriptProxy.class);
0898: return ctor.newInstance(this , extension, getScriptProxy());
0899: } catch (Exception ex) {
0900: throw new IllegalArgumentException("Unsupported type: "
0901: + jsx3.gui.HotKey.class.getName());
0902: }
0903: }
0904:
0905: /**
0906: * Registers a hot key with this JSX model node. All keydown events that bubble up to this object
0907: will be checked against the hot key. If an event matches, the callback function will execute and the event
0908: bubble will be canceled.
0909:
0910: If the four parameters vntKey, bShift, bControl, and bAlt
0911: match a previously registered hot key, the previous hot key is clobbered by the new one. Only one hot key callback
0912: function (the most recently registered) will be executed by a single keydown event.
0913: * @param vntCallback either a function, or the name of a method bound to this object.
0914: When a keydown event bubbles up to this object that matches the hot key created by this method, this function
0915: is called on this object. If this function returns <code>false</code> then this hot key will not cancel the
0916: key event. This parameter can also be an instance of <code>HotKey</code>, in which case all
0917: other parameters are ignored.
0918: * @param vntKey if this parameter is a String, the hot key matches that key (the keycode to match is
0919: determined by <code>HotKey.keyDownCharToCode()</code>). If it is an integer, the hot key will match that
0920: keycode value.
0921: * @param bShift if not <code>null</code> the shift key state of the keydown event must match this value
0922: to invoke the hot key.
0923: * @param bControl if not <code>null</code> the control key state of the keydown event must match this value
0924: to invoke the hot key.
0925: * @param bAlt if not <code>null</code> the alt key state of the keydown event must match this value
0926: to invoke the hot key.
0927: * @return the registered hot key.
0928: */
0929: @SuppressWarnings("unchecked")
0930: public jsx3.gui.HotKey registerHotKey(
0931: org.directwebremoting.proxy.CodeBlock vntCallback,
0932: int vntKey, boolean bShift, boolean bControl, boolean bAlt) {
0933: String extension = "registerHotKey(\"" + vntCallback + "\", \""
0934: + vntKey + "\", \"" + bShift + "\", \"" + bControl
0935: + "\", \"" + bAlt + "\").";
0936: try {
0937: java.lang.reflect.Constructor<jsx3.gui.HotKey> ctor = jsx3.gui.HotKey.class
0938: .getConstructor(Context.class, String.class,
0939: ScriptProxy.class);
0940: return ctor.newInstance(this , extension, getScriptProxy());
0941: } catch (Exception ex) {
0942: throw new IllegalArgumentException("Unsupported type: "
0943: + jsx3.gui.HotKey.class.getName());
0944: }
0945: }
0946:
0947: /**
0948: * Registers a hot key with this JSX model node. All keydown events that bubble up to this object
0949: will be checked against the hot key. If an event matches, the callback function will execute and the event
0950: bubble will be canceled.
0951:
0952: If the four parameters vntKey, bShift, bControl, and bAlt
0953: match a previously registered hot key, the previous hot key is clobbered by the new one. Only one hot key callback
0954: function (the most recently registered) will be executed by a single keydown event.
0955: * @param vntCallback either a function, or the name of a method bound to this object.
0956: When a keydown event bubbles up to this object that matches the hot key created by this method, this function
0957: is called on this object. If this function returns <code>false</code> then this hot key will not cancel the
0958: key event. This parameter can also be an instance of <code>HotKey</code>, in which case all
0959: other parameters are ignored.
0960: * @param vntKey if this parameter is a String, the hot key matches that key (the keycode to match is
0961: determined by <code>HotKey.keyDownCharToCode()</code>). If it is an integer, the hot key will match that
0962: keycode value.
0963: * @param bShift if not <code>null</code> the shift key state of the keydown event must match this value
0964: to invoke the hot key.
0965: * @param bControl if not <code>null</code> the control key state of the keydown event must match this value
0966: to invoke the hot key.
0967: * @param bAlt if not <code>null</code> the alt key state of the keydown event must match this value
0968: to invoke the hot key.
0969: * @return the registered hot key.
0970: */
0971: @SuppressWarnings("unchecked")
0972: public jsx3.gui.HotKey registerHotKey(String vntCallback,
0973: int vntKey, boolean bShift, boolean bControl, boolean bAlt) {
0974: String extension = "registerHotKey(\"" + vntCallback + "\", \""
0975: + vntKey + "\", \"" + bShift + "\", \"" + bControl
0976: + "\", \"" + bAlt + "\").";
0977: try {
0978: java.lang.reflect.Constructor<jsx3.gui.HotKey> ctor = jsx3.gui.HotKey.class
0979: .getConstructor(Context.class, String.class,
0980: ScriptProxy.class);
0981: return ctor.newInstance(this , extension, getScriptProxy());
0982: } catch (Exception ex) {
0983: throw new IllegalArgumentException("Unsupported type: "
0984: + jsx3.gui.HotKey.class.getName());
0985: }
0986: }
0987:
0988: /**
0989: * Registers a hot key with this JSX model node. All keydown events that bubble up to this object
0990: will be checked against the hot key. If an event matches, the callback function will execute and the event
0991: bubble will be canceled.
0992:
0993: If the four parameters vntKey, bShift, bControl, and bAlt
0994: match a previously registered hot key, the previous hot key is clobbered by the new one. Only one hot key callback
0995: function (the most recently registered) will be executed by a single keydown event.
0996: * @param vntCallback either a function, or the name of a method bound to this object.
0997: When a keydown event bubbles up to this object that matches the hot key created by this method, this function
0998: is called on this object. If this function returns <code>false</code> then this hot key will not cancel the
0999: key event. This parameter can also be an instance of <code>HotKey</code>, in which case all
1000: other parameters are ignored.
1001: * @param vntKey if this parameter is a String, the hot key matches that key (the keycode to match is
1002: determined by <code>HotKey.keyDownCharToCode()</code>). If it is an integer, the hot key will match that
1003: keycode value.
1004: * @param bShift if not <code>null</code> the shift key state of the keydown event must match this value
1005: to invoke the hot key.
1006: * @param bControl if not <code>null</code> the control key state of the keydown event must match this value
1007: to invoke the hot key.
1008: * @param bAlt if not <code>null</code> the alt key state of the keydown event must match this value
1009: to invoke the hot key.
1010: * @return the registered hot key.
1011: */
1012: @SuppressWarnings("unchecked")
1013: public jsx3.gui.HotKey registerHotKey(String vntCallback,
1014: String vntKey, boolean bShift, boolean bControl,
1015: boolean bAlt) {
1016: String extension = "registerHotKey(\"" + vntCallback + "\", \""
1017: + vntKey + "\", \"" + bShift + "\", \"" + bControl
1018: + "\", \"" + bAlt + "\").";
1019: try {
1020: java.lang.reflect.Constructor<jsx3.gui.HotKey> ctor = jsx3.gui.HotKey.class
1021: .getConstructor(Context.class, String.class,
1022: ScriptProxy.class);
1023: return ctor.newInstance(this , extension, getScriptProxy());
1024: } catch (Exception ex) {
1025: throw new IllegalArgumentException("Unsupported type: "
1026: + jsx3.gui.HotKey.class.getName());
1027: }
1028: }
1029:
1030: }
|