ActionCheckUncheck.java

1
package com.jsql.view.swing.tree;
2
3
import com.jsql.view.swing.tree.model.AbstractNodeModel;
4
import com.jsql.view.swing.util.MediatorHelper;
5
6
import javax.swing.*;
7
import javax.swing.tree.DefaultMutableTreeNode;
8
import javax.swing.tree.DefaultTreeModel;
9
import java.awt.event.ActionEvent;
10
import java.awt.event.ActionListener;
11
12
/**
13
 * Check and uncheck column as checkbox.
14
 */
15
public class ActionCheckUncheck implements ActionListener {
16
17
    private final AbstractNodeModel nodeModel;
18
    private final DefaultMutableTreeNode currentTableNode;
19
20
    public ActionCheckUncheck(AbstractNodeModel nodeModel, DefaultMutableTreeNode currentTableNode) {
21
        
22
        this.nodeModel = nodeModel;
23
        this.currentTableNode = currentTableNode;
24
    }
25
26
    @Override
27
    public void actionPerformed(ActionEvent actionEvent) {
28
        
29
        Object source = actionEvent.getSource();
30
        JCheckBox columnCheckBox = (JCheckBox) source;
31 1 1. actionPerformed : removed call to com/jsql/view/swing/tree/model/AbstractNodeModel::setSelected → NO_COVERAGE
        this.nodeModel.setSelected(columnCheckBox.isSelected());
32
33
        DefaultTreeModel treeModel = (DefaultTreeModel) MediatorHelper.treeDatabase().getModel();
34
        DefaultMutableTreeNode tableNode = (DefaultMutableTreeNode) this.currentTableNode.getParent();
35
36
        int tableChildCount = treeModel.getChildCount(tableNode);
37
        var isOneChildSelected = false;
38
        
39 2 1. actionPerformed : negated conditional → NO_COVERAGE
2. actionPerformed : changed conditional boundary → NO_COVERAGE
        for (var i = 0 ; i < tableChildCount ; i++) {
40
            
41
            DefaultMutableTreeNode currentChild = (DefaultMutableTreeNode) treeModel.getChild(tableNode, i);
42
            
43 1 1. actionPerformed : negated conditional → NO_COVERAGE
            if (currentChild.getUserObject() instanceof AbstractNodeModel) {
44
                
45
                AbstractNodeModel columnTreeNodeModel = (AbstractNodeModel) currentChild.getUserObject();
46
                
47 1 1. actionPerformed : negated conditional → NO_COVERAGE
                if (columnTreeNodeModel.isSelected()) {
48
                    
49
                    isOneChildSelected = true;
50
                    break;
51
                }
52
            }
53
        }
54
55
        AbstractNodeModel nodeUserObject = (AbstractNodeModel) tableNode.getUserObject();
56 1 1. actionPerformed : removed call to com/jsql/view/swing/tree/model/AbstractNodeModel::setContainingSelection → NO_COVERAGE
        nodeUserObject.setContainingSelection(isOneChildSelected);
57
    }
58
}

Mutations

31

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

39

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

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

43

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

47

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

56

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

Active mutators

Tests examined


Report generated by PIT 1.16.1