r20924: Change the way searches are performed, also change a bit the layouts
[Samba/bb.git] / webapps / swat / source / class / swat / module / ldbbrowse / ldifViewer.js
blob61f04bd3e198a69a409b058c6c0b5abe6750b50b
1 /*                                                                                                                    
2  * Copyright::                                                                                                         
3  *   (C) 2006 by Simo Sorce
4  * 
5  * License: 
6  *   GPL v2 or later
7  */
9 /**
10  * Swat LDB Browser class graphical user interface
11  */
13 qx.OO.defineClass("swat.module.ldbbrowse.ldifViewer", qx.ui.embed.HtmlEmbed,
14 function()
16   qx.ui.embed.HtmlEmbed.call(this, "");
18   this.setStyleProperty("whiteSpace", "nowrap");
19   this.setStyleProperty("textOverflow", "ellipsis");
21   this.setOverflow("auto");
22   this.setSelectable(true);
24   this.innerText = "";
25 });
27 //qx.OO.changeProperty({ name : "appearance", type : "string", defaultValue : "???" });
29 qx.OO.addProperty({ name : "innerText", type : "string" });
31 swat.module.ldbbrowse.ldifViewer.empty = {
32   html : "",
33   innerText : ""
36 qx.Proto.reset = function() {
37   this.innerText = "";
38   this.setHtml("");
41 qx.Proto._update = function() {
42   this.setHtml("<pre>" + this.innerText + "</pre>");
45 qx.Proto.appendComment = function(aText) {
46   this.innerText = this.innerText + "# " + a Text + "\n\n";
47   this._update();
50 qx.Proto.appendObject = function(o) {
52   // First print the Object name as comment
53   // TODO: Prettify it later
54   var ldifRecord = "# " + o["dn"] + "\n";
56   // Now the dn
57   ldifRecord = ldifRecord + "dn: " + o["dn"] + "\n";
59   // Now the attributes;
60   for (var field in o)
61   {
63     // If it's multi-valued (type is an array)...
64     if (typeof(o[field]) == "object")
65     {
66       // ... then add each value with same name
67       var a = o[field];
68       for (var i = 0; i < a.length; i++)
69       {
70         ldifRecord = ldifRecord + field + ": " + a[i] + "\n";
71       }
72     }
73     else    // single-valued
74     {
75       ldifRecord = ldifRecord + field + ": " + o[field] + "\n";
76     }
77   }
79   // Terminate the record with an empty line
80   ldifRecord = ldifRecord + "\n";
82   this.innerText = this.innerText + ldifRecord;
83   this._update();