use of com.jsql.view.swing.tree.model.AbstractNodeModel 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);
}
}
use of com.jsql.view.swing.tree.model.AbstractNodeModel 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);
}
use of com.jsql.view.swing.tree.model.AbstractNodeModel 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);
}
}
use of com.jsql.view.swing.tree.model.AbstractNodeModel in project jsql-injection by ron190.
the class CellEditorNode method showPopup.
/**
* Fix compatibility issue with right click on Linux.
* @param e Mouse event
*/
private void showPopup(MouseEvent e) {
if (e.isPopupTrigger()) {
JTree tree = (JTree) e.getSource();
TreePath path = tree.getPathForLocation(e.getX(), e.getY());
if (path == null) {
return;
}
DefaultMutableTreeNode currentTableNode = (DefaultMutableTreeNode) path.getLastPathComponent();
if (currentTableNode.getUserObject() instanceof AbstractNodeModel) {
AbstractNodeModel currentTableModel = (AbstractNodeModel) currentTableNode.getUserObject();
if (currentTableModel.isPopupDisplayable()) {
currentTableModel.showPopup(currentTableNode, path, e);
}
}
}
}
use of com.jsql.view.swing.tree.model.AbstractNodeModel in project jsql-injection by ron190.
the class StartProgress 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();
DefaultMutableTreeNode node = MediatorGui.frame().getTreeNodeModels().get(this.dataElementDatabase);
// Get the node
AbstractNodeModel progressingTreeNodeModel = (AbstractNodeModel) node.getUserObject();
// Mark the node model as 'display progress bar'
progressingTreeNodeModel.setLoading(true);
// Update the node
treeModel.nodeChanged(node);
}
Aggregations