Search in sources :

Example 11 with AbstractNodeModel

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

the class ActionCheckUncheck method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();
    JCheckBox columnCheckBox = (JCheckBox) source;
    this.nodeModel.setSelected(columnCheckBox.isSelected());
    DefaultTreeModel treeModel = (DefaultTreeModel) MediatorGui.treeDatabase().getModel();
    DefaultMutableTreeNode tableNode = (DefaultMutableTreeNode) this.currentTableNode.getParent();
    int tableChildCount = treeModel.getChildCount(tableNode);
    boolean isOneChildSelected = false;
    for (int i = 0; i < tableChildCount; i++) {
        DefaultMutableTreeNode currentChild = (DefaultMutableTreeNode) treeModel.getChild(tableNode, i);
        if (currentChild.getUserObject() instanceof AbstractNodeModel) {
            AbstractNodeModel columnTreeNodeModel = (AbstractNodeModel) currentChild.getUserObject();
            if (columnTreeNodeModel.isSelected()) {
                isOneChildSelected = true;
                break;
            }
        }
    }
    AbstractNodeModel nodeUserObject = (AbstractNodeModel) tableNode.getUserObject();
    nodeUserObject.setContainingSelection(isOneChildSelected);
}
Also used : JCheckBox(javax.swing.JCheckBox) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AbstractNodeModel(com.jsql.view.swing.tree.model.AbstractNodeModel) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 12 with AbstractNodeModel

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

the class ActionLoadStop method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    DefaultTreeModel treeModel = (DefaultTreeModel) MediatorGui.treeDatabase().getModel();
    DefaultMutableTreeNode tableNode = this.currentTableNode;
    final List<Column> columnsToSearch = new ArrayList<>();
    int tableChildCount = treeModel.getChildCount(tableNode);
    for (int i = 0; i < tableChildCount; i++) {
        DefaultMutableTreeNode currentChild = (DefaultMutableTreeNode) treeModel.getChild(tableNode, i);
        if (currentChild.getUserObject() instanceof AbstractNodeModel) {
            AbstractNodeModel columnTreeNodeModel = (AbstractNodeModel) currentChild.getUserObject();
            if (columnTreeNodeModel.isSelected()) {
                columnsToSearch.add((Column) columnTreeNodeModel.getElementDatabase());
            }
        }
    }
    if (!this.nodeModel.isRunning() && columnsToSearch.isEmpty()) {
        return;
    }
    if (!this.nodeModel.isRunning()) {
        new SwingWorker<Object, Object>() {

            @Override
            protected Object doInBackground() throws Exception {
                Thread.currentThread().setName("SwingWorkerActionLoadStop");
                DataAccess.listValues(columnsToSearch);
                return null;
            }
        }.execute();
    } else {
        AbstractSuspendable<?> suspendableTask = ThreadUtil.get(this.nodeModel.getElementDatabase());
        // Fix #21394: NullPointerException on stop()
        if (suspendableTask != null) {
            suspendableTask.stop();
        }
        this.nodeModel.setIndexProgress(0);
        this.nodeModel.setProgressing(false);
        this.nodeModel.setLoading(false);
        ThreadUtil.remove(this.nodeModel.getElementDatabase());
    }
    this.nodeModel.setRunning(!this.nodeModel.isRunning());
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Column(com.jsql.model.bean.database.Column) ArrayList(java.util.ArrayList) AbstractNodeModel(com.jsql.view.swing.tree.model.AbstractNodeModel) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 13 with AbstractNodeModel

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

the class CellRendererNode method getTreeCellRendererComponent.

@Override
public Component getTreeCellRendererComponent(JTree tree, Object nodeRenderer, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) nodeRenderer;
    Object userObject = currentNode.getUserObject();
    AbstractNodeModel dataModel = (AbstractNodeModel) userObject;
    return dataModel.getComponent(tree, nodeRenderer, selected, leaf, hasFocus);
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AbstractNodeModel(com.jsql.view.swing.tree.model.AbstractNodeModel)

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