From dd86bb95effcb1df10e31852097fb601fee0aa74 Mon Sep 17 00:00:00 2001 From: "ondrej.zara" Date: Sat, 14 Nov 2009 14:55:14 +0000 Subject: [PATCH] #32 multiple table selection --HG-- extra : convert_revision : svn%3Ab267cdba-c1da-11dd-874b-8bacd04a0a74/trunk%4063 --- js/wwwsqldesigner.js | 90 +++++++++++++++++++++++++++++++------------- locale/cs.xml | 1 + locale/de.xml | 1 + locale/el.xml | 1 + locale/en.xml | 1 + locale/eo.xml | 1 + locale/es.xml | 1 + locale/fr.xml | 1 + locale/hu.xml | 1 + locale/pl.xml | 1 + locale/pt_BR.xml | 1 + locale/ru.xml | 1 + 12 files changed, 74 insertions(+), 27 deletions(-) diff --git a/js/wwwsqldesigner.js b/js/wwwsqldesigner.js index cd83207..1d8a04b 100644 --- a/js/wwwsqldesigner.js +++ b/js/wwwsqldesigner.js @@ -796,11 +796,21 @@ SQL.Table.prototype.snap = function() { SQL.Table.prototype.down = function(e) { /* mousedown - start drag */ OZ.Event.prevent(e); - this.owner.tableManager.select(this); + /* a non-shift click within a selection preserves the selection */ + if (e.shiftKey || ! this.selected) { + this.owner.tableManager.select(this, e.shiftKey); + } - SQL.Table.active = this; - SQL.Table.x = this.x - e.clientX; /* position relative to mouse cursor */ - SQL.Table.y = this.y - e.clientY; + var t = SQL.Table; + t.active = this.owner.tableManager.selection; + var n = t.active.length; + t.x = new Array(n); + t.y = new Array(n); + for (i in SQL.Table.active) { + /* position relative to mouse cursor */ + t.x[i] = t.active[i].x - e.clientX; + t.y[i] = t.active[i].y - e.clientY; + } if (this.owner.getOption("hide")) { this.hideRelations(); } } @@ -889,12 +899,13 @@ SQL.Table.prototype.getComment = function() { SQL.Table.move = function(e) { /* mousemove */ var t = SQL.Table; - var d = SQL.Designer; if (!t.active) { return; } SQL.Designer.removeSelection(); - var x = t.x + e.clientX; - var y = t.y + e.clientY; - t.active.moveTo(x, y); + for (var i in t.active) { + var x = t.x[i] + e.clientX; + var y = t.y[i] + e.clientY; + t.active[i].moveTo(x,y); + } } SQL.Table.up = function(e) { @@ -1323,7 +1334,7 @@ SQL.TableManager.prototype.init = function(owner) { name:OZ.$("tablename"), comment:OZ.$("tablecomment") }; - this.selected = null; + this.selection = []; this.adding = false; var ids = ["addtable","removetable","aligntables","cleartables","addrow","edittable","tablekeys"]; @@ -1360,32 +1371,54 @@ SQL.TableManager.prototype.init = function(owner) { } SQL.TableManager.prototype.addRow = function(e) { - var newrow = this.selected.addRow(_("newrow")); + var newrow = this.selection[0].addRow(_("newrow")); this.owner.rowManager.select(newrow); newrow.expand(); } -SQL.TableManager.prototype.select = function(table) { /* activate table */ - if (this.selected === table) { return; } - this.selected = table; +SQL.TableManager.prototype.select = function(table, multi) { /* activate table */ + if (table) { + if (multi) { + var i = this.selection.indexOf(table); + if (i < 0) { + this.selection.push(table); + } else { + this.selection.splice(i, 1); + } + } else { + if (this.selection[0] === table) { return; } + this.selection = [table]; + } + } else { + this.selection = []; + } var tables = this.owner.tables; for (var i=0;i 1) { this.dom.removetable.value = _("removetables"); } + } else { + this.dom.removetable.disabled = true; + this.dom.removetable.value = _("removetable"); + } + for (var t in this.selection) { + t = this.selection[t]; + t.owner.raise(t); + t.select(); + } } SQL.TableManager.prototype.click = function(e) { /* finish adding new table */ @@ -1404,7 +1437,7 @@ SQL.TableManager.prototype.click = function(e) { /* finish adding new table */ } this.select(newtable); this.owner.rowManager.select(false); - if (this.selected) { this.edit(e); } + if (this.selection.length == 1) { this.edit(e); } } SQL.TableManager.prototype.preAdd = function(e) { /* click add new table */ @@ -1428,18 +1461,21 @@ SQL.TableManager.prototype.clear = function(e) { /* remove all tables */ } SQL.TableManager.prototype.remove = function(e) { - var result = confirm(_("confirmtable")+" '"+this.selected.getTitle()+"' ?"); + var titles = this.selection.slice(0); + for (var i in titles) { titles[i] = "'"+titles[i].getTitle()+"'"; } + var result = confirm(_("confirmtable")+" "+titles.join(", ")+"?"); if (!result) { return; } - this.owner.removeTable(this.selected); + var sel = this.selection.slice(0); + for (var i in sel) { this.owner.removeTable(sel[i]); } } SQL.TableManager.prototype.edit = function(e) { this.owner.window.open(_("edittable"), this.dom.container, this.save); - var title = this.selected.getTitle(); + var title = this.selection[0].getTitle(); this.dom.name.value = title; try { /* throws in ie6 */ - this.dom.comment.value = this.selected.getComment(); + this.dom.comment.value = this.selection[0].getComment(); } catch(e) {} /* pre-select table name */ @@ -1454,16 +1490,16 @@ SQL.TableManager.prototype.edit = function(e) { } SQL.TableManager.prototype.keys = function(e) { /* open keys dialog */ - this.owner.keyManager.open(this.selected); + this.owner.keyManager.open(this.selection[0]); } SQL.TableManager.prototype.save = function() { - this.selected.setTitle(this.dom.name.value); - this.selected.setComment(this.dom.comment.value); + this.selection[0].setTitle(this.dom.name.value); + this.selection[0].setComment(this.dom.comment.value); } SQL.TableManager.prototype.press = function(e) { - if (!this.selected) { return; } + if (! this.selection.length) { return; } /* do not process keypresses if a row is selected */ if (this.owner.rowManager.selected) { return; } switch (e.keyCode) { diff --git a/locale/cs.xml b/locale/cs.xml index 6c8558e..138ced2 100644 --- a/locale/cs.xml +++ b/locale/cs.xml @@ -4,6 +4,7 @@ Přidat tabulku Upravit tabulku Smazat tabulku + Smazat tabulky Srovnat tabulky Zrušit tabulky Opravdu zrušit všechny tabulky diff --git a/locale/de.xml b/locale/de.xml index a5f40ef..a865fe2 100644 --- a/locale/de.xml +++ b/locale/de.xml @@ -4,6 +4,7 @@ Tabelle hinzufügen Tabelle bearbeiten Tabelle entfernen + Tabellen entfernen Tabellen ausrichten Tabellen löschen Wirklich alle Tabellen löschen diff --git a/locale/el.xml b/locale/el.xml index 176b7ba..f157dfd 100644 --- a/locale/el.xml +++ b/locale/el.xml @@ -4,6 +4,7 @@ Προσθήκη πίνακα Επεξεργασία πίνακα Διαγραφή πίνακα + Διαγραφή πινάκων Στοίχιση Πινάκων Καθαρισμός πινάκων Διαγραφή όλων των πινάκων diff --git a/locale/en.xml b/locale/en.xml index 7b77772..e8aed8a 100644 --- a/locale/en.xml +++ b/locale/en.xml @@ -4,6 +4,7 @@ Add table Edit table Remove table + Remove tables Align tables Clear tables Really delete all tables diff --git a/locale/eo.xml b/locale/eo.xml index 8e033aa..9aa41d2 100644 --- a/locale/eo.xml +++ b/locale/eo.xml @@ -4,6 +4,7 @@ Aldoni la tabelon Modifi la tabelon Forigi la tabelon + Forigi la tabelojn Ĝisrandigi la tabelojn Vakigi la tabelon Ja forigi ĉiujn tabelojn diff --git a/locale/es.xml b/locale/es.xml index 0220785..c895d59 100644 --- a/locale/es.xml +++ b/locale/es.xml @@ -4,6 +4,7 @@ Agregar tabla Editar tabla Remover tabla + Remover tablas Alinear tablas Limpiar tablas Realmente borrar todas las tablas diff --git a/locale/fr.xml b/locale/fr.xml index 5c30cd3..00e47aa 100644 --- a/locale/fr.xml +++ b/locale/fr.xml @@ -4,6 +4,7 @@ Ajouter une table Éditer la table Supprimer la table + Supprimer les tables Aligner les tables Supprimer les tables Vraiment supprimer toutes les tables diff --git a/locale/hu.xml b/locale/hu.xml index d410e5b..c6ca773 100644 --- a/locale/hu.xml +++ b/locale/hu.xml @@ -4,6 +4,7 @@ Tábla létrehozása Tábla módosítása Tábla törlése + Táblak törlése Táblák rendezése Táblák törlése Valóban töröljem az összes táblát diff --git a/locale/pl.xml b/locale/pl.xml index 71541ab..72b8fc2 100644 --- a/locale/pl.xml +++ b/locale/pl.xml @@ -4,6 +4,7 @@ Dodaj tabelę Edytuj tabelę Usuń tabelę + Usuń tabele Wyrównaj tabele Wyczyść tabele Czy na pewno usunąć wszystkie tabele diff --git a/locale/pt_BR.xml b/locale/pt_BR.xml index 67dac16..1410e45 100644 --- a/locale/pt_BR.xml +++ b/locale/pt_BR.xml @@ -4,6 +4,7 @@ Adicionar tabela Editar tabela Remover tabela + Remover tabelas Alinhar tabelas Limpar tabelas Realmente excluir todas as tabelas diff --git a/locale/ru.xml b/locale/ru.xml index 88c0aa5..4248c7a 100644 --- a/locale/ru.xml +++ b/locale/ru.xml @@ -4,6 +4,7 @@ Добавить таблицу Редактировать таблицу Удалить таблицу + Удалить таблицы Выровнять таблицы Очистить таблицы Действительно удалить все таблицы