ActionCheckbox.java

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

Mutations

34

1.1
Location : actionPerformed
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : actionPerformed
Killed by : none
changed conditional boundary → NO_COVERAGE

38

1.1
Location : actionPerformed
Killed by : none
negated conditional → NO_COVERAGE

41

1.1
Location : actionPerformed
Killed by : none
removed call to com/jsql/view/swing/tree/model/AbstractNodeModel::setSelected → NO_COVERAGE

43

1.1
Location : actionPerformed
Killed by : none
removed call to com/jsql/view/swing/tree/model/AbstractNodeModel::setContainingSelection → NO_COVERAGE

47

1.1
Location : actionPerformed
Killed by : none
removed call to javax/swing/tree/DefaultTreeModel::nodeChanged → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.16.1