3 * (C) 2006 by Derrell Lipman
7 * LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
11 * Common facilities for modules' finite state machines. Each module's FSM
12 * should extend this class.
14 qx.OO.defineClass("swat.module.AbstractModuleFsm", qx.core.Object, function()
16 qx.core.Object.call(this);
20 qx.Proto.buildFsm = function(module)
22 throw new Error("Module must overload buildFsm() " +
23 "to build its custom finite state machine.");
26 qx.Proto.addAwaitRpcResultState = function(module)
31 * State: AwaitRpcResult
34 * - enable any objects in group "swat.module.fsmUtils.enable_during_rpc"
35 * - disable any objects in group "swat.module.fsmUtils.disable_during_rpc"
38 * - disable any objects in group "group_enable_during_rpc"
39 * - enable any objects in group "group_disable_during_rpc"
42 * "completed" (on RPC)
44 * "execute" on swat.module.fsmUtils.abort_rpc
46 var state = new qx.util.fsm.State(
47 "State_AwaitRpcResult",
49 "autoActionsBeforeOnentry" :
51 // The name of a function.
55 // We want to enable objects in the group
56 // swat.module.fsmUtils.enable_during_rpc
57 "parameters" : [ true ],
59 // Call this.getObject(<object>).setEnabled(true) on
60 // state entry, for each <object> in the group called
61 // "swat.module.fsmUtils.enable_during_rpc".
62 "groups" : [ "swat.module.fsmUtils.enable_during_rpc" ]
66 // We want to disable objects in the group
67 // swat.module.fsmUtils.disable_during_rpc
68 "parameters" : [ false ],
70 // Call this.getObject(<object>).setEnabled(false) on
71 // state entry, for each <object> in the group called
72 // "swat.module.fsmUtils.disable_during_rpc".
73 "groups" : [ "swat.module.fsmUtils.disable_during_rpc" ]
78 "autoActionsBeforeOnexit" :
80 // The name of a function.
84 // We want to re-disable objects we had enabled, in the group
85 // swat.module.fsmUtils.enable_during_rpc
86 "parameters" : [ false ],
88 // Call this.getObject(<object>).setEnabled(false) on
89 // state entry, for each <object> in the group called
90 // "swat.module.fsmUtils.enable_during_rpc".
91 "groups" : [ "swat.module.fsmUtils.enable_during_rpc" ]
95 // We want to re-enable objects we had disabled, in the group
96 // swat.module.fsmUtils.disable_during_rpc
97 "parameters" : [ true ],
99 // Call this.getObject(<object>).setEnabled(true) on
100 // state entry, for each <object> in the group called
101 // "swat.module.fsmUtils.disable_during_rpc".
102 "groups" : [ "swat.module.fsmUtils.disable_during_rpc" ]
110 // If we're coming from some other start...
111 if (fsm.getPreviousState() != "State_AwaitRpcResult")
113 // ... then push the previous state onto the state stack
114 fsm.pushState(false);
122 "swat.module.fsmUtils.abort_rpc" :
123 "Transition_AwaitRpcResult_to_AwaitRpcResult_via_button_abort"
127 "Transition_AwaitRpcResult_to_PopStack_via_complete",
130 "Transition_AwaitRpcResult_to_PopStack_via_failed"
136 * Transition: AwaitRpcResult to AwaitRpcResult
138 * Cause: "execute" on swat.module.fsmUtils.abort_rpc
140 var trans = new qx.util.fsm.Transition(
141 "Transition_AwaitRpcResult_to_AwaitRpcResult_via_button_abort",
144 "State_AwaitRpcResult",
149 // Get the request object
150 var request = fsm.getObject("swat.module.fsmUtils.request");
152 // Issue an abort for the pending request
156 state.addTransition(trans);
159 * Transition: AwaitRpcResult to PopStack
161 * Cause: "complete" (on RPC)
163 var trans = new qx.util.fsm.Transition(
164 "Transition_AwaitRpcResult_to_PopStack_via_complete",
167 qx.util.fsm.FiniteStateMachine.StateChange.POP_STATE_STACK,
172 // Get the request object
173 var request = fsm.getObject("swat.module.fsmUtils.request");
175 // Generate the result for a completed request
179 data : event.getData()
183 state.addTransition(trans);
186 * Transition: AwaitRpcResult to PopStack
188 * Cause: "failed" (on RPC)
190 var trans = new qx.util.fsm.Transition(
191 "Transition_AwaitRpcResult_to_PopStack_via_failed",
194 qx.util.fsm.FiniteStateMachine.StateChange.POP_STATE_STACK,
199 // Get the request object
200 var request = fsm.getObject("swat.module.fsmUtils.request");
202 // Generate the result for a completed request
206 data : event.getData()
210 state.addTransition(trans);
215 * Singleton Instance Getter
217 qx.Class.getInstance = qx.util.Return.returnInstance;