TabbedPaneWheeled.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.tab;
12
13
import com.jsql.util.LogLevelUtil;
14
import com.jsql.view.swing.action.HotkeyUtil;
15
import org.apache.logging.log4j.LogManager;
16
import org.apache.logging.log4j.Logger;
17
18
import javax.swing.*;
19
import java.awt.*;
20
21
/**
22
 * Tabs with mouse-wheel and right click action.
23
 */
24
public class TabbedPaneWheeled extends JTabbedPane {
25
26
    /**
27
     * Log4j logger sent to view.
28
     */
29
    private static final Logger LOGGER = LogManager.getRootLogger();
30
31
    /**
32
     * Create tabs with ctrl-TAB, mouse-wheel.
33
     */
34
    public TabbedPaneWheeled() {
35
        this(SwingConstants.TOP);
36
    }
37
38
    public TabbedPaneWheeled(int tabPlacement) {
39
        super(tabPlacement, JTabbedPane.SCROLL_TAB_LAYOUT);
40 1 1. <init> : removed call to com/jsql/view/swing/tab/TabbedPaneWheeled::addMouseWheelListener → NO_COVERAGE
        this.addMouseWheelListener(new TabbedPaneMouseWheelListener());
41 1 1. <init> : removed call to com/jsql/view/swing/action/HotkeyUtil::addShortcut → NO_COVERAGE
        HotkeyUtil.addShortcut(this);  // Hotkeys ctrl-TAB, ctrl-shift-TAB
42
    }
43
44
    /**
45
     * Highlight tab to mark when new content added
46
     */
47
    public void setBold(String label) {
48
        int tabIndex = this.indexOfTab(label);
49
        // Highlight only if tab not selected and tab exists
50
        if (
51 3 1. setBold : changed conditional boundary → NO_COVERAGE
2. setBold : negated conditional → NO_COVERAGE
3. setBold : negated conditional → NO_COVERAGE
            this.getSelectedIndex() != tabIndex
52 2 1. setBold : negated conditional → NO_COVERAGE
2. setBold : changed conditional boundary → NO_COVERAGE
            && 0 <= tabIndex && tabIndex < this.getTabCount()
53
        ) {
54
            var tabHeader = this.getTabComponentAt(tabIndex);
55
            // Unhandled ClassCastException #91158 on setFont()
56
            try {
57 1 1. setBold : removed call to java/awt/Component::setFont → NO_COVERAGE
                tabHeader.setFont(tabHeader.getFont().deriveFont(Font.BOLD));
58
            } catch (ClassCastException e) {
59
                LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e, e);
60
            }
61
        }
62
    }
63
}

Mutations

40

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/tab/TabbedPaneWheeled::addMouseWheelListener → NO_COVERAGE

41

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/action/HotkeyUtil::addShortcut → NO_COVERAGE

51

1.1
Location : setBold
Killed by : none
changed conditional boundary → NO_COVERAGE

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

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

52

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

2.2
Location : setBold
Killed by : none
changed conditional boundary → NO_COVERAGE

57

1.1
Location : setBold
Killed by : none
removed call to java/awt/Component::setFont → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.19.1