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