use of com.jsql.view.swing.tree.model.NodeModelTable in project jsql-injection by ron190.
the class AddTables method execute.
@Override
public void execute() {
if (MediatorGui.treeDatabase() == null) {
LOGGER.error("Unexpected unregistered MediatorGui.treeDatabase() in " + this.getClass());
}
// Tree model, update the tree (refresh, add node, etc)
DefaultTreeModel treeModel = (DefaultTreeModel) MediatorGui.treeDatabase().getModel();
// The database to update
DefaultMutableTreeNode databaseNode = null;
// Loop into the list of tables
for (Table table : this.tables) {
// Create a node model with the table element
AbstractNodeModel newTreeNodeModel = new NodeModelTable(table);
// Create the node
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(newTreeNodeModel);
// Save the node
MediatorGui.frame().getTreeNodeModels().put(table, newNode);
// Get the parent database
databaseNode = MediatorGui.frame().getTreeNodeModels().get(table.getParent());
// Report NullPointerException #1670
if (databaseNode != null) {
// Add the table to the database
treeModel.insertNodeInto(newNode, databaseNode, databaseNode.getChildCount());
} else {
LOGGER.warn("Missing database for table " + table.toString() + ".");
}
}
if (databaseNode != null) {
// Open the database node
MediatorGui.treeDatabase().expandPath(new TreePath(databaseNode.getPath()));
// The database has just been search (avoid double check)
((AbstractNodeModel) databaseNode.getUserObject()).setLoaded(true);
}
}
Aggregations