Skip to content

Commit

Permalink
0004753: Added server-side lazy loading to SQL Explorer tree (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-miller-jumpmind committed Jan 12, 2021
1 parent 1163ba6 commit c5c3823
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Expand Up @@ -88,12 +88,16 @@ public DbTree(IDbProvider databaseProvider, ISettingsProvider settingsProvider)

expandedNodes.add(node);

if (!node.getType().equals(NODE_TYPE_TRIGGER) && !node.hasChildren()) {
loadChildren(node);
}

DbTreeNode firstChild = treeData.getChildren(node).get(0);
if (node.hasChildren() && firstChild.getType().equals(NODE_TYPE_PLACEHOLDER)) {
treeData.removeItem(firstChild);
for (DbTreeNode child : node.getChildren()) {
treeData.addItem(node, child);
if (child.hasChildren()) {
if (!child.getType().equals(NODE_TYPE_TRIGGER)) {
treeData.addItem(child, new DbTreeNode(this, NODE_TYPE_PLACEHOLDER, child));
}
}
Expand Down Expand Up @@ -139,7 +143,6 @@ public void refresh(boolean fullRefresh) {
rootNodes = new LinkedHashSet<DbTreeNode>();
for (IDb database : databases) {
DbTreeNode databaseNode = new DbTreeNode(this, database.getName(), NODE_TYPE_DATABASE, VaadinIcons.DATABASE, null);
loadChildren(databaseNode);
treeData.addItem(null, databaseNode);
treeData.addItem(databaseNode, new DbTreeNode(this, NODE_TYPE_PLACEHOLDER, databaseNode));
rootNodes.add(databaseNode);
Expand Down Expand Up @@ -302,7 +305,6 @@ protected void addTableNodes(IDdlReader reader, DbTreeNode parent,
List<DbTreeNode> nodes = getTableTreeNodes(reader, parent, catalogName, schemaName);
for (DbTreeNode treeNode : nodes) {
parent.getChildren().add(treeNode);
loadChildren(treeNode);
}
}

Expand Down Expand Up @@ -343,7 +345,6 @@ protected void addCatalogNodes(IDdlReader reader, DbTreeNode parent, IDatabasePl
for (String catalog : catalogs) {
DbTreeNode catalogNode = new DbTreeNode(this, catalog, NODE_TYPE_CATALOG, VaadinIcons.BOOK, parent);
parent.getChildren().add(catalogNode);
loadChildren(catalogNode);
}
}

Expand All @@ -355,7 +356,6 @@ protected void addSchemaNodes(IDdlReader reader, DbTreeNode parent, IDatabasePla
for (String schema : schemas) {
DbTreeNode schemaNode = new DbTreeNode(this, schema, NODE_TYPE_SCHEMA, VaadinIcons.BOOK, parent);
parent.getChildren().add(schemaNode);
loadChildren(schemaNode);
}
}

Expand Down
Expand Up @@ -61,6 +61,7 @@ public DbTreeNode(DbTree dbTree, String name, String type, Resource icon,
}

public DbTreeNode(DbTree dbTree, String type, DbTreeNode parent) {
this.name = "<empty>";
this.type = type;
this.parent = parent;
this.dbTree = dbTree;
Expand Down

0 comments on commit c5c3823

Please sign in to comment.