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
    private static final Logger LOGGER = LogManager.getRootLogger();
17
    
18
    @Override
19
    public void mouseWheelMoved(MouseWheelEvent event) {
20
        JTabbedPane tabPane = (JTabbedPane) event.getSource();
21
22 1 1. mouseWheelMoved : removed negation → NO_COVERAGE
        int dir = -event.getWheelRotation();
23
        int selIndex = tabPane.getSelectedIndex();
24 1 1. mouseWheelMoved : Replaced integer subtraction with addition → NO_COVERAGE
        int maxIndex = tabPane.getTabCount() - 1;
25
        
26 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)) {
27 1 1. mouseWheelMoved : Replaced integer subtraction with addition → NO_COVERAGE
            selIndex = maxIndex - selIndex;
28
        } else {
29 1 1. mouseWheelMoved : Replaced integer addition with subtraction → NO_COVERAGE
            selIndex += dir;
30
        }
31
        
32 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()) {
33
            // Fix #54575: NullPointerException on setSelectedIndex()
34
            // Fix #90835: IllegalArgumentException on setSelectedIndex()
35
            try {
36 1 1. mouseWheelMoved : removed call to javax/swing/JTabbedPane::setSelectedIndex → NO_COVERAGE
                tabPane.setSelectedIndex(selIndex);
37
            } catch (IllegalArgumentException | NullPointerException e) {
38
                LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e, e);
39
            }
40
        }
41
    }
42
}

Mutations

22

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

24

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

26

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

27

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

29

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

32

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

36

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.22.1