ActionStart.java

1
package com.jsql.view.swing.panel.address;
2
3
import com.jsql.model.bean.util.Interaction;
4
import com.jsql.model.bean.util.Request;
5
import com.jsql.util.I18nUtil;
6
import com.jsql.util.LogLevelUtil;
7
import com.jsql.view.swing.manager.util.StateButton;
8
import com.jsql.view.swing.panel.PanelAddressBar;
9
import com.jsql.view.swing.util.MediatorHelper;
10
import org.apache.logging.log4j.LogManager;
11
import org.apache.logging.log4j.Logger;
12
13
import javax.swing.*;
14
import java.awt.event.ActionEvent;
15
import java.awt.event.ActionListener;
16
17
public class ActionStart implements ActionListener {
18
    
19
    /**
20
     * Log4j logger sent to view.
21
     */
22
    private static final Logger LOGGER = LogManager.getRootLogger();
23
    
24
    protected final PanelAddressBar panelAddressBar;
25
    
26
    public ActionStart(PanelAddressBar panelAddressBar) {
27
        this.panelAddressBar = panelAddressBar;
28
    }
29
30
    @Override
31
    public void actionPerformed(ActionEvent e) {
32
        // No injection running
33 1 1. actionPerformed : negated conditional → NO_COVERAGE
        if (this.panelAddressBar.getAddressMenuBar().getButtonInUrl().getState() == StateButton.STARTABLE) {
34 1 1. actionPerformed : removed call to com/jsql/view/swing/panel/address/ActionStart::startInjection → NO_COVERAGE
            this.startInjection();
35 1 1. actionPerformed : negated conditional → NO_COVERAGE
        } else if (this.panelAddressBar.getAddressMenuBar().getButtonInUrl().getState() == StateButton.STOPPABLE) {
36 1 1. actionPerformed : removed call to com/jsql/view/swing/panel/address/ActionStart::stopInjection → NO_COVERAGE
            this.stopInjection();  // Injection currently running, stop the process
37
        }
38
    }
39
    
40
    protected void startInjection() {
41
        
42
        int option = JOptionPane.OK_OPTION;
43
        
44
        // Ask the user confirmation if injection already built
45 1 1. startInjection : negated conditional → NO_COVERAGE
        if (MediatorHelper.model().shouldErasePreviousInjection()) {
46
            // Fix #93469: IllegalArgumentException on showConfirmDialog()
47
            // Fix #33930: ClassCastException on showConfirmDialog()
48
            // Implementation by sun.awt.image
49
            try {
50
                option = JOptionPane.showConfirmDialog(
51
                    null,
52
                    I18nUtil.valueByKey("DIALOG_NEW_INJECTION_TEXT"),
53
                    I18nUtil.valueByKey("DIALOG_NEW_INJECTION_TITLE"),
54
                    JOptionPane.OK_CANCEL_OPTION
55
                );
56
            } catch (IllegalArgumentException | ClassCastException e) {
57
                LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e, e);
58
            }
59
        }
60
61
        // Then start injection
62 1 1. startInjection : negated conditional → NO_COVERAGE
        if (option == JOptionPane.OK_OPTION) {
63
            
64 1 1. startInjection : removed call to com/jsql/view/swing/panel/util/ButtonAddressBar::setToolTipText → NO_COVERAGE
            this.panelAddressBar.getAddressMenuBar().getButtonInUrl().setToolTipText(I18nUtil.valueByKey("BUTTON_STOP_TOOLTIP"));
65 1 1. startInjection : removed call to com/jsql/view/swing/panel/util/ButtonAddressBar::setInjectionRunning → NO_COVERAGE
            this.panelAddressBar.getAddressMenuBar().getButtonInUrl().setInjectionRunning();
66 1 1. startInjection : removed call to javax/swing/JLabel::setVisible → NO_COVERAGE
            this.panelAddressBar.getAddressMenuBar().getLoader().setVisible(true);
67
68
            // Erase everything in the view from a previous injection
69
            var requests = new Request();
70 1 1. startInjection : removed call to com/jsql/model/bean/util/Request::setMessage → NO_COVERAGE
            requests.setMessage(Interaction.RESET_INTERFACE);
71 1 1. startInjection : removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE
            MediatorHelper.model().sendToViews(requests);
72
73 1 1. startInjection : removed call to com/jsql/util/ParameterUtil::controlInput → NO_COVERAGE
            MediatorHelper.model().getMediatorUtils().getParameterUtil().controlInput(
74
                this.panelAddressBar.getTextFieldAddress().getText().trim(),
75
                this.panelAddressBar.getTextFieldRequest().getText().trim(),
76
                this.panelAddressBar.getTextFieldHeader().getText().trim(),
77
                this.panelAddressBar.getMethodInjection(),
78
                this.panelAddressBar.getRequestPanel().getTypeRequest(),
79
                false
80
            );
81
        }
82
    }
83
    
84
    private void stopInjection() {
85
        
86 1 1. stopInjection : removed call to javax/swing/JLabel::setVisible → NO_COVERAGE
        this.panelAddressBar.getAddressMenuBar().getLoader().setVisible(false);
87 1 1. stopInjection : removed call to com/jsql/view/swing/panel/util/ButtonAddressBar::setInjectionStopping → NO_COVERAGE
        this.panelAddressBar.getAddressMenuBar().getButtonInUrl().setInjectionStopping();
88 1 1. stopInjection : removed call to com/jsql/view/swing/panel/util/ButtonAddressBar::setToolTipText → NO_COVERAGE
        this.panelAddressBar.getAddressMenuBar().getButtonInUrl().setToolTipText(I18nUtil.valueByKey("BUTTON_STOPPING_TOOLTIP"));
89
        
90 1 1. stopInjection : removed call to com/jsql/model/InjectionModel::setIsStoppedByUser → NO_COVERAGE
        MediatorHelper.model().setIsStoppedByUser(true);
91
    }
92
}

Mutations

33

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

34

1.1
Location : actionPerformed
Killed by : none
removed call to com/jsql/view/swing/panel/address/ActionStart::startInjection → NO_COVERAGE

35

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

36

1.1
Location : actionPerformed
Killed by : none
removed call to com/jsql/view/swing/panel/address/ActionStart::stopInjection → NO_COVERAGE

45

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

62

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

64

1.1
Location : startInjection
Killed by : none
removed call to com/jsql/view/swing/panel/util/ButtonAddressBar::setToolTipText → NO_COVERAGE

65

1.1
Location : startInjection
Killed by : none
removed call to com/jsql/view/swing/panel/util/ButtonAddressBar::setInjectionRunning → NO_COVERAGE

66

1.1
Location : startInjection
Killed by : none
removed call to javax/swing/JLabel::setVisible → NO_COVERAGE

70

1.1
Location : startInjection
Killed by : none
removed call to com/jsql/model/bean/util/Request::setMessage → NO_COVERAGE

71

1.1
Location : startInjection
Killed by : none
removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE

73

1.1
Location : startInjection
Killed by : none
removed call to com/jsql/util/ParameterUtil::controlInput → NO_COVERAGE

86

1.1
Location : stopInjection
Killed by : none
removed call to javax/swing/JLabel::setVisible → NO_COVERAGE

87

1.1
Location : stopInjection
Killed by : none
removed call to com/jsql/view/swing/panel/util/ButtonAddressBar::setInjectionStopping → NO_COVERAGE

88

1.1
Location : stopInjection
Killed by : none
removed call to com/jsql/view/swing/panel/util/ButtonAddressBar::setToolTipText → NO_COVERAGE

90

1.1
Location : stopInjection
Killed by : none
removed call to com/jsql/model/InjectionModel::setIsStoppedByUser → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.16.1