1 | package com.jsql.view.swing.panel; | |
2 | ||
3 | import com.jsql.util.I18nUtil; | |
4 | import com.jsql.view.swing.panel.preferences.*; | |
5 | import com.jsql.view.swing.panel.preferences.listener.ActionListenerSave; | |
6 | import com.jsql.view.swing.util.MediatorHelper; | |
7 | import com.jsql.view.swing.util.UiUtil; | |
8 | import org.apache.commons.text.WordUtils; | |
9 | ||
10 | import javax.swing.*; | |
11 | import java.awt.*; | |
12 | import java.awt.event.ActionListener; | |
13 | import java.util.Arrays; | |
14 | ||
15 | public class PanelPreferences extends JPanel { | |
16 | | |
17 | private final transient ActionListener actionListenerSave = new ActionListenerSave(this); | |
18 | | |
19 | private final PanelConnection panelConnection = new PanelConnection(this); | |
20 | private final PanelStrategies panelStrategies = new PanelStrategies(this); | |
21 | private final PanelInjection panelInjection = new PanelInjection(this); | |
22 | private final PanelTampering panelTampering = new PanelTampering(this); | |
23 | private final PanelUserAgent panelUserAgent = new PanelUserAgent(this); | |
24 | private final PanelAuthentication panelAuthentication = new PanelAuthentication(this); | |
25 | private final PanelProxy panelProxy = new PanelProxy(this); | |
26 | private final PanelGeneral panelGeneral = new PanelGeneral(this); | |
27 | ||
28 | private enum CategoryPreference { | |
29 | CONNECTION, | |
30 | STRATEGIES, | |
31 | INJECTION, | |
32 | TAMPERING, | |
33 | EXPLOIT, | |
34 | USER_AGENT, | |
35 | AUTHENTICATION, | |
36 | PROXY, | |
37 | GENERAL; | |
38 | ||
39 | @Override | |
40 | public String toString() { | |
41 |
1
1. toString : replaced return value with "" for com/jsql/view/swing/panel/PanelPreferences$CategoryPreference::toString → NO_COVERAGE |
return " "+ WordUtils.capitalizeFully(this.name()).replace('_', ' ') +" "; |
42 | } | |
43 | } | |
44 | | |
45 | public PanelPreferences() { | |
46 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::setLayout → NO_COVERAGE |
this.setLayout(new BorderLayout()); |
47 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::setBorder → NO_COVERAGE |
this.setBorder(UiUtil.BORDER_5PX); |
48 | ||
49 | var cards = new JPanel(new CardLayout()); | |
50 |
1
1. <init> : removed call to javax/swing/JPanel::setMinimumSize → NO_COVERAGE |
cards.setMinimumSize(new Dimension(0, 0)); // required |
51 | ||
52 | JList<CategoryPreference> categories = PanelPreferences.getCategories(cards); | |
53 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::add → NO_COVERAGE |
this.add(categories, BorderLayout.LINE_START); |
54 | ||
55 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE |
this.addToCard(cards, this.panelConnection, CategoryPreference.CONNECTION); |
56 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE |
this.addToCard(cards, this.panelStrategies, CategoryPreference.STRATEGIES); |
57 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE |
this.addToCard(cards, this.panelInjection, CategoryPreference.INJECTION); |
58 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE |
this.addToCard(cards, this.panelTampering, CategoryPreference.TAMPERING); |
59 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE |
this.addToCard(cards, new PanelExploit(), CategoryPreference.EXPLOIT); |
60 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE |
this.addToCard(cards, this.panelUserAgent, CategoryPreference.USER_AGENT); |
61 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE |
this.addToCard(cards, this.panelAuthentication, CategoryPreference.AUTHENTICATION); |
62 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE |
this.addToCard(cards, this.panelProxy, CategoryPreference.PROXY); |
63 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE |
this.addToCard(cards, this.panelGeneral, CategoryPreference.GENERAL); |
64 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::add → NO_COVERAGE |
this.add(cards, BorderLayout.CENTER); |
65 | ||
66 |
2
1. <init> : removed call to javax/swing/SwingUtilities::invokeLater → NO_COVERAGE 2. lambda$new$0 : removed call to com/jsql/view/swing/menubar/AppMenubar::switchLocale → NO_COVERAGE |
SwingUtilities.invokeLater(() -> MediatorHelper.menubar().switchLocale(I18nUtil.getCurrentLocale())); // required for arabic |
67 | } | |
68 | ||
69 | private static JList<CategoryPreference> getCategories(JPanel cards) { | |
70 | JList<CategoryPreference> categories = new JList<>(CategoryPreference.values()); | |
71 |
1
1. getCategories : removed call to javax/swing/JList::setMinimumSize → NO_COVERAGE |
categories.setMinimumSize(new Dimension(0, 0)); |
72 |
1
1. getCategories : removed call to javax/swing/JList::setName → NO_COVERAGE |
categories.setName("listCategoriesPreference"); |
73 |
1
1. getCategories : removed call to javax/swing/JList::setSelectionMode → NO_COVERAGE |
categories.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
74 |
1
1. getCategories : removed call to javax/swing/JList::setSelectedIndex → NO_COVERAGE |
categories.setSelectedIndex(0); |
75 |
1
1. getCategories : removed call to javax/swing/JList::addListSelectionListener → NO_COVERAGE |
categories.addListSelectionListener(e -> { |
76 | CardLayout cardLayout = (CardLayout) cards.getLayout(); | |
77 |
1
1. lambda$getCategories$1 : removed call to java/awt/CardLayout::show → NO_COVERAGE |
cardLayout.show(cards, categories.getSelectedValue().name()); |
78 | }); | |
79 |
1
1. getCategories : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getCategories → NO_COVERAGE |
return categories; |
80 | } | |
81 | ||
82 | private void addToCard(JPanel cards, JPanel panel, CategoryPreference category) { | |
83 |
1
1. addToCard : removed call to javax/swing/JPanel::setBorder → NO_COVERAGE |
panel.setBorder(BorderFactory.createEmptyBorder(10, 15, 10, 15)); |
84 |
1
1. addToCard : negated conditional → NO_COVERAGE |
if (Arrays.asList(CategoryPreference.USER_AGENT, CategoryPreference.EXPLOIT).contains(category)) { |
85 |
1
1. addToCard : removed call to javax/swing/JPanel::add → NO_COVERAGE |
cards.add(panel, category.name()); |
86 | } else { | |
87 | var scrollPane = new JScrollPane(panel); | |
88 |
1
1. addToCard : removed call to javax/swing/JScrollPane::setBorder → NO_COVERAGE |
scrollPane.setBorder(BorderFactory.createEmptyBorder()); // required to hide border |
89 |
1
1. addToCard : removed call to javax/swing/JScrollBar::setUnitIncrement → NO_COVERAGE |
scrollPane.getVerticalScrollBar().setUnitIncrement(16); |
90 |
1
1. addToCard : removed call to javax/swing/JScrollBar::setUnitIncrement → NO_COVERAGE |
scrollPane.getHorizontalScrollBar().setUnitIncrement(16); |
91 |
1
1. addToCard : removed call to javax/swing/JPanel::add → NO_COVERAGE |
cards.add(scrollPane, category.name()); |
92 | } | |
93 | } | |
94 | ||
95 | | |
96 | // Getter and setter | |
97 | ||
98 | public PanelAuthentication getPanelAuthentication() { | |
99 |
1
1. getPanelAuthentication : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelAuthentication → NO_COVERAGE |
return this.panelAuthentication; |
100 | } | |
101 | ||
102 | public PanelProxy getPanelProxy() { | |
103 |
1
1. getPanelProxy : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelProxy → NO_COVERAGE |
return this.panelProxy; |
104 | } | |
105 | ||
106 | public PanelInjection getPanelInjection() { | |
107 |
1
1. getPanelInjection : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelInjection → NO_COVERAGE |
return this.panelInjection; |
108 | } | |
109 | ||
110 | public PanelTampering getPanelTampering() { | |
111 |
1
1. getPanelTampering : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelTampering → NO_COVERAGE |
return this.panelTampering; |
112 | } | |
113 | ||
114 | public PanelGeneral getPanelGeneral() { | |
115 |
1
1. getPanelGeneral : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelGeneral → NO_COVERAGE |
return this.panelGeneral; |
116 | } | |
117 | | |
118 | public PanelConnection getPanelConnection() { | |
119 |
1
1. getPanelConnection : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelConnection → NO_COVERAGE |
return this.panelConnection; |
120 | } | |
121 | ||
122 | public PanelStrategies getPanelStrategies() { | |
123 |
1
1. getPanelStrategies : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelStrategies → NO_COVERAGE |
return this.panelStrategies; |
124 | } | |
125 | ||
126 | public PanelUserAgent getPanelUserAgent() { | |
127 |
1
1. getPanelUserAgent : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelUserAgent → NO_COVERAGE |
return this.panelUserAgent; |
128 | } | |
129 | ||
130 | public ActionListener getActionListenerSave() { | |
131 |
1
1. getActionListenerSave : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getActionListenerSave → NO_COVERAGE |
return this.actionListenerSave; |
132 | } | |
133 | } | |
Mutations | ||
41 |
1.1 |
|
46 |
1.1 |
|
47 |
1.1 |
|
50 |
1.1 |
|
53 |
1.1 |
|
55 |
1.1 |
|
56 |
1.1 |
|
57 |
1.1 |
|
58 |
1.1 |
|
59 |
1.1 |
|
60 |
1.1 |
|
61 |
1.1 |
|
62 |
1.1 |
|
63 |
1.1 |
|
64 |
1.1 |
|
66 |
1.1 2.2 |
|
71 |
1.1 |
|
72 |
1.1 |
|
73 |
1.1 |
|
74 |
1.1 |
|
75 |
1.1 |
|
77 |
1.1 |
|
79 |
1.1 |
|
83 |
1.1 |
|
84 |
1.1 |
|
85 |
1.1 |
|
88 |
1.1 |
|
89 |
1.1 |
|
90 |
1.1 |
|
91 |
1.1 |
|
99 |
1.1 |
|
103 |
1.1 |
|
107 |
1.1 |
|
111 |
1.1 |
|
115 |
1.1 |
|
119 |
1.1 |
|
123 |
1.1 |
|
127 |
1.1 |
|
131 |
1.1 |