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);
}
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());
}
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);
}
Aggregations