r20445: add README file indicating that the swat directory is no longer relevant
[sfrench/samba-autobuild/.git] / swat / apps / qooxdoo-examples / test / ListView_7.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>Testing qx.ui.listview.ListView with text cells.</p>
16     <p>Added some buttons to fill/clear the list dynamically.</p>
17   </div>
18
19   <script type="text/javascript">
20     qx.core.Init.getInstance().defineMain(function()
21     {
22       var ld = [];
23       var lt = [ "Image", "Text", "PDF", "Illustration", "Document" ];
24
25       var lc =
26       {
27         name : { label : "Name", width : 100, type : "text", sortable : true, sortProp : "text" },
28         size: { label : "Size", width : 50, type : "text", sortable : true, sortProp : "text", sortMethod : qx.util.Compare.byIntegerString },
29         type : { label : "Type", width : 80, type : "text", sortable : true, sortProp : "text" },
30         modified : { label : "Last Modified", width : 150, type : "text" },
31         rights : { label : "Rights", width: 80, type : "text" }
32       };
33
34       var lv = new qx.ui.listview.ListView(ld, lc);
35
36       lv.setBorder(qx.renderer.border.BorderPresets.getInstance().shadow);
37       lv.setBackgroundColor("white");
38       lv.setWidth(500);
39       lv.setHeight(350);
40       lv.setLocation(20, 48);
41
42       qx.ui.core.ClientDocument.getInstance().add(lv);
43
44       function add(nu)
45       {
46         nu = nu||10;
47
48         for (var i=0, t; i<nu; i++)
49         {
50           t=Math.round(Math.random()*4);
51           ld.push({ name : { text : "File " + ld.length }, size : { text : Math.round(Math.random()*100) + "kb" }, type : { text : lt[t] }, modified : { text : "Nov " + Math.round(Math.random() * 30 + 1) + " 2005" }, rights: { text : "-rw-r--r--" }});
52         };
53
54         lv.updateSort();
55         lv.update();
56       };
57
58       function remove(nu)
59       {
60         nu = Math.min(ld.length, nu || 10);
61
62         ld.splice(ld.length-nu, nu);
63
64         lv.updateSort();
65         lv.update();
66       };
67
68       function clear()
69       {
70         ld.removeAll();
71         lv.update();
72       };
73
74       var btnAdd10 = new qx.ui.form.Button("Add 10", "icon/16/insert-table-row.png");
75       var btnAdd50 = new qx.ui.form.Button("Add 50", "icon/16/insert-table-row.png");
76       var btnAdd100 = new qx.ui.form.Button("Add 100", "icon/16/insert-table-row.png");
77       var btnAdd1000 = new qx.ui.form.Button("Add 1000", "icon/16/insert-table-row.png");
78
79       var btnRemove10 = new qx.ui.form.Button("Remove 10", "icon/16/delete-table-row.png");
80       var btnRemove50 = new qx.ui.form.Button("Remove 50", "icon/16/delete-table-row.png");
81       var btnRemove100 = new qx.ui.form.Button("Remove 100", "icon/16/delete-table-row.png");
82       var btnRemove1000 = new qx.ui.form.Button("Remove 1000", "icon/16/delete-table-row.png");
83
84       var btnClear = new qx.ui.form.Button("Clear", "icon/16/delete-table.png");
85
86       btnAdd10.setLocation(550, 48);
87       btnAdd50.setLocation(550, 78);
88       btnAdd100.setLocation(550, 108);
89       btnAdd1000.setLocation(550, 138);
90
91       btnRemove10.setLocation(550, 188);
92       btnRemove50.setLocation(550, 218);
93       btnRemove100.setLocation(550, 248);
94       btnRemove1000.setLocation(550, 278);
95
96       btnClear.setLocation(550, 328);
97
98       btnAdd10.addEventListener("execute", function(e) { add(10); });
99       btnAdd50.addEventListener("execute", function(e) { add(50); });
100       btnAdd100.addEventListener("execute", function(e) { add(100); });
101       btnAdd1000.addEventListener("execute", function(e) { add(1000); });
102
103       btnRemove10.addEventListener("execute", function(e) { remove(10); });
104       btnRemove50.addEventListener("execute", function(e) { remove(50); });
105       btnRemove100.addEventListener("execute", function(e) { remove(100); });
106       btnRemove1000.addEventListener("execute", function(e) { remove(1000); });
107
108       btnClear.addEventListener("execute", function(e) { clear(); });
109
110       qx.ui.core.ClientDocument.getInstance().add(btnAdd10, btnAdd50, btnAdd100, btnAdd1000, btnRemove10, btnRemove50, btnRemove100, btnRemove1000, btnClear);
111     });
112   </script>
113 </body>
114 </html>