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