ButtonStart.java

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.address;
12
13
import com.jsql.util.I18nUtil;
14
import com.jsql.view.swing.manager.util.StateButton;
15
import com.jsql.view.swing.text.JToolTipI18n;
16
import com.jsql.view.swing.util.I18nViewUtil;
17
import com.jsql.view.swing.util.UiUtil;
18
19
import javax.swing.*;
20
import java.awt.*;
21
import java.util.concurrent.atomic.AtomicReference;
22
23
/**
24
 * A button displayed in address.
25
 */
26
public class ButtonStart extends JButton {
27
28
    private static final String BUTTON_START_TOOLTIP = "BUTTON_START_TOOLTIP";
29
    public static final String BUTTON_IN_URL = "buttonInUrl";
30
31
    /**
32
     * State of current injection.
33
     */
34
    private StateButton state = StateButton.STARTABLE;
35
36
    private final AtomicReference<JToolTipI18n> tooltip = new AtomicReference<>(
37
        new JToolTipI18n(I18nUtil.valueByKey(ButtonStart.BUTTON_START_TOOLTIP))
38
    );
39
40
    @Override
41
    public JToolTip createToolTip() {
42 1 1. createToolTip : negated conditional → NO_COVERAGE
        if (this.state == StateButton.STARTABLE) {
43 1 1. createToolTip : removed call to com/jsql/view/swing/text/JToolTipI18n::setText → NO_COVERAGE
            this.tooltip.get().setText(I18nUtil.valueByKey(ButtonStart.BUTTON_START_TOOLTIP));
44 1 1. createToolTip : negated conditional → NO_COVERAGE
        } else if (this.state == StateButton.STOPPABLE) {
45 1 1. createToolTip : removed call to com/jsql/view/swing/text/JToolTipI18n::setText → NO_COVERAGE
            this.tooltip.get().setText(I18nUtil.valueByKey("BUTTON_STOP_TOOLTIP"));
46 1 1. createToolTip : negated conditional → NO_COVERAGE
        } else if (this.state == StateButton.STOPPING) {
47 1 1. createToolTip : removed call to com/jsql/view/swing/text/JToolTipI18n::setText → NO_COVERAGE
            this.tooltip.get().setText(I18nUtil.valueByKey("BUTTON_STOPPING_TOOLTIP"));
48
        }
49 1 1. createToolTip : replaced return value with null for com/jsql/view/swing/panel/address/ButtonStart::createToolTip → NO_COVERAGE
        return this.tooltip.get();
50
    }
51
52
    /**
53
     * Create a button in address bar.
54
     */
55
    public ButtonStart() {
56 1 1. <init> : removed call to com/jsql/view/swing/panel/address/ButtonStart::setName → NO_COVERAGE
        this.setName(ButtonStart.BUTTON_IN_URL);
57 1 1. <init> : removed call to com/jsql/view/swing/panel/address/ButtonStart::setToolTipText → NO_COVERAGE
        this.setToolTipText(I18nUtil.valueByKey(ButtonStart.BUTTON_START_TOOLTIP));
58 1 1. <init> : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE
        I18nViewUtil.addComponentForKey(ButtonStart.BUTTON_START_TOOLTIP, this.tooltip.get());
59
60 1 1. <init> : removed call to com/jsql/view/swing/panel/address/ButtonStart::setPreferredSize → NO_COVERAGE
        this.setPreferredSize(new Dimension(18, 16));
61 1 1. <init> : removed call to com/jsql/view/swing/panel/address/ButtonStart::setOpaque → NO_COVERAGE
        this.setOpaque(false);
62 1 1. <init> : removed call to com/jsql/view/swing/panel/address/ButtonStart::setContentAreaFilled → NO_COVERAGE
        this.setContentAreaFilled(false);
63 1 1. <init> : removed call to com/jsql/view/swing/panel/address/ButtonStart::setBorderPainted → NO_COVERAGE
        this.setBorderPainted(false);
64 1 1. <init> : removed call to com/jsql/view/swing/panel/address/ButtonStart::setRolloverEnabled → NO_COVERAGE
        this.setRolloverEnabled(true);
65 1 1. <init> : removed call to com/jsql/view/swing/panel/address/ButtonStart::setIcons → NO_COVERAGE
        this.setIcons();
66
    }
67
68
    public void setIcons() {
69
        // required to get correct color at startup instead of blu
70 1 1. setIcons : negated conditional → NO_COVERAGE
        if (ComponentOrientation.getOrientation(I18nUtil.getCurrentLocale()).isLeftToRight()) {
71 1 1. setIcons : removed call to com/jsql/view/swing/panel/address/ButtonStart::setIcon → NO_COVERAGE
            this.setIcon(UiUtil.ARROW.getIcon());
72 1 1. setIcons : removed call to com/jsql/view/swing/panel/address/ButtonStart::setRolloverIcon → NO_COVERAGE
            this.setRolloverIcon(UiUtil.ARROW_HOVER.getIcon());
73 1 1. setIcons : removed call to com/jsql/view/swing/panel/address/ButtonStart::setPressedIcon → NO_COVERAGE
            this.setPressedIcon(UiUtil.ARROW_PRESSED.getIcon());
74
        } else {
75 1 1. setIcons : removed call to com/jsql/view/swing/panel/address/ButtonStart::setIcon → NO_COVERAGE
            this.setIcon(UiUtil.ARROW_LEFT.getIcon());
76 1 1. setIcons : removed call to com/jsql/view/swing/panel/address/ButtonStart::setRolloverIcon → NO_COVERAGE
            this.setRolloverIcon(UiUtil.ARROW_LEFT_HOVER.getIcon());
77 1 1. setIcons : removed call to com/jsql/view/swing/panel/address/ButtonStart::setPressedIcon → NO_COVERAGE
            this.setPressedIcon(UiUtil.ARROW_LEFT_PRESSED.getIcon());
78
        }
79
    }
80
81
    /**
82
     * Replace button with Stop icon ; user can stop current process.
83
     */
84
    public void setInjectionReady() {
85
        this.state = StateButton.STARTABLE;
86 1 1. setInjectionReady : removed call to com/jsql/view/swing/panel/address/ButtonStart::setRolloverEnabled → NO_COVERAGE
        this.setRolloverEnabled(true);
87 1 1. setInjectionReady : removed call to com/jsql/view/swing/panel/address/ButtonStart::setEnabled → NO_COVERAGE
        this.setEnabled(true);
88 1 1. setInjectionReady : removed call to com/jsql/view/swing/panel/address/ButtonStart::setIcons → NO_COVERAGE
        this.setIcons();
89
    }
90
91
    /**
92
     * Replace button with Stop icon ; user can stop current process.
93
     */
94
    public void setInjectionRunning() {
95
        this.state = StateButton.STOPPABLE;
96 1 1. setInjectionRunning : removed call to com/jsql/view/swing/panel/address/ButtonStart::setRolloverEnabled → NO_COVERAGE
        this.setRolloverEnabled(false);
97 1 1. setInjectionRunning : removed call to com/jsql/view/swing/panel/address/ButtonStart::setEnabled → NO_COVERAGE
        this.setEnabled(true);
98 1 1. setInjectionRunning : removed call to com/jsql/view/swing/panel/address/ButtonStart::setIcon → NO_COVERAGE
        this.setIcon(UiUtil.CROSS_RED.getIcon());
99
    }
100
101
    /**
102
     * Replace button with icon loader until injection process
103
     * is finished ; user waits the end of process.
104
     */
105
    public void setInjectionStopping() {
106
        this.state = StateButton.STOPPING;
107 1 1. setInjectionStopping : removed call to com/jsql/view/swing/panel/address/ButtonStart::setRolloverEnabled → NO_COVERAGE
        this.setRolloverEnabled(false);
108 1 1. setInjectionStopping : removed call to com/jsql/view/swing/panel/address/ButtonStart::setEnabled → NO_COVERAGE
        this.setEnabled(false);
109 1 1. setInjectionStopping : removed call to com/jsql/view/swing/panel/address/ButtonStart::setIcon → NO_COVERAGE
        this.setIcon(UiUtil.HOURGLASS.getIcon());
110
    }
111
112
    /**
113
     * Return the current state of current process.
114
     * @return State of process
115
     */
116
    public StateButton getState() {
117 1 1. getState : replaced return value with null for com/jsql/view/swing/panel/address/ButtonStart::getState → NO_COVERAGE
        return this.state;
118
    }
119
}

Mutations

42

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

43

1.1
Location : createToolTip
Killed by : none
removed call to com/jsql/view/swing/text/JToolTipI18n::setText → NO_COVERAGE

44

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

45

1.1
Location : createToolTip
Killed by : none
removed call to com/jsql/view/swing/text/JToolTipI18n::setText → NO_COVERAGE

46

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

47

1.1
Location : createToolTip
Killed by : none
removed call to com/jsql/view/swing/text/JToolTipI18n::setText → NO_COVERAGE

49

1.1
Location : createToolTip
Killed by : none
replaced return value with null for com/jsql/view/swing/panel/address/ButtonStart::createToolTip → NO_COVERAGE

56

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

57

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

58

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE

60

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

61

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

62

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

63

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

64

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

65

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

70

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

71

1.1
Location : setIcons
Killed by : none
removed call to com/jsql/view/swing/panel/address/ButtonStart::setIcon → NO_COVERAGE

72

1.1
Location : setIcons
Killed by : none
removed call to com/jsql/view/swing/panel/address/ButtonStart::setRolloverIcon → NO_COVERAGE

73

1.1
Location : setIcons
Killed by : none
removed call to com/jsql/view/swing/panel/address/ButtonStart::setPressedIcon → NO_COVERAGE

75

1.1
Location : setIcons
Killed by : none
removed call to com/jsql/view/swing/panel/address/ButtonStart::setIcon → NO_COVERAGE

76

1.1
Location : setIcons
Killed by : none
removed call to com/jsql/view/swing/panel/address/ButtonStart::setRolloverIcon → NO_COVERAGE

77

1.1
Location : setIcons
Killed by : none
removed call to com/jsql/view/swing/panel/address/ButtonStart::setPressedIcon → NO_COVERAGE

86

1.1
Location : setInjectionReady
Killed by : none
removed call to com/jsql/view/swing/panel/address/ButtonStart::setRolloverEnabled → NO_COVERAGE

87

1.1
Location : setInjectionReady
Killed by : none
removed call to com/jsql/view/swing/panel/address/ButtonStart::setEnabled → NO_COVERAGE

88

1.1
Location : setInjectionReady
Killed by : none
removed call to com/jsql/view/swing/panel/address/ButtonStart::setIcons → NO_COVERAGE

96

1.1
Location : setInjectionRunning
Killed by : none
removed call to com/jsql/view/swing/panel/address/ButtonStart::setRolloverEnabled → NO_COVERAGE

97

1.1
Location : setInjectionRunning
Killed by : none
removed call to com/jsql/view/swing/panel/address/ButtonStart::setEnabled → NO_COVERAGE

98

1.1
Location : setInjectionRunning
Killed by : none
removed call to com/jsql/view/swing/panel/address/ButtonStart::setIcon → NO_COVERAGE

107

1.1
Location : setInjectionStopping
Killed by : none
removed call to com/jsql/view/swing/panel/address/ButtonStart::setRolloverEnabled → NO_COVERAGE

108

1.1
Location : setInjectionStopping
Killed by : none
removed call to com/jsql/view/swing/panel/address/ButtonStart::setEnabled → NO_COVERAGE

109

1.1
Location : setInjectionStopping
Killed by : none
removed call to com/jsql/view/swing/panel/address/ButtonStart::setIcon → NO_COVERAGE

117

1.1
Location : getState
Killed by : none
replaced return value with null for com/jsql/view/swing/panel/address/ButtonStart::getState → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.22.1