r19141: add a reasonable subset of the qooxdoo runtime environment, and example appli...
[jelmer/samba4-debian.git] / swat / apps / qooxdoo-examples / test / Generate_1.html
1 <html>
2 <head>
3   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4   <title>qooxdoo &raquo; Demo</title>
5   <link type="text/css" rel="stylesheet" href="../../resource/css/layout.css"/>
6   <!--[if IE]>
7   <link type="text/css" rel="stylesheet" href="../../resource/css/layout_ie.css"/>
8   <![endif]-->
9   <script type="text/javascript" src="../../script/qx.js"></script>
10 </head>
11 <body>
12   <script type="text/javascript" src="../../script/layout.js"></script>
13
14   <div id="demoDescription">
15     <p>qx.ui.basic.Atom is the parent class for buttons, menu entries, icons, checkboxes. While you can do,
16     you usually don't have to instantiate qx.ui.basic.Atom directly.</p>
17   </div>
18
19   <script type="text/javascript">
20   qx.lang.Array.merge = function(firstArray, secondArray)
21   {
22     var combinedArray = [], currentValue, indexInSecond;
23
24     for (var i=0, l=firstArray.length; i<l; i++) {
25       (indexInSecond = secondArray.indexOf(currentValue = firstArray[i])) == -1 ? combinedArray.push(currentValue) : qx.lang.Array.append(combinedArray, secondArray.splice(0, indexInSecond+1));
26     };
27
28     return combinedArray.concat(secondArray);
29   };
30
31   var a = [ "before3Mnu", "fileMnu", "editMnu", "saveMnu", "exitMenu" ];
32   var b = [ "before1Mnu", "before2Mnu", "fileMnu", "fooMnu", "editMnu", "saveMnu", "after1Mnu" ];
33
34   //alert(qx.lang.Array.merge(a, b));
35
36   var comp1 =
37   {
38     bars :
39     [
40       {
41         id : "menubar",
42         groups : [ "mainMp", "helpMp" ]
43       },
44
45       {
46         id : "toolbar",
47         groups : [ "openTb", "editTb" ]
48       }
49     ],
50
51     groups :
52     {
53       // Menu Bar Parts
54       "mainMp" : { commands : [ "fileBtn", "editBtn", "viewBtn" ] },
55       "helpMp" : { commands : [ "helpBtn" ] },
56
57       // Tool Bar Parts
58       "openTb" : { commands : [ "openBtn", "openRecentlyBtn" ] },
59       "editTb" : { commands : [ "cutBtn", "copyBtn", "pasteBtn" ] },
60
61       // Menu Content
62       "openMn" : { commands : [ "openBtn", "openWithBtn", "openRecentlyBtn" ] },
63       "saveMn" : { commands : [ "saveBtn", "saveAsBtn" ] },
64       "closeMn" : { commands : [ "closeBtn" ] },
65       "exitMn" : { commands : [ "exitBtn" ] },
66       "undoMn" : { commands : [ "undoBtn", "redoBtn" ] },
67       "editMn" : { commands : [ "cutBtn", "copyBtn", "pasteBtn", "deleteBtn", "clipboardBtn" ] },
68       "searchMn" : { commands : [ "searchBtn", "replaceBtn", "continueSearchBtn" ] },
69
70       "barsMn" : { commands : [] },
71       "fontMn" : { commands : [] },
72
73       "aboutMn" : { commands : [ "aboutBtn" ] },
74       "recentDocsMn" : { commands : [ "doc1Btn", "doc2Btn", "doc3Btn" ] }
75     },
76
77     menus :
78     {
79       "fileMnu" : { groups : [ "openMn", "saveMn", "closeMn", "exitMn" ] },
80       "editMnu" : { groups : [ "undoMn", "editMn", "searchMn" ] },
81       "viewMnu" : { groups : [ "barsMn", "fontMn" ] },
82       "helpMnu" : { groups : [ "aboutMn" ] },
83       "openRecentlyMnu" : { groups : [ "recentDocsMn" ] }
84     },
85
86     commands :
87     {
88       // Menu-Buttons
89       "fileBtn" : { title : "Datei", menu : "fileMnu" },
90       "editBtn" : { title : "Bearbeiten", menu : "editMnu" },
91       "viewBtn" : { title : "Ansicht", menu : "viewMnu" },
92       "helpBtn" : { title : "Hilfe", menu : "helpMnu" },
93
94       // Execute-Buttons: Open
95       "openBtn" : { title : "Öffnen", execute : "open" },
96       "openWithBtn" : { title : "Öffnen mit...", execute : "openWith" },
97       "openRecentlyBtn" : { title : "Letzte öffnen...", menu : "openRecentlyMnu" },
98
99       "saveBtn" : { title : "Speichern", execute : "save" },
100       "saveAsBtn" : { title : "Speichern als...", execute : "saveAs" },
101       "closeBtn" : { title : "Schließen", execute : "close" },
102       "exitBtn" : { title : "Beenden", execute : "exit" },
103
104       "undoBtn" : { title : "Rückgängig", execute : "undo" },
105       "redoBtn" : { title : "Wiederherstellen", execute : "redo" },
106       "deleteBtn" : { title : "Löschen", execute : "delete" },
107       "clipboardBtn" : { title : "Zwischenablage", execute : "clipboard" },
108
109       // Execute-Buttons: Search
110       "searchBtn" : { title : "Suchen", execute : "search" },
111       "replaceBtn" : { title : "Ersetzen", execute : "replace" },
112       "continueSearchBtn" : { title : "Weitersuchen", execute : "continuesearch" },
113
114       // Execute-Buttons: Edit
115       "cutBtn" : { title : "Ausschneiden", execute : "cut" },
116       "copyBtn" : { title : "Kopieren", execute : "copy" },
117       "pasteBtn" : { title : "Einfügen", execute : "paste" },
118
119       // Execute-Buttons: Info
120       "aboutBtn" : { title : "Über", execute : "about" },
121
122       "doc1Btn" : { title : "Dokument 1", execute : "openDoc1" },
123       "doc2Btn" : { title : "Dokument 2", execute : "openDoc2" },
124       "doc3Btn" : { title : "Dokument 3", execute : "openDoc3" }
125     }
126   };
127
128   var comp2 =
129   {
130   };
131
132
133
134
135
136
137   qx.OO.defineClass("qx.Generator", qx.core.Target,
138   function(comp)
139   {
140     this._comp = comp;
141
142   });
143
144   qx.Proto._generateMenu = function(id)
145   {
146     var menu = new qx.ui.menu.Menu;
147
148     var menuData = this._comp.menus[id];
149
150     if (!menuData) {
151       alert("Missing menu: " + id);
152     };
153
154     for (var i=0; i<menuData.groups.length; i++)
155     {
156       var groupcontent = this._comp.groups[menuData.groups[i]];
157
158       if (!groupcontent) {
159         alert("Missing menu: " + menuData.groups[i]);
160       };
161
162       var groupcommandlist = groupcontent.commands;
163
164       for (var j=0; j<groupcommandlist.length; j++)
165       {
166         var commandData = this._comp.commands[groupcommandlist[j]];
167
168         if (!commandData) {
169           alert("Missing command: " + groupcommandlist[j]);
170         };
171
172         if (commandData.menu)
173         {
174           var subMenu = this._generateMenu(commandData.menu);
175           var menuButton = new qx.ui.menu.MenuButton(commandData.title, null, null, subMenu);
176
177         subMenu.addToDocument();
178         }
179         else
180         {
181           var menuButton = new qx.ui.menu.MenuButton(commandData.title);
182         };
183
184         menu.add(menuButton);
185       };
186
187       if (i < menuData.groups.length-1) {
188         menu.add(new qx.ui.menu.MenuSeparator);
189       };
190     };
191
192     return menu;
193   };
194
195   qx.Proto.getWidget = function()
196   {
197     var can = new qx.ui.layout.CanvasLayout;
198     can.auto();
199     can.setLocation(100, 100);
200     can.setBorder("2px solid red");
201
202     for (var i=0; i<this._comp.bars.length; i++)
203     {
204       var tb = new qx.ui.toolbar.ToolBar;
205       tb.setLocation(0, (i * 50));
206       tb.setRight(0);
207       can.add(tb);
208
209
210
211       var bardata = this._comp.bars[i];
212       var groupdata = bardata.groups;
213
214       for(var j=0; j<groupdata.length; j++)
215       {
216         var part = new qx.ui.toolbar.ToolBarPart;
217
218         var groupcontent = this._comp.groups[groupdata[j]];
219         var groupcommandlist = groupcontent.commands;
220
221         if (!groupcommandlist)
222         {
223           alert("Missing commands in: " + groupcontent);
224         };
225
226         for (var k=0; k<groupcommandlist.length; k++)
227         {
228           var commanddata = this._comp.commands[groupcommandlist[k]];
229
230           if (commanddata)
231           {
232             if (typeof commanddata.menu != qx.constant.Type.UNDEFINED)
233             {
234               menu = this._generateMenu(commanddata.menu);
235           menu.addToDocument();
236     
237               btn = new qx.ui.toolbar.ToolBarMenuButton(commanddata.title, menu);
238             }
239             else
240             {
241               btn = new qx.ui.toolbar.ToolBarButton(commanddata.title);
242             };
243
244             part.add(btn);
245           }
246           else
247           {
248             alert("Missing: " + groupcommandlist[k]);
249           };
250         };
251
252         tb.add(part);
253       };
254     };
255
256     return can;
257   };
258
259   qx.core.Init.getInstance().defineMain(function()
260   {
261     var c1 = new qx.Generator(comp1);
262     qx.ui.core.ClientDocument.getInstance().add(c1.getWidget());
263   });
264
265   </script>
266 </body>
267 </html>