use of com.jsql.view.swing.tree.model.NodeModelColumn in project jsql-injection by ron190.
the class AddColumns 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 table to update
DefaultMutableTreeNode tableNode = null;
// Loop into the list of columns
for (Column column : this.columns) {
// Create a node model with the column element
AbstractNodeModel newTreeNodeModel = new NodeModelColumn(column);
// Create the node
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(newTreeNodeModel);
// Get the parent table
tableNode = MediatorGui.frame().getTreeNodeModels().get(column.getParent());
// Fix #1805 : NullPointerException on tableNode.getChildCount()
if (tableNode != null) {
// Add the column to the table
treeModel.insertNodeInto(newNode, tableNode, tableNode.getChildCount());
}
}
if (tableNode != null) {
// Open the table node
MediatorGui.treeDatabase().expandPath(new TreePath(tableNode.getPath()));
// The table has just been search (avoid double check)
((AbstractNodeModel) tableNode.getUserObject()).setLoaded(true);
}
}
Aggregations