|
|
@@ -766,6 +766,9 @@ SQL.Table.prototype.redraw = function() {
|
|
|
|
this.dom.mini.style.left = Math.round(x)+"px";
|
|
|
|
this.dom.mini.style.left = Math.round(x)+"px";
|
|
|
|
this.dom.mini.style.top = Math.round(y)+"px";
|
|
|
|
this.dom.mini.style.top = Math.round(y)+"px";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.width = this.dom.container.offsetWidth;
|
|
|
|
|
|
|
|
this.height = this.dom.container.offsetHeight;
|
|
|
|
|
|
|
|
|
|
|
|
var rs = this.getRelations();
|
|
|
|
var rs = this.getRelations();
|
|
|
|
for (var i=0;i<rs.length;i++) { rs[i].redraw(); }
|
|
|
|
for (var i=0;i<rs.length;i++) { rs[i].redraw(); }
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -795,6 +798,7 @@ SQL.Table.prototype.snap = function() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SQL.Table.prototype.down = function(e) { /* mousedown - start drag */
|
|
|
|
SQL.Table.prototype.down = function(e) { /* mousedown - start drag */
|
|
|
|
|
|
|
|
OZ.Event.stop(e);
|
|
|
|
OZ.Event.prevent(e);
|
|
|
|
OZ.Event.prevent(e);
|
|
|
|
/* a non-shift click within a selection preserves the selection */
|
|
|
|
/* a non-shift click within a selection preserves the selection */
|
|
|
|
if (e.shiftKey || ! this.selected) {
|
|
|
|
if (e.shiftKey || ! this.selected) {
|
|
|
@@ -1002,6 +1006,56 @@ SQL.Key.prototype.fromXML = function(node) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* --------------------- rubberband -------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SQL.Rubberband = OZ.Class().extend(SQL.Visual);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SQL.Rubberband.prototype.init = function(owner) {
|
|
|
|
|
|
|
|
this.owner = owner;
|
|
|
|
|
|
|
|
SQL.Visual.prototype.init.apply(this);
|
|
|
|
|
|
|
|
this.dom.container = this.dom.content = OZ.$("rubberband");
|
|
|
|
|
|
|
|
OZ.Event.add("area", "mousedown", this.bind(this.down));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SQL.Rubberband.prototype.down = function(e) {
|
|
|
|
|
|
|
|
OZ.Event.prevent(e);
|
|
|
|
|
|
|
|
var scroll = OZ.DOM.scroll();
|
|
|
|
|
|
|
|
this.x = this.x0 = e.clientX + scroll[0];
|
|
|
|
|
|
|
|
this.y = this.y0 = e.clientY + scroll[1];
|
|
|
|
|
|
|
|
this.width = 0;
|
|
|
|
|
|
|
|
this.height = 0;
|
|
|
|
|
|
|
|
this.redraw();
|
|
|
|
|
|
|
|
this.documentMove = OZ.Event.add(document, "mousemove", this.bind(this.move));
|
|
|
|
|
|
|
|
this.documentUp = OZ.Event.add(document, "mouseup", this.bind(this.up));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SQL.Rubberband.prototype.move = function(e) {
|
|
|
|
|
|
|
|
var scroll = OZ.DOM.scroll();
|
|
|
|
|
|
|
|
var x = e.clientX + scroll[0];
|
|
|
|
|
|
|
|
var y = e.clientY + scroll[1];
|
|
|
|
|
|
|
|
this.width = Math.abs(x-this.x0);
|
|
|
|
|
|
|
|
this.height = Math.abs(y-this.y0);
|
|
|
|
|
|
|
|
if (x<this.x0) { this.x = x; } else { this.x = this.x0; }
|
|
|
|
|
|
|
|
if (y<this.y0) { this.y = y; } else { this.y = this.y0; }
|
|
|
|
|
|
|
|
this.redraw();
|
|
|
|
|
|
|
|
this.dom.container.style.visibility = "visible";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SQL.Rubberband.prototype.up = function(e) {
|
|
|
|
|
|
|
|
OZ.Event.prevent(e);
|
|
|
|
|
|
|
|
this.dom.container.style.visibility = "hidden";
|
|
|
|
|
|
|
|
OZ.Event.remove(this.documentMove);
|
|
|
|
|
|
|
|
OZ.Event.remove(this.documentUp);
|
|
|
|
|
|
|
|
this.owner.tableManager.selectRect(this.x, this.y, this.width, this.height);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SQL.Rubberband.prototype.redraw = function() {
|
|
|
|
|
|
|
|
this.dom.container.style.left = this.x+"px";
|
|
|
|
|
|
|
|
this.dom.container.style.top = this.y+"px";
|
|
|
|
|
|
|
|
this.dom.container.style.width = this.width+"px";
|
|
|
|
|
|
|
|
this.dom.container.style.height = this.height+"px";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* --------------------- minimap ------------ */
|
|
|
|
/* --------------------- minimap ------------ */
|
|
|
|
|
|
|
|
|
|
|
|
SQL.Map = OZ.Class().extend(SQL.Visual);
|
|
|
|
SQL.Map = OZ.Class().extend(SQL.Visual);
|
|
|
@@ -1395,7 +1449,10 @@ SQL.TableManager.prototype.select = function(table, multi) { /* activate table *
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.selection = [];
|
|
|
|
this.selection = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.processSelection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SQL.TableManager.prototype.processSelection = function() {
|
|
|
|
var tables = this.owner.tables;
|
|
|
|
var tables = this.owner.tables;
|
|
|
|
for (var i=0;i<tables.length;i++) {
|
|
|
|
for (var i=0;i<tables.length;i++) {
|
|
|
|
tables[i].deselect();
|
|
|
|
tables[i].deselect();
|
|
|
@@ -1424,6 +1481,24 @@ SQL.TableManager.prototype.select = function(table, multi) { /* activate table *
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SQL.TableManager.prototype.selectRect = function(x,y,width,height) { /* select all tables intersecting a rectangle */
|
|
|
|
|
|
|
|
this.selection = [];
|
|
|
|
|
|
|
|
var tables = this.owner.tables;
|
|
|
|
|
|
|
|
var x1 = x+width;
|
|
|
|
|
|
|
|
var y1 = y+height;
|
|
|
|
|
|
|
|
for (var i=0;i<tables.length;i++) {
|
|
|
|
|
|
|
|
var t = tables[i];
|
|
|
|
|
|
|
|
var tx = t.x;
|
|
|
|
|
|
|
|
var tx1 = t.x+t.width;
|
|
|
|
|
|
|
|
var ty = t.y;
|
|
|
|
|
|
|
|
var ty1 = t.y+t.height;
|
|
|
|
|
|
|
|
if (((tx>=x && tx<x1) || (tx1>=x && tx1<x1) || (tx<x && tx1>x1)) &&
|
|
|
|
|
|
|
|
((ty>=y && ty<y1) || (ty1>=y && ty1<y1) || (ty<y && ty1>y1)))
|
|
|
|
|
|
|
|
{ this.selection.push(t); }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.processSelection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SQL.TableManager.prototype.click = function(e) { /* finish adding new table */
|
|
|
|
SQL.TableManager.prototype.click = function(e) { /* finish adding new table */
|
|
|
|
var newtable = false;
|
|
|
|
var newtable = false;
|
|
|
|
if (this.adding) {
|
|
|
|
if (this.adding) {
|
|
|
@@ -2147,6 +2222,7 @@ SQL.Designer.prototype.dbResponse = function(xmlDoc) {
|
|
|
|
|
|
|
|
|
|
|
|
SQL.Designer.prototype.init2 = function() { /* secondary init, after locale & datatypes were retrieved */
|
|
|
|
SQL.Designer.prototype.init2 = function() { /* secondary init, after locale & datatypes were retrieved */
|
|
|
|
this.map = new SQL.Map(this);
|
|
|
|
this.map = new SQL.Map(this);
|
|
|
|
|
|
|
|
this.rubberband = new SQL.Rubberband(this);
|
|
|
|
this.tableManager = new SQL.TableManager(this);
|
|
|
|
this.tableManager = new SQL.TableManager(this);
|
|
|
|
this.rowManager = new SQL.RowManager(this);
|
|
|
|
this.rowManager = new SQL.RowManager(this);
|
|
|
|
this.keyManager = new SQL.KeyManager(this);
|
|
|
|
this.keyManager = new SQL.KeyManager(this);
|
|
|
|