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