TabbedPaneMouseWheelListener.java

1
package com.jsql.view.swing.tab;
2
3
import com.jsql.util.LogLevelUtil;
4
import org.apache.logging.log4j.LogManager;
5
import org.apache.logging.log4j.Logger;
6
7
import javax.swing.*;
8
import java.awt.event.MouseWheelEvent;
9
import java.awt.event.MouseWheelListener;
10
11
/**
12
 * Mouse wheel allows to navigate to next/previous tab.
13
 */
14
public class TabbedPaneMouseWheelListener implements MouseWheelListener {
15
    
16
    /**
17
     * Log4j logger sent to view.
18
     */
19
    private static final Logger LOGGER = LogManager.getRootLogger();
20
    
21
    @Override
22
    public void mouseWheelMoved(MouseWheelEvent event) {
23
        
24
        JTabbedPane tabPane = (JTabbedPane) event.getSource();
25
26 1 1. mouseWheelMoved : removed negation → NO_COVERAGE
        int dir = -event.getWheelRotation();
27
        int selIndex = tabPane.getSelectedIndex();
28 1 1. mouseWheelMoved : Replaced integer subtraction with addition → NO_COVERAGE
        int maxIndex = tabPane.getTabCount() - 1;
29
        
30 6 1. mouseWheelMoved : negated conditional → NO_COVERAGE
2. mouseWheelMoved : negated conditional → NO_COVERAGE
3. mouseWheelMoved : negated conditional → NO_COVERAGE
4. mouseWheelMoved : negated conditional → NO_COVERAGE
5. mouseWheelMoved : changed conditional boundary → NO_COVERAGE
6. mouseWheelMoved : changed conditional boundary → NO_COVERAGE
        if ((selIndex == 0 && dir < 0) || (selIndex == maxIndex && dir > 0)) {
31 1 1. mouseWheelMoved : Replaced integer subtraction with addition → NO_COVERAGE
            selIndex = maxIndex - selIndex;
32
        } else {
33 1 1. mouseWheelMoved : Replaced integer addition with subtraction → NO_COVERAGE
            selIndex += dir;
34
        }
35
        
36 4 1. mouseWheelMoved : negated conditional → NO_COVERAGE
2. mouseWheelMoved : negated conditional → NO_COVERAGE
3. mouseWheelMoved : changed conditional boundary → NO_COVERAGE
4. mouseWheelMoved : changed conditional boundary → NO_COVERAGE
        if (0 <= selIndex && selIndex < tabPane.getTabCount()) {
37
            // Fix #54575: NullPointerException on setSelectedIndex()
38
            // Fix #90835: IllegalArgumentException on setSelectedIndex()
39
            try {
40 1 1. mouseWheelMoved : removed call to javax/swing/JTabbedPane::setSelectedIndex → NO_COVERAGE
                tabPane.setSelectedIndex(selIndex);
41
            } catch (IllegalArgumentException | NullPointerException e) {
42
                LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e, e);
43
            }
44
        }
45
    }
46
}

Mutations

26

1.1
Location : mouseWheelMoved
Killed by : none
removed negation → NO_COVERAGE

28

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

30

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

2.2
Location : mouseWheelMoved
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : mouseWheelMoved
Killed by : none
negated conditional → NO_COVERAGE

4.4
Location : mouseWheelMoved
Killed by : none
negated conditional → NO_COVERAGE

5.5
Location : mouseWheelMoved
Killed by : none
changed conditional boundary → NO_COVERAGE

6.6
Location : mouseWheelMoved
Killed by : none
changed conditional boundary → NO_COVERAGE

31

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

33

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

36

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

2.2
Location : mouseWheelMoved
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : mouseWheelMoved
Killed by : none
changed conditional boundary → NO_COVERAGE

4.4
Location : mouseWheelMoved
Killed by : none
changed conditional boundary → NO_COVERAGE

40

1.1
Location : mouseWheelMoved
Killed by : none
removed call to javax/swing/JTabbedPane::setSelectedIndex → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.16.1