001: /*
002: * GWT-Ext Widget Library
003: * Copyright(c) 2007-2008, GWT-Ext.
004: * licensing@gwt-ext.com
005: *
006: * http://www.gwt-ext.com/license
007: */
008: package com.gwtext.client.widgets;
009:
010: import com.google.gwt.core.client.JavaScriptObject;
011: import com.gwtext.client.core.BaseConfig;
012: import com.gwtext.client.core.NameValuePair;
013: import com.gwtext.client.util.JavaScriptObjectHelper;
014:
015: /**
016: * {@link com.gwtext.client.widgets.MessageBox} configuration class.
017: *
018: * @see com.gwtext.client.widgets.MessageBox#show(MessageBoxConfig)
019: */
020: public class MessageBoxConfig extends BaseConfig {
021:
022: /**
023: * An id from which the message box should animate as it opens and closes (defaults to undefined).
024: *
025: * @param animEl the anim elem ID
026: */
027: public void setAnimEl(String animEl) {
028: JavaScriptObjectHelper.setAttribute(jsObj, "animEl", animEl);
029: }
030:
031: /**
032: * The title text.
033: *
034: * @param title the title
035: */
036: public void setTitle(String title) {
037: JavaScriptObjectHelper.setAttribute(jsObj, "title", title);
038: }
039:
040: /**
041: * False to hide the top-right close button (defaults to true). Note that progress and wait dialogs will ignore
042: * this property and always hide the close button as they can only be closed programmatically.
043: *
044: * @param closable true for closable
045: */
046: public void setClosable(boolean closable) {
047: JavaScriptObjectHelper
048: .setAttribute(jsObj, "closable", closable);
049: }
050:
051: /**
052: * A custom CSS class to apply to the message box element.
053: *
054: * @param cls the css class
055: */
056: public void setCls(String cls) {
057: JavaScriptObjectHelper.setAttribute(jsObj, "cls", cls);
058: }
059:
060: /**
061: * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75).
062: *
063: * @param defaultTextHeight the default text height
064: */
065: public void setDefaultTextHeight(int defaultTextHeight) {
066: JavaScriptObjectHelper.setAttribute(jsObj, "defaultTextHeight",
067: defaultTextHeight);
068: }
069:
070: /**
071: * True to prompt the user to enter single-line text (defaults to false).
072: *
073: * @param prompt true to prompt
074: */
075: public void setPrompt(boolean prompt) {
076: JavaScriptObjectHelper.setAttribute(jsObj, "prompt", prompt);
077: }
078:
079: /**
080: * True to prompt the user to enter multi-line text (defaults to false).
081: *
082: * @param multiline true for multiline prompt
083: */
084: public void setMultiline(boolean multiline) {
085: JavaScriptObjectHelper.setAttribute(jsObj, "multiline",
086: multiline);
087: }
088:
089: /**
090: * True to display a progress bar (defaults to false)
091: *
092: * @param progress true for progress bar
093: */
094: public void setProgress(boolean progress) {
095: JavaScriptObjectHelper
096: .setAttribute(jsObj, "progress", progress);
097: }
098:
099: /**
100: * The text to display inside the progress bar if progress = true (defaults to '').
101: *
102: * @param progressText the progress text
103: */
104: public void setProgressText(String progressText) {
105: JavaScriptObjectHelper.setAttribute(jsObj, "progressText",
106: progressText);
107: }
108:
109: /**
110: * he string value to set into the active textbox element if displayed.
111: *
112: * @param value the value text
113: */
114: public void setValue(String value) {
115: JavaScriptObjectHelper.setAttribute(jsObj, "value", value);
116: }
117:
118: /**
119: * The button to display.
120: *
121: * @param buttons the buttons
122: */
123: public void setButtons(MessageBox.Button buttons) {
124: JavaScriptObjectHelper.setAttribute(jsObj, "buttons", buttons
125: .getJsObj());
126: }
127:
128: /**
129: * False to not show any buttons.
130: *
131: * @param buttons display buttons
132: */
133: public void setButtons(boolean buttons) {
134: JavaScriptObjectHelper.setAttribute(jsObj, "buttons", buttons);
135: }
136:
137: /**
138: * A callback function to execute after closing the dialog. The arguments to the function will be btn
139: * (the name of the button that was clicked, if applicable, e.g. "ok"),
140: * and text (the value of the active text field, if applicable).
141: * Progress and wait dialogs will ignore this option since they do not respond to user actions and can only be
142: * closed programmatically, so any required function should be called by the same code after it closes the dialog.
143: *
144: * @param cb the callback
145: */
146: public native void setCallback(MessageBox.PromptCallback cb)/*-{
147: var config = this.@com.gwtext.client.core.JsObject::getJsObj()();
148: config['fn'] = function(btnID, text) {
149: if(btnID === undefined) btnID = null;
150: if(text === undefined || text == '') text = null;
151: cb.@com.gwtext.client.widgets.MessageBox.PromptCallback::execute(Ljava/lang/String;Ljava/lang/String;)(btnID, text);
152: };
153: }-*/;
154:
155: /**
156: * name = button id, value = button label
157: * Name has to be one of 'ok, cancel, yes, no, and value is the label to be dispalyed
158: *
159: * @param buttons the nambe value pairs for the buttons
160: */
161: public void setButtons(NameValuePair[] buttons) {
162: JavaScriptObject config = NameValuePair.getJsObj(buttons);
163: JavaScriptObjectHelper.setAttribute(jsObj, "buttons", config);
164: }
165:
166: /**
167: * The string that will replace the existing message box body text (defaults to the XHTML-compliant non-breaking space
168: * character ' ')
169: *
170: * @param msg the message
171: */
172: public void setMsg(String msg) {
173: JavaScriptObjectHelper.setAttribute(jsObj, "msg", msg);
174: }
175:
176: /**
177: * A CSS class that provides a background image to be used as an icon for the dialog (e.g., Ext.MessageBox.WARNING
178: * or 'custom-class', defaults to '').
179: *
180: * @param iconCls the icon CSS class
181: */
182: public void setIconCls(String iconCls) {
183: JavaScriptObjectHelper.setAttribute(jsObj, "icon", iconCls);
184: }
185:
186: /**
187: * True to display a lightweight proxy while dragging (defaults to false).
188: *
189: * @param proxyDrag true for proxy drag
190: */
191: public void setProxyDrag(boolean proxyDrag) {
192: JavaScriptObjectHelper.setAttribute(jsObj, "proxyDrag",
193: proxyDrag);
194: }
195:
196: /**
197: * False to allow user interaction with the page while the message box is displayed
198: * (defaults to true).
199: *
200: * @param modal false for non modal
201: */
202: public void setModal(boolean modal) {
203: JavaScriptObjectHelper.setAttribute(jsObj, "modal", modal);
204: }
205:
206: /**
207: * The minimum width in pixels of the message box (defaults to 100).
208: *
209: * @param minWidth the min width
210: */
211: public void setMinWidth(int minWidth) {
212: JavaScriptObjectHelper
213: .setAttribute(jsObj, "minWidth", minWidth);
214: }
215:
216: /**
217: * The maximum width in pixels of the message box (defaults to 600).
218: *
219: * @param maxWidth the max width
220: */
221: public void setMaxWidth(int maxWidth) {
222: JavaScriptObjectHelper
223: .setAttribute(jsObj, "maxWidth", maxWidth);
224: }
225:
226: /**
227: * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful for setting a
228: * different minimum width than text-only dialogs may need (defaults to 250)
229: *
230: * @param minProgressWidth the minimum width in pixels of the message box if it is a progress-style dialog.
231: */
232: public void setMinProgressWidth(int minProgressWidth) {
233: JavaScriptObjectHelper.setAttribute(jsObj, "minProgressWidth",
234: minProgressWidth);
235: }
236:
237: /**
238: * True to display a progress bar (defaults to false).
239: *
240: * @param wait true to display progress bar
241: */
242: public void setWait(boolean wait) {
243: JavaScriptObjectHelper.setAttribute(jsObj, "wait", wait);
244: }
245:
246: /**
247: * Applies a wait with the specified waitConfig object (applies only if wait = true).
248: *
249: * @param waitConfig the wait config
250: */
251: public void setWaitConfig(WaitConfig waitConfig) {
252: JavaScriptObjectHelper.setAttribute(jsObj, "waitConfig",
253: waitConfig.getJsObj());
254: }
255:
256: /**
257: * The width of the dialog in pixels.
258: *
259: * @param width the dialog width
260: */
261: public void setWidth(int width) {
262: JavaScriptObjectHelper.setAttribute(jsObj, "width", width);
263: }
264: }
|