2 * Abstract Module class. All modules should extend this class.
4 qx.OO.defineClass("swat.module.AbstractModule", qx.core.Object,
7 qx.core.Object.call(this);
8 this.debug("AbstractModule constructor");
13 * Build the initial finite state machine.
15 * In order to prevent long load times, as minimal as possible of an initial
16 * FSM should be created. The FSM will receive a "visible" event when the
17 * module is first selected (and each subsequent time), and the FSM can use
18 * that event to build the complete FSM.
20 * @param module {Object}
21 * An object containing at least the following properties:
23 * The finite state machine for this module. It should be filled in
26 * The canvas on which to create the gui for this module
28 * The name of this module
30 * The class for this module
33 qx.Proto.buildInitialFsm = function(module)
35 // Create a new finite state machine
36 var fsm = new qx.util.fsm.FiniteStateMachine(module.name);
38 // For this simple example application, show all debug messages.
39 qx.Settings.setCustomOfClass(
40 "qx.util.fsm.FiniteStateMachine",
42 (qx.util.fsm.FiniteStateMachine.DebugFlags.EVENTS |
43 qx.util.fsm.FiniteStateMachine.DebugFlags.TRANSITIONS |
44 qx.util.fsm.FiniteStateMachine.DebugFlags.FUNCTION_DETAIL |
45 qx.util.fsm.FiniteStateMachine.DebugFlags.OBJECT_NOT_FOUND));
51 * "appear" on swat.module.canvas
53 var state = new qx.util.fsm.State(
58 // When we get an appear event the first time, run the transition
59 // that will load the module's finite state machine and graphical
63 "swat.module.canvas" :
64 "Transition_Idle_to_Idle_Load_Gui"
71 * Transition: Idle to (replaced) Idle
73 * Cause: "appear" on canvas for the first time
76 * Load module's finite state machine and graphical user interface
78 var thisModule = this;
79 var trans = new qx.util.fsm.Transition(
80 "Transition_Idle_to_Idle_Load_Gui",
83 qx.util.fsm.FiniteStateMachine.StateChange.CURRENT_STATE,
88 // Make the "Loading" message go away. (We need to learn how to
89 // remove it entirely. Just doing canvas.removeAll() leaves
90 // something in the widget queue and we get spurious error
92 var children = module.canvas.getVisibleChildren();
93 for (var child in children)
95 children[child].hide();
98 // Call the module's initialAppear function to build FSM and GUI.
99 // That function should *replace* this state, State_Idle, to which
101 thisModule.initialAppear(module);
104 state.addTransition(trans);
106 // Save the finite state machine for this module
108 fsm.addObject("swat.module.fsm", fsm);
113 * Build the initial graphical user interface.
115 * In order to prevent long load times, as minimal as possible of an initial
116 * GUI should be created. Generally, this is just a "Loading..." message.
118 * @param module {Object}
119 * An object containing at least the following properties:
121 * The finite state machine for this module. It should be filled in
124 * The canvas on which to create the gui for this module
126 * The name of this module
128 * The class for this module
131 qx.Proto.buildInitialGui = function(module)
133 // For now, just create the "Loading" text
134 var o = new qx.ui.basic.Label("Loading module '" + module.name + "'...");
140 module.canvas.add(o);
143 qx.Proto.finalize = function(module)
145 this.debug("AbstractModule.finalize()");
150 ---------------------------------------------------------------------------
151 DEFER SINGLETON INSTANCE
152 ---------------------------------------------------------------------------
156 * Singleton Instance Getter
158 qx.Class.getInstance = qx.util.Return.returnInstance;