ActionCheckSingle.java

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.*;
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 ActionCheckSingle implements ActionListener {
16
17
    private final AbstractNodeModel nodeModel;
18
    private final DefaultMutableTreeNode currentTableNode;
19
20
    public ActionCheckSingle(AbstractNodeModel nodeModel, DefaultMutableTreeNode currentTableNode) {
21
        this.nodeModel = nodeModel;
22
        this.currentTableNode = currentTableNode;
23
    }
24
25
    @Override
26
    public void actionPerformed(ActionEvent actionEvent) {
27
        JCheckBox columnCheckBox = (JCheckBox) actionEvent.getSource();
28 1 1. actionPerformed : removed call to com/jsql/view/swing/tree/model/AbstractNodeModel::setSelected → NO_COVERAGE
        this.nodeModel.setSelected(columnCheckBox.isSelected());
29
30
        DefaultTreeModel treeModel = (DefaultTreeModel) MediatorHelper.treeDatabase().getModel();
31
        DefaultMutableTreeNode tableNode = (DefaultMutableTreeNode) this.currentTableNode.getParent();
32
33
        int tableChildCount = treeModel.getChildCount(tableNode);
34
        var isOneChildSelected = false;
35
        
36 2 1. actionPerformed : changed conditional boundary → NO_COVERAGE
2. actionPerformed : negated conditional → NO_COVERAGE
        for (var i = 0 ; i < tableChildCount ; i++) {
37
            DefaultMutableTreeNode currentChild = (DefaultMutableTreeNode) treeModel.getChild(tableNode, i);
38 1 1. actionPerformed : negated conditional → NO_COVERAGE
            if (currentChild.getUserObject() instanceof AbstractNodeModel) {
39
                AbstractNodeModel columnTreeNodeModel = (AbstractNodeModel) currentChild.getUserObject();
40 1 1. actionPerformed : negated conditional → NO_COVERAGE
                if (columnTreeNodeModel.isSelected()) {
41
                    isOneChildSelected = true;
42
                    break;
43
                }
44
            }
45
        }
46
47
        AbstractNodeModel nodeUserObject = (AbstractNodeModel) tableNode.getUserObject();
48 1 1. actionPerformed : removed call to com/jsql/view/swing/tree/model/AbstractNodeModel::setIsAnyCheckboxSelected → NO_COVERAGE
        nodeUserObject.setIsAnyCheckboxSelected(isOneChildSelected);
49
    }
50
}

Mutations

28

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

36

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

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

38

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

40

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

48

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

Active mutators

Tests examined


Report generated by PIT 1.19.1