From f36f5b797882ac3029c8d7a9ccec2e78a5192c34 Mon Sep 17 00:00:00 2001 From: Eric Long Date: Mon, 21 Jan 2019 16:15:38 -0500 Subject: [PATCH] 0003860: SqlExplorer dbfill and dbexport should use the hide tables regex --- .../vaadin/ui/sqlexplorer/DbExportDialog.java | 8 +++---- .../vaadin/ui/sqlexplorer/DbFillDialog.java | 8 +++---- .../ui/sqlexplorer/DefaultButtonBar.java | 6 +++-- .../vaadin/ui/sqlexplorer/SqlExplorer.java | 6 +++-- .../ui/sqlexplorer/TableSelectionLayout.java | 23 +++++++++++++++---- 5 files changed, 34 insertions(+), 17 deletions(-) diff --git a/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/DbExportDialog.java b/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/DbExportDialog.java index de75748d68..ff57918883 100644 --- a/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/DbExportDialog.java +++ b/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/DbExportDialog.java @@ -116,18 +116,18 @@ public class DbExportDialog extends ResizableWindow { private IDatabasePlatform databasePlatform; - public DbExportDialog(IDatabasePlatform databasePlatform, QueryPanel queryPanel) { - this(databasePlatform, new HashSet(), queryPanel); + public DbExportDialog(IDatabasePlatform databasePlatform, QueryPanel queryPanel, String excludeTablesRegex) { + this(databasePlatform, new HashSet
(), queryPanel, excludeTablesRegex); } public DbExportDialog(IDatabasePlatform databasePlatform, Set
selectedTableSet, - QueryPanel queryPanel) { + QueryPanel queryPanel, String excludeTablesRegex) { super("Database Export"); this.databasePlatform = databasePlatform; this.queryPanel = queryPanel; - tableSelectionLayout = new TableSelectionLayout(databasePlatform, selectedTableSet) { + tableSelectionLayout = new TableSelectionLayout(databasePlatform, selectedTableSet, excludeTablesRegex) { private static final long serialVersionUID = 1L; @Override diff --git a/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/DbFillDialog.java b/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/DbFillDialog.java index 325fe7c47c..cd6ecc77b6 100644 --- a/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/DbFillDialog.java +++ b/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/DbFillDialog.java @@ -94,12 +94,12 @@ public class DbFillDialog extends ResizableWindow { private IDatabasePlatform databasePlatform; - public DbFillDialog(IDatabasePlatform databasePlatform, QueryPanel queryPanel) { - this(databasePlatform, new HashSet
(0), queryPanel); + public DbFillDialog(IDatabasePlatform databasePlatform, QueryPanel queryPanel, String excludeTablesRegex) { + this(databasePlatform, new HashSet
(0), queryPanel, excludeTablesRegex); } public DbFillDialog(IDatabasePlatform databasePlatform, Set
selectedTableSet, - QueryPanel queryPanel) { + QueryPanel queryPanel, String excludeTablesRegex) { super("Database Fill"); setModal(true); setHeight(500, Unit.PIXELS); @@ -108,7 +108,7 @@ public DbFillDialog(IDatabasePlatform databasePlatform, Set
selectedTable this.databasePlatform = databasePlatform; this.queryPanel = queryPanel; - tableSelectionLayout = new TableSelectionLayout(databasePlatform, selectedTableSet) { + tableSelectionLayout = new TableSelectionLayout(databasePlatform, selectedTableSet, excludeTablesRegex) { private static final long serialVersionUID = 1L; protected void selectionChanged() { diff --git a/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/DefaultButtonBar.java b/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/DefaultButtonBar.java index c9894e7e66..7301711a4e 100644 --- a/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/DefaultButtonBar.java +++ b/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/DefaultButtonBar.java @@ -166,7 +166,8 @@ public void menuSelected(MenuItem selectedItem) { @Override public void menuSelected(MenuItem selectedItem) { - new DbExportDialog(db.getPlatform(), queryPanel).showAtSize(0.6); + String excludeTablesRegex = settingsProvider.get().getProperties().get(Settings.SQL_EXPLORER_EXCLUDE_TABLES_REGEX); + new DbExportDialog(db.getPlatform(), queryPanel, excludeTablesRegex).showAtSize(0.6); } }); @@ -176,7 +177,8 @@ public void menuSelected(MenuItem selectedItem) { @Override public void menuSelected(MenuItem selectedItem) { - new DbFillDialog(db.getPlatform(), queryPanel).showAtSize(0.6); + String excludeTablesRegex = settingsProvider.get().getProperties().get(Settings.SQL_EXPLORER_EXCLUDE_TABLES_REGEX); + new DbFillDialog(db.getPlatform(), queryPanel, excludeTablesRegex).showAtSize(0.6); } }); diff --git a/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/SqlExplorer.java b/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/SqlExplorer.java index 2b09ccaa41..b1b0b55f18 100644 --- a/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/SqlExplorer.java +++ b/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/SqlExplorer.java @@ -567,7 +567,8 @@ public void handle(Set nodes) { public void handle(Set nodes) { if (nodes.size() > 0) { IDb db = dbTree.getDbForNode(nodes.iterator().next()); - new DbExportDialog(db.getPlatform(), dbTree.getSelectedTables(), findQueryPanelForDb(db)).showAtSize(0.6); + String excludeTablesRegex = settingsProvider.get().getProperties().get(Settings.SQL_EXPLORER_EXCLUDE_TABLES_REGEX); + new DbExportDialog(db.getPlatform(), dbTree.getSelectedTables(), findQueryPanelForDb(db), excludeTablesRegex).showAtSize(0.6); } } }, DbTree.NODE_TYPE_TABLE, DbTree.NODE_TYPE_TRIGGER); @@ -579,7 +580,8 @@ public void handle(Set nodes) { public void handle(Set nodes) { if (nodes.size() > 0) { IDb db = dbTree.getDbForNode(nodes.iterator().next()); - new DbFillDialog(db.getPlatform(), dbTree.getSelectedTables(), findQueryPanelForDb(db)).showAtSize(0.6); + String excludeTablesRegex = settingsProvider.get().getProperties().get(Settings.SQL_EXPLORER_EXCLUDE_TABLES_REGEX); + new DbFillDialog(db.getPlatform(), dbTree.getSelectedTables(), findQueryPanelForDb(db), excludeTablesRegex).showAtSize(0.6); } } diff --git a/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/TableSelectionLayout.java b/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/TableSelectionLayout.java index 4f55ab0b0c..48d1232a4e 100644 --- a/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/TableSelectionLayout.java +++ b/symmetric-sqlexplorer/src/main/java/org/jumpmind/vaadin/ui/sqlexplorer/TableSelectionLayout.java @@ -75,18 +75,20 @@ public class TableSelectionLayout extends VerticalLayout { private List excludedTables; + private String excludeTablesRegex; + public TableSelectionLayout(IDatabasePlatform databasePlatform, - Set selectedSet) { - this("Please select from the following tables", databasePlatform, selectedSet, null); + Set selectedSet, String excludeTablesRegex) { + this("Please select from the following tables", databasePlatform, selectedSet, null, excludeTablesRegex); } public TableSelectionLayout(String titleKey, IDatabasePlatform databasePlatform, Set selectedSet) { - this(titleKey, databasePlatform, selectedSet, null); + this(titleKey, databasePlatform, selectedSet, null, null); } public TableSelectionLayout(String titleKey, IDatabasePlatform databasePlatform, - Set selectedSet, List excludedTables) { + Set selectedSet, List excludedTables, String excludeTablesRegex) { super(); this.setSizeFull(); this.setMargin(true); @@ -95,6 +97,7 @@ public TableSelectionLayout(String titleKey, IDatabasePlatform databasePlatform, this.selectedTablesSet = selectedSet; this.databasePlatform = databasePlatform; this.excludedTables = excludedTables; + this.excludeTablesRegex = excludeTablesRegex; createTableSelectionLayout(titleKey); } @@ -324,8 +327,18 @@ public List getCatalogs() { } public List getTables() { - return databasePlatform.getDdlReader().getTableNames((String) catalogSelect.getValue(), + List tableNames = databasePlatform.getDdlReader().getTableNames((String) catalogSelect.getValue(), (String) schemaSelect.getValue(), new String[] { "TABLE" }); + Iterator iter = tableNames.iterator(); + while (iter.hasNext()) { + String tableName = iter.next(); + if (tableName.matches(excludeTablesRegex) + || tableName.toUpperCase().matches(excludeTablesRegex) + || tableName.toLowerCase().matches(excludeTablesRegex)) { + iter.remove(); + } + } + return tableNames; } public List getExcludedTables() {