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