SplitNS.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.panel.split;
12
13
import com.jsql.view.swing.util.JSplitPaneWithZeroSizeDivider;
14
import com.jsql.model.InjectionModel;
15
import com.jsql.util.I18nUtil;
16
import com.jsql.util.PreferencesUtil;
17
import com.jsql.view.swing.panel.PanelConsoles;
18
import com.jsql.view.swing.tab.TabManagersCards;
19
import com.jsql.view.swing.tab.TabResults;
20
import com.jsql.view.swing.util.MediatorHelper;
21
import com.jsql.view.swing.util.UiUtil;
22
23
import javax.swing.*;
24
import java.awt.*;
25
import java.awt.event.MouseAdapter;
26
import java.awt.event.MouseEvent;
27
import java.util.prefs.Preferences;
28
29
/**
30
 * SplitPane composed of tree and tabs on top, and info tabs on bottom.
31
 */
32
public class SplitNS extends JSplitPaneWithZeroSizeDivider {
33
34
    public static final String BUTTON_SHOW_CONSOLES_HIDDEN = "buttonShowConsolesHidden";
35
36
    /**
37
     * SplitPane containing Manager panels on the left and result tabs on the right.
38
     */
39
    private final JSplitPane splitEW = new JSplitPaneWithZeroSizeDivider(JSplitPane.HORIZONTAL_SPLIT);
40
41
    private static final JPanel PANEL_HIDDEN_CONSOLES = new JPanel();
42
    
43
    /**
44
     * MouseAdapter used on arrow on tabbedpane header and on
45
     * ersatz button when bottom panel is hidden.
46
     */
47
    private static final ActionHideShowConsole ACTION_HIDE_SHOW_CONSOLE = new ActionHideShowConsole(SplitNS.PANEL_HIDDEN_CONSOLES);
48
    private static final ActionHideShowResult ACTION_HIDE_SHOW_RESULT= new ActionHideShowResult();
49
50
    /**
51
     * Create main panel with Manager panels on the left, result tabs on the right,
52
     * and consoles in the bottom.
53
     */
54
    public SplitNS() {
55
        super(JSplitPane.VERTICAL_SPLIT);
56
        var preferences = Preferences.userRoot().node(InjectionModel.class.getName());
57
        var tabManagersProxy = new TabManagersCards();
58
        new TabResults();  // initialized but hidden
59
60
        // Tree and tabs on top
61 1 1. <init> : removed call to javax/swing/JSplitPane::setLeftComponent → NO_COVERAGE
        this.splitEW.setLeftComponent(tabManagersProxy);
62
        JLabel labelApp = new JLabel(UiUtil.APP_BIG.getIcon());
63 1 1. <init> : removed call to javax/swing/JLabel::setMinimumSize → NO_COVERAGE
        labelApp.setMinimumSize(new Dimension(100, 0));
64 1 1. <init> : removed call to javax/swing/JSplitPane::setRightComponent → NO_COVERAGE
        this.splitEW.setRightComponent(labelApp);
65
        var verticalLeftRightSplitter = preferences.getDouble(PreferencesUtil.EW_SPLIT, 0.33);
66 1 1. <init> : removed call to javax/swing/JSplitPane::setDividerLocation → NO_COVERAGE
        this.splitEW.setDividerLocation(Math.clamp(verticalLeftRightSplitter, 0.0, 1.0));
67
68
        JLabel labelShowConsoles = new JLabel(UiUtil.ARROW_UP.getIcon());
69 1 1. <init> : removed call to javax/swing/JLabel::setBorder → NO_COVERAGE
        labelShowConsoles.setBorder(BorderFactory.createEmptyBorder());
70 1 1. <init> : removed call to javax/swing/JLabel::addMouseListener → NO_COVERAGE
        labelShowConsoles.addMouseListener(new MouseAdapter() {
71
            @Override
72
            public void mouseClicked(MouseEvent e) {
73 1 1. mouseClicked : removed call to com/jsql/view/swing/panel/split/ActionHideShowConsole::actionPerformed → NO_COVERAGE
                SplitNS.ACTION_HIDE_SHOW_CONSOLE.actionPerformed(null);
74
            }
75
        });
76 1 1. <init> : removed call to javax/swing/JLabel::setName → NO_COVERAGE
        labelShowConsoles.setName(SplitNS.BUTTON_SHOW_CONSOLES_HIDDEN);
77 1 1. <init> : removed call to javax/swing/JPanel::setLayout → NO_COVERAGE
        SplitNS.PANEL_HIDDEN_CONSOLES.setLayout(new BorderLayout());
78 1 1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE
        SplitNS.PANEL_HIDDEN_CONSOLES.add(labelShowConsoles, BorderLayout.LINE_END);
79 1 1. <init> : removed call to javax/swing/JPanel::setVisible → NO_COVERAGE
        SplitNS.PANEL_HIDDEN_CONSOLES.setVisible(false);
80 1 1. <init> : removed call to javax/swing/JPanel::addMouseListener → NO_COVERAGE
        SplitNS.PANEL_HIDDEN_CONSOLES.addMouseListener(new MouseAdapter() {
81
            @Override
82
            public void mousePressed(MouseEvent e) {
83 1 1. mousePressed : negated conditional → NO_COVERAGE
                if (e.getButton() == MouseEvent.BUTTON2) {  // middle click on header with no tab
84 1 1. mousePressed : removed call to com/jsql/view/swing/panel/split/ActionHideShowConsole::actionPerformed → NO_COVERAGE
                    SplitNS.ACTION_HIDE_SHOW_CONSOLE.actionPerformed(null);
85
                }
86
            }
87
        });
88
89
        var panelManagerResult = new JPanel(new BorderLayout());
90 1 1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE
        panelManagerResult.add(this.splitEW, BorderLayout.CENTER);
91 1 1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE
        panelManagerResult.add(SplitNS.PANEL_HIDDEN_CONSOLES, BorderLayout.SOUTH);
92 1 1. <init> : removed call to com/jsql/view/swing/panel/split/SplitNS::setTopComponent → NO_COVERAGE
        this.setTopComponent(panelManagerResult);
93
94
        var panelConsoles = new PanelConsoles();
95 1 1. <init> : removed call to com/jsql/view/swing/util/MediatorHelper::register → NO_COVERAGE
        MediatorHelper.register(panelConsoles);
96 1 1. <init> : removed call to com/jsql/view/swing/panel/split/SplitNS::setBottomComponent → NO_COVERAGE
        this.setBottomComponent(panelConsoles);
97
98 1 1. <init> : removed call to com/jsql/view/swing/panel/split/SplitNS::setResizeWeight → NO_COVERAGE
        this.setResizeWeight(1);
99
    }
100
101
    /**
102
     * Switch left component with right component when locale orientation requires it.
103
     */
104
    public void initSplitOrientation() {
105 1 1. initSplitOrientation : negated conditional → NO_COVERAGE
        if (MediatorHelper.tabResults().getTabCount() == 0) {
106
            int dividerLocation = this.splitEW.getDividerLocation();
107 1 1. initSplitOrientation : negated conditional → NO_COVERAGE
            if (ComponentOrientation.RIGHT_TO_LEFT.equals(ComponentOrientation.getOrientation(I18nUtil.getCurrentLocale()))) {
108 1 1. initSplitOrientation : removed call to javax/swing/JSplitPane::setLeftComponent → NO_COVERAGE
                this.splitEW.setLeftComponent(MediatorHelper.tabResults());
109
            } else {
110 1 1. initSplitOrientation : removed call to javax/swing/JSplitPane::setRightComponent → NO_COVERAGE
                this.splitEW.setRightComponent(MediatorHelper.tabResults());
111
            }
112 2 1. lambda$initSplitOrientation$0 : removed call to javax/swing/JSplitPane::setDividerLocation → NO_COVERAGE
2. initSplitOrientation : removed call to javax/swing/SwingUtilities::invokeLater → NO_COVERAGE
            SwingUtilities.invokeLater(() -> this.splitEW.setDividerLocation(dividerLocation));  // wait for EDT refresh to prevent wrong location
113
        }
114
    }
115
116
    public void invokeLaterWithSplitOrientation(Runnable runnable) {
117 1 1. invokeLaterWithSplitOrientation : removed call to javax/swing/SwingUtilities::invokeLater → NO_COVERAGE
        SwingUtilities.invokeLater(() -> {
118 1 1. lambda$invokeLaterWithSplitOrientation$1 : removed call to com/jsql/view/swing/panel/split/SplitNS::initSplitOrientation → NO_COVERAGE
            this.initSplitOrientation();
119 1 1. lambda$invokeLaterWithSplitOrientation$1 : removed call to java/lang/Runnable::run → NO_COVERAGE
            runnable.run();
120
        });
121
    }
122
123
124
    // Getter and setter
125
126
    public JSplitPane getSplitEW() {
127 1 1. getSplitEW : replaced return value with null for com/jsql/view/swing/panel/split/SplitNS::getSplitEW → NO_COVERAGE
        return this.splitEW;
128
    }
129
130
    public static ActionHideShowConsole getActionHideShowConsole() {
131 1 1. getActionHideShowConsole : replaced return value with null for com/jsql/view/swing/panel/split/SplitNS::getActionHideShowConsole → NO_COVERAGE
        return SplitNS.ACTION_HIDE_SHOW_CONSOLE;
132
    }
133
    
134
    public static ActionHideShowResult getActionHideShowResult() {
135 1 1. getActionHideShowResult : replaced return value with null for com/jsql/view/swing/panel/split/SplitNS::getActionHideShowResult → NO_COVERAGE
        return SplitNS.ACTION_HIDE_SHOW_RESULT;
136
    }
137
}

Mutations

61

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JSplitPane::setLeftComponent → NO_COVERAGE

63

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JLabel::setMinimumSize → NO_COVERAGE

64

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JSplitPane::setRightComponent → NO_COVERAGE

66

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JSplitPane::setDividerLocation → NO_COVERAGE

69

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JLabel::setBorder → NO_COVERAGE

70

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

73

1.1
Location : mouseClicked
Killed by : none
removed call to com/jsql/view/swing/panel/split/ActionHideShowConsole::actionPerformed → NO_COVERAGE

76

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

77

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JPanel::setLayout → NO_COVERAGE

78

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JPanel::add → NO_COVERAGE

79

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JPanel::setVisible → NO_COVERAGE

80

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JPanel::addMouseListener → NO_COVERAGE

83

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

84

1.1
Location : mousePressed
Killed by : none
removed call to com/jsql/view/swing/panel/split/ActionHideShowConsole::actionPerformed → NO_COVERAGE

90

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JPanel::add → NO_COVERAGE

91

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JPanel::add → NO_COVERAGE

92

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/split/SplitNS::setTopComponent → NO_COVERAGE

95

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/util/MediatorHelper::register → NO_COVERAGE

96

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/split/SplitNS::setBottomComponent → NO_COVERAGE

98

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/split/SplitNS::setResizeWeight → NO_COVERAGE

105

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

107

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

108

1.1
Location : initSplitOrientation
Killed by : none
removed call to javax/swing/JSplitPane::setLeftComponent → NO_COVERAGE

110

1.1
Location : initSplitOrientation
Killed by : none
removed call to javax/swing/JSplitPane::setRightComponent → NO_COVERAGE

112

1.1
Location : lambda$initSplitOrientation$0
Killed by : none
removed call to javax/swing/JSplitPane::setDividerLocation → NO_COVERAGE

2.2
Location : initSplitOrientation
Killed by : none
removed call to javax/swing/SwingUtilities::invokeLater → NO_COVERAGE

117

1.1
Location : invokeLaterWithSplitOrientation
Killed by : none
removed call to javax/swing/SwingUtilities::invokeLater → NO_COVERAGE

118

1.1
Location : lambda$invokeLaterWithSplitOrientation$1
Killed by : none
removed call to com/jsql/view/swing/panel/split/SplitNS::initSplitOrientation → NO_COVERAGE

119

1.1
Location : lambda$invokeLaterWithSplitOrientation$1
Killed by : none
removed call to java/lang/Runnable::run → NO_COVERAGE

127

1.1
Location : getSplitEW
Killed by : none
replaced return value with null for com/jsql/view/swing/panel/split/SplitNS::getSplitEW → NO_COVERAGE

131

1.1
Location : getActionHideShowConsole
Killed by : none
replaced return value with null for com/jsql/view/swing/panel/split/SplitNS::getActionHideShowConsole → NO_COVERAGE

135

1.1
Location : getActionHideShowResult
Killed by : none
replaced return value with null for com/jsql/view/swing/panel/split/SplitNS::getActionHideShowResult → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.22.1