1 | package com.jsql.view.swing.tree.action; | |
2 | ||
3 | import com.jsql.view.swing.tree.model.AbstractNodeModel; | |
4 | import com.jsql.view.swing.util.MediatorHelper; | |
5 | ||
6 | import javax.swing.tree.DefaultMutableTreeNode; | |
7 | import javax.swing.tree.DefaultTreeModel; | |
8 | import javax.swing.tree.TreePath; | |
9 | import java.awt.event.ActionEvent; | |
10 | import java.awt.event.ActionListener; | |
11 | ||
12 | /** | |
13 | * Listener to check or uncheck every children menu items. | |
14 | * Usually required from a table node to un/check every column | |
15 | */ | |
16 | public class ActionCheckAll implements ActionListener { | |
17 | | |
18 | private final boolean isCheckboxesSelected; | |
19 | private final TreePath path; | |
20 | | |
21 | public ActionCheckAll(boolean isCheckboxesSelected, TreePath path) { | |
22 | this.isCheckboxesSelected = isCheckboxesSelected; | |
23 | this.path = path; | |
24 | } | |
25 | ||
26 | @Override | |
27 | public void actionPerformed(ActionEvent actionEvent) { | |
28 | DefaultMutableTreeNode currentTableNode = (DefaultMutableTreeNode) this.path.getLastPathComponent(); | |
29 | AbstractNodeModel currentTableModel = (AbstractNodeModel) currentTableNode.getUserObject(); | |
30 | DefaultTreeModel treeModel = (DefaultTreeModel) MediatorHelper.treeDatabase().getModel(); | |
31 | int tableChildCount = treeModel.getChildCount(currentTableNode); | |
32 |
2
1. actionPerformed : negated conditional → NO_COVERAGE 2. actionPerformed : changed conditional boundary → NO_COVERAGE |
for (var i = 0 ; i < tableChildCount ; i++) { |
33 | DefaultMutableTreeNode currentChild = (DefaultMutableTreeNode) treeModel.getChild(currentTableNode, i); | |
34 |
1
1. actionPerformed : negated conditional → NO_COVERAGE |
if (currentChild.getUserObject() instanceof AbstractNodeModel) { |
35 | AbstractNodeModel columnTreeNodeModel = (AbstractNodeModel) currentChild.getUserObject(); | |
36 |
1
1. actionPerformed : removed call to com/jsql/view/swing/tree/model/AbstractNodeModel::setSelected → NO_COVERAGE |
columnTreeNodeModel.setSelected(this.isCheckboxesSelected); |
37 | | |
38 |
1
1. actionPerformed : removed call to com/jsql/view/swing/tree/model/AbstractNodeModel::setIsAnyCheckboxSelected → NO_COVERAGE |
currentTableModel.setIsAnyCheckboxSelected(this.isCheckboxesSelected); |
39 | } | |
40 | } | |
41 | ||
42 |
1
1. actionPerformed : removed call to javax/swing/tree/DefaultTreeModel::nodeChanged → NO_COVERAGE |
treeModel.nodeChanged(currentTableNode); |
43 | } | |
44 | } | |
Mutations | ||
32 |
1.1 2.2 |
|
34 |
1.1 |
|
36 |
1.1 |
|
38 |
1.1 |
|
42 |
1.1 |