/* --------------------- table row ( = db column) ------------ */ SQL.Row = function(owner, title, data) { this.owner = owner; this.relations = []; this.keys = []; this.selected = false; this.expanded = false; SQL.Visual.apply(this); this.data.type = 0; this.data.size = ""; this.data.def = null; this.data.nll = true; this.data.ai = false; this.data.comment = ""; if (data) { this.update(data); } this.setTitle(title); } SQL.Row.prototype = Object.create(SQL.Visual.prototype); SQL.Row.prototype._build = function() { this.dom.container = OZ.DOM.elm("tbody"); this.dom.content = OZ.DOM.elm("tr"); this.dom.selected = OZ.DOM.elm("div", {className:"selected",innerHTML:"» "}); this.dom.title = OZ.DOM.elm("div", {className:"title"}); var td1 = OZ.DOM.elm("td"); var td2 = OZ.DOM.elm("td", {className:"typehint"}); this.dom.typehint = td2; OZ.DOM.append( [this.dom.container, this.dom.content], [this.dom.content, td1, td2], [td1, this.dom.selected, this.dom.title] ); this.enter = this.enter.bind(this); this.changeComment = this.changeComment.bind(this); OZ.Event.add(this.dom.container, "click",this.click.bind(this)); OZ.Event.add(this.dom.container, "dblclick",this.dblclick.bind(this)); } SQL.Row.prototype.select = function() { if (this.selected) { return; } this.selected = true; this.redraw(); } SQL.Row.prototype.deselect = function() { if (!this.selected) { return; } this.selected = false; this.redraw(); this.collapse(); } SQL.Row.prototype.setTitle = function(t) { var old = this.getTitle(); for (var i=0;i\n'; var elm = this.getDataType(); var t = elm.getAttribute("sql"); if (this.data.size.length) { t += "("+this.data.size+")"; } xml += ""+t+"\n"; if (this.data.def || this.data.def === null) { var q = elm.getAttribute("quote"); var d = this.data.def; if (d === null) { d = "NULL"; } else if (d != "CURRENT_TIMESTAMP") { d = q+d+q; } xml += ""+SQL.escape(d)+""; } for (var i=0;i\n'; } if (this.data.comment) { xml += ""+SQL.escape(this.data.comment)+"\n"; } xml += "\n"; return xml; } SQL.Row.prototype.fromXML = function(node) { var name = node.getAttribute("name"); var obj = { type:0, size:"" }; obj.nll = (node.getAttribute("null") == "1"); obj.ai = (node.getAttribute("autoincrement") == "1"); var cs = node.getElementsByTagName("comment"); if (cs.length && cs[0].firstChild) { obj.comment = cs[0].firstChild.nodeValue; } var d = node.getElementsByTagName("datatype"); if (d.length && d[0].firstChild) { var s = d[0].firstChild.nodeValue; var r = s.match(/^([^\(]+)(\((.*)\))?.*$/); var type = r[1]; if (r[3]) { obj.size = r[3]; } var types = window.DATATYPES.getElementsByTagName("type"); for (var i=0;i 0; } SQL.Row.prototype.enter = function(e) { if (e.keyCode == 13) { this.collapse(); } }