01: package com.gwtext.client.widgets;
02:
03: import com.gwtext.client.core.BaseConfig;
04: import com.gwtext.client.core.Function;
05: import com.gwtext.client.util.JavaScriptObjectHelper;
06:
07: /**
08: * Wait configuration class.
09: *
10: * @see MessageBoxConfig#setWaitConfig(WaitConfig)
11: * @see com.gwtext.client.widgets.ProgressBar#wait(WaitConfig)
12: */
13: public class WaitConfig extends BaseConfig {
14: /**
15: * Create a new WaitConfig.
16: */
17: public WaitConfig() {
18: }
19:
20: /**
21: * Create a new WaitConfig.
22: *
23: * @param duration the length of time in milliseconds that the progress bar should run before resetting itself
24: */
25: public WaitConfig(int duration) {
26: setDuration(duration);
27: }
28:
29: /**
30: * Create a new WaitConfig.
31: *
32: * @param duration the length of time in milliseconds that the progress bar should run before resetting itself
33: * @param interval The length of time in milliseconds between each progress update
34: * @param increment the number of progress update segments to display within the progress bar (defaults to 10).
35: */
36: public WaitConfig(int duration, int interval, int increment) {
37: setDuration(duration);
38: setInterval(interval);
39: setIncrement(increment);
40: }
41:
42: /**
43: * The length of time in milliseconds that the progress bar should run before resetting itself (defaults to undefined,
44: * in which case it will run indefinitely until reset is called).
45: *
46: * @param duration the duration
47: */
48: public void setDuration(int duration) {
49: JavaScriptObjectHelper
50: .setAttribute(jsObj, "duration", duration);
51: }
52:
53: /**
54: * The length of time in milliseconds between each progress update (defaults to 1000 ms).
55: *
56: * @param interval the interval
57: */
58: public void setInterval(int interval) {
59: JavaScriptObjectHelper
60: .setAttribute(jsObj, "interval", interval);
61: }
62:
63: /**
64: * The number of progress update segments to display within the progress bar (defaults to 10). If the bar reaches
65: * the end and is still updating, it will automatically wrap back to the beginning.
66: *
67: * @param increment the increment
68: */
69: public void setIncrement(int increment) {
70: JavaScriptObjectHelper.setAttribute(jsObj, "increment",
71: increment);
72: }
73:
74: /**
75: * A callback function to execute after the progress bar finishes auto-updating.
76: * This function will be ignored if duration is not specified since in that case the
77: * progress bar can only be stopped programmatically, so any required function should be called by the same code after
78: * it resets the progress bar.
79: *
80: * @param callback the callback function
81: */
82: public native void setCallback(Function callback) /*-{
83: var config = this.@com.gwtext.client.core.JsObject::getJsObj()();
84: config['fn'] = function() {
85: callback.@com.gwtext.client.core.Function::execute()();
86: };
87: }-*/;
88: }
|