NodeModelEmpty.java

1
/*******************************************************************************
2
 * Copyhacked (H) 2012-2025.
3
 * This program and the accompanying materials
4
 * are made available under no term at all, use it like
5
 * you want, but share and discuss it
6
 * every time possible with every body.
7
 * 
8
 * Contributors:
9
 *      ron190 at ymail dot com - initial implementation
10
 ******************************************************************************/
11
package com.jsql.view.swing.tree.model;
12
13
import com.jsql.model.bean.database.Column;
14
import com.jsql.view.swing.tree.custom.JPopupMenuCustomExtract;
15
16
import javax.swing.*;
17
import javax.swing.tree.DefaultMutableTreeNode;
18
import javax.swing.tree.TreePath;
19
import java.awt.*;
20
import java.awt.event.MouseEvent;
21
22
/**
23
 * Model for default item used on an empty tree.
24
 */
25
public class NodeModelEmpty extends AbstractNodeModel {
26
    
27
    /**
28
     * Flat node for empty tree.
29
     */
30
    public NodeModelEmpty(String textNode) {
31
        super(textNode);
32
    }
33
34
    public NodeModelEmpty(Column column) {
35
        super(column);
36
    }
37
38
    @Override
39
    public Component getComponent(
40
        final JTree tree, Object nodeRenderer, final boolean isSelected, boolean isLeaf, boolean hasFocus
41
    ) {
42
        DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) nodeRenderer;
43
        var panelEmpty = new JPanel(new BorderLayout());
44
        var labelEmpty = new JLabel(currentNode.getUserObject().toString());
45
        panelEmpty.add(labelEmpty);
46 1 1. getComponent : removed call to javax/swing/JLabel::setBorder → NO_COVERAGE
        labelEmpty.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
47
48 1 1. getComponent : negated conditional → NO_COVERAGE
        if (isSelected) {
49 1 1. getComponent : removed call to javax/swing/JPanel::setBackground → NO_COVERAGE
            panelEmpty.setBackground(UIManager.getColor("Tree.selectionBackground"));
50
        } else {
51 1 1. getComponent : removed call to javax/swing/JPanel::setBackground → NO_COVERAGE
            panelEmpty.setBackground(UIManager.getColor("Tree.selectionInactiveBackground"));
52
        }
53 1 1. getComponent : replaced return value with null for com/jsql/view/swing/tree/model/NodeModelEmpty::getComponent → NO_COVERAGE
        return panelEmpty;
54
    }
55
56
    @Override
57
    protected Icon getLeafIcon(boolean leaf) {
58
        // No icon for default node
59
        return null;
60
    }
61
    
62
    @Override
63
    public void runAction() {
64
        // Not used
65
    }
66
    
67
    @Override
68
    protected void buildMenu(JPopupMenuCustomExtract tablePopupMenu, TreePath path) {
69
        // Not used
70
    }
71
    
72
    @Override
73
    public void showPopup(final DefaultMutableTreeNode currentTableNode, TreePath path, MouseEvent e) {
74
        // Not used
75
    }
76
    
77
    @Override
78
    public boolean isPopupDisplayable() {
79 1 1. isPopupDisplayable : replaced boolean return with true for com/jsql/view/swing/tree/model/NodeModelEmpty::isPopupDisplayable → NO_COVERAGE
        return false;
80
    }
81
}

Mutations

46

1.1
Location : getComponent
Killed by : none
removed call to javax/swing/JLabel::setBorder → NO_COVERAGE

48

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

49

1.1
Location : getComponent
Killed by : none
removed call to javax/swing/JPanel::setBackground → NO_COVERAGE

51

1.1
Location : getComponent
Killed by : none
removed call to javax/swing/JPanel::setBackground → NO_COVERAGE

53

1.1
Location : getComponent
Killed by : none
replaced return value with null for com/jsql/view/swing/tree/model/NodeModelEmpty::getComponent → NO_COVERAGE

79

1.1
Location : isPopupDisplayable
Killed by : none
replaced boolean return with true for com/jsql/view/swing/tree/model/NodeModelEmpty::isPopupDisplayable → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.19.1