1 | package com.jsql.view.swing.panel; | |
2 | ||
3 | import com.jsql.view.swing.action.ActionCheckIP; | |
4 | import com.jsql.view.swing.panel.preferences.*; | |
5 | import com.jsql.view.swing.ui.FlatButtonMouseAdapter; | |
6 | import com.jsql.view.swing.util.UiUtil; | |
7 | import org.apache.commons.text.WordUtils; | |
8 | ||
9 | import javax.swing.*; | |
10 | import javax.swing.border.Border; | |
11 | import java.awt.*; | |
12 | import java.awt.event.ActionListener; | |
13 | ||
14 | public class PanelPreferences extends JPanel { | |
15 | | |
16 | private final transient ActionListener actionListenerSave = new ActionListenerSave(this); | |
17 | | |
18 | private final PanelTampering panelTamperingPreferences = new PanelTampering(this); | |
19 | private final PanelInjection panelInjectionPreferences = new PanelInjection(this); | |
20 | private final PanelProxy panelProxyPreferences = new PanelProxy(this); | |
21 | private final PanelAuth panelAuthPreferences = new PanelAuth(this); | |
22 | private final PanelGeneral panelGeneralPreferences = new PanelGeneral(this); | |
23 | private final PanelUserAgent panelUserAgentPreferences = new PanelUserAgent(); | |
24 | private final PanelConnection panelConnectionPreferences = new PanelConnection(this); | |
25 | private final PanelStrategies panelStrategiesPreferences = new PanelStrategies(this); | |
26 | ||
27 | private static final JPanel panelInjection = new JPanel(new BorderLayout()); | |
28 | private static final JPanel panelAuth = new JPanel(new BorderLayout()); | |
29 | private static final JPanel panelProxy = new JPanel(new BorderLayout()); | |
30 | private static final JPanel panelGeneral = new JPanel(new BorderLayout()); | |
31 | private static final JPanel panelUserAgent = new JPanel(new BorderLayout()); | |
32 | private static final JPanel panelTampering = new JPanel(new BorderLayout()); | |
33 | private static final JPanel panelConnection = new JPanel(new BorderLayout()); | |
34 | private static final JPanel panelStrategies = new JPanel(new BorderLayout()); | |
35 | ||
36 | private final transient Border panelBorder = BorderFactory.createEmptyBorder(10, 15, 0, 15); | |
37 | | |
38 | private enum CategoryPreference { | |
39 | | |
40 | INJECTION(panelInjection), | |
41 | TAMPERING(panelTampering), | |
42 | CONNECTION(panelConnection), | |
43 | STRATEGIES(panelStrategies), | |
44 | AUTH(panelAuth), | |
45 | USER_AGENT(panelUserAgent), | |
46 | PROXY(panelProxy), | |
47 | GENERAL(panelGeneral); | |
48 | | |
49 | private final Component panel; | |
50 | ||
51 | CategoryPreference(Component panel) { | |
52 | this.panel = panel; | |
53 | } | |
54 | | |
55 | @Override | |
56 | public String toString() { | |
57 |
1
1. toString : replaced return value with "" for com/jsql/view/swing/panel/PanelPreferences$CategoryPreference::toString → NO_COVERAGE |
return " "+ WordUtils.capitalizeFully(this.name()).replace('_', ' ') +" "; |
58 | } | |
59 | ||
60 | public Component getPanel() { | |
61 |
1
1. getPanel : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences$CategoryPreference::getPanel → NO_COVERAGE |
return this.panel; |
62 | } | |
63 | } | |
64 | | |
65 | public PanelPreferences() { | |
66 | | |
67 | var borderLayoutPreferences = new BorderLayout(); | |
68 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::setLayout → NO_COVERAGE |
this.setLayout(borderLayoutPreferences); |
69 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::setBorder → NO_COVERAGE |
this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
70 | | |
71 | JList<CategoryPreference> categories = this.getCategories(borderLayoutPreferences); | |
72 | | |
73 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::add → NO_COVERAGE |
this.add(categories, BorderLayout.LINE_START); |
74 | | |
75 |
1
1. <init> : removed call to javax/swing/JPanel::setBorder → NO_COVERAGE |
panelInjection.setBorder(this.panelBorder); |
76 |
1
1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE |
panelInjection.add(new JLabel("<html><b>Injection</b> / Process configuration</html>"), BorderLayout.NORTH); |
77 |
1
1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE |
panelInjection.add(this.panelInjectionPreferences, BorderLayout.CENTER); |
78 | | |
79 |
1
1. <init> : removed call to javax/swing/JPanel::setBorder → NO_COVERAGE |
panelTampering.setBorder(this.panelBorder); |
80 |
1
1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE |
panelTampering.add(new JLabel("<html><b>Tampering</b> / SQL transform to bypass Web Application Firewall</html>"), BorderLayout.NORTH); |
81 |
1
1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE |
panelTampering.add(this.panelTamperingPreferences, BorderLayout.CENTER); |
82 | | |
83 |
1
1. <init> : removed call to javax/swing/JPanel::setBorder → NO_COVERAGE |
panelConnection.setBorder(this.panelBorder); |
84 |
1
1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE |
panelConnection.add(new JLabel("<html><b>Connection</b> / Network and threads</html>"), BorderLayout.NORTH); |
85 |
1
1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE |
panelConnection.add(this.panelConnectionPreferences, BorderLayout.CENTER); |
86 | | |
87 |
1
1. <init> : removed call to javax/swing/JPanel::setBorder → NO_COVERAGE |
panelStrategies.setBorder(this.panelBorder); |
88 |
1
1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE |
panelStrategies.add(new JLabel("<html><b>Strategies</b> / Reduce processing load</html>"), BorderLayout.NORTH); |
89 |
1
1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE |
panelStrategies.add(this.panelStrategiesPreferences, BorderLayout.CENTER); |
90 | ||
91 |
1
1. <init> : removed call to javax/swing/JPanel::setBorder → NO_COVERAGE |
panelAuth.setBorder(this.panelBorder); |
92 |
1
1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE |
panelAuth.add(new JLabel("<html><b>Authentication</b> / Basic, Digest, NTLM or Kerberos connection</html>"), BorderLayout.NORTH); |
93 |
1
1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE |
panelAuth.add(this.panelAuthPreferences, BorderLayout.CENTER); |
94 | | |
95 |
1
1. <init> : removed call to javax/swing/JPanel::setBorder → NO_COVERAGE |
panelUserAgent.setBorder(this.panelBorder); |
96 |
1
1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE |
panelUserAgent.add(new JLabel("<html><b>User Agent</b> / Network connection agents</html>"), BorderLayout.NORTH); |
97 |
1
1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE |
panelUserAgent.add(this.panelUserAgentPreferences, BorderLayout.CENTER); |
98 | | |
99 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::initializePanelProxy → NO_COVERAGE |
this.initializePanelProxy(); |
100 | | |
101 |
1
1. <init> : removed call to javax/swing/JPanel::setBorder → NO_COVERAGE |
panelGeneral.setBorder(this.panelBorder); |
102 |
1
1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE |
panelGeneral.add(new JLabel("<html><b>General</b> / Basic options</html>"), BorderLayout.NORTH); |
103 |
1
1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE |
panelGeneral.add(this.panelGeneralPreferences, BorderLayout.CENTER); |
104 | | |
105 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::add → NO_COVERAGE |
this.add(panelInjection, BorderLayout.CENTER); |
106 | } | |
107 | ||
108 | private void initializePanelProxy() { | |
109 | | |
110 |
1
1. initializePanelProxy : removed call to javax/swing/JPanel::setLayout → NO_COVERAGE |
panelProxy.setLayout(new BoxLayout(panelProxy, BoxLayout.Y_AXIS)); |
111 |
1
1. initializePanelProxy : removed call to javax/swing/JPanel::setBorder → NO_COVERAGE |
panelProxy.setBorder(this.panelBorder); |
112 | | |
113 | final var buttonCheckIp = new JButton("Check your IP"); | |
114 |
1
1. initializePanelProxy : removed call to javax/swing/JButton::addActionListener → NO_COVERAGE |
buttonCheckIp.addActionListener(new ActionCheckIP()); |
115 |
1
1. initializePanelProxy : removed call to javax/swing/JButton::setToolTipText → NO_COVERAGE |
buttonCheckIp.setToolTipText( |
116 | "<html><b>Verify what public IP address is used by jSQL</b><br>" | |
117 | + "Usually it's your own public IP if you don't use a proxy. If you use a proxy<br>" | |
118 | + "like TOR then your public IP is hidden and another one is used instead.</html>" | |
119 | ); | |
120 |
1
1. initializePanelProxy : removed call to javax/swing/JButton::setContentAreaFilled → NO_COVERAGE |
buttonCheckIp.setContentAreaFilled(true); |
121 |
1
1. initializePanelProxy : removed call to javax/swing/JButton::setBorder → NO_COVERAGE |
buttonCheckIp.setBorder(UiUtil.BORDER_ROUND_BLU); |
122 | | |
123 | var flatButtonMouseAdapter = new FlatButtonMouseAdapter(buttonCheckIp); | |
124 |
1
1. initializePanelProxy : removed call to com/jsql/view/swing/ui/FlatButtonMouseAdapter::setContentVisible → NO_COVERAGE |
flatButtonMouseAdapter.setContentVisible(true); |
125 |
1
1. initializePanelProxy : removed call to javax/swing/JButton::addMouseListener → NO_COVERAGE |
buttonCheckIp.addMouseListener(flatButtonMouseAdapter); |
126 | | |
127 | var labelProxy = new JLabel("<html><b>Proxy</b> / Settings for tools like Burp and Tor</html>"); | |
128 |
1
1. initializePanelProxy : removed call to javax/swing/JPanel::removeAll → NO_COVERAGE |
panelProxy.removeAll(); |
129 |
1
1. initializePanelProxy : removed call to javax/swing/JPanel::add → NO_COVERAGE |
panelProxy.add(labelProxy, BorderLayout.NORTH); |
130 | panelProxy.add(this.panelProxyPreferences); | |
131 | | |
132 | var panelCheckIp = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0)); | |
133 |
1
1. initializePanelProxy : removed call to javax/swing/JPanel::setBorder → NO_COVERAGE |
panelCheckIp.setBorder(BorderFactory.createEmptyBorder(15, 0, 0, 0)); |
134 | panelCheckIp.add(buttonCheckIp); | |
135 | panelCheckIp.add(Box.createGlue()); | |
136 | panelProxy.add(panelCheckIp); | |
137 | | |
138 |
1
1. initializePanelProxy : removed call to javax/swing/JLabel::setAlignmentX → NO_COVERAGE |
labelProxy.setAlignmentX(Component.LEFT_ALIGNMENT); |
139 |
1
1. initializePanelProxy : removed call to com/jsql/view/swing/panel/preferences/PanelProxy::setAlignmentX → NO_COVERAGE |
this.panelProxyPreferences.setAlignmentX(Component.LEFT_ALIGNMENT); |
140 |
1
1. initializePanelProxy : removed call to javax/swing/JPanel::setAlignmentX → NO_COVERAGE |
panelCheckIp.setAlignmentX(Component.LEFT_ALIGNMENT); |
141 | } | |
142 | ||
143 | private JList<CategoryPreference> getCategories(BorderLayout borderLayoutPreferences) { | |
144 | | |
145 | JList<CategoryPreference> categories = new JList<>(CategoryPreference.values()); | |
146 |
1
1. getCategories : removed call to javax/swing/JList::setName → NO_COVERAGE |
categories.setName("listCategoriesPreference"); |
147 |
1
1. getCategories : removed call to javax/swing/JList::setSelectionMode → NO_COVERAGE |
categories.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
148 |
1
1. getCategories : removed call to javax/swing/JList::setSelectedIndex → NO_COVERAGE |
categories.setSelectedIndex(0); |
149 | | |
150 |
1
1. getCategories : removed call to javax/swing/JList::setBorder → NO_COVERAGE |
categories.setBorder(BorderFactory.createLineBorder(UiUtil.COLOR_COMPONENT_BORDER)); |
151 |
1
1. getCategories : removed call to javax/swing/JList::addListSelectionListener → NO_COVERAGE |
categories.addListSelectionListener(e -> { |
152 | | |
153 |
1
1. lambda$getCategories$0 : removed call to com/jsql/view/swing/panel/PanelPreferences::remove → NO_COVERAGE |
PanelPreferences.this.remove(borderLayoutPreferences.getLayoutComponent(BorderLayout.CENTER)); |
154 |
1
1. lambda$getCategories$0 : removed call to com/jsql/view/swing/panel/PanelPreferences::add → NO_COVERAGE |
PanelPreferences.this.add(categories.getSelectedValue().getPanel(), BorderLayout.CENTER); |
155 | // Both required | |
156 |
1
1. lambda$getCategories$0 : removed call to com/jsql/view/swing/panel/PanelPreferences::revalidate → NO_COVERAGE |
PanelPreferences.this.revalidate(); |
157 |
1
1. lambda$getCategories$0 : removed call to com/jsql/view/swing/panel/PanelPreferences::repaint → NO_COVERAGE |
PanelPreferences.this.repaint(); |
158 | }); | |
159 | | |
160 |
1
1. getCategories : removed call to javax/swing/JList::setCellRenderer → NO_COVERAGE |
categories.setCellRenderer(new DefaultListCellRenderer() { |
161 | ||
162 | @Override | |
163 | public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { | |
164 | | |
165 | JLabel labelItemList = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); | |
166 | | |
167 |
1
1. getListCellRendererComponent : negated conditional → NO_COVERAGE |
if (isSelected) { |
168 | | |
169 |
1
1. getListCellRendererComponent : removed call to javax/swing/JLabel::setBackground → NO_COVERAGE |
labelItemList.setBackground(UiUtil.COLOR_FOCUS_GAINED); |
170 | | |
171 | // Hardcode color black for Mac uses white by default | |
172 |
1
1. getListCellRendererComponent : removed call to javax/swing/JLabel::setForeground → NO_COVERAGE |
labelItemList.setForeground(Color.BLACK); |
173 | } | |
174 | | |
175 |
1
1. getListCellRendererComponent : removed call to javax/swing/JLabel::setBorder → NO_COVERAGE |
labelItemList.setBorder( |
176 | BorderFactory.createCompoundBorder( | |
177 | BorderFactory.createMatteBorder(3, 3, 0, 3, Color.WHITE), | |
178 |
1
1. getListCellRendererComponent : negated conditional → NO_COVERAGE |
isSelected |
179 | ? BorderFactory.createLineBorder(UiUtil.COLOR_COMPONENT_BORDER) | |
180 | : labelItemList.getBorder() | |
181 | ) | |
182 | ); | |
183 | | |
184 |
1
1. getListCellRendererComponent : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences$1::getListCellRendererComponent → NO_COVERAGE |
return labelItemList; |
185 | } | |
186 | }); | |
187 | | |
188 |
1
1. getCategories : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getCategories → NO_COVERAGE |
return categories; |
189 | } | |
190 | | |
191 | | |
192 | // Getter and setter | |
193 | ||
194 | public PanelAuth getPanelAuth() { | |
195 |
1
1. getPanelAuth : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelAuth → NO_COVERAGE |
return this.panelAuthPreferences; |
196 | } | |
197 | ||
198 | public PanelProxy getPanelProxy() { | |
199 |
1
1. getPanelProxy : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelProxy → NO_COVERAGE |
return this.panelProxyPreferences; |
200 | } | |
201 | ||
202 | public PanelInjection getPanelInjection() { | |
203 |
1
1. getPanelInjection : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelInjection → NO_COVERAGE |
return this.panelInjectionPreferences; |
204 | } | |
205 | ||
206 | public PanelTampering getPanelTampering() { | |
207 |
1
1. getPanelTampering : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelTampering → NO_COVERAGE |
return this.panelTamperingPreferences; |
208 | } | |
209 | ||
210 | public PanelGeneral getPanelGeneral() { | |
211 |
1
1. getPanelGeneral : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelGeneral → NO_COVERAGE |
return this.panelGeneralPreferences; |
212 | } | |
213 | | |
214 | public PanelUserAgent getPanelUserAgent() { | |
215 |
1
1. getPanelUserAgent : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelUserAgent → NO_COVERAGE |
return this.panelUserAgentPreferences; |
216 | } | |
217 | | |
218 | public PanelConnection getPanelConnection() { | |
219 |
1
1. getPanelConnection : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelConnection → NO_COVERAGE |
return this.panelConnectionPreferences; |
220 | } | |
221 | ||
222 | public PanelStrategies getPanelStrategies() { | |
223 |
1
1. getPanelStrategies : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelStrategies → NO_COVERAGE |
return this.panelStrategiesPreferences; |
224 | } | |
225 | ||
226 | public ActionListener getActionListenerSave() { | |
227 |
1
1. getActionListenerSave : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getActionListenerSave → NO_COVERAGE |
return this.actionListenerSave; |
228 | } | |
229 | } | |
Mutations | ||
57 |
1.1 |
|
61 |
1.1 |
|
68 |
1.1 |
|
69 |
1.1 |
|
73 |
1.1 |
|
75 |
1.1 |
|
76 |
1.1 |
|
77 |
1.1 |
|
79 |
1.1 |
|
80 |
1.1 |
|
81 |
1.1 |
|
83 |
1.1 |
|
84 |
1.1 |
|
85 |
1.1 |
|
87 |
1.1 |
|
88 |
1.1 |
|
89 |
1.1 |
|
91 |
1.1 |
|
92 |
1.1 |
|
93 |
1.1 |
|
95 |
1.1 |
|
96 |
1.1 |
|
97 |
1.1 |
|
99 |
1.1 |
|
101 |
1.1 |
|
102 |
1.1 |
|
103 |
1.1 |
|
105 |
1.1 |
|
110 |
1.1 |
|
111 |
1.1 |
|
114 |
1.1 |
|
115 |
1.1 |
|
120 |
1.1 |
|
121 |
1.1 |
|
124 |
1.1 |
|
125 |
1.1 |
|
128 |
1.1 |
|
129 |
1.1 |
|
133 |
1.1 |
|
138 |
1.1 |
|
139 |
1.1 |
|
140 |
1.1 |
|
146 |
1.1 |
|
147 |
1.1 |
|
148 |
1.1 |
|
150 |
1.1 |
|
151 |
1.1 |
|
153 |
1.1 |
|
154 |
1.1 |
|
156 |
1.1 |
|
157 |
1.1 |
|
160 |
1.1 |
|
167 |
1.1 |
|
169 |
1.1 |
|
172 |
1.1 |
|
175 |
1.1 |
|
178 |
1.1 |
|
184 |
1.1 |
|
188 |
1.1 |
|
195 |
1.1 |
|
199 |
1.1 |
|
203 |
1.1 |
|
207 |
1.1 |
|
211 |
1.1 |
|
215 |
1.1 |
|
219 |
1.1 |
|
223 |
1.1 |
|
227 |
1.1 |