001: /*
002: * Copyright 2005 Joe Walker
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package jsx3.gui.matrix;
017:
018: import org.directwebremoting.ScriptBuffer;
019: import org.directwebremoting.proxy.ScriptProxy;
020: import org.directwebremoting.proxy.io.Context;
021:
022: /**
023: * The interface that defines the methods that affect the behavior of a composite object used as an edit mask of a
024: matrix column. Any object used as an edit mask that extends jsx3.gui.Block but does not implement
025: jsx3.gui.Form will have these methods inserted into it. Such an object only has to define the methods
026: whose default behavior it wishes to override.
027: * @author Joe Walker [joe at getahead dot org]
028: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
029: */
030: public class BlockMask extends jsx3.gui.matrix.EditMask {
031: /**
032: * All reverse ajax proxies need context to work from
033: * @param scriptProxy The place we are writing scripts to
034: * @param context The script that got us to where we are now
035: */
036: public BlockMask(Context context, String extension,
037: ScriptProxy scriptProxy) {
038: super (context, extension, scriptProxy);
039: }
040:
041: /**
042: *
043: * @param objColumn
044: */
045: public void emInit(java.lang.Object objColumn) {
046: ScriptBuffer script = new ScriptBuffer();
047: script.appendCall(getContextPath() + "emInit", objColumn);
048: getScriptProxy().addScript(script);
049: }
050:
051: /**
052: *
053: * @param strValue
054: * @param objTdDim
055: * @param objPaneDim
056: * @param objMatrix
057: * @param objColumn
058: * @param strRecordId
059: * @param objTD
060: */
061: public void emBeginEdit(String strValue, java.lang.Object objTdDim,
062: java.lang.Object objPaneDim, java.lang.Object objMatrix,
063: java.lang.Object objColumn, String strRecordId,
064: java.lang.Object objTD) {
065: ScriptBuffer script = new ScriptBuffer();
066: script.appendCall(getContextPath() + "emBeginEdit", strValue,
067: objTdDim, objPaneDim, objMatrix, objColumn,
068: strRecordId, objTD);
069: getScriptProxy().addScript(script);
070: }
071:
072: /**
073: *
074: */
075: public void emGetValue() {
076: ScriptBuffer script = new ScriptBuffer();
077: script.appendCall(getContextPath() + "emGetValue");
078: getScriptProxy().addScript(script);
079: }
080:
081: /**
082: * Returns the DOM node that should be focused when the edit session begins. The default behavior is to return
083: the first descendant (breadth-first) that implements jsx3.gui.Form.
084: */
085: @SuppressWarnings("unchecked")
086: public jsx3.gui.Painted getMaskFirstResponder() {
087: String extension = "getMaskFirstResponder().";
088: try {
089: java.lang.reflect.Constructor<jsx3.gui.Painted> ctor = jsx3.gui.Painted.class
090: .getConstructor(Context.class, String.class,
091: ScriptProxy.class);
092: return ctor.newInstance(this , extension, getScriptProxy());
093: } catch (Exception ex) {
094: throw new IllegalArgumentException("Unsupported type: "
095: + jsx3.gui.Painted.class.getName());
096: }
097: }
098:
099: /**
100: * Returns the DOM node that should be focused when the edit session begins. The default behavior is to return
101: the first descendant (breadth-first) that implements jsx3.gui.Form.
102: * @param returnType The expected return type
103: */
104: @SuppressWarnings("unchecked")
105: public <T> T getMaskFirstResponder(Class<T> returnType) {
106: String extension = "getMaskFirstResponder().";
107: try {
108: java.lang.reflect.Constructor<T> ctor = returnType
109: .getConstructor(Context.class, String.class,
110: ScriptProxy.class);
111: return ctor.newInstance(this , extension, getScriptProxy());
112: } catch (Exception ex) {
113: throw new IllegalArgumentException(
114: "Unsupported return type: " + returnType.getName());
115: }
116: }
117:
118: /**
119: * Returns the value currently stored in this edit mask. The default behavior is to return the value of
120: the first descendant (breadth-first) that implements jsx3.gui.Form.
121: */
122: @SuppressWarnings("unchecked")
123: public void getMaskValue(
124: org.directwebremoting.proxy.Callback<String> callback) {
125: ScriptBuffer script = new ScriptBuffer();
126: String callbackPrefix = "";
127:
128: if (callback != null) {
129: callbackPrefix = "var reply = ";
130: }
131:
132: script.appendCall(callbackPrefix + getContextPath()
133: + "getMaskValue");
134:
135: if (callback != null) {
136: String key = org.directwebremoting.extend.CallbackHelper
137: .saveCallback(callback, String.class);
138: script
139: .appendCall("__System.activateCallback", key,
140: "reply");
141: }
142:
143: getScriptProxy().addScript(script);
144: }
145:
146: /**
147: * Sets the value currently stored in this edit mask. The default behavior is to set the value of
148: the first descendant (breadth-first) that implements jsx3.gui.Form.
149: * @param strValue
150: */
151: public void setMaskValue(String strValue) {
152: ScriptBuffer script = new ScriptBuffer();
153: script.appendCall(getContextPath() + "setMaskValue", strValue);
154: getScriptProxy().addScript(script);
155: }
156:
157: /**
158: *
159: */
160: public void emEndEdit() {
161: ScriptBuffer script = new ScriptBuffer();
162: script.appendCall(getContextPath() + "emEndEdit");
163: getScriptProxy().addScript(script);
164: }
165:
166: }
|