16b2dd395cee629e6835dbe9b460947be7f0144c
[jelmer/samba4-debian.git] / swat / apps / swat / source / class / swat / main / Main.js
1 /*
2  * Copyright:
3  *   (C) 2006 by Derrell Lipman
4  *       All rights reserved
5  *
6  * License:
7  *   LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
8  */
9
10 /*
11 #require(swat.module.AbstractModule)
12 #require(swat.module.statistics.Statistics)
13 #require(swat.module.documentation.Documentation)
14 #require(api.Viewer)
15 */
16
17 /**
18  * Swat main menu
19  */
20 qx.OO.defineClass("swat.main.Main", qx.component.AbstractApplication,
21 function()
22 {
23   qx.component.AbstractApplication.call(this);
24 });
25
26 /**
27  * The list of supported modules
28  */
29 qx.Class.modules =
30 {
31   list :
32   {
33     "System Status" :
34     {
35       "canvas" : null,
36       "fsm"    : null,
37       "gui"    : null,
38       "class"  : swat.module.statistics.Statistics
39     },
40     "Documentation" :
41     {
42       "canvas" : null,
43       "fsm"    : null,
44       "gui"    : null,
45       "class"  : swat.module.documentation.Documentation
46     }
47   }
48 };
49
50
51 /*
52 ---------------------------------------------------------------------------
53   METHODS
54 ---------------------------------------------------------------------------
55 */
56
57 qx.Proto.initialize = function()
58 {
59   var modules = swat.main.Main.modules;
60
61   // Set the resource URI
62   qx.Settings.setCustom("resourceUri", "./resource");
63
64   // Turn on JSON debugging for the time being
65   qx.Settings.setCustomOfClass("qx.io.Json", "enableDebug", true);
66
67   // For each module...
68   for (moduleName in modules.list)
69   {
70     // ... add the module's name to the module object, ...
71     modules.list[moduleName].name = moduleName;
72
73     // ... and call the module's buildInitialFsm() function
74     var module = modules.list[moduleName]["class"].getInstance();
75     module.buildInitialFsm(modules.list[moduleName]);
76   }
77 };
78
79
80 qx.Proto.main = function()
81 {
82   var modules = swat.main.Main.modules;
83
84   // Initialize the gui for the main menu
85   swat.main.Gui.buildGui(modules);
86
87   // Similarly, now that we have a canvas for each module, ...
88   for (moduleName in modules.list)
89   {
90     // ... call the module's buildInitialGui() function
91     var module = modules.list[moduleName]["class"].getInstance();
92     module.buildInitialGui(modules.list[moduleName]);
93   }
94 };
95
96
97 qx.Proto.finalize = function()
98 {
99   var modules = swat.main.Main.modules;
100
101   // Call each module's finalization function
102   for (moduleName in modules.list)
103   {
104     var module = modules.list[moduleName]["class"].getInstance();
105     module.finalize(modules.list[moduleName]);
106   }
107 };
108