1 | /******************************************************************************* | |
2 | * Copyhacked (H) 2012-2025. | |
3 | * This program and the accompanying materials | |
4 | * are made available under no term at all, use it like | |
5 | * you want, but share and discuss it | |
6 | * every time possible with every body. | |
7 | * | |
8 | * Contributors: | |
9 | * ron190 at ymail dot com - initial implementation | |
10 | ******************************************************************************/ | |
11 | package com.jsql.view.swing.panel; | |
12 | ||
13 | import com.formdev.flatlaf.FlatClientProperties; | |
14 | import com.formdev.flatlaf.icons.FlatRadioButtonMenuItemIcon; | |
15 | import com.jsql.model.injection.method.AbstractMethodInjection; | |
16 | import com.jsql.util.I18nUtil; | |
17 | import com.jsql.util.LogLevelUtil; | |
18 | import com.jsql.util.ParameterUtil; | |
19 | import com.jsql.util.StringUtil; | |
20 | import com.jsql.view.swing.panel.address.ActionEnterAddressBar; | |
21 | import com.jsql.view.swing.panel.address.PanelTrailingAddress; | |
22 | import com.jsql.view.swing.panel.address.ModelAddressLine; | |
23 | import com.jsql.view.swing.panel.util.ButtonExpandText; | |
24 | import com.jsql.view.swing.text.*; | |
25 | import com.jsql.view.swing.text.listener.DocumentListenerEditing; | |
26 | import com.jsql.view.swing.util.I18nViewUtil; | |
27 | import com.jsql.view.swing.util.MediatorHelper; | |
28 | import com.jsql.view.swing.util.RadioItemPreventClose; | |
29 | import com.jsql.view.swing.util.UiUtil; | |
30 | import org.apache.commons.lang3.StringUtils; | |
31 | import org.apache.logging.log4j.LogManager; | |
32 | import org.apache.logging.log4j.Logger; | |
33 | ||
34 | import javax.swing.*; | |
35 | import java.awt.*; | |
36 | import java.awt.event.MouseAdapter; | |
37 | import java.awt.event.MouseEvent; | |
38 | import java.util.Arrays; | |
39 | import java.util.concurrent.atomic.AtomicReference; | |
40 | import java.util.function.Supplier; | |
41 | import java.util.stream.Stream; | |
42 | ||
43 | /** | |
44 | * Create panel at the top of the window. | |
45 | * Contains textfields in a panel. | |
46 | */ | |
47 | public class PanelAddressBar extends JPanel { | |
48 | ||
49 | /** | |
50 | * Log4j logger sent to view. | |
51 | */ | |
52 | private static final Logger LOGGER = LogManager.getRootLogger(); | |
53 | ||
54 | private final AtomicReference<JTextField> atomicTextFieldAddress = new AtomicReference<>(); // atomic to build dynamically | |
55 | private final AtomicReference<JTextField> atomicTextFieldRequest = new AtomicReference<>(); | |
56 | private final AtomicReference<JTextField> atomicTextFieldHeader = new AtomicReference<>(); | |
57 | ||
58 | private final AtomicReference<JRadioButton> atomicRadioRequest = new AtomicReference<>(); // atomic to build dynamically | |
59 | private final AtomicReference<JRadioButton> atomicRadioMethod = new AtomicReference<>(); | |
60 | private final AtomicReference<JRadioButton> atomicRadioHeader = new AtomicReference<>(); | |
61 | ||
62 | private static final String KEY_ADDRESS_BAR_PLACEHOLDER = "ADDRESS_BAR_PLACEHOLDER"; | |
63 | private static final String BUTTON_ADVANCED = "BUTTON_ADVANCED"; | |
64 | ||
65 | // Current injection method | |
66 | private AbstractMethodInjection methodInjection = MediatorHelper.model().getMediatorMethod().getQuery(); | |
67 | private String typeRequest = StringUtil.GET; | |
68 | ||
69 | private final PanelTrailingAddress panelTrailingAddress; | |
70 | ||
71 | private boolean isAdvanceActivated = false; | |
72 | | |
73 | public PanelAddressBar() { | |
74 | var buttonGroup = new ButtonGroup(); | |
75 | ||
76 | Stream.of( | |
77 | new ModelAddressLine( | |
78 | "URL", | |
79 | true, | |
80 | MediatorHelper.model().getMediatorMethod().getQuery(), | |
81 | "METHOD_QUERYSTRING_TOOLTIP", | |
82 | this.atomicRadioRequest, | |
83 | "FIELD_QUERYSTRING_TOOLTIP", | |
84 | I18nUtil.valueByKey(PanelAddressBar.KEY_ADDRESS_BAR_PLACEHOLDER), | |
85 | this.atomicTextFieldAddress, | |
86 | 18 | |
87 | ), | |
88 | new ModelAddressLine( | |
89 | StringUtil.GET, | |
90 | false, | |
91 | MediatorHelper.model().getMediatorMethod().getRequest(), | |
92 | "METHOD_REQUEST_TOOLTIP", | |
93 | this.atomicRadioMethod, | |
94 | "FIELD_REQUEST_TOOLTIP", | |
95 | "e.g. key=value&injectMe=", | |
96 | this.atomicTextFieldRequest, | |
97 | 0 | |
98 | ), | |
99 | new ModelAddressLine( | |
100 | "Header", | |
101 | false, | |
102 | MediatorHelper.model().getMediatorMethod().getHeader(), | |
103 | "METHOD_HEADER_TOOLTIP", | |
104 | this.atomicRadioHeader, | |
105 | "FIELD_HEADER_TOOLTIP", | |
106 | "e.g. key: value\\r\\nCookie: cKey1=cValue1; cKey2=cValue2\\r\\nAuthorization: Basic dXNlcjpwYXNz\\r\\ninjectMe:", | |
107 | this.atomicTextFieldHeader, | |
108 | 0 | |
109 | ) | |
110 | ) | |
111 |
1
1. <init> : removed call to java/util/stream/Stream::forEach → NO_COVERAGE |
.forEach(modelLine -> { |
112 | var tooltipTextfield = new AtomicReference<>(new JToolTipI18n(I18nUtil.valueByKey(modelLine.keyTooltipQuery))); | |
113 |
1
1. lambda$new$1 : removed call to java/util/concurrent/atomic/AtomicReference::set → NO_COVERAGE |
modelLine.textfield.set(new JPopupTextField(new JTextFieldPlaceholder(modelLine.placeholder, modelLine.offset) { |
114 | @Override | |
115 | public JToolTip createToolTip() { | |
116 |
1
1. createToolTip : replaced return value with null for com/jsql/view/swing/panel/PanelAddressBar$1::createToolTip → NO_COVERAGE |
return tooltipTextfield.get(); |
117 | } | |
118 | }).getProxy()); | |
119 |
1
1. lambda$new$1 : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey(modelLine.keyTooltipQuery, tooltipTextfield.get()); |
120 |
1
1. lambda$new$1 : removed call to javax/swing/JTextField::addActionListener → NO_COVERAGE |
modelLine.textfield.get().addActionListener(new ActionEnterAddressBar(this)); |
121 |
1
1. lambda$new$1 : removed call to javax/swing/JTextField::setVisible → NO_COVERAGE |
modelLine.textfield.get().setVisible(false); // query will be set back to visible |
122 |
1
1. lambda$new$1 : removed call to javax/swing/JTextField::setToolTipText → NO_COVERAGE |
modelLine.textfield.get().setToolTipText(I18nUtil.valueByKey(modelLine.keyTooltipQuery)); |
123 | ||
124 | var tooltipRadio = new AtomicReference<>(new JToolTipI18n(I18nUtil.valueByKey(modelLine.i18nRadio))); | |
125 |
1
1. lambda$new$1 : removed call to java/util/concurrent/atomic/AtomicReference::set → NO_COVERAGE |
modelLine.radio.set( |
126 | new JRadioButton(modelLine.request) { | |
127 | @Override | |
128 | public JToolTip createToolTip() { | |
129 |
1
1. createToolTip : replaced return value with null for com/jsql/view/swing/panel/PanelAddressBar$2::createToolTip → NO_COVERAGE |
return tooltipRadio.get(); |
130 | } | |
131 | } | |
132 | ); | |
133 |
1
1. lambda$new$1 : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey(modelLine.i18nRadio, tooltipRadio.get()); |
134 |
1
1. lambda$new$1 : removed call to javax/swing/JRadioButton::setToolTipText → NO_COVERAGE |
modelLine.radio.get().setToolTipText(I18nUtil.valueByKey(modelLine.i18nRadio)); |
135 |
1
1. lambda$new$1 : removed call to javax/swing/JRadioButton::setSelected → NO_COVERAGE |
modelLine.radio.get().setSelected(modelLine.isSelected); |
136 |
1
1. lambda$new$1 : removed call to javax/swing/JRadioButton::setHorizontalTextPosition → NO_COVERAGE |
modelLine.radio.get().setHorizontalTextPosition(SwingConstants.LEFT); |
137 |
1
1. lambda$new$1 : removed call to javax/swing/JRadioButton::setVisible → NO_COVERAGE |
modelLine.radio.get().setVisible(false); |
138 |
2
1. lambda$new$1 : removed call to javax/swing/JRadioButton::addActionListener → NO_COVERAGE 2. lambda$new$0 : removed call to com/jsql/view/swing/panel/PanelAddressBar::setMethodInjection → NO_COVERAGE |
modelLine.radio.get().addActionListener(e -> MediatorHelper.panelAddressBar().setMethodInjection(modelLine.method)); |
139 |
1
1. lambda$new$1 : removed call to javax/swing/ButtonGroup::add → NO_COVERAGE |
buttonGroup.add(modelLine.radio.get()); |
140 | }); | |
141 | ||
142 |
1
1. <init> : removed call to javax/swing/JTextField::setFont → NO_COVERAGE |
this.atomicTextFieldAddress.get().setFont(UiUtil.FONT_NON_MONO_BIG); |
143 |
1
1. <init> : removed call to javax/swing/JTextField::setName → NO_COVERAGE |
this.atomicTextFieldAddress.get().setName("textFieldAddress"); |
144 |
1
1. <init> : removed call to javax/swing/JTextField::setPreferredSize → NO_COVERAGE |
this.atomicTextFieldAddress.get().setPreferredSize(new Dimension(50, 32)); // required to set correct height |
145 |
1
1. <init> : removed call to javax/swing/JTextField::setVisible → NO_COVERAGE |
this.atomicTextFieldAddress.get().setVisible(true); |
146 |
1
1. <init> : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey(PanelAddressBar.KEY_ADDRESS_BAR_PLACEHOLDER, this.atomicTextFieldAddress.get()); // only i18n placeholder |
147 | ||
148 |
1
1. <init> : removed call to javax/swing/JRadioButton::setBorder → NO_COVERAGE |
this.atomicRadioRequest.get().setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 3)); |
149 |
1
1. <init> : removed call to javax/swing/JRadioButton::setBorder → NO_COVERAGE |
this.atomicRadioMethod.get().setBorder(BorderFactory.createEmptyBorder(6, 3, 0, 3)); |
150 |
1
1. <init> : removed call to javax/swing/JRadioButton::setBorder → NO_COVERAGE |
this.atomicRadioHeader.get().setBorder(BorderFactory.createEmptyBorder(6, 3, 0, 3)); |
151 | ||
152 | this.panelTrailingAddress = new PanelTrailingAddress(this); | |
153 |
1
1. <init> : removed call to javax/swing/JTextField::putClientProperty → NO_COVERAGE |
this.atomicTextFieldAddress.get().putClientProperty(FlatClientProperties.TEXT_FIELD_TRAILING_COMPONENT, this.panelTrailingAddress); |
154 |
1
1. <init> : removed call to javax/swing/JTextField::putClientProperty → NO_COVERAGE |
this.atomicTextFieldAddress.get().putClientProperty(FlatClientProperties.TEXT_FIELD_LEADING_ICON, UiUtil.GLOBE.getIcon()); |
155 |
1
1. <init> : removed call to javax/swing/JTextField::putClientProperty → NO_COVERAGE |
this.atomicTextFieldRequest.get().putClientProperty( |
156 | FlatClientProperties.TEXT_FIELD_TRAILING_COMPONENT, | |
157 | new ButtonExpandText(this.atomicTextFieldRequest.get()) | |
158 | ); | |
159 |
1
1. <init> : removed call to javax/swing/JTextField::putClientProperty → NO_COVERAGE |
this.atomicTextFieldHeader.get().putClientProperty( |
160 | FlatClientProperties.TEXT_FIELD_TRAILING_COMPONENT, | |
161 | new ButtonExpandText(this.atomicTextFieldHeader.get()) | |
162 | ); | |
163 | ||
164 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelAddressBar::initLayout → NO_COVERAGE |
this.initLayout(); |
165 | } | |
166 | ||
167 | private void initLayout() { | |
168 | final JLabel advancedButton = this.initAdvancedButton(); | |
169 | | |
170 |
1
1. initLayout : removed call to com/jsql/view/swing/panel/PanelAddressBar::setLayout → NO_COVERAGE |
this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); |
171 | | |
172 | // First panel at the top, contains text components | |
173 | var panelTextFields = new JPanel(); | |
174 | var groupLayout = new GroupLayout(panelTextFields); | |
175 |
1
1. initLayout : removed call to javax/swing/JPanel::setLayout → NO_COVERAGE |
panelTextFields.setLayout(groupLayout); |
176 |
1
1. initLayout : removed call to javax/swing/JPanel::setBorder → NO_COVERAGE |
panelTextFields.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 0)); |
177 | this.add(panelTextFields); | |
178 | ||
179 | final var popup = new JPopupMenu(); | |
180 | final var buttonGroupMethod = new ButtonGroup(); | |
181 | ||
182 | for (String method: new String[]{ "DELETE", StringUtil.GET, "HEAD", "OPTIONS", StringUtil.POST, "PUT", "TRACE" }) { | |
183 | final JMenuItem newMenuItem = new RadioItemPreventClose(method, StringUtil.GET.equals(method)); | |
184 |
1
1. initLayout : removed call to javax/swing/JMenuItem::addActionListener → NO_COVERAGE |
newMenuItem.addActionListener(actionEvent -> { |
185 | this.typeRequest = newMenuItem.getText(); | |
186 |
1
1. lambda$initLayout$2 : removed call to javax/swing/JRadioButton::setText → NO_COVERAGE |
this.atomicRadioMethod.get().setText(this.typeRequest); |
187 | this.atomicRadioMethod.get().requestFocusInWindow(); // required to set proper focus | |
188 | }); | |
189 | popup.add(newMenuItem); | |
190 |
1
1. initLayout : removed call to javax/swing/ButtonGroup::add → NO_COVERAGE |
buttonGroupMethod.add(newMenuItem); |
191 | } | |
192 | ||
193 | var tooltipPanel = new AtomicReference<>(new JToolTipI18n(I18nUtil.valueByKey("METHOD_CUSTOM_TOOLTIP"))); | |
194 | var panelCustomMethod = new JPanel(new BorderLayout()) { | |
195 | @Override | |
196 | public JToolTip createToolTip() { | |
197 |
1
1. createToolTip : replaced return value with null for com/jsql/view/swing/panel/PanelAddressBar$3::createToolTip → NO_COVERAGE |
return tooltipPanel.get(); |
198 | } | |
199 | }; | |
200 |
1
1. initLayout : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey("METHOD_CUSTOM_TOOLTIP", tooltipPanel.get()); |
201 |
1
1. lambda$initLayout$3 : replaced return value with null for com/jsql/view/swing/panel/PanelAddressBar::lambda$initLayout$3 → NO_COVERAGE |
Supplier<Color> colorBackground = () -> UIManager.getColor("MenuItem.background"); // adapt to current theme |
202 |
1
1. lambda$initLayout$4 : replaced return value with null for com/jsql/view/swing/panel/PanelAddressBar::lambda$initLayout$4 → NO_COVERAGE |
Supplier<Color> colorSelectionBackground = () -> UIManager.getColor("MenuItem.selectionBackground"); // adapt to current theme |
203 |
1
1. initLayout : removed call to com/jsql/view/swing/panel/PanelAddressBar$3::setBackground → NO_COVERAGE |
panelCustomMethod.setBackground(colorBackground.get()); // required for correct color |
204 | ||
205 | final var radioCustomMethod = new JRadioButton() { | |
206 | @Override | |
207 | public JToolTip createToolTip() { | |
208 |
1
1. createToolTip : replaced return value with null for com/jsql/view/swing/panel/PanelAddressBar$4::createToolTip → NO_COVERAGE |
return tooltipPanel.get(); |
209 | } | |
210 | }; | |
211 |
1
1. initLayout : removed call to com/jsql/view/swing/panel/PanelAddressBar$4::setBorder → NO_COVERAGE |
radioCustomMethod.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 0)); |
212 |
1
1. initLayout : removed call to com/jsql/view/swing/panel/PanelAddressBar$4::setIcon → NO_COVERAGE |
radioCustomMethod.setIcon(new FlatRadioButtonMenuItemIcon()); |
213 |
1
1. initLayout : removed call to com/jsql/view/swing/panel/PanelAddressBar$4::setBackground → NO_COVERAGE |
radioCustomMethod.setBackground(colorBackground.get()); // required for correct color |
214 |
1
1. initLayout : removed call to javax/swing/ButtonGroup::add → NO_COVERAGE |
buttonGroupMethod.add(radioCustomMethod); |
215 | ||
216 | final JTextField inputCustomMethod = new JPopupTextField("CUSTOM"){ | |
217 | @Override | |
218 | public JToolTip createToolTip() { | |
219 |
1
1. createToolTip : replaced return value with null for com/jsql/view/swing/panel/PanelAddressBar$5::createToolTip → NO_COVERAGE |
return tooltipPanel.get(); |
220 | } | |
221 | }.getProxy(); | |
222 |
1
1. initLayout : removed call to javax/swing/JTextField::addMouseListener → NO_COVERAGE |
inputCustomMethod.addMouseListener(new MouseAdapter() { |
223 | @Override | |
224 | public void mouseClicked(MouseEvent e) { | |
225 |
2
1. mouseClicked : removed call to com/jsql/view/swing/panel/PanelAddressBar$4::setSelected → NO_COVERAGE 2. mouseClicked : negated conditional → NO_COVERAGE |
radioCustomMethod.setSelected(!radioCustomMethod.isSelected()); |
226 | } | |
227 | }); | |
228 |
1
1. initLayout : removed call to javax/swing/text/Document::addDocumentListener → NO_COVERAGE |
inputCustomMethod.getDocument().addDocumentListener(new DocumentListenerEditing() { |
229 | @Override | |
230 | public void process() { | |
231 |
1
1. process : removed call to com/jsql/view/swing/panel/PanelAddressBar::validate → NO_COVERAGE |
PanelAddressBar.this.validate(inputCustomMethod); |
232 | } | |
233 | }); | |
234 |
2
1. initLayout : removed call to com/jsql/view/swing/panel/PanelAddressBar$4::addActionListener → NO_COVERAGE 2. lambda$initLayout$5 : removed call to com/jsql/view/swing/panel/PanelAddressBar::validate → NO_COVERAGE |
radioCustomMethod.addActionListener(actionEvent -> this.validate(inputCustomMethod)); |
235 | ||
236 | var tooltipCustomMethod = "<html>Set user defined HTTP method.<br/>" + | |
237 | "A valid method is limited to chars:<br>" + | |
238 | "!#$%&'*+-.^_`|~0123456789<br>" + | |
239 | "abcdefghijklmnopqrstuvwxyz<br>" + | |
240 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + | |
241 | "</html>"; | |
242 | MouseAdapter mouseAdapterSetBackground = new MouseAdapter() { | |
243 | @Override | |
244 | public void mouseEntered(MouseEvent e) { | |
245 |
1
1. mouseEntered : removed call to java/awt/event/MouseAdapter::mouseEntered → NO_COVERAGE |
super.mouseEntered(e); |
246 |
1
1. mouseEntered : removed call to com/jsql/view/swing/panel/PanelAddressBar$3::setBackground → NO_COVERAGE |
panelCustomMethod.setBackground(colorSelectionBackground.get()); |
247 |
1
1. mouseEntered : removed call to com/jsql/view/swing/panel/PanelAddressBar$4::setBackground → NO_COVERAGE |
radioCustomMethod.setBackground(colorSelectionBackground.get()); |
248 | } | |
249 | @Override | |
250 | public void mouseExited(MouseEvent e) { | |
251 |
1
1. mouseExited : removed call to java/awt/event/MouseAdapter::mouseExited → NO_COVERAGE |
super.mouseExited(e); |
252 |
1
1. mouseExited : removed call to com/jsql/view/swing/panel/PanelAddressBar$3::setBackground → NO_COVERAGE |
panelCustomMethod.setBackground(colorBackground.get()); |
253 |
1
1. mouseExited : removed call to com/jsql/view/swing/panel/PanelAddressBar$4::setBackground → NO_COVERAGE |
radioCustomMethod.setBackground(colorBackground.get()); |
254 | } | |
255 | }; | |
256 |
1
1. initLayout : removed call to java/util/List::forEach → NO_COVERAGE |
Arrays.asList(radioCustomMethod, inputCustomMethod, panelCustomMethod).forEach(component -> { |
257 |
1
1. lambda$initLayout$6 : removed call to javax/swing/JComponent::addMouseListener → NO_COVERAGE |
component.addMouseListener(mouseAdapterSetBackground); |
258 |
1
1. lambda$initLayout$6 : removed call to javax/swing/JComponent::setToolTipText → NO_COVERAGE |
component.setToolTipText(tooltipCustomMethod); |
259 | }); | |
260 | ||
261 |
1
1. initLayout : removed call to com/jsql/view/swing/panel/PanelAddressBar$3::add → NO_COVERAGE |
panelCustomMethod.add(radioCustomMethod, BorderLayout.LINE_START); |
262 |
1
1. initLayout : removed call to com/jsql/view/swing/panel/PanelAddressBar$3::add → NO_COVERAGE |
panelCustomMethod.add(inputCustomMethod, BorderLayout.CENTER); |
263 |
1
1. initLayout : removed call to javax/swing/JPopupMenu::insert → NO_COVERAGE |
popup.insert(panelCustomMethod, popup.getComponentCount()); |
264 | ||
265 |
1
1. initLayout : removed call to javax/swing/JRadioButton::addMouseListener → NO_COVERAGE |
this.atomicRadioMethod.get().addMouseListener(new MouseAdapter() { |
266 | @Override | |
267 | public void mousePressed(MouseEvent e) { | |
268 |
2
1. lambda$mousePressed$0 : replaced return value with null for com/jsql/view/swing/panel/PanelAddressBar$9::lambda$mousePressed$0 → NO_COVERAGE 2. mousePressed : removed call to java/util/stream/Stream::forEach → NO_COVERAGE |
Arrays.stream(popup.getComponents()).map(a -> (JComponent) a).forEach(JComponent::updateUI); // required: incorrect when dark/light mode switch |
269 |
1
1. mousePressed : removed call to com/jsql/view/swing/panel/PanelAddressBar$4::setIcon → NO_COVERAGE |
radioCustomMethod.setIcon(new FlatRadioButtonMenuItemIcon()); |
270 |
1
1. mousePressed : removed call to com/jsql/view/swing/panel/PanelAddressBar$4::updateUI → NO_COVERAGE |
radioCustomMethod.updateUI(); // required: incorrect when dark/light mode switch |
271 |
1
1. mousePressed : removed call to javax/swing/JTextField::updateUI → NO_COVERAGE |
inputCustomMethod.updateUI(); // required: incorrect when dark/light mode switch |
272 |
1
1. mousePressed : removed call to javax/swing/JPopupMenu::updateUI → NO_COVERAGE |
popup.updateUI(); // required: incorrect when dark/light mode switch |
273 |
1
1. mousePressed : removed call to javax/swing/JPopupMenu::applyComponentOrientation → NO_COVERAGE |
popup.applyComponentOrientation(ComponentOrientation.getOrientation(I18nUtil.getCurrentLocale())); |
274 | ||
275 |
1
1. mousePressed : negated conditional → NO_COVERAGE |
if (ComponentOrientation.RIGHT_TO_LEFT.equals(ComponentOrientation.getOrientation(I18nUtil.getCurrentLocale()))) { |
276 |
1
1. mousePressed : removed call to com/jsql/view/swing/panel/PanelAddressBar$4::setBorder → NO_COVERAGE |
radioCustomMethod.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 6)); |
277 | } else { | |
278 |
1
1. mousePressed : removed call to com/jsql/view/swing/panel/PanelAddressBar$4::setBorder → NO_COVERAGE |
radioCustomMethod.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 0)); |
279 | } | |
280 | ||
281 | // TODO Failure on arabic | |
282 | // Fix #96032: NullPointerException on show() | |
283 | try { | |
284 |
1
1. mousePressed : removed call to javax/swing/JPopupMenu::show → NO_COVERAGE |
popup.show( |
285 | e.getComponent(), | |
286 |
1
1. mousePressed : negated conditional → NO_COVERAGE |
ComponentOrientation.RIGHT_TO_LEFT.equals(ComponentOrientation.getOrientation(I18nUtil.getCurrentLocale())) |
287 |
2
1. mousePressed : Replaced integer subtraction with addition → NO_COVERAGE 2. mousePressed : Replaced integer subtraction with addition → NO_COVERAGE |
? e.getComponent().getX() - e.getComponent().getWidth() - popup.getWidth() |
288 | : e.getComponent().getX(), | |
289 |
1
1. mousePressed : Replaced integer addition with subtraction → NO_COVERAGE |
e.getComponent().getY() + e.getComponent().getHeight() |
290 | ); | |
291 |
1
1. mousePressed : removed call to javax/swing/JPopupMenu::setLocation → NO_COVERAGE |
popup.setLocation( // required for proper location |
292 |
1
1. mousePressed : negated conditional → NO_COVERAGE |
ComponentOrientation.RIGHT_TO_LEFT.equals(ComponentOrientation.getOrientation(I18nUtil.getCurrentLocale())) |
293 |
2
1. mousePressed : Replaced integer subtraction with addition → NO_COVERAGE 2. mousePressed : Replaced integer addition with subtraction → NO_COVERAGE |
? e.getComponent().getLocationOnScreen().x + e.getComponent().getWidth() - popup.getWidth() |
294 | : e.getComponent().getLocationOnScreen().x, | |
295 |
1
1. mousePressed : Replaced integer addition with subtraction → NO_COVERAGE |
e.getComponent().getLocationOnScreen().y + e.getComponent().getHeight() |
296 | ); | |
297 | } catch (NullPointerException ex) { | |
298 | LOGGER.log(LogLevelUtil.CONSOLE_JAVA, ex); | |
299 | } | |
300 | } | |
301 | }); | |
302 | ||
303 |
1
1. initLayout : removed call to javax/swing/GroupLayout::setHorizontalGroup → NO_COVERAGE |
groupLayout.setHorizontalGroup( |
304 | groupLayout | |
305 | .createSequentialGroup() | |
306 | .addGroup( | |
307 | groupLayout | |
308 | .createParallelGroup(GroupLayout.Alignment.TRAILING, false) | |
309 | .addComponent(this.atomicRadioRequest.get()) | |
310 | .addComponent(this.atomicRadioMethod.get()) | |
311 | .addComponent(this.atomicRadioHeader.get()) | |
312 | ) | |
313 | .addGroup( | |
314 | groupLayout | |
315 | .createParallelGroup() | |
316 | .addComponent(this.atomicTextFieldAddress.get()) | |
317 | .addComponent(this.atomicTextFieldRequest.get()) | |
318 | .addComponent(this.atomicTextFieldHeader.get()) | |
319 | ) | |
320 | .addGroup( | |
321 | groupLayout | |
322 | .createParallelGroup(GroupLayout.Alignment.LEADING, false) | |
323 | .addComponent(advancedButton) | |
324 | ) | |
325 | ); | |
326 | ||
327 |
1
1. initLayout : removed call to javax/swing/GroupLayout::setVerticalGroup → NO_COVERAGE |
groupLayout.setVerticalGroup( |
328 | groupLayout | |
329 | .createSequentialGroup() | |
330 | .addGroup( | |
331 | groupLayout | |
332 | .createParallelGroup(GroupLayout.Alignment.CENTER, false) | |
333 | .addComponent(this.atomicRadioRequest.get()) | |
334 | .addComponent(this.atomicTextFieldAddress.get()) | |
335 | .addComponent(advancedButton) | |
336 | ) | |
337 | .addGroup( | |
338 | groupLayout | |
339 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
340 | .addComponent(this.atomicRadioMethod.get()) | |
341 | .addComponent(this.atomicTextFieldRequest.get()) | |
342 | ) | |
343 | .addGroup( | |
344 | groupLayout | |
345 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
346 | .addComponent(this.atomicRadioHeader.get()) | |
347 | .addComponent(this.atomicTextFieldHeader.get()) | |
348 | ) | |
349 | ); | |
350 | } | |
351 | ||
352 | private void validate(JTextField inputCustomMethod) { | |
353 |
1
1. validate : negated conditional → NO_COVERAGE |
if (StringUtils.isEmpty(inputCustomMethod.getText())) { |
354 | LOGGER.log(LogLevelUtil.CONSOLE_ERROR, "Missing custom method label"); | |
355 |
1
1. validate : negated conditional → NO_COVERAGE |
} else if (ParameterUtil.isInvalidName(inputCustomMethod.getText())) { |
356 | LOGGER.log(LogLevelUtil.CONSOLE_ERROR, () -> String.format("Illegal method: \"%s\"", inputCustomMethod.getText())); | |
357 | } else { | |
358 | this.typeRequest = inputCustomMethod.getText(); | |
359 |
1
1. validate : removed call to javax/swing/JRadioButton::setText → NO_COVERAGE |
this.atomicRadioMethod.get().setText(this.typeRequest); |
360 | } | |
361 | } | |
362 | ||
363 | private JLabel initAdvancedButton() { | |
364 | var tooltip = new AtomicReference<>(new JToolTipI18n(I18nUtil.valueByKey(PanelAddressBar.BUTTON_ADVANCED))); | |
365 | var advancedButton = new JLabel(UiUtil.ARROW_DOWN.getIcon()) { | |
366 | @Override | |
367 | public JToolTip createToolTip() { | |
368 |
1
1. createToolTip : replaced return value with null for com/jsql/view/swing/panel/PanelAddressBar$10::createToolTip → NO_COVERAGE |
return tooltip.get(); |
369 | } | |
370 | }; | |
371 |
1
1. initAdvancedButton : removed call to com/jsql/view/swing/panel/PanelAddressBar$10::setName → NO_COVERAGE |
advancedButton.setName("advancedButton"); |
372 |
1
1. initAdvancedButton : removed call to com/jsql/view/swing/panel/PanelAddressBar$10::setToolTipText → NO_COVERAGE |
advancedButton.setToolTipText(I18nUtil.valueByKey(PanelAddressBar.BUTTON_ADVANCED)); |
373 |
1
1. initAdvancedButton : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey(PanelAddressBar.BUTTON_ADVANCED, tooltip.get()); |
374 |
1
1. initAdvancedButton : removed call to com/jsql/view/swing/panel/PanelAddressBar$10::addMouseListener → NO_COVERAGE |
advancedButton.addMouseListener(new MouseAdapter() { |
375 | @Override | |
376 | public void mouseClicked(MouseEvent e) { | |
377 |
1
1. mouseClicked : negated conditional → NO_COVERAGE |
boolean isVisible = advancedButton.getIcon() == UiUtil.ARROW_DOWN.getIcon(); |
378 |
1
1. mouseClicked : removed call to javax/swing/JTextField::setVisible → NO_COVERAGE |
PanelAddressBar.this.atomicTextFieldRequest.get().setVisible(isVisible); |
379 |
1
1. mouseClicked : removed call to javax/swing/JTextField::setVisible → NO_COVERAGE |
PanelAddressBar.this.atomicTextFieldHeader.get().setVisible(isVisible); |
380 |
1
1. mouseClicked : removed call to javax/swing/JRadioButton::setVisible → NO_COVERAGE |
PanelAddressBar.this.atomicRadioRequest.get().setVisible(isVisible); |
381 |
1
1. mouseClicked : removed call to javax/swing/JRadioButton::setVisible → NO_COVERAGE |
PanelAddressBar.this.atomicRadioMethod.get().setVisible(isVisible); |
382 |
1
1. mouseClicked : removed call to javax/swing/JRadioButton::setVisible → NO_COVERAGE |
PanelAddressBar.this.atomicRadioHeader.get().setVisible(isVisible); |
383 | PanelAddressBar.this.isAdvanceActivated = isVisible; | |
384 |
1
1. mouseClicked : removed call to com/jsql/view/swing/menubar/AppMenubar::setVisible → NO_COVERAGE |
MediatorHelper.menubar().setVisible(isVisible); |
385 |
2
1. mouseClicked : negated conditional → NO_COVERAGE 2. mouseClicked : removed call to com/jsql/view/swing/panel/PanelAddressBar$10::setIcon → NO_COVERAGE |
advancedButton.setIcon(isVisible ? UiUtil.ARROW_UP.getIcon() : UiUtil.ARROW_DOWN.getIcon()); |
386 | } | |
387 | }); | |
388 |
1
1. initAdvancedButton : replaced return value with null for com/jsql/view/swing/panel/PanelAddressBar::initAdvancedButton → NO_COVERAGE |
return advancedButton; |
389 | } | |
390 | | |
391 | | |
392 | // Getter and setter | |
393 | ||
394 | public void setMethodInjection(AbstractMethodInjection methodInjection) { | |
395 | this.methodInjection = methodInjection; | |
396 | } | |
397 | ||
398 | public boolean isAdvanceActivated() { | |
399 |
2
1. isAdvanceActivated : replaced boolean return with true for com/jsql/view/swing/panel/PanelAddressBar::isAdvanceActivated → NO_COVERAGE 2. isAdvanceActivated : negated conditional → NO_COVERAGE |
return !this.isAdvanceActivated; |
400 | } | |
401 | ||
402 | public JTextField getTextFieldAddress() { | |
403 |
1
1. getTextFieldAddress : replaced return value with null for com/jsql/view/swing/panel/PanelAddressBar::getTextFieldAddress → NO_COVERAGE |
return this.atomicTextFieldAddress.get(); |
404 | } | |
405 | ||
406 | public JTextField getTextFieldRequest() { | |
407 |
1
1. getTextFieldRequest : replaced return value with null for com/jsql/view/swing/panel/PanelAddressBar::getTextFieldRequest → NO_COVERAGE |
return this.atomicTextFieldRequest.get(); |
408 | } | |
409 | ||
410 | public JTextField getTextFieldHeader() { | |
411 |
1
1. getTextFieldHeader : replaced return value with null for com/jsql/view/swing/panel/PanelAddressBar::getTextFieldHeader → NO_COVERAGE |
return this.atomicTextFieldHeader.get(); |
412 | } | |
413 | ||
414 | public AbstractMethodInjection getMethodInjection() { | |
415 |
1
1. getMethodInjection : replaced return value with null for com/jsql/view/swing/panel/PanelAddressBar::getMethodInjection → NO_COVERAGE |
return this.methodInjection; |
416 | } | |
417 | ||
418 | public PanelTrailingAddress getPanelTrailingAddress() { | |
419 |
1
1. getPanelTrailingAddress : replaced return value with null for com/jsql/view/swing/panel/PanelAddressBar::getPanelTrailingAddress → NO_COVERAGE |
return this.panelTrailingAddress; |
420 | } | |
421 | ||
422 | public String getTypeRequest() { | |
423 |
1
1. getTypeRequest : replaced return value with "" for com/jsql/view/swing/panel/PanelAddressBar::getTypeRequest → NO_COVERAGE |
return this.typeRequest; |
424 | } | |
425 | ||
426 | public JRadioButton getAtomicRadioRequest() { | |
427 |
1
1. getAtomicRadioRequest : replaced return value with null for com/jsql/view/swing/panel/PanelAddressBar::getAtomicRadioRequest → NO_COVERAGE |
return this.atomicRadioRequest.get(); |
428 | } | |
429 | ||
430 | public JRadioButton getAtomicRadioMethod() { | |
431 |
1
1. getAtomicRadioMethod : replaced return value with null for com/jsql/view/swing/panel/PanelAddressBar::getAtomicRadioMethod → NO_COVERAGE |
return this.atomicRadioMethod.get(); |
432 | } | |
433 | ||
434 | public JRadioButton getAtomicRadioHeader() { | |
435 |
1
1. getAtomicRadioHeader : replaced return value with null for com/jsql/view/swing/panel/PanelAddressBar::getAtomicRadioHeader → NO_COVERAGE |
return this.atomicRadioHeader.get(); |
436 | } | |
437 | } | |
Mutations | ||
111 |
1.1 |
|
113 |
1.1 |
|
116 |
1.1 |
|
119 |
1.1 |
|
120 |
1.1 |
|
121 |
1.1 |
|
122 |
1.1 |
|
125 |
1.1 |
|
129 |
1.1 |
|
133 |
1.1 |
|
134 |
1.1 |
|
135 |
1.1 |
|
136 |
1.1 |
|
137 |
1.1 |
|
138 |
1.1 2.2 |
|
139 |
1.1 |
|
142 |
1.1 |
|
143 |
1.1 |
|
144 |
1.1 |
|
145 |
1.1 |
|
146 |
1.1 |
|
148 |
1.1 |
|
149 |
1.1 |
|
150 |
1.1 |
|
153 |
1.1 |
|
154 |
1.1 |
|
155 |
1.1 |
|
159 |
1.1 |
|
164 |
1.1 |
|
170 |
1.1 |
|
175 |
1.1 |
|
176 |
1.1 |
|
184 |
1.1 |
|
186 |
1.1 |
|
190 |
1.1 |
|
197 |
1.1 |
|
200 |
1.1 |
|
201 |
1.1 |
|
202 |
1.1 |
|
203 |
1.1 |
|
208 |
1.1 |
|
211 |
1.1 |
|
212 |
1.1 |
|
213 |
1.1 |
|
214 |
1.1 |
|
219 |
1.1 |
|
222 |
1.1 |
|
225 |
1.1 2.2 |
|
228 |
1.1 |
|
231 |
1.1 |
|
234 |
1.1 2.2 |
|
245 |
1.1 |
|
246 |
1.1 |
|
247 |
1.1 |
|
251 |
1.1 |
|
252 |
1.1 |
|
253 |
1.1 |
|
256 |
1.1 |
|
257 |
1.1 |
|
258 |
1.1 |
|
261 |
1.1 |
|
262 |
1.1 |
|
263 |
1.1 |
|
265 |
1.1 |
|
268 |
1.1 2.2 |
|
269 |
1.1 |
|
270 |
1.1 |
|
271 |
1.1 |
|
272 |
1.1 |
|
273 |
1.1 |
|
275 |
1.1 |
|
276 |
1.1 |
|
278 |
1.1 |
|
284 |
1.1 |
|
286 |
1.1 |
|
287 |
1.1 2.2 |
|
289 |
1.1 |
|
291 |
1.1 |
|
292 |
1.1 |
|
293 |
1.1 2.2 |
|
295 |
1.1 |
|
303 |
1.1 |
|
327 |
1.1 |
|
353 |
1.1 |
|
355 |
1.1 |
|
359 |
1.1 |
|
368 |
1.1 |
|
371 |
1.1 |
|
372 |
1.1 |
|
373 |
1.1 |
|
374 |
1.1 |
|
377 |
1.1 |
|
378 |
1.1 |
|
379 |
1.1 |
|
380 |
1.1 |
|
381 |
1.1 |
|
382 |
1.1 |
|
384 |
1.1 |
|
385 |
1.1 2.2 |
|
388 |
1.1 |
|
399 |
1.1 2.2 |
|
403 |
1.1 |
|
407 |
1.1 |
|
411 |
1.1 |
|
415 |
1.1 |
|
419 |
1.1 |
|
423 |
1.1 |
|
427 |
1.1 |
|
431 |
1.1 |
|
435 |
1.1 |