3 * (C) 2006 by Simo Sorce
12 qx.OO.defineClass("swat.module.ldbbrowse.LdifViewer", qx.ui.embed.HtmlEmbed,
15 qx.ui.embed.HtmlEmbed.call(this, "");
17 this.setStyleProperty("whiteSpace", "nowrap");
18 this.setStyleProperty("textOverflow", "ellipsis");
20 this.setOverflow("auto");
21 this.setSelectable(true);
26 qx.OO.addProperty({ name : "innerText", type : "string" });
28 qx.Proto._update = function() {
29 this.setHtml("<pre>" + this.innerText + "</pre>");
33 * Reset the ldif contents and return to an empty page
35 qx.Proto.reset = function() {
41 * Add a comment to the ldif output
43 * @param aText {String}
44 * A string to show up as an ldif Comment
46 qx.Proto.appendComment = function(aText) {
47 this.innerText = this.innerText + "# " + a Text + "\n\n";
52 * Append an object to be shown
55 * An Object returned by an ldb search
57 qx.Proto.appendObject = function(o) {
59 // First print the Object name as comment
60 // TODO: Prettify it later
61 var ldifRecord = "# " + o["dn"] + "\n";
64 ldifRecord = ldifRecord + "dn: " + o["dn"] + "\n";
66 // Now the attributes;
70 // If it's multi-valued (type is an array)...
71 if (typeof(o[field]) == "object")
73 // ... then add each value with same name
75 for (var i = 0; i < a.length; i++)
77 ldifRecord = ldifRecord + field + ": " + a[i] + "\n";
82 ldifRecord = ldifRecord + field + ": " + o[field] + "\n";
86 // Terminate the record with an empty line
87 ldifRecord = ldifRecord + "\n";
89 this.innerText = this.innerText + ldifRecord;