use of com.jsql.view.swing.tree.model.NodeModelDatabase in project jsql-injection by ron190.
the class AddDatabases 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();
// First node in tree
DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot();
// Loop into the list of databases
for (Database database : this.databases) {
// Create a node model with the database element
AbstractNodeModel newTreeNodeModel = new NodeModelDatabase(database);
// Create the node
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(newTreeNodeModel);
// Save the node
MediatorGui.frame().getTreeNodeModels().put(database, newNode);
// Add the node to the tree
root.add(newNode);
}
// Refresh the tree
treeModel.reload(root);
// Open the root node
MediatorGui.treeDatabase().expandPath(new TreePath(root.getPath()));
MediatorGui.treeDatabase().setRootVisible(false);
}
Aggregations