Search in sources :

Example 6 with AbstractNodeModel

use of com.jsql.view.swing.tree.model.AbstractNodeModel in project jsql-injection by ron190.

the class UpdateProgress method execute.

@Override
public void execute() {
    if (MediatorGui.frame() == null) {
        LOGGER.error("Unexpected unregistered MediatorGui.frame() in " + this.getClass());
    }
    DefaultMutableTreeNode node = MediatorGui.frame().getTreeNodeModels().get(this.dataElementDatabase);
    // Fix Report #1368: ignore if no element database
    if (node != null) {
        // Get the node
        AbstractNodeModel progressingTreeNodeModel = (AbstractNodeModel) node.getUserObject();
        // Update the progress value of the model
        progressingTreeNodeModel.setIndexProgress(this.dataCount);
        // Tree model, update the tree (refresh, add node, etc)
        DefaultTreeModel treeModel = (DefaultTreeModel) MediatorGui.treeDatabase().getModel();
        // Update the node
        treeModel.nodeChanged(node);
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AbstractNodeModel(com.jsql.view.swing.tree.model.AbstractNodeModel) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 7 with AbstractNodeModel

use of com.jsql.view.swing.tree.model.AbstractNodeModel in project jsql-injection by ron190.

the class EndIndeterminateProgress 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 nodeModel = MediatorGui.frame().getTreeNodeModels().get(this.dataElementDatabase);
    // Fix #1806 : NullPointerException on ...odels().get(dataElementDatabase).getUserObject()
    if (nodeModel != null) {
        // Get the node
        AbstractNodeModel progressingTreeNodeModel = (AbstractNodeModel) nodeModel.getUserObject();
        // Mark the node model as 'no loading bar'
        progressingTreeNodeModel.setProgressing(false);
        // Mark the node model as 'no stop/pause/resume button'
        progressingTreeNodeModel.setRunning(false);
        // Update the node
        treeModel.nodeChanged(nodeModel);
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AbstractNodeModel(com.jsql.view.swing.tree.model.AbstractNodeModel) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 8 with AbstractNodeModel

use of com.jsql.view.swing.tree.model.AbstractNodeModel in project jsql-injection by ron190.

the class EndProgress 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();
    // Report NullPointerException #1671
    DefaultMutableTreeNode node = MediatorGui.frame().getTreeNodeModels().get(this.dataElementDatabase);
    if (node != null) {
        // Get the node
        AbstractNodeModel progressingTreeNodeModel = (AbstractNodeModel) node.getUserObject();
        // Mark the node model as 'no progress bar'
        progressingTreeNodeModel.setLoading(false);
        // Mark the node model as 'no stop/pause/resume button'
        progressingTreeNodeModel.setRunning(false);
        // Reset the progress value of the model
        progressingTreeNodeModel.setIndexProgress(0);
        // Update the node and progressbar
        treeModel.nodeChanged(node);
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AbstractNodeModel(com.jsql.view.swing.tree.model.AbstractNodeModel) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 9 with AbstractNodeModel

use of com.jsql.view.swing.tree.model.AbstractNodeModel in project jsql-injection by ron190.

the class StartIndeterminateProgress 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);
    // Fix #45540: NullPointerException on node.getUserObject()
    if (node != null) {
        // Get the node
        AbstractNodeModel progressingTreeNodeModel = (AbstractNodeModel) node.getUserObject();
        // Mark the node model as 'loading'
        progressingTreeNodeModel.setProgressing(true);
        // Update the node
        treeModel.nodeChanged(node);
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AbstractNodeModel(com.jsql.view.swing.tree.model.AbstractNodeModel) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 10 with AbstractNodeModel

use of com.jsql.view.swing.tree.model.AbstractNodeModel in project jsql-injection by ron190.

the class CreateValuesTab method execute.

@Override
public void execute() {
    if (MediatorGui.frame() == null) {
        LOGGER.error("Unexpected unregistered MediatorGui.frame() in " + this.getClass());
    }
    // Report NullPointerException #1683
    DefaultMutableTreeNode node = MediatorGui.frame().getTreeNodeModels().get(this.table);
    if (node != null) {
        // Get the node
        AbstractNodeModel progressingTreeNodeModel = (AbstractNodeModel) node.getUserObject();
        // Update the progress value of the model, end the progress
        progressingTreeNodeModel.setIndexProgress(this.table.getChildCount());
        // Mark the node model as 'no stop/pause/resume button'
        progressingTreeNodeModel.setRunning(false);
        // Create a new table to display the values
        PanelTable newTableJPanel = new PanelTable(this.data, this.columnNames);
        // Create a new tab: add header and table
        MediatorGui.tabResults().addTab(StringUtil.detectUtf8(this.table.toString()), newTableJPanel);
        newTableJPanel.setComponentOrientation(ComponentOrientation.getOrientation(I18n.getLocaleDefault()));
        // Focus on the new tab
        MediatorGui.tabResults().setSelectedComponent(newTableJPanel);
        // Create a custom tab header with close button
        TabHeader header = new TabHeader(StringUtil.detectUtf8Html(this.table.toString()));
        MediatorGui.tabResults().setToolTipTextAt(MediatorGui.tabResults().indexOfComponent(newTableJPanel), "<html>" + "<b>" + this.table.getParent() + "." + this.table + "</b><br>" + "<i>" + String.join("<br>", Arrays.copyOfRange(this.columnNames, 2, this.columnNames.length)) + "</i>" + "</html>");
        // Apply the custom header to the tab
        MediatorGui.tabResults().setTabComponentAt(MediatorGui.tabResults().indexOfComponent(newTableJPanel), header);
    }
}
Also used : TabHeader(com.jsql.view.swing.tab.TabHeader) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AbstractNodeModel(com.jsql.view.swing.tree.model.AbstractNodeModel) PanelTable(com.jsql.view.swing.table.PanelTable)

Aggregations

AbstractNodeModel (com.jsql.view.swing.tree.model.AbstractNodeModel)13 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)13 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)10 TreePath (javax.swing.tree.TreePath)4 Column (com.jsql.model.bean.database.Column)2 Database (com.jsql.model.bean.database.Database)1 Table (com.jsql.model.bean.database.Table)1 TabHeader (com.jsql.view.swing.tab.TabHeader)1 PanelTable (com.jsql.view.swing.table.PanelTable)1 NodeModelColumn (com.jsql.view.swing.tree.model.NodeModelColumn)1 NodeModelDatabase (com.jsql.view.swing.tree.model.NodeModelDatabase)1 NodeModelTable (com.jsql.view.swing.tree.model.NodeModelTable)1 ArrayList (java.util.ArrayList)1 JCheckBox (javax.swing.JCheckBox)1 JTree (javax.swing.JTree)1