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