TabManagers.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.I18nUtil;
14
import com.jsql.view.swing.text.JToolTipI18n;
15
import com.jsql.view.swing.util.I18nViewUtil;
16
import com.jsql.view.swing.util.MediatorHelper;
17
import com.jsql.view.swing.util.ModelSvgIcon;
18
import com.jsql.view.swing.util.UiUtil;
19
20
import javax.swing.*;
21
import java.awt.*;
22
import java.awt.event.MouseAdapter;
23
import java.awt.event.MouseEvent;
24
import java.util.Arrays;
25
import java.util.List;
26
import java.util.concurrent.atomic.AtomicInteger;
27
import java.util.concurrent.atomic.AtomicReference;
28
29
/**
30
 * Panel on the left with functionalities like webshell, file reading and admin page finder.
31
 */
32
public class TabManagers extends TabbedPaneWheeled {
33
34
    public static final String TAB_MANAGERS = "tabManagers";
35
36
    private final transient List<ModelSvgIcon> iconsTabs = Arrays.asList(
37
        UiUtil.DATABASE_BOLD, UiUtil.ADMIN, UiUtil.DOWNLOAD, UiUtil.TERMINAL, UiUtil.LOCK, UiUtil.TEXTFIELD, UiUtil.BATCH
38
    );
39
40
    /**
41
     * Create manager panel.
42
     */
43
    public TabManagers() {
44 1 1. <init> : removed call to com/jsql/view/swing/tab/TabManagers::setName → NO_COVERAGE
        this.setName(TabManagers.TAB_MANAGERS);
45 1 1. <init> : removed call to com/jsql/view/swing/tab/TabManagers::setMaximumSize → NO_COVERAGE
        this.setMaximumSize(new Dimension(this.getMaximumSize().width, 35));
46 1 1. <init> : removed call to com/jsql/view/swing/tab/TabManagers::setPreferredSize → NO_COVERAGE
        this.setPreferredSize(new Dimension(this.getPreferredSize().width, 35));
47
48
        AtomicInteger indexTab = new AtomicInteger();
49 2 1. <init> : removed call to java/util/List::forEach → NO_COVERAGE
2. lambda$new$0 : removed call to com/jsql/view/swing/tab/TabManagers::buildI18nTab → NO_COVERAGE
        this.iconsTabs.forEach(modelSvgIcon -> this.buildI18nTab(modelSvgIcon, indexTab.getAndIncrement()));
50 1 1. <init> : removed call to com/jsql/view/swing/tab/TabManagers::addChangeListener → NO_COVERAGE
        this.addChangeListener(e -> {
51
            CardLayout cardLayout = (CardLayout) MediatorHelper.tabManagersCards().getLayout();
52 1 1. lambda$new$1 : removed call to java/awt/CardLayout::show → NO_COVERAGE
            cardLayout.show(MediatorHelper.tabManagersCards(), this.getTabComponentAt(this.getSelectedIndex()).getName());
53
        });
54
    }
55
    
56
    private void buildI18nTab(ModelSvgIcon modelSvgIcon, int index) {
57
        Icon icon = modelSvgIcon.getIcon();
58
        String keyLabel = modelSvgIcon.getKeyLabel();
59
        String keyTooltip = modelSvgIcon.getKeyTooltip();
60
        AtomicReference<JToolTipI18n> tooltipAtomic = new AtomicReference<>(new JToolTipI18n(I18nUtil.valueByKey(keyTooltip)));
61
        JLabel labelTab = new JLabel(I18nUtil.valueByKey(keyLabel), icon, SwingConstants.CENTER) {
62
            @Override
63
            public JToolTip createToolTip() {
64 1 1. createToolTip : removed call to java/util/concurrent/atomic/AtomicReference::set → NO_COVERAGE
                tooltipAtomic.set(new JToolTipI18n(I18nUtil.valueByKey(keyTooltip)));
65 1 1. createToolTip : replaced return value with null for com/jsql/view/swing/tab/TabManagers$1::createToolTip → NO_COVERAGE
                return tooltipAtomic.get();
66
            }
67
        };
68
        
69 1 1. buildI18nTab : removed call to javax/swing/JLabel::setName → NO_COVERAGE
        labelTab.setName(keyLabel);
70 1 1. buildI18nTab : removed call to javax/swing/JLabel::addMouseListener → NO_COVERAGE
        labelTab.addMouseListener(new MouseAdapter() {
71
            @Override
72
            public void mousePressed(MouseEvent e) {
73
                CardLayout cardLayout = (CardLayout) MediatorHelper.tabManagersCards().getLayout();
74 1 1. mousePressed : removed call to java/awt/CardLayout::show → NO_COVERAGE
                cardLayout.show(MediatorHelper.tabManagersCards(), TabManagers.this.getTabComponentAt(index).getName());
75 1 1. mousePressed : removed call to com/jsql/view/swing/tab/TabManagers::setSelectedIndex → NO_COVERAGE
                TabManagers.this.setSelectedIndex(index);
76
            }
77
        });
78
79 1 1. buildI18nTab : removed call to com/jsql/view/swing/tab/TabManagers::addTab → NO_COVERAGE
        this.addTab(I18nUtil.valueByKey(keyLabel), icon, null);  // Required for i18n to work
80 1 1. buildI18nTab : removed call to com/jsql/view/swing/tab/TabManagers::setTabComponentAt → NO_COVERAGE
        this.setTabComponentAt(  // TODO Break focus, should not be used
81
            this.indexOfTab(I18nUtil.valueByKey(keyLabel)),
82
            labelTab
83
        );
84
85 1 1. buildI18nTab : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE
        I18nViewUtil.addComponentForKey(keyLabel, labelTab);
86 1 1. buildI18nTab : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE
        I18nViewUtil.addComponentForKey(keyTooltip, tooltipAtomic.get());
87
        
88 1 1. buildI18nTab : removed call to javax/swing/JLabel::setToolTipText → NO_COVERAGE
        labelTab.setToolTipText(I18nUtil.valueByKey(keyTooltip));
89
    }
90
91
    public List<ModelSvgIcon> getIconsTabs() {
92 1 1. getIconsTabs : replaced return value with Collections.emptyList for com/jsql/view/swing/tab/TabManagers::getIconsTabs → NO_COVERAGE
        return this.iconsTabs;
93
    }
94
}

Mutations

44

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

45

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

46

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

49

1.1
Location : <init>
Killed by : none
removed call to java/util/List::forEach → NO_COVERAGE

2.2
Location : lambda$new$0
Killed by : none
removed call to com/jsql/view/swing/tab/TabManagers::buildI18nTab → NO_COVERAGE

50

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

52

1.1
Location : lambda$new$1
Killed by : none
removed call to java/awt/CardLayout::show → NO_COVERAGE

64

1.1
Location : createToolTip
Killed by : none
removed call to java/util/concurrent/atomic/AtomicReference::set → NO_COVERAGE

65

1.1
Location : createToolTip
Killed by : none
replaced return value with null for com/jsql/view/swing/tab/TabManagers$1::createToolTip → NO_COVERAGE

69

1.1
Location : buildI18nTab
Killed by : none
removed call to javax/swing/JLabel::setName → NO_COVERAGE

70

1.1
Location : buildI18nTab
Killed by : none
removed call to javax/swing/JLabel::addMouseListener → NO_COVERAGE

74

1.1
Location : mousePressed
Killed by : none
removed call to java/awt/CardLayout::show → NO_COVERAGE

75

1.1
Location : mousePressed
Killed by : none
removed call to com/jsql/view/swing/tab/TabManagers::setSelectedIndex → NO_COVERAGE

79

1.1
Location : buildI18nTab
Killed by : none
removed call to com/jsql/view/swing/tab/TabManagers::addTab → NO_COVERAGE

80

1.1
Location : buildI18nTab
Killed by : none
removed call to com/jsql/view/swing/tab/TabManagers::setTabComponentAt → NO_COVERAGE

85

1.1
Location : buildI18nTab
Killed by : none
removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE

86

1.1
Location : buildI18nTab
Killed by : none
removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE

88

1.1
Location : buildI18nTab
Killed by : none
removed call to javax/swing/JLabel::setToolTipText → NO_COVERAGE

92

1.1
Location : getIconsTabs
Killed by : none
replaced return value with Collections.emptyList for com/jsql/view/swing/tab/TabManagers::getIconsTabs → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.22.1