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
    /**
35
     * SplitPane containing Manager panels on the left and result tabs on the right.
36
     */
37
    private final JSplitPane splitEW = new JSplitPaneWithZeroSizeDivider(JSplitPane.HORIZONTAL_SPLIT);
38
39
    private static final JPanel PANEL_HIDDEN_CONSOLES = new JPanel();
40
    
41
    /**
42
     * MouseAdapter used on arrow on tabbedpane header and on
43
     * ersatz button when bottom panel is hidden.
44
     */
45
    private static final ActionHideShowConsole ACTION_HIDE_SHOW_CONSOLE = new ActionHideShowConsole(SplitNS.PANEL_HIDDEN_CONSOLES);
46
    private static final ActionHideShowResult ACTION_HIDE_SHOW_RESULT= new ActionHideShowResult();
47
48
    /**
49
     * Create main panel with Manager panels on the left, result tabs on the right,
50
     * and consoles in the bottom.
51
     */
52
    public SplitNS() {
53
        super(JSplitPane.VERTICAL_SPLIT);
54
        var preferences = Preferences.userRoot().node(InjectionModel.class.getName());
55
        var verticalLeftRightSplitter = preferences.getInt(PreferencesUtil.EW_SPLIT, 350);
56
        var tabManagersProxy = new TabManagersCards();
57
        new TabResults();  // initialized but hidden
58
59
        // Tree and tabs on top
60 1 1. <init> : removed call to javax/swing/JSplitPane::setLeftComponent → NO_COVERAGE
        this.splitEW.setLeftComponent(tabManagersProxy);
61
        JLabel labelApp = new JLabel(UiUtil.APP_BIG.getIcon());
62 1 1. <init> : removed call to javax/swing/JLabel::setMinimumSize → NO_COVERAGE
        labelApp.setMinimumSize(new Dimension(100, 0));
63 1 1. <init> : removed call to javax/swing/JSplitPane::setRightComponent → NO_COVERAGE
        this.splitEW.setRightComponent(labelApp);
64 1 1. <init> : removed call to javax/swing/JSplitPane::setDividerLocation → NO_COVERAGE
        this.splitEW.setDividerLocation(verticalLeftRightSplitter);
65
66
        JLabel labelShowConsoles = new JLabel(UiUtil.ARROW_UP.getIcon());
67 1 1. <init> : removed call to javax/swing/JLabel::setBorder → NO_COVERAGE
        labelShowConsoles.setBorder(BorderFactory.createEmptyBorder());
68 1 1. <init> : removed call to javax/swing/JLabel::addMouseListener → NO_COVERAGE
        labelShowConsoles.addMouseListener(new MouseAdapter() {
69
            @Override
70
            public void mouseClicked(MouseEvent e) {
71 1 1. mouseClicked : removed call to com/jsql/view/swing/panel/split/ActionHideShowConsole::actionPerformed → NO_COVERAGE
                SplitNS.ACTION_HIDE_SHOW_CONSOLE.actionPerformed(null);
72
            }
73
        });
74 1 1. <init> : removed call to javax/swing/JLabel::setName → NO_COVERAGE
        labelShowConsoles.setName("buttonShowConsolesHidden");
75 1 1. <init> : removed call to javax/swing/JPanel::setLayout → NO_COVERAGE
        SplitNS.PANEL_HIDDEN_CONSOLES.setLayout(new BorderLayout());
76 1 1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE
        SplitNS.PANEL_HIDDEN_CONSOLES.add(labelShowConsoles, BorderLayout.LINE_END);
77 1 1. <init> : removed call to javax/swing/JPanel::setVisible → NO_COVERAGE
        SplitNS.PANEL_HIDDEN_CONSOLES.setVisible(false);
78 1 1. <init> : removed call to javax/swing/JPanel::addMouseListener → NO_COVERAGE
        SplitNS.PANEL_HIDDEN_CONSOLES.addMouseListener(new MouseAdapter() {
79
            @Override
80
            public void mousePressed(MouseEvent e) {
81 1 1. mousePressed : negated conditional → NO_COVERAGE
                if (e.getButton() == MouseEvent.BUTTON2) {  // middle click on header with no tab
82 1 1. mousePressed : removed call to com/jsql/view/swing/panel/split/ActionHideShowConsole::actionPerformed → NO_COVERAGE
                    SplitNS.ACTION_HIDE_SHOW_CONSOLE.actionPerformed(null);
83
                }
84
            }
85
        });
86
87
        var panelManagerResult = new JPanel(new BorderLayout());
88 1 1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE
        panelManagerResult.add(this.splitEW, BorderLayout.CENTER);
89 1 1. <init> : removed call to javax/swing/JPanel::add → NO_COVERAGE
        panelManagerResult.add(SplitNS.PANEL_HIDDEN_CONSOLES, BorderLayout.SOUTH);
90 1 1. <init> : removed call to com/jsql/view/swing/panel/split/SplitNS::setTopComponent → NO_COVERAGE
        this.setTopComponent(panelManagerResult);
91
92
        var panelConsoles = new PanelConsoles();
93 1 1. <init> : removed call to com/jsql/view/swing/util/MediatorHelper::register → NO_COVERAGE
        MediatorHelper.register(panelConsoles);
94 1 1. <init> : removed call to com/jsql/view/swing/panel/split/SplitNS::setBottomComponent → NO_COVERAGE
        this.setBottomComponent(panelConsoles);
95
96 1 1. <init> : removed call to com/jsql/view/swing/panel/split/SplitNS::setResizeWeight → NO_COVERAGE
        this.setResizeWeight(1);
97
    }
98
99
    /**
100
     * Switch left component with right component when locale orientation requires this.
101
     */
102
    public void initSplitOrientation() {
103 1 1. initSplitOrientation : negated conditional → NO_COVERAGE
        if (MediatorHelper.tabResults().getTabCount() == 0) {
104
            int dividerLocation = this.splitEW.getDividerLocation();
105 1 1. initSplitOrientation : negated conditional → NO_COVERAGE
            if (ComponentOrientation.RIGHT_TO_LEFT.equals(ComponentOrientation.getOrientation(I18nUtil.getCurrentLocale()))) {
106 1 1. initSplitOrientation : removed call to javax/swing/JSplitPane::setLeftComponent → NO_COVERAGE
                this.splitEW.setLeftComponent(MediatorHelper.tabResults());
107
            } else {
108 1 1. initSplitOrientation : removed call to javax/swing/JSplitPane::setRightComponent → NO_COVERAGE
                this.splitEW.setRightComponent(MediatorHelper.tabResults());
109
            }
110 1 1. initSplitOrientation : removed call to javax/swing/JSplitPane::setDividerLocation → NO_COVERAGE
            this.splitEW.setDividerLocation(dividerLocation);
111
        }
112
    }
113
114
115
    // Getter and setter
116
117
    public JSplitPane getSplitEW() {
118 1 1. getSplitEW : replaced return value with null for com/jsql/view/swing/panel/split/SplitNS::getSplitEW → NO_COVERAGE
        return this.splitEW;
119
    }
120
121
    public static ActionHideShowConsole getActionHideShowConsole() {
122 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;
123
    }
124
    
125
    public static ActionHideShowResult getActionHideShowResult() {
126 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;
127
    }
128
}

Mutations

60

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

62

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

63

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

64

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

67

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

68

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

71

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

74

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

75

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

76

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

77

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

78

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

81

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

82

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

88

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

89

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

90

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

93

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

94

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

96

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

103

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

105

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

106

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

108

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

110

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

118

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

122

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

126

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