1 | /******************************************************************************* | |
2 | * Copyhacked (H) 2012-2020. | |
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 about 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; | |
12 | ||
13 | import com.jsql.model.InjectionModel; | |
14 | import com.jsql.util.LogLevelUtil; | |
15 | import com.jsql.view.swing.console.JTextPaneAppender; | |
16 | import com.jsql.view.swing.console.JavaConsoleAdapter; | |
17 | import com.jsql.view.swing.console.SimpleConsoleAdapter; | |
18 | import com.jsql.view.swing.panel.consoles.NetworkTable; | |
19 | import com.jsql.view.swing.panel.consoles.TabbedPaneNetworkTab; | |
20 | import com.jsql.view.swing.panel.split.SplitHorizontalTopBottom; | |
21 | import com.jsql.view.swing.scrollpane.JScrollIndicator; | |
22 | import com.jsql.view.swing.scrollpane.LightScrollPane; | |
23 | import com.jsql.view.swing.splitpane.JSplitPaneWithZeroSizeDivider; | |
24 | import com.jsql.view.swing.tab.TabConsoles; | |
25 | import com.jsql.view.swing.text.JPopupTextArea; | |
26 | import com.jsql.view.swing.text.JTextAreaPlaceholderConsole; | |
27 | import com.jsql.view.swing.text.JToolTipI18n; | |
28 | import com.jsql.view.swing.ui.CustomMetalTabbedPaneUI; | |
29 | import com.jsql.view.swing.util.I18nViewUtil; | |
30 | import com.jsql.view.swing.util.MediatorHelper; | |
31 | import com.jsql.view.swing.util.UiUtil; | |
32 | import org.apache.commons.lang3.StringUtils; | |
33 | import org.apache.logging.log4j.LogManager; | |
34 | import org.apache.logging.log4j.Logger; | |
35 | ||
36 | import javax.swing.*; | |
37 | import javax.swing.plaf.basic.BasicArrowButton; | |
38 | import javax.swing.table.DefaultTableModel; | |
39 | import java.awt.*; | |
40 | import java.awt.event.AdjustmentEvent; | |
41 | import java.awt.event.AdjustmentListener; | |
42 | import java.awt.event.MouseAdapter; | |
43 | import java.awt.event.MouseEvent; | |
44 | import java.util.prefs.Preferences; | |
45 | ||
46 | /** | |
47 | * A panel with different consoles displayed on the bottom. | |
48 | */ | |
49 | public class PanelConsoles extends JPanel { | |
50 | | |
51 | /** | |
52 | * Log4j logger sent to view. | |
53 | */ | |
54 | private static final Logger LOGGER = LogManager.getRootLogger(); | |
55 | ||
56 | /** | |
57 | * Console for java exception messages. | |
58 | */ | |
59 | private final JavaConsoleAdapter javaTextPane = new JavaConsoleAdapter("Java", "Java unhandled exception"); | |
60 | | |
61 | /** | |
62 | * Console for raw SQL results. | |
63 | */ | |
64 | private JTextArea chunkTextArea; | |
65 | ||
66 | /** | |
67 | * Panel displaying table of HTTP requests and responses. | |
68 | */ | |
69 | private JSplitPaneWithZeroSizeDivider networkSplitPane; | |
70 | ||
71 | /** | |
72 | * Console for binary representation of characters found with blind/time injection. | |
73 | */ | |
74 | private JTextArea binaryTextArea; | |
75 | ||
76 | private final TabConsoles tabConsoles = new TabConsoles(); | |
77 | private TabbedPaneNetworkTab tabbedPaneNetworkTab; | |
78 | private NetworkTable networkTable; | |
79 | | |
80 | private final BasicArrowButton buttonShowNorth = new BasicArrowButton(SwingConstants.NORTH); | |
81 | private int location = 0; | |
82 | | |
83 | /** | |
84 | * Create panel at the bottom with different consoles to report injection process. | |
85 | */ | |
86 | public PanelConsoles() { | |
87 | | |
88 |
1
1. <init> : removed call to javax/swing/JTextPane::setEditable → NO_COVERAGE |
this.javaTextPane.getProxy().setEditable(false); |
89 |
1
1. <init> : removed call to com/jsql/view/swing/console/JTextPaneAppender::register → NO_COVERAGE |
JTextPaneAppender.register(this.javaTextPane); |
90 | | |
91 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelConsoles::initializeSplit → NO_COVERAGE |
this.initializeSplit(); |
92 | ||
93 |
1
1. <init> : removed call to com/jsql/view/swing/util/MediatorHelper::register → NO_COVERAGE |
MediatorHelper.register(this.tabConsoles); |
94 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelConsoles::initializeTabsConsoles → NO_COVERAGE |
this.initializeTabsConsoles(); |
95 | ||
96 |
1
1. <init> : removed call to com/jsql/view/swing/panel/PanelConsoles::setLayout → NO_COVERAGE |
this.setLayout(new OverlayLayout(this)); |
97 | ||
98 | JPanel expandPanel = this.initializeExpandPanel(); | |
99 | | |
100 | this.add(expandPanel); | |
101 | this.add(this.tabConsoles); | |
102 | ||
103 | // Do Overlay | |
104 |
1
1. <init> : removed call to javax/swing/JPanel::setAlignmentX → NO_COVERAGE |
expandPanel.setAlignmentX(FlowLayout.TRAILING); |
105 |
1
1. <init> : removed call to javax/swing/JPanel::setAlignmentY → NO_COVERAGE |
expandPanel.setAlignmentY(Component.TOP_ALIGNMENT); |
106 |
1
1. <init> : removed call to com/jsql/view/swing/tab/TabConsoles::setAlignmentX → NO_COVERAGE |
this.tabConsoles.setAlignmentX(FlowLayout.LEADING); |
107 |
1
1. <init> : removed call to com/jsql/view/swing/tab/TabConsoles::setAlignmentY → NO_COVERAGE |
this.tabConsoles.setAlignmentY(Component.TOP_ALIGNMENT); |
108 | } | |
109 | ||
110 | private void initializeSplit() { | |
111 | | |
112 | this.networkSplitPane = new JSplitPaneWithZeroSizeDivider(JSplitPane.HORIZONTAL_SPLIT); | |
113 | | |
114 |
1
1. initializeSplit : removed call to com/jsql/view/swing/splitpane/JSplitPaneWithZeroSizeDivider::setResizeWeight → NO_COVERAGE |
this.networkSplitPane.setResizeWeight(1); |
115 |
1
1. initializeSplit : removed call to com/jsql/view/swing/splitpane/JSplitPaneWithZeroSizeDivider::setDividerSize → NO_COVERAGE |
this.networkSplitPane.setDividerSize(0); |
116 |
1
1. initializeSplit : removed call to com/jsql/view/swing/splitpane/JSplitPaneWithZeroSizeDivider::setDividerLocation → NO_COVERAGE |
this.networkSplitPane.setDividerLocation(600); |
117 |
1
1. initializeSplit : removed call to com/jsql/view/swing/splitpane/JSplitPaneWithZeroSizeDivider::setBorder → NO_COVERAGE |
this.networkSplitPane.setBorder(BorderFactory.createEmptyBorder()); |
118 | | |
119 | this.tabbedPaneNetworkTab = new TabbedPaneNetworkTab(); | |
120 | | |
121 |
1
1. initializeSplit : removed call to com/jsql/view/swing/splitpane/JSplitPaneWithZeroSizeDivider::setRightComponent → NO_COVERAGE |
this.networkSplitPane.setRightComponent(this.tabbedPaneNetworkTab); |
122 | | |
123 | this.networkTable = new NetworkTable(this.tabbedPaneNetworkTab); | |
124 | | |
125 | JScrollIndicator scrollerNetwork = this.initializeScrollerTable(); | |
126 |
1
1. initializeSplit : removed call to com/jsql/view/swing/splitpane/JSplitPaneWithZeroSizeDivider::setLeftComponent → NO_COVERAGE |
this.networkSplitPane.setLeftComponent(scrollerNetwork); |
127 | } | |
128 | ||
129 | private JScrollIndicator initializeScrollerTable() { | |
130 | | |
131 | var scrollerNetwork = new JScrollIndicator(this.networkTable, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); | |
132 |
1
1. initializeScrollerTable : removed call to javax/swing/JScrollPane::setBorder → NO_COVERAGE |
scrollerNetwork.getScrollPane().setBorder(BorderFactory.createEmptyBorder(0, 0, -1, -1)); |
133 |
1
1. initializeScrollerTable : removed call to javax/swing/JScrollPane::setViewportBorder → NO_COVERAGE |
scrollerNetwork.getScrollPane().setViewportBorder(BorderFactory.createEmptyBorder(0, 0, -1, -1)); |
134 | | |
135 | AdjustmentListener singleItemScroll = adjustmentEvent -> { | |
136 | | |
137 | // The user scrolled the List (using the bar, mouse wheel or something else): | |
138 |
1
1. lambda$initializeScrollerTable$0 : negated conditional → NO_COVERAGE |
if (adjustmentEvent.getAdjustmentType() == AdjustmentEvent.TRACK) { |
139 | | |
140 | // Jump to the next "block" (which is a row". | |
141 |
1
1. lambda$initializeScrollerTable$0 : removed call to java/awt/Adjustable::setBlockIncrement → NO_COVERAGE |
adjustmentEvent.getAdjustable().setBlockIncrement(100); |
142 |
1
1. lambda$initializeScrollerTable$0 : removed call to java/awt/Adjustable::setUnitIncrement → NO_COVERAGE |
adjustmentEvent.getAdjustable().setUnitIncrement(100); |
143 | } | |
144 | }; | |
145 | ||
146 |
1
1. initializeScrollerTable : removed call to javax/swing/JScrollBar::addAdjustmentListener → NO_COVERAGE |
scrollerNetwork.getScrollPane().getVerticalScrollBar().addAdjustmentListener(singleItemScroll); |
147 |
1
1. initializeScrollerTable : removed call to javax/swing/JScrollBar::addAdjustmentListener → NO_COVERAGE |
scrollerNetwork.getScrollPane().getHorizontalScrollBar().addAdjustmentListener(singleItemScroll); |
148 | | |
149 |
1
1. initializeScrollerTable : replaced return value with null for com/jsql/view/swing/panel/PanelConsoles::initializeScrollerTable → NO_COVERAGE |
return scrollerNetwork; |
150 | } | |
151 | ||
152 | private void initializeTabsConsoles() { | |
153 | | |
154 | this.chunkTextArea = new JPopupTextArea(new JTextAreaPlaceholderConsole("Raw data extracted during injection")).getProxy(); | |
155 |
1
1. initializeTabsConsoles : removed call to javax/swing/JTextArea::setEditable → NO_COVERAGE |
this.chunkTextArea.setEditable(false); |
156 | | |
157 | this.binaryTextArea = new JPopupTextArea(new JTextAreaPlaceholderConsole("Characters extracted during blind or time injection")).getProxy(); | |
158 |
1
1. initializeTabsConsoles : removed call to javax/swing/JTextArea::setEditable → NO_COVERAGE |
this.binaryTextArea.setEditable(false); |
159 | ||
160 |
1
1. initializeTabsConsoles : removed call to javax/swing/JTextArea::setLineWrap → NO_COVERAGE |
this.chunkTextArea.setLineWrap(true); |
161 |
1
1. initializeTabsConsoles : removed call to javax/swing/JTextArea::setLineWrap → NO_COVERAGE |
this.binaryTextArea.setLineWrap(true); |
162 | | |
163 | var consoleTextPane = new SimpleConsoleAdapter("Console", "Event logging"); | |
164 | | |
165 | // Object creation after customization | |
166 |
1
1. initializeTabsConsoles : removed call to javax/swing/JTextPane::setEditable → NO_COVERAGE |
consoleTextPane.getProxy().setEditable(false); |
167 | ||
168 |
1
1. initializeTabsConsoles : removed call to com/jsql/view/swing/console/JTextPaneAppender::register → NO_COVERAGE |
JTextPaneAppender.register(consoleTextPane); |
169 | | |
170 |
1
1. initializeTabsConsoles : removed call to com/jsql/view/swing/tab/TabConsoles::setUI → NO_COVERAGE |
this.tabConsoles.setUI(new CustomMetalTabbedPaneUI() { |
171 | | |
172 | @Override protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) { | |
173 |
1
1. calculateTabWidth : replaced int return with 0 for com/jsql/view/swing/panel/PanelConsoles$1::calculateTabWidth → NO_COVERAGE |
return Math.max(80, super.calculateTabWidth(tabPlacement, tabIndex, metrics)); |
174 | } | |
175 | }); | |
176 | | |
177 |
1
1. initializeTabsConsoles : removed call to com/jsql/view/swing/tab/TabConsoles::setBorder → NO_COVERAGE |
this.tabConsoles.setBorder(BorderFactory.createEmptyBorder(1, 0, 0, 0)); |
178 | ||
179 |
1
1. initializeTabsConsoles : removed call to com/jsql/view/swing/panel/PanelConsoles::buildI18nTab → NO_COVERAGE |
this.buildI18nTab( |
180 | "CONSOLE_MAIN_LABEL", | |
181 | "CONSOLE_MAIN_TOOLTIP", | |
182 | UiUtil.ICON_CONSOLE, | |
183 | new LightScrollPane(1, 0, 0, 0, consoleTextPane.getProxy()), | |
184 | 0 | |
185 | ); | |
186 | ||
187 | // Order is important | |
188 | var preferences = Preferences.userRoot().node(InjectionModel.class.getName()); | |
189 |
1
1. initializeTabsConsoles : negated conditional → NO_COVERAGE |
if (preferences.getBoolean(UiUtil.JAVA_VISIBLE, false)) { |
190 |
1
1. initializeTabsConsoles : removed call to com/jsql/view/swing/panel/PanelConsoles::insertJavaTab → NO_COVERAGE |
this.insertJavaTab(); |
191 | } | |
192 | | |
193 |
1
1. initializeTabsConsoles : negated conditional → NO_COVERAGE |
if (preferences.getBoolean(UiUtil.NETWORK_VISIBLE, true)) { |
194 |
1
1. initializeTabsConsoles : removed call to com/jsql/view/swing/panel/PanelConsoles::insertNetworkTab → NO_COVERAGE |
this.insertNetworkTab(); |
195 | } | |
196 | | |
197 |
1
1. initializeTabsConsoles : negated conditional → NO_COVERAGE |
if (preferences.getBoolean(UiUtil.CHUNK_VISIBLE, true)) { |
198 |
1
1. initializeTabsConsoles : removed call to com/jsql/view/swing/panel/PanelConsoles::insertChunkTab → NO_COVERAGE |
this.insertChunkTab(); |
199 | } | |
200 | | |
201 |
1
1. initializeTabsConsoles : negated conditional → NO_COVERAGE |
if (preferences.getBoolean(UiUtil.BINARY_VISIBLE, true)) { |
202 |
1
1. initializeTabsConsoles : removed call to com/jsql/view/swing/panel/PanelConsoles::insertBooleanTab → NO_COVERAGE |
this.insertBooleanTab(); |
203 | } | |
204 | ||
205 | // Reset Font when tab is selected | |
206 |
1
1. initializeTabsConsoles : removed call to com/jsql/view/swing/tab/TabConsoles::addChangeListener → NO_COVERAGE |
this.tabConsoles.addChangeListener(changeEvent -> { |
207 | | |
208 | JTabbedPane tabs = this.tabConsoles; | |
209 | | |
210 |
2
1. lambda$initializeTabsConsoles$1 : negated conditional → NO_COVERAGE 2. lambda$initializeTabsConsoles$1 : changed conditional boundary → NO_COVERAGE |
if (tabs.getSelectedIndex() > -1) { |
211 | | |
212 | var currentTabHeader = tabs.getTabComponentAt(tabs.getSelectedIndex()); | |
213 | | |
214 |
1
1. lambda$initializeTabsConsoles$1 : negated conditional → NO_COVERAGE |
if (currentTabHeader != null) { |
215 | | |
216 |
1
1. lambda$initializeTabsConsoles$1 : removed call to java/awt/Component::setFont → NO_COVERAGE |
currentTabHeader.setFont(currentTabHeader.getFont().deriveFont(Font.PLAIN)); |
217 |
1
1. lambda$initializeTabsConsoles$1 : removed call to java/awt/Component::setForeground → NO_COVERAGE |
currentTabHeader.setForeground(Color.BLACK); |
218 | } | |
219 | } | |
220 | }); | |
221 | } | |
222 | ||
223 | private JPanel initializeExpandPanel() { | |
224 | ||
225 | var buttonShowSouth = new BasicArrowButton(SwingConstants.SOUTH); | |
226 |
1
1. initializeExpandPanel : removed call to javax/swing/plaf/basic/BasicArrowButton::setName → NO_COVERAGE |
buttonShowSouth.setName("buttonShowSouth"); |
227 | ||
228 |
1
1. initializeExpandPanel : removed call to javax/swing/plaf/basic/BasicArrowButton::setBorderPainted → NO_COVERAGE |
buttonShowSouth.setBorderPainted(false); |
229 |
1
1. initializeExpandPanel : removed call to javax/swing/plaf/basic/BasicArrowButton::setPreferredSize → NO_COVERAGE |
buttonShowSouth.setPreferredSize(new Dimension(buttonShowSouth.getPreferredSize().width, buttonShowSouth.getPreferredSize().height)); |
230 |
1
1. initializeExpandPanel : removed call to javax/swing/plaf/basic/BasicArrowButton::setMaximumSize → NO_COVERAGE |
buttonShowSouth.setMaximumSize(buttonShowSouth.getPreferredSize()); |
231 |
1
1. initializeExpandPanel : removed call to javax/swing/plaf/basic/BasicArrowButton::setOpaque → NO_COVERAGE |
buttonShowSouth.setOpaque(false); |
232 |
1
1. initializeExpandPanel : removed call to javax/swing/plaf/basic/BasicArrowButton::setBorder → NO_COVERAGE |
buttonShowSouth.setBorder(BorderFactory.createEmptyBorder()); |
233 |
1
1. initializeExpandPanel : removed call to javax/swing/plaf/basic/BasicArrowButton::addActionListener → NO_COVERAGE |
buttonShowSouth.addActionListener(SplitHorizontalTopBottom.getActionHideShowConsole()); |
234 | | |
235 |
1
1. initializeExpandPanel : removed call to javax/swing/plaf/basic/BasicArrowButton::setBorderPainted → NO_COVERAGE |
this.buttonShowNorth.setBorderPainted(false); |
236 |
1
1. initializeExpandPanel : removed call to javax/swing/plaf/basic/BasicArrowButton::setPreferredSize → NO_COVERAGE |
this.buttonShowNorth.setPreferredSize(new Dimension(this.buttonShowNorth.getPreferredSize().width, this.buttonShowNorth.getPreferredSize().height)); |
237 |
1
1. initializeExpandPanel : removed call to javax/swing/plaf/basic/BasicArrowButton::setMaximumSize → NO_COVERAGE |
this.buttonShowNorth.setMaximumSize(this.buttonShowNorth.getPreferredSize()); |
238 |
1
1. initializeExpandPanel : removed call to javax/swing/plaf/basic/BasicArrowButton::setOpaque → NO_COVERAGE |
this.buttonShowNorth.setOpaque(false); |
239 |
1
1. initializeExpandPanel : removed call to javax/swing/plaf/basic/BasicArrowButton::setBorder → NO_COVERAGE |
this.buttonShowNorth.setBorder(BorderFactory.createEmptyBorder()); |
240 |
1
1. initializeExpandPanel : removed call to javax/swing/plaf/basic/BasicArrowButton::addActionListener → NO_COVERAGE |
this.buttonShowNorth.addActionListener(SplitHorizontalTopBottom.getActionHideShowResult()); |
241 |
1
1. initializeExpandPanel : removed call to javax/swing/plaf/basic/BasicArrowButton::setName → NO_COVERAGE |
this.buttonShowNorth.setName("buttonShowNorth"); |
242 | ||
243 | var arrowDownPanel = new JPanel(); | |
244 |
1
1. initializeExpandPanel : removed call to javax/swing/JPanel::setLayout → NO_COVERAGE |
arrowDownPanel.setLayout(new BorderLayout()); |
245 |
1
1. initializeExpandPanel : removed call to javax/swing/JPanel::setOpaque → NO_COVERAGE |
arrowDownPanel.setOpaque(false); |
246 | | |
247 | // Disable overlap with zerosizesplitter | |
248 |
1
1. initializeExpandPanel : removed call to javax/swing/JPanel::setBorder → NO_COVERAGE |
arrowDownPanel.setBorder(BorderFactory.createEmptyBorder(1, 0, 0, 0)); |
249 |
1
1. initializeExpandPanel : removed call to javax/swing/JPanel::setPreferredSize → NO_COVERAGE |
arrowDownPanel.setPreferredSize(new Dimension(Integer.MAX_VALUE, 26)); |
250 |
1
1. initializeExpandPanel : removed call to javax/swing/JPanel::setMaximumSize → NO_COVERAGE |
arrowDownPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 26)); |
251 | ||
252 | var panelExpander = new JPanel(new BorderLayout()); | |
253 |
1
1. initializeExpandPanel : removed call to javax/swing/JPanel::setBorder → NO_COVERAGE |
panelExpander.setBorder(BorderFactory.createEmptyBorder()); |
254 |
1
1. initializeExpandPanel : removed call to javax/swing/JPanel::add → NO_COVERAGE |
panelExpander.add(buttonShowSouth, BorderLayout.LINE_END); |
255 |
1
1. initializeExpandPanel : removed call to javax/swing/JPanel::add → NO_COVERAGE |
panelExpander.add(this.buttonShowNorth, BorderLayout.LINE_START); |
256 |
1
1. initializeExpandPanel : removed call to javax/swing/JPanel::add → NO_COVERAGE |
arrowDownPanel.add(panelExpander, BorderLayout.LINE_END); |
257 | | |
258 |
1
1. initializeExpandPanel : replaced return value with null for com/jsql/view/swing/panel/PanelConsoles::initializeExpandPanel → NO_COVERAGE |
return arrowDownPanel; |
259 | } | |
260 | ||
261 | public void reset() { | |
262 | | |
263 |
1
1. reset : removed call to java/util/List::clear → NO_COVERAGE |
this.networkTable.getListHttpHeader().clear(); |
264 | | |
265 | // Empty infos tabs | |
266 |
1
1. reset : removed call to javax/swing/JTextArea::setText → NO_COVERAGE |
this.getChunkTab().setText(StringUtils.EMPTY); |
267 |
1
1. reset : removed call to javax/swing/JTextArea::setText → NO_COVERAGE |
this.getBinaryTab().setText(StringUtils.EMPTY); |
268 | | |
269 | // Fix #4657, Fix #1860: Multiple Exceptions on setRowCount() | |
270 | try { | |
271 |
1
1. reset : removed call to javax/swing/table/DefaultTableModel::setRowCount → NO_COVERAGE |
((DefaultTableModel) this.networkTable.getModel()).setRowCount(0); |
272 | } catch(NullPointerException | ArrayIndexOutOfBoundsException e) { | |
273 | LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e, e); | |
274 | } | |
275 | | |
276 |
1
1. reset : removed call to javax/swing/JTextPane::setText → NO_COVERAGE |
this.javaTextPane.getProxy().setText(StringUtils.EMPTY); |
277 | | |
278 |
1
1. reset : removed call to com/jsql/view/swing/panel/consoles/TabbedPaneNetworkTab::reset → NO_COVERAGE |
this.tabbedPaneNetworkTab.reset(); |
279 | } | |
280 | ||
281 | /** | |
282 | * Add Chunk console to bottom panel. | |
283 | */ | |
284 | public void insertChunkTab() { | |
285 |
1
1. insertChunkTab : removed call to com/jsql/view/swing/panel/PanelConsoles::buildI18nTab → NO_COVERAGE |
this.buildI18nTab( |
286 | "CONSOLE_CHUNK_LABEL", | |
287 | "CONSOLE_CHUNK_TOOLTIP", | |
288 | UiUtil.ICON_CHUNK, | |
289 | new LightScrollPane(1, 0, 0, 0, PanelConsoles.this.chunkTextArea), | |
290 | 1 | |
291 | ); | |
292 | } | |
293 | ||
294 | /** | |
295 | * Add Binary console to bottom panel. | |
296 | */ | |
297 | public void insertBooleanTab() { | |
298 |
1
1. insertBooleanTab : removed call to com/jsql/view/swing/panel/PanelConsoles::buildI18nTab → NO_COVERAGE |
this.buildI18nTab( |
299 | "CONSOLE_BINARY_LABEL", | |
300 | "CONSOLE_BINARY_TOOLTIP", | |
301 | UiUtil.ICON_BINARY, | |
302 | new LightScrollPane(1, 0, 0, 0, PanelConsoles.this.binaryTextArea), | |
303 |
2
1. insertBooleanTab : negated conditional → NO_COVERAGE 2. insertBooleanTab : Replaced integer addition with subtraction → NO_COVERAGE |
1 + (MediatorHelper.menubar().getChunkMenu().isSelected() ? 1 : 0) |
304 | ); | |
305 | } | |
306 | ||
307 | /** | |
308 | * Add Network tab to bottom panel. | |
309 | */ | |
310 | public void insertNetworkTab() { | |
311 |
1
1. insertNetworkTab : removed call to com/jsql/view/swing/panel/PanelConsoles::buildI18nTab → NO_COVERAGE |
this.buildI18nTab( |
312 | "CONSOLE_NETWORK_LABEL", | |
313 | "CONSOLE_NETWORK_TOOLTIP", | |
314 | UiUtil.ICON_HEADER, | |
315 | new LightScrollPane(1, 0, 0, 0, PanelConsoles.this.networkSplitPane), | |
316 |
2
1. insertNetworkTab : negated conditional → NO_COVERAGE 2. insertNetworkTab : Replaced integer subtraction with addition → NO_COVERAGE |
this.tabConsoles.getTabCount() - (MediatorHelper.menubar().getJavaDebugMenu().isSelected() ? 1 : 0) |
317 | ); | |
318 | } | |
319 | ||
320 | /** | |
321 | * Add Java console to bottom panel. | |
322 | */ | |
323 | public void insertJavaTab() { | |
324 |
1
1. insertJavaTab : removed call to com/jsql/view/swing/panel/PanelConsoles::buildI18nTab → NO_COVERAGE |
this.buildI18nTab( |
325 | "CONSOLE_JAVA_LABEL", | |
326 | "CONSOLE_JAVA_TOOLTIP", | |
327 | UiUtil.ICON_CUP, | |
328 | new LightScrollPane(1, 0, 0, 0, this.javaTextPane.getProxy()), | |
329 | this.tabConsoles.getTabCount() | |
330 | ); | |
331 | } | |
332 | | |
333 | private void buildI18nTab(String keyLabel, String keyTooltip, Icon icon, Component manager, int position) { | |
334 | | |
335 | final var refJToolTipI18n = new JToolTipI18n[]{ new JToolTipI18n(I18nViewUtil.valueByKey(keyTooltip)) }; | |
336 | | |
337 | var labelTab = new JLabel(I18nViewUtil.valueByKey(keyLabel), icon, SwingConstants.CENTER) { | |
338 | @Override | |
339 | public JToolTip createToolTip() { | |
340 | | |
341 | JToolTipI18n tipI18n = new JToolTipI18n(I18nViewUtil.valueByKey(keyTooltip)); | |
342 | refJToolTipI18n[0] = tipI18n; | |
343 | | |
344 |
1
1. createToolTip : replaced return value with null for com/jsql/view/swing/panel/PanelConsoles$2::createToolTip → NO_COVERAGE |
return tipI18n; |
345 | } | |
346 | }; | |
347 | | |
348 |
1
1. buildI18nTab : removed call to com/jsql/view/swing/panel/PanelConsoles$2::setName → NO_COVERAGE |
labelTab.setName(keyLabel); |
349 |
1
1. buildI18nTab : removed call to com/jsql/view/swing/panel/PanelConsoles$2::addMouseListener → NO_COVERAGE |
labelTab.addMouseListener(new MouseAdapter() { |
350 | @Override | |
351 | public void mousePressed(MouseEvent event) { | |
352 | | |
353 | // Fix #90428: IllegalArgumentException in setSelectedComponent() | |
354 | // ArrayIndexOutOfBoundsException #92973 on setSelectedComponent() | |
355 | try { | |
356 |
1
1. mousePressed : removed call to com/jsql/view/swing/tab/TabConsoles::setSelectedComponent → NO_COVERAGE |
PanelConsoles.this.tabConsoles.setSelectedComponent(manager); |
357 | } catch (IllegalArgumentException e) { | |
358 | LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e, e); | |
359 | } | |
360 | | |
361 |
1
1. mousePressed : removed call to java/awt/event/MouseAdapter::mousePressed → NO_COVERAGE |
super.mousePressed(event); |
362 | } | |
363 | }); | |
364 | | |
365 |
1
1. buildI18nTab : removed call to com/jsql/view/swing/tab/TabConsoles::insertTab → NO_COVERAGE |
this.tabConsoles.insertTab(I18nViewUtil.valueByKey(keyLabel), icon, manager, null, position); |
366 |
1
1. buildI18nTab : removed call to com/jsql/view/swing/tab/TabConsoles::setTabComponentAt → NO_COVERAGE |
this.tabConsoles.setTabComponentAt( |
367 | this.tabConsoles.indexOfTab(I18nViewUtil.valueByKey(keyLabel)), | |
368 | labelTab | |
369 | ); | |
370 | | |
371 |
1
1. buildI18nTab : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey(keyLabel, labelTab); |
372 |
1
1. buildI18nTab : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey(keyTooltip, refJToolTipI18n[0]); |
373 |
1
1. buildI18nTab : removed call to com/jsql/view/swing/panel/PanelConsoles$2::setToolTipText → NO_COVERAGE |
labelTab.setToolTipText(I18nViewUtil.valueByKey(keyTooltip)); |
374 | } | |
375 | | |
376 | public void messageChunk(String text) { | |
377 | try { | |
378 |
1
1. messageChunk : removed call to javax/swing/JTextArea::append → NO_COVERAGE |
this.chunkTextArea.append(text +"\n"); |
379 |
1
1. messageChunk : removed call to javax/swing/JTextArea::setCaretPosition → NO_COVERAGE |
this.chunkTextArea.setCaretPosition(this.chunkTextArea.getDocument().getLength()); |
380 | | |
381 | } catch (NullPointerException | ArrayIndexOutOfBoundsException e) { | |
382 | // Fix #67063: NullPointerException on chunkTab.append() | |
383 | // Fix #4770 on chunkTab.append() | |
384 | LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e.getMessage(), e); | |
385 | } | |
386 | } | |
387 | | |
388 | public void messageBinary(String text) { | |
389 | try { | |
390 |
1
1. messageBinary : removed call to javax/swing/JTextArea::append → NO_COVERAGE |
this.binaryTextArea.append( |
391 | String.format("\t%s", text) | |
392 | ); | |
393 |
1
1. messageBinary : removed call to javax/swing/JTextArea::setCaretPosition → NO_COVERAGE |
this.binaryTextArea.setCaretPosition(this.binaryTextArea.getDocument().getLength()); |
394 | | |
395 | } catch (NullPointerException | ArrayIndexOutOfBoundsException e) { | |
396 | LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e.getMessage(), e); | |
397 | } | |
398 | } | |
399 | | |
400 | | |
401 | // Getter and setter | |
402 | ||
403 | public JTextArea getChunkTab() { | |
404 |
1
1. getChunkTab : replaced return value with null for com/jsql/view/swing/panel/PanelConsoles::getChunkTab → NO_COVERAGE |
return this.chunkTextArea; |
405 | } | |
406 | ||
407 | public JSplitPaneWithZeroSizeDivider getNetworkSplitPane() { | |
408 |
1
1. getNetworkSplitPane : replaced return value with null for com/jsql/view/swing/panel/PanelConsoles::getNetworkSplitPane → NO_COVERAGE |
return this.networkSplitPane; |
409 | } | |
410 | ||
411 | public JTextArea getBinaryTab() { | |
412 |
1
1. getBinaryTab : replaced return value with null for com/jsql/view/swing/panel/PanelConsoles::getBinaryTab → NO_COVERAGE |
return this.binaryTextArea; |
413 | } | |
414 | ||
415 | public int getDividerLocation() { | |
416 |
1
1. getDividerLocation : replaced int return with 0 for com/jsql/view/swing/panel/PanelConsoles::getDividerLocation → NO_COVERAGE |
return this.location; |
417 | } | |
418 | ||
419 | public void setDividerLocation(int location) { | |
420 | this.location = location; | |
421 | } | |
422 | ||
423 | public BasicArrowButton getButtonShowNorth() { | |
424 |
1
1. getButtonShowNorth : replaced return value with null for com/jsql/view/swing/panel/PanelConsoles::getButtonShowNorth → NO_COVERAGE |
return this.buttonShowNorth; |
425 | } | |
426 | ||
427 | public NetworkTable getNetworkTable() { | |
428 |
1
1. getNetworkTable : replaced return value with null for com/jsql/view/swing/panel/PanelConsoles::getNetworkTable → NO_COVERAGE |
return this.networkTable; |
429 | } | |
430 | } | |
Mutations | ||
88 |
1.1 |
|
89 |
1.1 |
|
91 |
1.1 |
|
93 |
1.1 |
|
94 |
1.1 |
|
96 |
1.1 |
|
104 |
1.1 |
|
105 |
1.1 |
|
106 |
1.1 |
|
107 |
1.1 |
|
114 |
1.1 |
|
115 |
1.1 |
|
116 |
1.1 |
|
117 |
1.1 |
|
121 |
1.1 |
|
126 |
1.1 |
|
132 |
1.1 |
|
133 |
1.1 |
|
138 |
1.1 |
|
141 |
1.1 |
|
142 |
1.1 |
|
146 |
1.1 |
|
147 |
1.1 |
|
149 |
1.1 |
|
155 |
1.1 |
|
158 |
1.1 |
|
160 |
1.1 |
|
161 |
1.1 |
|
166 |
1.1 |
|
168 |
1.1 |
|
170 |
1.1 |
|
173 |
1.1 |
|
177 |
1.1 |
|
179 |
1.1 |
|
189 |
1.1 |
|
190 |
1.1 |
|
193 |
1.1 |
|
194 |
1.1 |
|
197 |
1.1 |
|
198 |
1.1 |
|
201 |
1.1 |
|
202 |
1.1 |
|
206 |
1.1 |
|
210 |
1.1 2.2 |
|
214 |
1.1 |
|
216 |
1.1 |
|
217 |
1.1 |
|
226 |
1.1 |
|
228 |
1.1 |
|
229 |
1.1 |
|
230 |
1.1 |
|
231 |
1.1 |
|
232 |
1.1 |
|
233 |
1.1 |
|
235 |
1.1 |
|
236 |
1.1 |
|
237 |
1.1 |
|
238 |
1.1 |
|
239 |
1.1 |
|
240 |
1.1 |
|
241 |
1.1 |
|
244 |
1.1 |
|
245 |
1.1 |
|
248 |
1.1 |
|
249 |
1.1 |
|
250 |
1.1 |
|
253 |
1.1 |
|
254 |
1.1 |
|
255 |
1.1 |
|
256 |
1.1 |
|
258 |
1.1 |
|
263 |
1.1 |
|
266 |
1.1 |
|
267 |
1.1 |
|
271 |
1.1 |
|
276 |
1.1 |
|
278 |
1.1 |
|
285 |
1.1 |
|
298 |
1.1 |
|
303 |
1.1 2.2 |
|
311 |
1.1 |
|
316 |
1.1 2.2 |
|
324 |
1.1 |
|
344 |
1.1 |
|
348 |
1.1 |
|
349 |
1.1 |
|
356 |
1.1 |
|
361 |
1.1 |
|
365 |
1.1 |
|
366 |
1.1 |
|
371 |
1.1 |
|
372 |
1.1 |
|
373 |
1.1 |
|
378 |
1.1 |
|
379 |
1.1 |
|
390 |
1.1 |
|
393 |
1.1 |
|
404 |
1.1 |
|
408 |
1.1 |
|
412 |
1.1 |
|
416 |
1.1 |
|
424 |
1.1 |
|
428 |
1.1 |