NetworkTable.java

1
package com.jsql.view.swing.panel.consoles;
2
3
import com.jsql.view.subscriber.Seal;
4
import com.jsql.util.I18nUtil;
5
import com.jsql.view.swing.popupmenu.JPopupMenuTable;
6
import com.jsql.view.swing.util.MediatorHelper;
7
8
import javax.swing.*;
9
import javax.swing.table.DefaultTableCellRenderer;
10
import javax.swing.table.DefaultTableModel;
11
import java.awt.*;
12
import java.awt.event.InputEvent;
13
import java.awt.event.KeyEvent;
14
import java.awt.event.MouseAdapter;
15
import java.awt.event.MouseEvent;
16
import java.util.ArrayList;
17
import java.util.HashSet;
18
import java.util.List;
19
import java.util.Set;
20
21
public class NetworkTable extends JTable {
22
23
    public static final String NETWORK_TABLE = "networkTable";
24
25
    /**
26
     * List of HTTP injection requests and responses.
27
     */
28
    private final transient List<Seal.MessageHeader> listHttpHeader = new ArrayList<>();
29
30
    public NetworkTable(TabbedPaneNetworkTab tabbedPaneNetworkTab) {
31
        super(0, 4);
32
        
33 1 1. <init> : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setName → NO_COVERAGE
        this.setName(NetworkTable.NETWORK_TABLE);
34 1 1. <init> : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setComponentPopupMenu → NO_COVERAGE
        this.setComponentPopupMenu(new JPopupMenuTable(this));
35 1 1. <init> : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setRowSelectionAllowed → NO_COVERAGE
        this.setRowSelectionAllowed(true);
36 1 1. <init> : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setSelectionMode → NO_COVERAGE
        this.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
37 1 1. <init> : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setRowHeight → NO_COVERAGE
        this.setRowHeight(20);
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
            @Override
42
            public void mousePressed(MouseEvent e) {
43
                NetworkTable.this.requestFocusInWindow();
44
                
45
                // move selected row and place cursor on focused cell
46 1 1. mousePressed : negated conditional → NO_COVERAGE
                if (SwingUtilities.isRightMouseButton(e)) {
47
                    var point = e.getPoint();
48
49
                    // get the row index that contains that coordinate
50
                    var rowNumber = NetworkTable.this.rowAtPoint(point);
51
                    var colNumber = NetworkTable.this.columnAtPoint(point);
52
                    
53
                    // Get the ListSelectionModel of the JTable
54
                    DefaultListSelectionModel modelRow = (DefaultListSelectionModel) NetworkTable.this.getSelectionModel();
55
                    DefaultListSelectionModel modelColumn = (DefaultListSelectionModel) NetworkTable.this.getColumnModel().getSelectionModel();
56
57 1 1. mousePressed : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setRowSelectionInterval → NO_COVERAGE
                    NetworkTable.this.setRowSelectionInterval(rowNumber, rowNumber);
58 1 1. mousePressed : removed call to javax/swing/DefaultListSelectionModel::moveLeadSelectionIndex → NO_COVERAGE
                    modelRow.moveLeadSelectionIndex(rowNumber);
59 1 1. mousePressed : removed call to javax/swing/DefaultListSelectionModel::moveLeadSelectionIndex → NO_COVERAGE
                    modelColumn.moveLeadSelectionIndex(colNumber);
60
                }
61
            }
62
        });
63
64 1 1. <init> : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setModel → NO_COVERAGE
        this.setModel(new DefaultTableModel() {
65
            private final String[] columns = {
66
                I18nUtil.valueByKey("NETWORK_TAB_URL_COLUMN"),
67
                String.format("%s (KB)", I18nUtil.valueByKey("NETWORK_TAB_SIZE_COLUMN")),
68
                I18nUtil.valueByKey("SQLENGINE_STRATEGY"),
69
                I18nUtil.valueByKey("SQLENGINE_METADATA")
70
            };
71
            @Override
72
            public int getColumnCount() {
73 1 1. getColumnCount : replaced int return with 0 for com/jsql/view/swing/panel/consoles/NetworkTable$2::getColumnCount → NO_COVERAGE
                return this.columns.length;
74
            }
75
            @Override
76
            public String getColumnName(int index) {
77 1 1. getColumnName : replaced return value with "" for com/jsql/view/swing/panel/consoles/NetworkTable$2::getColumnName → NO_COVERAGE
                return this.columns[index];
78
            }
79
        });
80
81 1 1. <init> : removed call to javax/swing/table/TableColumn::setCellRenderer → NO_COVERAGE
        this.getColumnModel().getColumn(0).setCellRenderer(new TooltipCellRenderer());
82
83
        DefaultTableCellRenderer centerHorizontalAlignment = new CenterRenderer();
84 1 1. <init> : removed call to javax/swing/table/TableColumn::setCellRenderer → NO_COVERAGE
        this.getColumnModel().getColumn(1).setCellRenderer(centerHorizontalAlignment);
85 1 1. <init> : removed call to javax/swing/table/TableColumn::setCellRenderer → NO_COVERAGE
        this.getColumnModel().getColumn(2).setCellRenderer(centerHorizontalAlignment);
86 1 1. <init> : removed call to javax/swing/table/TableColumn::setCellRenderer → NO_COVERAGE
        this.getColumnModel().getColumn(3).setCellRenderer(new CenterRendererWithIcon());
87
        
88 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);
89 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);
90
        
91
        Set<AWTKeyStroke> forward = new HashSet<>(this.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
92
        forward.add(KeyStroke.getKeyStroke("TAB"));  // required to unlock focus
93 1 1. <init> : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setFocusTraversalKeys → NO_COVERAGE
        this.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forward);
94
95
        Set<AWTKeyStroke> backward = new HashSet<>(this.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
96
        backward.add(KeyStroke.getKeyStroke("shift TAB"));  // required to unlock focus
97 1 1. <init> : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setFocusTraversalKeys → NO_COVERAGE
        this.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backward);
98
        
99 1 1. <init> : removed call to javax/swing/table/TableColumn::setPreferredWidth → NO_COVERAGE
        this.getColumnModel().getColumn(0).setPreferredWidth(300);
100 1 1. <init> : removed call to javax/swing/table/TableColumn::setPreferredWidth → NO_COVERAGE
        this.getColumnModel().getColumn(1).setPreferredWidth(20);
101 1 1. <init> : removed call to javax/swing/table/TableColumn::setPreferredWidth → NO_COVERAGE
        this.getColumnModel().getColumn(2).setPreferredWidth(50);
102 1 1. <init> : removed call to javax/swing/table/TableColumn::setPreferredWidth → NO_COVERAGE
        this.getColumnModel().getColumn(3).setPreferredWidth(70);
103
        
104 1 1. <init> : removed call to javax/swing/ListSelectionModel::addListSelectionListener → NO_COVERAGE
        this.getSelectionModel().addListSelectionListener(event -> {
105 3 1. lambda$new$0 : changed conditional boundary → NO_COVERAGE
2. lambda$new$0 : negated conditional → NO_COVERAGE
3. lambda$new$0 : negated conditional → NO_COVERAGE
            if (!event.getValueIsAdjusting() && this.getSelectedRow() > -1) {  // prevent double event
106
                var httpHeader = this.listHttpHeader.get(this.getSelectedRow());
107 1 1. lambda$new$0 : removed call to com/jsql/view/swing/panel/consoles/TabbedPaneNetworkTab::changeTextNetwork → NO_COVERAGE
                tabbedPaneNetworkTab.changeTextNetwork(httpHeader);
108
            }
109
        });
110 1 1. <init> : removed call to javax/swing/JCheckBox::addActionListener → NO_COVERAGE
        tabbedPaneNetworkTab.getCheckBoxDecode().addActionListener(e -> {
111
            MediatorHelper.model().getMediatorUtils().preferencesUtil().withIsUrlDecodeNetworkTab(
112
                tabbedPaneNetworkTab.getCheckBoxDecode().isSelected()
113 1 1. lambda$new$1 : removed call to com/jsql/util/PreferencesUtil::persist → NO_COVERAGE
            ).persist();
114 2 1. lambda$new$1 : negated conditional → NO_COVERAGE
2. lambda$new$1 : changed conditional boundary → NO_COVERAGE
            if (this.getSelectedRow() > -1) {  // prevent double event
115
                var httpHeader = this.listHttpHeader.get(this.getSelectedRow());
116 1 1. lambda$new$1 : removed call to com/jsql/view/swing/panel/consoles/TabbedPaneNetworkTab::changeTextNetwork → NO_COVERAGE
                tabbedPaneNetworkTab.changeTextNetwork(httpHeader);
117
            }
118
        });
119
    }
120
    
121
    @Override
122
    public boolean isCellEditable(int row, int column) {
123 1 1. isCellEditable : replaced boolean return with true for com/jsql/view/swing/panel/consoles/NetworkTable::isCellEditable → NO_COVERAGE
        return false;
124
    }
125
126
    public List<Seal.MessageHeader> getListHttpHeader() {
127 1 1. getListHttpHeader : replaced return value with Collections.emptyList for com/jsql/view/swing/panel/consoles/NetworkTable::getListHttpHeader → NO_COVERAGE
        return this.listHttpHeader;
128
    }
129
130
    public void addHeader(Seal.MessageHeader header) {
131
        this.listHttpHeader.add(header);
132
    }
133
}

Mutations

33

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

34

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

35

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

36

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

37

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/consoles/NetworkTable::setRowHeight → 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

46

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

57

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

58

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

59

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

64

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

73

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

77

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

81

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

84

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

85

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

86

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

88

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

89

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

93

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

97

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

99

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

100

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

101

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

102

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

104

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

105

1.1
Location : lambda$new$0
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : lambda$new$0
Killed by : none
negated conditional → NO_COVERAGE

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

107

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

110

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

113

1.1
Location : lambda$new$1
Killed by : none
removed call to com/jsql/util/PreferencesUtil::persist → NO_COVERAGE

114

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

116

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

123

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

127

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.22.1