Skip to content

Commit

Permalink
0003860: SqlExplorer dbfill and dbexport should use the hide tables
Browse files Browse the repository at this point in the history
regex
  • Loading branch information
erilong committed Jan 21, 2019
1 parent 209b26d commit f36f5b7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 17 deletions.
Expand Up @@ -116,18 +116,18 @@ public class DbExportDialog extends ResizableWindow {

private IDatabasePlatform databasePlatform;

public DbExportDialog(IDatabasePlatform databasePlatform, QueryPanel queryPanel) {
this(databasePlatform, new HashSet<Table>(), queryPanel);
public DbExportDialog(IDatabasePlatform databasePlatform, QueryPanel queryPanel, String excludeTablesRegex) {
this(databasePlatform, new HashSet<Table>(), queryPanel, excludeTablesRegex);
}

public DbExportDialog(IDatabasePlatform databasePlatform, Set<Table> 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
Expand Down
Expand Up @@ -94,12 +94,12 @@ public class DbFillDialog extends ResizableWindow {

private IDatabasePlatform databasePlatform;

public DbFillDialog(IDatabasePlatform databasePlatform, QueryPanel queryPanel) {
this(databasePlatform, new HashSet<Table>(0), queryPanel);
public DbFillDialog(IDatabasePlatform databasePlatform, QueryPanel queryPanel, String excludeTablesRegex) {
this(databasePlatform, new HashSet<Table>(0), queryPanel, excludeTablesRegex);
}

public DbFillDialog(IDatabasePlatform databasePlatform, Set<Table> selectedTableSet,
QueryPanel queryPanel) {
QueryPanel queryPanel, String excludeTablesRegex) {
super("Database Fill");
setModal(true);
setHeight(500, Unit.PIXELS);
Expand All @@ -108,7 +108,7 @@ public DbFillDialog(IDatabasePlatform databasePlatform, Set<Table> 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() {
Expand Down
Expand Up @@ -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);
}
});

Expand All @@ -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);
}
});

Expand Down
Expand Up @@ -567,7 +567,8 @@ public void handle(Set<DbTreeNode> nodes) {
public void handle(Set<DbTreeNode> 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);
Expand All @@ -579,7 +580,8 @@ public void handle(Set<DbTreeNode> nodes) {
public void handle(Set<DbTreeNode> 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);
}

}
Expand Down
Expand Up @@ -75,18 +75,20 @@ public class TableSelectionLayout extends VerticalLayout {

private List<String> excludedTables;

private String excludeTablesRegex;

public TableSelectionLayout(IDatabasePlatform databasePlatform,
Set<org.jumpmind.db.model.Table> selectedSet) {
this("Please select from the following tables", databasePlatform, selectedSet, null);
Set<org.jumpmind.db.model.Table> selectedSet, String excludeTablesRegex) {
this("Please select from the following tables", databasePlatform, selectedSet, null, excludeTablesRegex);
}

public TableSelectionLayout(String titleKey, IDatabasePlatform databasePlatform,
Set<org.jumpmind.db.model.Table> selectedSet) {
this(titleKey, databasePlatform, selectedSet, null);
this(titleKey, databasePlatform, selectedSet, null, null);
}

public TableSelectionLayout(String titleKey, IDatabasePlatform databasePlatform,
Set<org.jumpmind.db.model.Table> selectedSet, List<String> excludedTables) {
Set<org.jumpmind.db.model.Table> selectedSet, List<String> excludedTables, String excludeTablesRegex) {
super();
this.setSizeFull();
this.setMargin(true);
Expand All @@ -95,6 +97,7 @@ public TableSelectionLayout(String titleKey, IDatabasePlatform databasePlatform,
this.selectedTablesSet = selectedSet;
this.databasePlatform = databasePlatform;
this.excludedTables = excludedTables;
this.excludeTablesRegex = excludeTablesRegex;

createTableSelectionLayout(titleKey);
}
Expand Down Expand Up @@ -324,8 +327,18 @@ public List<String> getCatalogs() {
}

public List<String> getTables() {
return databasePlatform.getDdlReader().getTableNames((String) catalogSelect.getValue(),
List<String> tableNames = databasePlatform.getDdlReader().getTableNames((String) catalogSelect.getValue(),
(String) schemaSelect.getValue(), new String[] { "TABLE" });
Iterator<String> 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<String> getExcludedTables() {
Expand Down

0 comments on commit f36f5b7

Please sign in to comment.