r20445: add README file indicating that the swat directory is no longer relevant
[kai/samba.git] / swat / apps / qooxdoo-examples / test / ListView_9.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>And with drag and drop between the two qx.ui.listview.ListViews.</p>
17     <p>Reduced columns for second listview.</p>
18   </div>
19
20   <script type="text/javascript">
21     qx.core.Init.getInstance().defineMain(function()
22     {
23       var ld = [];
24       var lt = [ "Image", "Text", "PDF", "Illustration", "Document" ];
25
26       for (var i=0, t; i<1000; i++)
27       {
28         t=Math.round(Math.random()*4);
29         ld.push({ name : { text : "File " + i }, 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--" }});
30       };
31
32       var lc1 =
33       {
34         name : { label : "Name", width : 100, type : "text", sortable : true, sortProp : "text" },
35         size: { label : "Size", width : 50, type : "text", sortable : true, sortProp : "text", sortMethod : qx.util.Compare.byIntegerString },
36         type : { label : "Type", width : 80, type : "text", sortable : true, sortProp : "text" },
37         modified : { label : "Last Modified", width : 150, type : "text" },
38         rights : { label : "Rights", width: 80, type : "text" }
39       };
40
41       var lc2 =
42       {
43         name : { label : "Name", width : 200, type : "text", sortable : true, sortProp : "text" },
44         type : { label : "Type", width : 80, type : "text", sortable : true, sortProp : "text" }
45       };
46
47
48       function handleDrag(e)
49       {
50         e.addData("qx.ui.listview.ListViewEntries", qx.lang.Array.copy(e.getCurrentTarget().getManager().getSelectedItems()));
51         e.addAction("move");
52         e.startDrag();
53       };
54
55       function handleDrop(e)
56       {
57         var type = e.getDropDataTypes()[0];
58         var data = e.getData(type);
59
60         switch(e.getAction())
61         {
62           case "move":
63             sourceView.getPane().getManager().setSelectedItems([]);
64             sourceView.getPane().getManager().setAnchorItem(null);
65             sourceView.getPane().getManager().setLeadItem(null);
66
67             for (var i=0, l=data.length; i<l; i++)
68             {
69               qx.lang.Array.remove(sourceView.getData(), data[i]);
70               destView.getData().push(data[i]);
71             };
72
73             destView.getPane().getManager().setSelectedItems(data);
74
75             sourceView.updateSort();
76             destView.updateSort();
77
78             sourceView.update();
79             destView.update();
80         };
81       };
82
83
84
85
86
87       var sourceView = new qx.ui.listview.ListView(ld, lc1);
88
89       sourceView.setBorder(qx.renderer.border.BorderPresets.getInstance().shadow);
90       sourceView.setBackgroundColor("white");
91       sourceView.setWidth(600);
92       sourceView.setHeight(250);
93       sourceView.setLocation(20, 48);
94
95       sourceView.getPane().getManager().setDragSelection(false);
96       sourceView.getPane().addEventListener("dragstart", handleDrag);
97
98       qx.ui.core.ClientDocument.getInstance().add(sourceView);
99
100
101
102
103       var destView = new qx.ui.listview.ListView([], lc2);
104
105       destView.setBorder(qx.renderer.border.BorderPresets.getInstance().shadow);
106       destView.setBackgroundColor("white");
107       destView.setWidth(600);
108       destView.setHeight(250);
109       destView.setLocation(20, 318);
110
111       destView.getPane().getManager().setDragSelection(false);
112       destView.getPane().setDropDataTypes(["qx.ui.listview.ListViewEntries"]);
113       destView.getPane().addEventListener("dragdrop", handleDrop);
114
115       qx.ui.core.ClientDocument.getInstance().add(destView);
116     });
117   </script>
118 </body>
119 </html>