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 | private static final Logger LOGGER = LogManager.getRootLogger(); | |
27 | ||
28 | /** | |
29 | * Create tabs with ctrl-TAB, mouse-wheel. | |
30 | */ | |
31 | public TabbedPaneWheeled() { | |
32 | this(SwingConstants.TOP); | |
33 | } | |
34 | ||
35 | public TabbedPaneWheeled(int tabPlacement) { | |
36 | super(tabPlacement, JTabbedPane.SCROLL_TAB_LAYOUT); | |
37 |
1
1. <init> : removed call to com/jsql/view/swing/tab/TabbedPaneWheeled::addMouseWheelListener → NO_COVERAGE |
this.addMouseWheelListener(new TabbedPaneMouseWheelListener()); |
38 |
1
1. <init> : removed call to com/jsql/view/swing/action/HotkeyUtil::addShortcut → NO_COVERAGE |
HotkeyUtil.addShortcut(this); // Hotkeys ctrl-TAB, ctrl-shift-TAB |
39 | } | |
40 | ||
41 | /** | |
42 | * Highlight tab to mark when new content added | |
43 | */ | |
44 | public void setBold(String label) { | |
45 | int tabIndex = this.indexOfTab(label); | |
46 | // Highlight only if tab not selected and tab exists | |
47 | if ( | |
48 |
3
1. setBold : changed conditional boundary → NO_COVERAGE 2. setBold : negated conditional → NO_COVERAGE 3. setBold : negated conditional → NO_COVERAGE |
this.getSelectedIndex() != tabIndex |
49 |
2
1. setBold : negated conditional → NO_COVERAGE 2. setBold : changed conditional boundary → NO_COVERAGE |
&& 0 <= tabIndex && tabIndex < this.getTabCount() |
50 | ) { | |
51 | var tabHeader = this.getTabComponentAt(tabIndex); | |
52 | // Unhandled ClassCastException #91158 on setFont() | |
53 | try { | |
54 |
1
1. setBold : removed call to java/awt/Component::setFont → NO_COVERAGE |
tabHeader.setFont(tabHeader.getFont().deriveFont(Font.BOLD)); |
55 | } catch (ClassCastException e) { | |
56 | LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e, e); | |
57 | } | |
58 | } | |
59 | } | |
60 | } | |
Mutations | ||
37 |
1.1 |
|
38 |
1.1 |
|
48 |
1.1 2.2 3.3 |
|
49 |
1.1 2.2 |
|
54 |
1.1 |