SQL.Designer = function() { SQL.Designer = this; this.tables = []; this.relations = []; this.title = document.title; SQL.Visual.apply(this); new SQL.Toggle(OZ.$("toggle")); this.dom.container = OZ.$("area"); this.minSize = [ this.dom.container.offsetWidth, this.dom.container.offsetHeight ]; this.width = this.minSize[0]; this.height = this.minSize[1]; this.typeIndex = false; this.fkTypeFor = false; this.vector = this.getOption("vector") && document.createElementNS; if (this.vector) { this.svgNS = "http://www.w3.org/2000/svg"; this.dom.svg = document.createElementNS(this.svgNS, "svg"); this.dom.container.appendChild(this.dom.svg); } this.flag = 2; this.requestLanguage(); this.requestDB(); } SQL.Designer.prototype = Object.create(SQL.Visual.prototype); /* update area size */ SQL.Designer.prototype.sync = function() { var w = this.minSize[0]; var h = this.minSize[0]; for (var i=0;i max) { max = z; } } OZ.$("controls").style.zIndex = max+5; return max; } SQL.Designer.prototype.addTable = function(name, x, y) { var max = this.getMaxZ(); var t = new SQL.Table(this, name, x, y, max+1); this.tables.push(t); this.dom.container.appendChild(t.dom.container); return t; } SQL.Designer.prototype.removeTable = function(t) { this.tableManager.select(false); this.rowManager.select(false); var idx = this.tables.indexOf(t); if (idx == -1) { return; } t.destroy(); this.tables.splice(idx,1); } SQL.Designer.prototype.addRelation = function(row1, row2) { var r = new SQL.Relation(this, row1, row2); this.relations.push(r); return r; } SQL.Designer.prototype.removeRelation = function(r) { var idx = this.relations.indexOf(r); if (idx == -1) { return; } r.destroy(); this.relations.splice(idx,1); } SQL.Designer.prototype.getCookie = function() { var c = document.cookie; var obj = {}; var parts = c.split(";"); for (var i=0;i old) { t.setZ(t.getZ()-1); } } var m = table.dom.mini; m.parentNode.appendChild(m); } SQL.Designer.prototype.clearTables = function() { while (this.tables.length) { this.removeTable(this.tables[0]); } this.setTitle(false); } SQL.Designer.prototype.alignTables = function() { var win = OZ.DOM.win(); var avail = win[0] - OZ.$("bar").offsetWidth; var x = 10; var y = 10; var max = 0; this.tables.sort(function(a,b){ return b.getRelations().length - a.getRelations().length; }); for (var i=0;i avail) { x = 10; y += 10 + max; max = 0; } t.moveTo(x,y); x += 10 + w; if (h > max) { max = h; } } this.sync(); } SQL.Designer.prototype.findNamedTable = function(name) { /* find row specified as table(row) */ for (var i=0;i\n'; xml += '\n'; /* serialize datatypes */ if (window.XMLSerializer) { var s = new XMLSerializer(); xml += s.serializeToString(window.DATATYPES); } else if (window.DATATYPES.xml) { xml += window.DATATYPES.xml; } else { alert(_("errorxml")+': '+e.message); } for (var i=0;i