NetworkTable.java

1
package com.jsql.view.swing.panel.consoles;
2
3
import com.jsql.model.bean.util.HttpHeader;
4
import com.jsql.util.I18nUtil;
5
import com.jsql.view.swing.popupmenu.JPopupMenuTable;
6
7
import javax.swing.*;
8
import javax.swing.table.DefaultTableCellRenderer;
9
import javax.swing.table.DefaultTableModel;
10
import java.awt.*;
11
import java.awt.event.InputEvent;
12
import java.awt.event.KeyEvent;
13
import java.awt.event.MouseAdapter;
14
import java.awt.event.MouseEvent;
15
import java.util.ArrayList;
16
import java.util.HashSet;
17
import java.util.List;
18
import java.util.Set;
19
20
public class NetworkTable extends JTable {
21
    
22
    /**
23
     * List of HTTP injection requests and responses.
24
     */
25
    private final transient List<HttpHeader> listHttpHeader = new ArrayList<>();
26
27
    public NetworkTable(TabbedPaneNetworkTab tabbedPaneNetworkTab) {
28
        
29
        super(0, 4);
30
        
31 1 1. <init> : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setName → NO_COVERAGE
        this.setName("networkTable");
32 1 1. <init> : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setComponentPopupMenu → NO_COVERAGE
        this.setComponentPopupMenu(new JPopupMenuTable(this));
33 1 1. <init> : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setAutoResizeMode → NO_COVERAGE
        this.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
34 1 1. <init> : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setRowSelectionAllowed → NO_COVERAGE
        this.setRowSelectionAllowed(true);
35 1 1. <init> : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setSelectionMode → NO_COVERAGE
        this.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
36 1 1. <init> : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setRowHeight → NO_COVERAGE
        this.setRowHeight(20);
37 1 1. <init> : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setGridColor → NO_COVERAGE
        this.setGridColor(Color.LIGHT_GRAY);
38 1 1. <init> : removed call to javax/swing/table/JTableHeader::setReorderingAllowed → NO_COVERAGE
        this.getTableHeader().setReorderingAllowed(false);
39
        
40 1 1. <init> : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::addMouseListener → NO_COVERAGE
        this.addMouseListener(new MouseAdapter() {
41
            
42
            @Override
43
            public void mousePressed(MouseEvent e) {
44
                
45
                NetworkTable.this.requestFocusInWindow();
46
                
47
                // move selected row and place cursor on focused cell
48 1 1. mousePressed : negated conditional → NO_COVERAGE
                if (SwingUtilities.isRightMouseButton(e)) {
49
                    
50
                    var point = e.getPoint();
51
52
                    // get the row index that contains that coordinate
53
                    var rowNumber = NetworkTable.this.rowAtPoint(point);
54
                    var colNumber = NetworkTable.this.columnAtPoint(point);
55
                    
56
                    // Get the ListSelectionModel of the JTable
57
                    DefaultListSelectionModel modelRow = (DefaultListSelectionModel) NetworkTable.this.getSelectionModel();
58
                    DefaultListSelectionModel modelColumn = (DefaultListSelectionModel) NetworkTable.this.getColumnModel().getSelectionModel();
59
60 1 1. mousePressed : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setRowSelectionInterval → NO_COVERAGE
                    NetworkTable.this.setRowSelectionInterval(rowNumber, rowNumber);
61 1 1. mousePressed : removed call to javax/swing/DefaultListSelectionModel::moveLeadSelectionIndex → NO_COVERAGE
                    modelRow.moveLeadSelectionIndex(rowNumber);
62 1 1. mousePressed : removed call to javax/swing/DefaultListSelectionModel::moveLeadSelectionIndex → NO_COVERAGE
                    modelColumn.moveLeadSelectionIndex(colNumber);
63
                }
64
            }
65
        });
66
67 1 1. <init> : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setModel → NO_COVERAGE
        this.setModel(new DefaultTableModel() {
68
            
69
            private final String[] columns = {
70
                I18nUtil.valueByKey("NETWORK_TAB_URL_COLUMN"),
71
                String.format(
72
                    "%s (KB)",
73
                    I18nUtil.valueByKey("NETWORK_TAB_SIZE_COLUMN")
74
                ),
75
                "Strategy",
76
                "Metadata"
77
            };
78
79
            @Override
80
            public int getColumnCount() {
81 1 1. getColumnCount : replaced int return with 0 for com/jsql/view/swing/panel/consoles/NetworkTable$2::getColumnCount → NO_COVERAGE
                return this.columns.length;
82
            }
83
84
            @Override
85
            public String getColumnName(int index) {
86 1 1. getColumnName : replaced return value with "" for com/jsql/view/swing/panel/consoles/NetworkTable$2::getColumnName → NO_COVERAGE
                return this.columns[index];
87
            }
88
        });
89
90 1 1. <init> : removed call to javax/swing/table/TableColumn::setCellRenderer → NO_COVERAGE
        this.getColumnModel().getColumn(0).setCellRenderer(new TooltipCellRenderer());
91
92
        DefaultTableCellRenderer centerHorizontalAlignment = new CenterRenderer();
93 1 1. <init> : removed call to javax/swing/table/TableColumn::setCellRenderer → NO_COVERAGE
        this.getColumnModel().getColumn(1).setCellRenderer(centerHorizontalAlignment);
94 1 1. <init> : removed call to javax/swing/table/TableColumn::setCellRenderer → NO_COVERAGE
        this.getColumnModel().getColumn(2).setCellRenderer(centerHorizontalAlignment);
95 1 1. <init> : removed call to javax/swing/table/TableColumn::setCellRenderer → NO_COVERAGE
        this.getColumnModel().getColumn(3).setCellRenderer(new CenterRendererWithColor());
96
        
97 1 1. <init> : removed call to javax/swing/InputMap::put → NO_COVERAGE
        this.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), null);
98 1 1. <init> : removed call to javax/swing/InputMap::put → NO_COVERAGE
        this.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_DOWN_MASK), null);
99
        
100
        Set<AWTKeyStroke> forward = new HashSet<>(this.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
101
        forward.add(KeyStroke.getKeyStroke("TAB"));
102 1 1. <init> : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setFocusTraversalKeys → NO_COVERAGE
        this.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forward);
103
        
104
        Set<AWTKeyStroke> backward = new HashSet<>(this.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
105
        backward.add(KeyStroke.getKeyStroke("shift TAB"));
106 1 1. <init> : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setFocusTraversalKeys → NO_COVERAGE
        this.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backward);
107
        
108
        final var tableCellRenderer = this.getTableHeader().getDefaultRenderer();
109 1 1. <init> : removed call to javax/swing/table/JTableHeader::setDefaultRenderer → NO_COVERAGE
        this.getTableHeader().setDefaultRenderer(
110
            (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) -> {
111
                
112
                JLabel label = (JLabel) tableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
113
                
114 1 1. lambda$new$0 : removed call to javax/swing/JLabel::setBorder → NO_COVERAGE
                label.setBorder(
115
                    BorderFactory.createCompoundBorder(
116
                        BorderFactory.createMatteBorder(0, 0, 1, 1, Color.LIGHT_GRAY),
117
                        BorderFactory.createEmptyBorder(0, 5, 0, 5)
118
                    )
119
                );
120
                
121 1 1. lambda$new$0 : replaced return value with null for com/jsql/view/swing/panel/consoles/NetworkTable::lambda$new$0 → NO_COVERAGE
                return label;
122
            }
123
        );
124
        
125 1 1. <init> : removed call to javax/swing/table/TableColumn::setPreferredWidth → NO_COVERAGE
        this.getColumnModel().getColumn(0).setPreferredWidth(300);
126 1 1. <init> : removed call to javax/swing/table/TableColumn::setPreferredWidth → NO_COVERAGE
        this.getColumnModel().getColumn(1).setPreferredWidth(20);
127 1 1. <init> : removed call to javax/swing/table/TableColumn::setPreferredWidth → NO_COVERAGE
        this.getColumnModel().getColumn(2).setPreferredWidth(50);
128 1 1. <init> : removed call to javax/swing/table/TableColumn::setPreferredWidth → NO_COVERAGE
        this.getColumnModel().getColumn(3).setPreferredWidth(50);
129
        
130 1 1. <init> : removed call to javax/swing/ListSelectionModel::addListSelectionListener → NO_COVERAGE
        this.getSelectionModel().addListSelectionListener(event -> {
131
            
132
            // prevent double event
133 3 1. lambda$new$1 : negated conditional → NO_COVERAGE
2. lambda$new$1 : changed conditional boundary → NO_COVERAGE
3. lambda$new$1 : negated conditional → NO_COVERAGE
            if (!event.getValueIsAdjusting() && this.getSelectedRow() > -1) {
134
                
135
                var httpHeader = this.listHttpHeader.get(this.getSelectedRow());
136 1 1. lambda$new$1 : removed call to com/jsql/view/swing/panel/consoles/TabbedPaneNetworkTab::changeTextNetwork → NO_COVERAGE
                tabbedPaneNetworkTab.changeTextNetwork(httpHeader);
137
            }
138
        });
139
    }
140
    
141
    @Override
142
    public boolean isCellEditable(int row, int column) {
143 1 1. isCellEditable : replaced boolean return with true for com/jsql/view/swing/panel/consoles/NetworkTable::isCellEditable → NO_COVERAGE
        return false;
144
    }
145
146
    public List<HttpHeader> getListHttpHeader() {
147 1 1. getListHttpHeader : replaced return value with Collections.emptyList for com/jsql/view/swing/panel/consoles/NetworkTable::getListHttpHeader → NO_COVERAGE
        return this.listHttpHeader;
148
    }
149
    
150
    public void addHeader(HttpHeader header) {
151
        this.listHttpHeader.add(header);
152
    }
153
}

Mutations

31

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setName → NO_COVERAGE

32

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setComponentPopupMenu → NO_COVERAGE

33

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setAutoResizeMode → NO_COVERAGE

34

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setRowSelectionAllowed → NO_COVERAGE

35

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setSelectionMode → NO_COVERAGE

36

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setRowHeight → NO_COVERAGE

37

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setGridColor → NO_COVERAGE

38

1.1
Location : <init>
Killed by : none
removed call to javax/swing/table/JTableHeader::setReorderingAllowed → NO_COVERAGE

40

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/consoles/NetworkTable::addMouseListener → NO_COVERAGE

48

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

60

1.1
Location : mousePressed
Killed by : none
removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setRowSelectionInterval → NO_COVERAGE

61

1.1
Location : mousePressed
Killed by : none
removed call to javax/swing/DefaultListSelectionModel::moveLeadSelectionIndex → NO_COVERAGE

62

1.1
Location : mousePressed
Killed by : none
removed call to javax/swing/DefaultListSelectionModel::moveLeadSelectionIndex → NO_COVERAGE

67

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setModel → NO_COVERAGE

81

1.1
Location : getColumnCount
Killed by : none
replaced int return with 0 for com/jsql/view/swing/panel/consoles/NetworkTable$2::getColumnCount → NO_COVERAGE

86

1.1
Location : getColumnName
Killed by : none
replaced return value with "" for com/jsql/view/swing/panel/consoles/NetworkTable$2::getColumnName → NO_COVERAGE

90

1.1
Location : <init>
Killed by : none
removed call to javax/swing/table/TableColumn::setCellRenderer → NO_COVERAGE

93

1.1
Location : <init>
Killed by : none
removed call to javax/swing/table/TableColumn::setCellRenderer → NO_COVERAGE

94

1.1
Location : <init>
Killed by : none
removed call to javax/swing/table/TableColumn::setCellRenderer → NO_COVERAGE

95

1.1
Location : <init>
Killed by : none
removed call to javax/swing/table/TableColumn::setCellRenderer → NO_COVERAGE

97

1.1
Location : <init>
Killed by : none
removed call to javax/swing/InputMap::put → NO_COVERAGE

98

1.1
Location : <init>
Killed by : none
removed call to javax/swing/InputMap::put → NO_COVERAGE

102

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setFocusTraversalKeys → NO_COVERAGE

106

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setFocusTraversalKeys → NO_COVERAGE

109

1.1
Location : <init>
Killed by : none
removed call to javax/swing/table/JTableHeader::setDefaultRenderer → NO_COVERAGE

114

1.1
Location : lambda$new$0
Killed by : none
removed call to javax/swing/JLabel::setBorder → NO_COVERAGE

121

1.1
Location : lambda$new$0
Killed by : none
replaced return value with null for com/jsql/view/swing/panel/consoles/NetworkTable::lambda$new$0 → NO_COVERAGE

125

1.1
Location : <init>
Killed by : none
removed call to javax/swing/table/TableColumn::setPreferredWidth → NO_COVERAGE

126

1.1
Location : <init>
Killed by : none
removed call to javax/swing/table/TableColumn::setPreferredWidth → NO_COVERAGE

127

1.1
Location : <init>
Killed by : none
removed call to javax/swing/table/TableColumn::setPreferredWidth → NO_COVERAGE

128

1.1
Location : <init>
Killed by : none
removed call to javax/swing/table/TableColumn::setPreferredWidth → NO_COVERAGE

130

1.1
Location : <init>
Killed by : none
removed call to javax/swing/ListSelectionModel::addListSelectionListener → NO_COVERAGE

133

1.1
Location : lambda$new$1
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : lambda$new$1
Killed by : none
changed conditional boundary → NO_COVERAGE

3.3
Location : lambda$new$1
Killed by : none
negated conditional → NO_COVERAGE

136

1.1
Location : lambda$new$1
Killed by : none
removed call to com/jsql/view/swing/panel/consoles/TabbedPaneNetworkTab::changeTextNetwork → NO_COVERAGE

143

1.1
Location : isCellEditable
Killed by : none
replaced boolean return with true for com/jsql/view/swing/panel/consoles/NetworkTable::isCellEditable → NO_COVERAGE

147

1.1
Location : getListHttpHeader
Killed by : none
replaced return value with Collections.emptyList for com/jsql/view/swing/panel/consoles/NetworkTable::getListHttpHeader → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.16.1