RequestPanel.java

1
package com.jsql.view.swing.panel.address;
2
3
import com.jsql.util.I18nUtil;
4
import com.jsql.util.LogLevelUtil;
5
import com.jsql.view.swing.panel.PanelAddressBar;
6
import com.jsql.view.swing.panel.util.RadioMenuItemIconCustom;
7
import com.jsql.view.swing.text.JPopupTextField;
8
import org.apache.commons.lang3.StringUtils;
9
import org.apache.logging.log4j.LogManager;
10
import org.apache.logging.log4j.Logger;
11
12
import javax.swing.*;
13
import javax.swing.plaf.basic.BasicArrowButton;
14
import javax.swing.plaf.basic.BasicRadioButtonMenuItemUI;
15
import java.awt.*;
16
import java.awt.event.MouseAdapter;
17
import java.awt.event.MouseEvent;
18
import java.util.Collections;
19
20
public class RequestPanel extends JPanel {
21
    
22
    /**
23
     * Log4j logger sent to view.
24
     */
25
    private static final Logger LOGGER = LogManager.getRootLogger();
26
27
    private String typeRequest = "GET";
28
29
    public RequestPanel(PanelAddressBar panelAddressBar) {
30
        
31 1 1. <init> : removed call to com/jsql/view/swing/panel/address/RequestPanel::setLayout → NO_COVERAGE
        this.setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
32 1 1. <init> : removed call to com/jsql/view/swing/panel/address/RequestPanel::setMaximumSize → NO_COVERAGE
        this.setMaximumSize(new Dimension(Integer.MAX_VALUE, 16));
33 1 1. <init> : removed call to com/jsql/view/swing/panel/address/RequestPanel::setBorder → NO_COVERAGE
        this.setBorder(null);
34
        
35
        JButton buttonRequestMethod = new BasicArrowButton(SwingConstants.SOUTH);
36 1 1. <init> : removed call to javax/swing/JButton::setBorderPainted → NO_COVERAGE
        buttonRequestMethod.setBorderPainted(false);
37 1 1. <init> : removed call to javax/swing/JButton::setOpaque → NO_COVERAGE
        buttonRequestMethod.setOpaque(false);
38
        
39
        this.add(buttonRequestMethod);
40
        this.add(panelAddressBar.getRadioRequest());
41
        
42
        final var popup = new JPopupMenu();
43
        final var buttonGroup = new ButtonGroup();
44
        
45
        for (String protocol: new String[]{"DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT", "TRACE"}) {
46
            
47
            final JMenuItem newMenuItem = new JRadioButtonMenuItem(protocol, "GET".equals(protocol));
48
            
49 1 1. <init> : removed call to javax/swing/JMenuItem::addActionListener → NO_COVERAGE
            newMenuItem.addActionListener(actionEvent -> {
50
                
51
                this.typeRequest = (newMenuItem.getText());
52 1 1. lambda$new$0 : removed call to com/jsql/view/swing/radio/RadioLinkMethod::setText → NO_COVERAGE
                panelAddressBar.getRadioRequest().setText(this.typeRequest);
53
            });
54
            
55
            popup.add(newMenuItem);
56 1 1. <init> : removed call to javax/swing/ButtonGroup::add → NO_COVERAGE
            buttonGroup.add(newMenuItem);
57
        }
58
        
59
        for (AbstractButton radioButton: Collections.list(buttonGroup.getElements())) {
60 1 1. <init> : removed call to javax/swing/AbstractButton::setUI → NO_COVERAGE
            radioButton.setUI(
61
                new BasicRadioButtonMenuItemUI() {
62
                    @Override
63
                    protected void doClick(MenuSelectionManager msm) {
64 1 1. doClick : removed call to javax/swing/JMenuItem::doClick → NO_COVERAGE
                        this.menuItem.doClick(0);
65
                    }
66
                }
67
            );
68
        }
69
        
70
        var panelCustomMethod = new JPanel(new BorderLayout());
71
        final JTextField inputCustomMethod = new JPopupTextField("CUSTOM").getProxy();
72
73
        final var radioCustomMethod = new JRadioButton();
74 1 1. <init> : removed call to javax/swing/JRadioButton::setBorder → NO_COVERAGE
        radioCustomMethod.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 0));
75 1 1. <init> : removed call to javax/swing/JRadioButton::setIcon → NO_COVERAGE
        radioCustomMethod.setIcon(new RadioMenuItemIconCustom());
76
        
77 1 1. <init> : removed call to javax/swing/ButtonGroup::add → NO_COVERAGE
        buttonGroup.add(radioCustomMethod);
78
        
79 1 1. <init> : removed call to javax/swing/JRadioButton::addActionListener → NO_COVERAGE
        radioCustomMethod.addActionListener(actionEvent -> {
80 1 1. lambda$new$1 : negated conditional → NO_COVERAGE
            if (StringUtils.isNotEmpty(inputCustomMethod.getText())) {
81
                
82
                this.typeRequest = inputCustomMethod.getText();
83 1 1. lambda$new$1 : removed call to com/jsql/view/swing/radio/RadioLinkMethod::setText → NO_COVERAGE
                panelAddressBar.getRadioRequest().setText(this.typeRequest);
84
                
85
            } else {
86
                LOGGER.log(LogLevelUtil.CONSOLE_ERROR, "Define label of Custom request method");
87
            }
88
        });
89
      
90 1 1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE
        panelCustomMethod.add(radioCustomMethod, BorderLayout.LINE_START);
91 1 1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE
        panelCustomMethod.add(inputCustomMethod, BorderLayout.CENTER);
92 1 1. <init> : removed call to javax/swing/JPopupMenu::insert → NO_COVERAGE
        popup.insert(panelCustomMethod, popup.getComponentCount());
93
        
94 1 1. <init> : removed call to javax/swing/JButton::addMouseListener → NO_COVERAGE
        buttonRequestMethod.addMouseListener(new MouseAdapter() {
95
            
96
            @Override
97
            public void mousePressed(MouseEvent e) {
98
                
99 1 1. mousePressed : removed call to javax/swing/JPopupMenu::applyComponentOrientation → NO_COVERAGE
                popup.applyComponentOrientation(ComponentOrientation.getOrientation(I18nUtil.getLocaleDefault()));
100
                
101 1 1. mousePressed : negated conditional → NO_COVERAGE
                if (ComponentOrientation.RIGHT_TO_LEFT.equals(ComponentOrientation.getOrientation(I18nUtil.getLocaleDefault()))) {
102 1 1. mousePressed : removed call to javax/swing/JRadioButton::setBorder → NO_COVERAGE
                    radioCustomMethod.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 6));
103
                } else {
104 1 1. mousePressed : removed call to javax/swing/JRadioButton::setBorder → NO_COVERAGE
                    radioCustomMethod.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 0));
105
                }
106
                
107 1 1. mousePressed : removed call to javax/swing/JPopupMenu::show → NO_COVERAGE
                popup.show(
108
                    e.getComponent(),
109 1 1. mousePressed : negated conditional → NO_COVERAGE
                    ComponentOrientation.RIGHT_TO_LEFT.equals(ComponentOrientation.getOrientation(I18nUtil.getLocaleDefault()))
110 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()
111
                    : e.getComponent().getX(),
112 1 1. mousePressed : Replaced integer addition with subtraction → NO_COVERAGE
                    e.getComponent().getY() + e.getComponent().getWidth()
113
                );
114
                
115 1 1. mousePressed : removed call to javax/swing/JPopupMenu::setLocation → NO_COVERAGE
                popup.setLocation(
116 1 1. mousePressed : negated conditional → NO_COVERAGE
                    ComponentOrientation.RIGHT_TO_LEFT.equals(ComponentOrientation.getOrientation(I18nUtil.getLocaleDefault()))
117 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()
118
                    : e.getComponent().getLocationOnScreen().x,
119 1 1. mousePressed : Replaced integer addition with subtraction → NO_COVERAGE
                    e.getComponent().getLocationOnScreen().y + e.getComponent().getWidth()
120
                );
121
            }
122
        });
123
    }
124
125
    public String getTypeRequest() {
126 1 1. getTypeRequest : replaced return value with "" for com/jsql/view/swing/panel/address/RequestPanel::getTypeRequest → NO_COVERAGE
        return this.typeRequest;
127
    }
128
129
    public void setTypeRequest(String typeRequest) {
130
        this.typeRequest = typeRequest;
131
    }
132
}

Mutations

31

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/address/RequestPanel::setLayout → NO_COVERAGE

32

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/address/RequestPanel::setMaximumSize → NO_COVERAGE

33

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/address/RequestPanel::setBorder → NO_COVERAGE

36

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JButton::setBorderPainted → NO_COVERAGE

37

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JButton::setOpaque → NO_COVERAGE

49

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JMenuItem::addActionListener → NO_COVERAGE

52

1.1
Location : lambda$new$0
Killed by : none
removed call to com/jsql/view/swing/radio/RadioLinkMethod::setText → NO_COVERAGE

56

1.1
Location : <init>
Killed by : none
removed call to javax/swing/ButtonGroup::add → NO_COVERAGE

60

1.1
Location : <init>
Killed by : none
removed call to javax/swing/AbstractButton::setUI → NO_COVERAGE

64

1.1
Location : doClick
Killed by : none
removed call to javax/swing/JMenuItem::doClick → NO_COVERAGE

74

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JRadioButton::setBorder → NO_COVERAGE

75

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JRadioButton::setIcon → NO_COVERAGE

77

1.1
Location : <init>
Killed by : none
removed call to javax/swing/ButtonGroup::add → NO_COVERAGE

79

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JRadioButton::addActionListener → NO_COVERAGE

80

1.1
Location : lambda$new$1
Killed by : none
negated conditional → NO_COVERAGE

83

1.1
Location : lambda$new$1
Killed by : none
removed call to com/jsql/view/swing/radio/RadioLinkMethod::setText → NO_COVERAGE

90

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JPanel::add → NO_COVERAGE

91

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JPanel::add → NO_COVERAGE

92

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JPopupMenu::insert → NO_COVERAGE

94

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JButton::addMouseListener → NO_COVERAGE

99

1.1
Location : mousePressed
Killed by : none
removed call to javax/swing/JPopupMenu::applyComponentOrientation → NO_COVERAGE

101

1.1
Location : mousePressed
Killed by : none
negated conditional → NO_COVERAGE

102

1.1
Location : mousePressed
Killed by : none
removed call to javax/swing/JRadioButton::setBorder → NO_COVERAGE

104

1.1
Location : mousePressed
Killed by : none
removed call to javax/swing/JRadioButton::setBorder → NO_COVERAGE

107

1.1
Location : mousePressed
Killed by : none
removed call to javax/swing/JPopupMenu::show → NO_COVERAGE

109

1.1
Location : mousePressed
Killed by : none
negated conditional → NO_COVERAGE

110

1.1
Location : mousePressed
Killed by : none
Replaced integer subtraction with addition → NO_COVERAGE

2.2
Location : mousePressed
Killed by : none
Replaced integer subtraction with addition → NO_COVERAGE

112

1.1
Location : mousePressed
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

115

1.1
Location : mousePressed
Killed by : none
removed call to javax/swing/JPopupMenu::setLocation → NO_COVERAGE

116

1.1
Location : mousePressed
Killed by : none
negated conditional → NO_COVERAGE

117

1.1
Location : mousePressed
Killed by : none
Replaced integer subtraction with addition → NO_COVERAGE

2.2
Location : mousePressed
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

119

1.1
Location : mousePressed
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

126

1.1
Location : getTypeRequest
Killed by : none
replaced return value with "" for com/jsql/view/swing/panel/address/RequestPanel::getTypeRequest → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.16.1