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.menubar; | |
12 | ||
13 | import com.jsql.util.GitUtil.ShowOnConsole; | |
14 | import com.jsql.util.I18nUtil; | |
15 | import com.jsql.util.LogLevelUtil; | |
16 | import com.jsql.view.swing.action.ActionSaveTab; | |
17 | import com.jsql.view.swing.action.HotkeyUtil; | |
18 | import com.jsql.view.swing.console.JTextPaneAppender; | |
19 | import com.jsql.view.swing.dialog.DialogAbout; | |
20 | import com.jsql.view.swing.dialog.DialogTranslate; | |
21 | import com.jsql.view.swing.dialog.translate.Language; | |
22 | import com.jsql.view.swing.panel.preferences.PanelExploit; | |
23 | import com.jsql.view.swing.panel.preferences.PanelTampering; | |
24 | import com.jsql.view.swing.sql.SqlEngine; | |
25 | import com.jsql.view.swing.table.PanelTable; | |
26 | import com.jsql.view.swing.text.JPopupTextArea; | |
27 | import com.jsql.view.swing.util.I18nViewUtil; | |
28 | import com.jsql.view.swing.util.MediatorHelper; | |
29 | import com.jsql.view.swing.util.ModelSvgIcon; | |
30 | import com.jsql.view.swing.util.UiUtil; | |
31 | import org.apache.commons.lang3.StringUtils; | |
32 | import org.apache.logging.log4j.LogManager; | |
33 | import org.apache.logging.log4j.Logger; | |
34 | ||
35 | import javax.swing.*; | |
36 | import javax.swing.table.JTableHeader; | |
37 | import javax.swing.table.TableColumnModel; | |
38 | import javax.swing.text.JTextComponent; | |
39 | import javax.swing.text.StyleConstants; | |
40 | import java.awt.*; | |
41 | import java.awt.event.InputEvent; | |
42 | import java.awt.event.KeyEvent; | |
43 | import java.awt.event.MouseAdapter; | |
44 | import java.awt.event.MouseEvent; | |
45 | import java.util.Arrays; | |
46 | import java.util.List; | |
47 | import java.util.Locale; | |
48 | import java.util.stream.Collectors; | |
49 | import java.util.stream.Stream; | |
50 | ||
51 | /** | |
52 | * Application main menubar. | |
53 | */ | |
54 | public class AppMenubar extends JMenuBar { | |
55 | | |
56 | /** | |
57 | * Log4j logger sent to view. | |
58 | */ | |
59 | private static final Logger LOGGER = LogManager.getRootLogger(); | |
60 | ||
61 | private final MenuWindows menuWindows; | |
62 | ||
63 | protected static final List<ModelItemTranslate> MODELS_ITEM = Stream.of( | |
64 | Language.EN, Language.FR, Language.RU, Language.ZH, Language.ES, Language.TR, Language.KO, Language.SE, Language.FI, | |
65 | Language.AR, Language.CS, Language.IT, Language.PT, Language.PL, Language.IN, Language.NL, Language.RO, Language.DE | |
66 | ).map(ModelItemTranslate::new).collect(Collectors.toList()); | |
67 | ||
68 | private static final List<ModelItemTranslate> MODELS_ITEM_INTO = Stream.of( | |
69 | Language.FR, Language.ES, Language.SE, Language.FI, Language.TR, Language.CS, Language.RO, Language.IT, Language.PT, Language.AR, | |
70 | Language.PL, Language.RU, Language.ZH, Language.DE, Language.IN, Language.JA, Language.KO, Language.HI, Language.NL, Language.TA | |
71 | ).map(ModelItemTranslate::new).collect(Collectors.toList()); | |
72 | ||
73 | /** | |
74 | * Create a menubar on main frame. | |
75 | */ | |
76 | public AppMenubar() { | |
77 | this.add(this.initMenuFile()); | |
78 | this.add(this.initMenuEdit()); | |
79 | this.add(this.initMenuCommunity()); | |
80 | this.menuWindows = new MenuWindows(this); | |
81 | this.add(this.menuWindows); | |
82 | this.add(this.initMenuHelp()); | |
83 | } | |
84 | ||
85 | private JMenu initMenuFile() { | |
86 | var menuFile = new JMenu(I18nUtil.valueByKey("MENUBAR_FILE")); | |
87 |
1
1. initMenuFile : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey("MENUBAR_FILE", menuFile); |
88 |
1
1. initMenuFile : removed call to javax/swing/JMenu::setMnemonic → NO_COVERAGE |
menuFile.setMnemonic('F'); |
89 | ||
90 | JMenuItem itemSave = new JMenuItem(new ActionSaveTab()); | |
91 |
1
1. initMenuFile : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey("MENUBAR_FILE_SAVETABAS", itemSave); |
92 | ||
93 | JMenuItem itemExit = new JMenuItem(I18nUtil.valueByKey("MENUBAR_FILE_EXIT"), 'x'); | |
94 |
1
1. initMenuFile : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey("MENUBAR_FILE_EXIT", itemExit); |
95 |
2
1. initMenuFile : removed call to javax/swing/JMenuItem::addActionListener → NO_COVERAGE 2. lambda$initMenuFile$0 : removed call to com/jsql/view/swing/JFrameView::dispose → NO_COVERAGE |
itemExit.addActionListener(actionEvent -> MediatorHelper.frame().dispose()); |
96 | ||
97 |
1
1. initMenuFile : removed call to com/jsql/view/swing/action/HotkeyUtil::addShortcut → NO_COVERAGE |
HotkeyUtil.addShortcut(this); |
98 | ||
99 | menuFile.add(itemSave); | |
100 | menuFile.add(new JSeparator()); | |
101 | menuFile.add(itemExit); | |
102 |
1
1. initMenuFile : replaced return value with null for com/jsql/view/swing/menubar/AppMenubar::initMenuFile → NO_COVERAGE |
return menuFile; |
103 | } | |
104 | ||
105 | private JMenu initMenuEdit() { | |
106 | var menuEdit = new JMenu(I18nUtil.valueByKey("MENUBAR_EDIT")); | |
107 |
1
1. initMenuEdit : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey("MENUBAR_EDIT", menuEdit); |
108 |
1
1. initMenuEdit : removed call to javax/swing/JMenu::setMnemonic → NO_COVERAGE |
menuEdit.setMnemonic('E'); |
109 | ||
110 | JMenuItem itemCopy = new JMenuItem(I18nUtil.valueByKey("CONTEXT_MENU_COPY"), 'C'); | |
111 |
1
1. initMenuEdit : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey("CONTEXT_MENU_COPY", itemCopy); |
112 |
1
1. initMenuEdit : removed call to javax/swing/JMenuItem::setAccelerator → NO_COVERAGE |
itemCopy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK)); |
113 |
1
1. initMenuEdit : removed call to javax/swing/JMenuItem::addActionListener → NO_COVERAGE |
itemCopy.addActionListener(actionEvent -> { |
114 |
1
1. lambda$initMenuEdit$1 : negated conditional → NO_COVERAGE |
if (MediatorHelper.tabResults().getSelectedComponent() instanceof PanelTable) { |
115 |
1
1. lambda$initMenuEdit$1 : removed call to com/jsql/view/swing/table/PanelTable::copyTable → NO_COVERAGE |
((PanelTable) MediatorHelper.tabResults().getSelectedComponent()).copyTable(); |
116 |
1
1. lambda$initMenuEdit$1 : negated conditional → NO_COVERAGE |
} else if (MediatorHelper.tabResults().getSelectedComponent() instanceof JScrollPane) { |
117 |
1
1. lambda$initMenuEdit$1 : removed call to javax/swing/text/JTextComponent::copy → NO_COVERAGE |
((JTextComponent) ((JScrollPane) MediatorHelper.tabResults().getSelectedComponent()).getViewport().getView()).copy(); |
118 | } | |
119 | }); | |
120 | ||
121 | JMenuItem itemSelectAll = new JMenuItem(I18nUtil.valueByKey("CONTEXT_MENU_SELECT_ALL"), 'A'); | |
122 |
1
1. initMenuEdit : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey("CONTEXT_MENU_SELECT_ALL", itemSelectAll); |
123 |
1
1. initMenuEdit : removed call to javax/swing/JMenuItem::setAccelerator → NO_COVERAGE |
itemSelectAll.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK)); |
124 |
1
1. initMenuEdit : removed call to javax/swing/JMenuItem::addActionListener → NO_COVERAGE |
itemSelectAll.addActionListener(actionEvent -> { |
125 |
1
1. lambda$initMenuEdit$2 : negated conditional → NO_COVERAGE |
if (MediatorHelper.tabResults().getSelectedComponent() instanceof PanelTable) { |
126 |
1
1. lambda$initMenuEdit$2 : removed call to com/jsql/view/swing/table/PanelTable::selectTable → NO_COVERAGE |
((PanelTable) MediatorHelper.tabResults().getSelectedComponent()).selectTable(); |
127 |
1
1. lambda$initMenuEdit$2 : negated conditional → NO_COVERAGE |
} else if (MediatorHelper.tabResults().getSelectedComponent() instanceof JScrollPane) { |
128 | // Textarea need focus to select all | |
129 | ((JScrollPane) MediatorHelper.tabResults().getSelectedComponent()).getViewport().getView().requestFocusInWindow(); | |
130 |
1
1. lambda$initMenuEdit$2 : removed call to javax/swing/text/JTextComponent::selectAll → NO_COVERAGE |
((JTextComponent) ((JScrollPane) MediatorHelper.tabResults().getSelectedComponent()).getViewport().getView()).selectAll(); |
131 | } | |
132 | }); | |
133 | ||
134 | menuEdit.add(itemCopy); | |
135 | menuEdit.add(new JSeparator()); | |
136 | menuEdit.add(itemSelectAll); | |
137 |
1
1. initMenuEdit : replaced return value with null for com/jsql/view/swing/menubar/AppMenubar::initMenuEdit → NO_COVERAGE |
return menuEdit; |
138 | } | |
139 | ||
140 | private JMenu initMenuCommunity() { | |
141 | var menuCommunity = new JMenu(I18nUtil.valueByKey("MENUBAR_COMMUNITY")); | |
142 |
1
1. initMenuCommunity : removed call to javax/swing/JMenu::setMnemonic → NO_COVERAGE |
menuCommunity.setMnemonic('C'); |
143 |
1
1. initMenuCommunity : removed call to javax/swing/JMenu::setName → NO_COVERAGE |
menuCommunity.setName("menuCommunity"); |
144 |
1
1. initMenuCommunity : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey("MENUBAR_COMMUNITY", menuCommunity); |
145 | ||
146 | JMenu menuI18nContribution = this.initMenuI18nContribution(); | |
147 |
1
1. initMenuCommunity : removed call to javax/swing/JMenu::setName → NO_COVERAGE |
menuI18nContribution.setName("menuI18nContribution"); |
148 | ||
149 | JMenuItem itemReportIssue = this.initItemReportIssue(); | |
150 |
1
1. initMenuCommunity : removed call to javax/swing/JMenuItem::setName → NO_COVERAGE |
itemReportIssue.setName("itemReportIssue"); |
151 | ||
152 | menuCommunity.add(menuI18nContribution); | |
153 | menuCommunity.add(new JSeparator()); | |
154 | menuCommunity.add(itemReportIssue); | |
155 |
1
1. initMenuCommunity : replaced return value with null for com/jsql/view/swing/menubar/AppMenubar::initMenuCommunity → NO_COVERAGE |
return menuCommunity; |
156 | } | |
157 | ||
158 | private JMenu initMenuI18nContribution() { | |
159 | var menuI18nContribution = new JMenu(I18nUtil.valueByKey("MENUBAR_COMMUNITY_HELPTRANSLATE")); | |
160 |
1
1. initMenuI18nContribution : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey("MENUBAR_COMMUNITY_HELPTRANSLATE", menuI18nContribution); |
161 | ||
162 | final var dialogTranslate = new DialogTranslate(); // Render the About dialog behind scene | |
163 |
1
1. initMenuI18nContribution : removed call to java/util/List::forEach → NO_COVERAGE |
AppMenubar.MODELS_ITEM_INTO.forEach(model -> { |
164 |
1
1. lambda$initMenuI18nContribution$3 : removed call to com/jsql/view/swing/menubar/ModelItemTranslate::setMenuItem → NO_COVERAGE |
model.setMenuItem(new JMenuItem(model.getLanguage().getMenuItemLabel(), model.getLanguage().getFlag())); |
165 |
1
1. lambda$initMenuI18nContribution$3 : removed call to javax/swing/JMenuItem::addActionListener → NO_COVERAGE |
model.getMenuItem().addActionListener(new ActionTranslate(dialogTranslate, model.getLanguage())); |
166 | menuI18nContribution.add(model.getMenuItem()); | |
167 | }); | |
168 | ||
169 | var itemIntoOther = new JMenuItem(I18nUtil.valueByKey("MENUBAR_COMMUNITY_ANOTHERLANGUAGE")); | |
170 |
1
1. initMenuI18nContribution : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey("MENUBAR_COMMUNITY_ANOTHERLANGUAGE", itemIntoOther); |
171 | ||
172 |
2
1. lambda$initMenuI18nContribution$4 : replaced boolean return with true for com/jsql/view/swing/menubar/AppMenubar::lambda$initMenuI18nContribution$4 → NO_COVERAGE 2. lambda$initMenuI18nContribution$4 : negated conditional → NO_COVERAGE |
AppMenubar.MODELS_ITEM_INTO.stream().filter(model -> model.getLanguage() == Language.AR) |
173 |
2
1. lambda$initMenuI18nContribution$5 : removed call to javax/swing/JMenuItem::setComponentOrientation → NO_COVERAGE 2. initMenuI18nContribution : removed call to java/util/stream/Stream::forEach → NO_COVERAGE |
.forEach(modelItemTranslate -> modelItemTranslate.getMenuItem().setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)); |
174 |
2
1. lambda$initMenuI18nContribution$6 : negated conditional → NO_COVERAGE 2. lambda$initMenuI18nContribution$6 : replaced boolean return with true for com/jsql/view/swing/menubar/AppMenubar::lambda$initMenuI18nContribution$6 → NO_COVERAGE |
AppMenubar.MODELS_ITEM_INTO.stream().filter(model -> model.getLanguage() == Language.FR) |
175 |
2
1. lambda$initMenuI18nContribution$7 : removed call to javax/swing/JMenuItem::setName → NO_COVERAGE 2. initMenuI18nContribution : removed call to java/util/stream/Stream::forEach → NO_COVERAGE |
.forEach(modelItemTranslate -> modelItemTranslate.getMenuItem().setName("itemIntoFrench")); |
176 | ||
177 | menuI18nContribution.add(new JSeparator()); | |
178 | menuI18nContribution.add(itemIntoOther); | |
179 |
1
1. initMenuI18nContribution : removed call to javax/swing/JMenuItem::addActionListener → NO_COVERAGE |
itemIntoOther.addActionListener(new ActionTranslate(dialogTranslate, Language.OT)); |
180 | ||
181 |
1
1. initMenuI18nContribution : replaced return value with null for com/jsql/view/swing/menubar/AppMenubar::initMenuI18nContribution → NO_COVERAGE |
return menuI18nContribution; |
182 | } | |
183 | ||
184 | private JMenuItem initItemReportIssue() { | |
185 | JMenuItem itemReportIssue = new JMenuItem(I18nUtil.valueByKey("MENUBAR_COMMUNITY_REPORTISSUE"), 'R'); | |
186 |
1
1. initItemReportIssue : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey("MENUBAR_COMMUNITY_REPORTISSUE", itemReportIssue); |
187 | ||
188 |
1
1. initItemReportIssue : removed call to javax/swing/JMenuItem::addActionListener → NO_COVERAGE |
itemReportIssue.addActionListener(actionEvent -> { |
189 | ||
190 | var panel = new JPanel(new BorderLayout()); | |
191 | final JTextArea textarea = new JPopupTextArea(new JTextArea()).getProxy(); | |
192 |
1
1. lambda$initItemReportIssue$8 : removed call to javax/swing/JTextArea::setFont → NO_COVERAGE |
textarea.setFont(new Font( |
193 | UiUtil.FONT_NAME_MONOSPACED, | |
194 | Font.PLAIN, | |
195 | UIManager.getDefaults().getFont("TextField.font").getSize() | |
196 | )); | |
197 |
1
1. lambda$initItemReportIssue$8 : removed call to javax/swing/JTextArea::setText → NO_COVERAGE |
textarea.setText( |
198 | "## What's the expected behavior?\n\n" | |
199 | + "## What's the actual behavior?\n\n" | |
200 | + "## Any other detailed information on the Issue?\n\n" | |
201 | + "## Steps to reproduce the problem\n\n" | |
202 | + " 1. ...\n" | |
203 | + " 2. ...\n\n" | |
204 | + "## [Community] Request for new feature\n\n" | |
205 | ); | |
206 |
1
1. lambda$initItemReportIssue$8 : removed call to javax/swing/JPanel::add → NO_COVERAGE |
panel.add(new JLabel("Describe your bug or issue:"), BorderLayout.NORTH); |
207 | panel.add(new JScrollPane(textarea)); | |
208 |
1
1. lambda$initItemReportIssue$8 : removed call to javax/swing/JPanel::setPreferredSize → NO_COVERAGE |
panel.setPreferredSize(new Dimension(500, 350)); |
209 |
1
1. lambda$initItemReportIssue$8 : removed call to javax/swing/JPanel::setMinimumSize → NO_COVERAGE |
panel.setMinimumSize(new Dimension(500, 350)); |
210 | ||
211 |
1
1. lambda$initItemReportIssue$8 : removed call to javax/swing/JTextArea::addMouseListener → NO_COVERAGE |
textarea.addMouseListener(new MouseAdapter() { |
212 | @Override | |
213 | public void mousePressed(MouseEvent e) { | |
214 |
1
1. mousePressed : removed call to java/awt/event/MouseAdapter::mousePressed → NO_COVERAGE |
super.mousePressed(e); |
215 | textarea.requestFocusInWindow(); | |
216 | } | |
217 | }); | |
218 | ||
219 | int result = JOptionPane.showOptionDialog( | |
220 | MediatorHelper.frame(), | |
221 | panel, | |
222 | "Report an issue or a bug", | |
223 | JOptionPane.OK_CANCEL_OPTION, | |
224 | JOptionPane.QUESTION_MESSAGE, | |
225 | null, | |
226 | new String[] { | |
227 | "Send", | |
228 | I18nUtil.valueByKey("LIST_ADD_VALUE_CANCEL") | |
229 | }, | |
230 | I18nUtil.valueByKey("LIST_ADD_VALUE_CANCEL") | |
231 | ); | |
232 | ||
233 |
2
1. lambda$initItemReportIssue$8 : negated conditional → NO_COVERAGE 2. lambda$initItemReportIssue$8 : negated conditional → NO_COVERAGE |
if (StringUtils.isNotEmpty(textarea.getText()) && result == JOptionPane.YES_OPTION) { |
234 |
1
1. lambda$initItemReportIssue$8 : removed call to com/jsql/util/GitUtil::sendReport → NO_COVERAGE |
MediatorHelper.model().getMediatorUtils().getGitUtil().sendReport(textarea.getText(), ShowOnConsole.YES, "Report"); |
235 | } | |
236 | }); | |
237 | ||
238 |
1
1. initItemReportIssue : replaced return value with null for com/jsql/view/swing/menubar/AppMenubar::initItemReportIssue → NO_COVERAGE |
return itemReportIssue; |
239 | } | |
240 | ||
241 | private JMenu initMenuHelp() { | |
242 | var menuHelp = new JMenu(I18nUtil.valueByKey("MENUBAR_HELP")); | |
243 |
1
1. initMenuHelp : removed call to javax/swing/JMenu::setMnemonic → NO_COVERAGE |
menuHelp.setMnemonic('H'); |
244 |
1
1. initMenuHelp : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey("MENUBAR_HELP", menuHelp); |
245 |
1
1. initMenuHelp : removed call to javax/swing/JMenu::setName → NO_COVERAGE |
menuHelp.setName("menuHelp"); |
246 | ||
247 | JMenuItem itemHelp = new JMenuItem(I18nUtil.valueByKey("MENUBAR_HELP_ABOUT"), 'A'); | |
248 |
1
1. initMenuHelp : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey("MENUBAR_HELP_ABOUT", itemHelp); |
249 |
1
1. initMenuHelp : removed call to javax/swing/JMenuItem::setName → NO_COVERAGE |
itemHelp.setName("itemHelp"); |
250 | ||
251 | JMenuItem itemUpdate = new JMenuItem(I18nUtil.valueByKey("MENUBAR_HELP_UPDATE"), 'U'); | |
252 |
1
1. initMenuHelp : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey("MENUBAR_HELP_UPDATE", itemUpdate); |
253 | ||
254 | // Render the About dialog behind scene | |
255 |
1
1. initMenuHelp : removed call to javax/swing/JMenuItem::addActionListener → NO_COVERAGE |
itemHelp.addActionListener(actionEvent -> { |
256 | final var dialogAbout = new DialogAbout(); | |
257 |
1
1. lambda$initMenuHelp$9 : negated conditional → NO_COVERAGE |
if (!dialogAbout.isVisible()) { |
258 |
1
1. lambda$initMenuHelp$9 : removed call to com/jsql/view/swing/dialog/DialogAbout::initDialog → NO_COVERAGE |
dialogAbout.initDialog(); |
259 |
1
1. lambda$initMenuHelp$9 : removed call to com/jsql/view/swing/dialog/DialogAbout::setVisible → NO_COVERAGE |
dialogAbout.setVisible(true); // needed here for button focus |
260 |
1
1. lambda$initMenuHelp$9 : removed call to com/jsql/view/swing/dialog/DialogAbout::requestButtonFocus → NO_COVERAGE |
dialogAbout.requestButtonFocus(); |
261 | } | |
262 |
1
1. lambda$initMenuHelp$9 : removed call to com/jsql/view/swing/dialog/DialogAbout::setVisible → NO_COVERAGE |
dialogAbout.setVisible(true); |
263 | }); | |
264 |
1
1. initMenuHelp : removed call to javax/swing/JMenuItem::addActionListener → NO_COVERAGE |
itemUpdate.addActionListener(new ActionCheckUpdate()); |
265 | ||
266 | menuHelp.add(itemUpdate); | |
267 | menuHelp.add(new JSeparator()); | |
268 | menuHelp.add(itemHelp); | |
269 |
1
1. initMenuHelp : replaced return value with null for com/jsql/view/swing/menubar/AppMenubar::initMenuHelp → NO_COVERAGE |
return menuHelp; |
270 | } | |
271 | ||
272 | public static void applyTheme(String theme) { | |
273 |
1
1. applyTheme : removed call to com/jsql/view/swing/util/UiUtil::applyTheme → NO_COVERAGE |
UiUtil.applyTheme(theme); |
274 | ||
275 | Arrays.asList( | |
276 | UiUtil.DATABASE_BOLD, UiUtil.ADMIN, UiUtil.DOWNLOAD, UiUtil.TERMINAL, UiUtil.UPLOAD, UiUtil.LOCK, UiUtil.TEXTFIELD, UiUtil.BATCH, | |
277 | UiUtil.TABLE_LINEAR, UiUtil.TABLE_BOLD, UiUtil.NETWORK, UiUtil.DATABASE_LINEAR, UiUtil.COG, UiUtil.CUP, UiUtil.CONSOLE, UiUtil.BINARY, UiUtil.CHUNK, | |
278 | UiUtil.ARROW, UiUtil.ARROW_HOVER, UiUtil.ARROW_PRESSED, UiUtil.EXPAND, UiUtil.EXPAND_HOVER, UiUtil.EXPAND_PRESSED, | |
279 | UiUtil.HOURGLASS, UiUtil.ARROW_DOWN, UiUtil.ARROW_UP, UiUtil.SQUARE, UiUtil.GLOBE, UiUtil.TICK_GREEN, UiUtil.CROSS_RED, | |
280 | UiUtil.APP_ICON, UiUtil.APP_BIG, UiUtil.APP_MIDDLE | |
281 |
1
1. applyTheme : removed call to java/util/List::forEach → NO_COVERAGE |
).forEach(ModelSvgIcon::setColorFilter); |
282 | ||
283 |
1
1. applyTheme : removed call to com/jsql/view/swing/sql/SqlEngine::applyTheme → NO_COVERAGE |
SqlEngine.applyTheme(); |
284 |
1
1. applyTheme : removed call to com/jsql/view/swing/panel/preferences/PanelTampering::applyTheme → NO_COVERAGE |
PanelTampering.applyTheme(); |
285 |
1
1. applyTheme : removed call to com/jsql/view/swing/panel/preferences/PanelExploit::applyTheme → NO_COVERAGE |
PanelExploit.applyTheme(); |
286 |
1
1. applyTheme : removed call to com/jsql/view/swing/panel/consoles/TabbedPaneNetworkTab::applyTheme → NO_COVERAGE |
MediatorHelper.panelConsoles().getTabbedPaneNetworkTab().applyTheme(); |
287 |
1
1. applyTheme : removed call to com/jsql/view/swing/JFrameView::setIconImages → NO_COVERAGE |
MediatorHelper.frame().setIconImages(UiUtil.getIcons()); |
288 |
1
1. applyTheme : removed call to com/jsql/view/swing/JFrameView::revalidate → NO_COVERAGE |
MediatorHelper.frame().revalidate(); |
289 | ||
290 |
1
1. applyTheme : removed call to com/jsql/util/PreferencesUtil::persist → NO_COVERAGE |
MediatorHelper.model().getMediatorUtils().getPreferencesUtil().withThemeFlatLafName(theme).persist(); |
291 | } | |
292 | | |
293 | public void switchLocale(Locale newLocale) { | |
294 |
1
1. switchLocale : removed call to com/jsql/view/swing/menubar/AppMenubar::switchLocale → NO_COVERAGE |
this.switchLocale(I18nUtil.getCurrentLocale(), newLocale, false); |
295 | } | |
296 | | |
297 | public void switchLocaleWithStatus(Locale oldLocale, Locale newLocale, boolean isStartup) { | |
298 |
1
1. switchLocaleWithStatus : removed call to com/jsql/view/swing/menubar/AppMenubar::switchLocale → NO_COVERAGE |
this.switchLocale(oldLocale, newLocale, isStartup); |
299 |
1
1. switchLocaleWithStatus : removed call to com/jsql/util/PropertiesUtil::displayStatus → NO_COVERAGE |
MediatorHelper.model().getPropertiesUtil().displayStatus(newLocale); |
300 | } | |
301 | ||
302 | public void switchLocale(Locale oldLocale, Locale newLocale, boolean isStartup) { | |
303 |
1
1. switchLocale : removed call to com/jsql/util/I18nUtil::setCurrentBundle → NO_COVERAGE |
I18nUtil.setCurrentBundle(newLocale); |
304 | ||
305 | Stream.of( | |
306 | JTextPaneAppender.ATTRIBUTE_WARN, | |
307 | JTextPaneAppender.ATTRIBUTE_INFORM, | |
308 | JTextPaneAppender.ATTRIBUTE_SUCCESS, | |
309 | JTextPaneAppender.ATTRIBUTE_ALL | |
310 | ) | |
311 |
1
1. switchLocale : removed call to java/util/stream/Stream::forEach → NO_COVERAGE |
.forEach(attribute -> { |
312 |
2
1. lambda$switchLocale$10 : removed call to javax/swing/text/StyleConstants::setFontFamily → NO_COVERAGE 2. lambda$switchLocale$10 : negated conditional → NO_COVERAGE |
StyleConstants.setFontFamily(attribute, I18nViewUtil.isNonUbuntu(newLocale) ? UiUtil.FONT_NAME_MONO_ASIAN : UiUtil.FONT_NAME_MONO_NON_ASIAN); |
313 |
2
1. lambda$switchLocale$10 : removed call to javax/swing/text/StyleConstants::setFontSize → NO_COVERAGE 2. lambda$switchLocale$10 : negated conditional → NO_COVERAGE |
StyleConstants.setFontSize(attribute, I18nViewUtil.isNonUbuntu(newLocale) ? UiUtil.FONT_SIZE_MONO_ASIAN : UiUtil.FONT_SIZE_MONO_NON_ASIAN); |
314 | }); | |
315 | ||
316 |
2
1. switchLocale : negated conditional → NO_COVERAGE 2. switchLocale : removed call to javax/swing/JTextPane::setFont → NO_COVERAGE |
MediatorHelper.managerBruteForce().getResult().setFont(I18nViewUtil.isNonUbuntu(newLocale) ? UiUtil.FONT_MONO_ASIAN : UiUtil.FONT_MONO_NON_ASIAN); |
317 | ||
318 |
1
1. switchLocale : removed call to com/jsql/view/swing/menubar/AppMenubar::switchNetworkTable → NO_COVERAGE |
this.switchNetworkTable(); |
319 |
1
1. switchLocale : removed call to com/jsql/view/swing/util/I18nViewUtil::switchI18nComponents → NO_COVERAGE |
I18nViewUtil.switchI18nComponents(); |
320 |
1
1. switchLocale : removed call to com/jsql/view/swing/menubar/AppMenubar::switchOrientation → NO_COVERAGE |
this.switchOrientation(oldLocale, newLocale, isStartup); |
321 |
1
1. switchLocale : removed call to com/jsql/view/swing/menubar/AppMenubar::switchMenuItems → NO_COVERAGE |
this.switchMenuItems(); // required to restore proper language orientation |
322 | | |
323 |
1
1. switchLocale : removed call to com/jsql/view/swing/tree/TreeDatabase::reloadNodes → NO_COVERAGE |
MediatorHelper.treeDatabase().reloadNodes(); |
324 | ||
325 | // IllegalArgumentException #92981 on revalidate() | |
326 | try { | |
327 |
1
1. switchLocale : removed call to com/jsql/view/swing/JFrameView::revalidate → NO_COVERAGE |
MediatorHelper.frame().revalidate(); // Fix glitches on Linux |
328 | } catch (IllegalArgumentException e) { | |
329 | LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e, e); | |
330 | } | |
331 | } | |
332 | ||
333 | private void switchOrientation(Locale oldLocale, Locale newLocale, boolean isStartup) { | |
334 | var componentOrientation = ComponentOrientation.getOrientation(I18nUtil.getCurrentLocale()); | |
335 |
1
1. switchOrientation : removed call to com/jsql/view/swing/JFrameView::applyComponentOrientation → NO_COVERAGE |
MediatorHelper.frame().applyComponentOrientation(componentOrientation); |
336 | | |
337 |
1
1. switchOrientation : negated conditional → NO_COVERAGE |
if (!ComponentOrientation.getOrientation(oldLocale).equals(ComponentOrientation.getOrientation(newLocale))) { |
338 | | |
339 | JSplitPane splitPaneLeftRight = MediatorHelper.frame().getSplitNS().getSplitEW(); | |
340 | var componentLeft = splitPaneLeftRight.getLeftComponent(); | |
341 | var componentRight = splitPaneLeftRight.getRightComponent(); | |
342 | ||
343 | // Reset components | |
344 |
1
1. switchOrientation : removed call to javax/swing/JSplitPane::setLeftComponent → NO_COVERAGE |
splitPaneLeftRight.setLeftComponent(null); |
345 |
1
1. switchOrientation : removed call to javax/swing/JSplitPane::setRightComponent → NO_COVERAGE |
splitPaneLeftRight.setRightComponent(null); |
346 |
1
1. switchOrientation : removed call to javax/swing/JSplitPane::setLeftComponent → NO_COVERAGE |
splitPaneLeftRight.setLeftComponent(componentRight); |
347 |
1
1. switchOrientation : removed call to javax/swing/JSplitPane::setRightComponent → NO_COVERAGE |
splitPaneLeftRight.setRightComponent(componentLeft); |
348 | ||
349 |
1
1. switchOrientation : negated conditional → NO_COVERAGE |
if (isStartup) { |
350 | // TODO unclear and not working properly when starting as locale arabic | |
351 |
1
1. switchOrientation : removed call to javax/swing/JSplitPane::setDividerLocation → NO_COVERAGE |
splitPaneLeftRight.setDividerLocation( |
352 | splitPaneLeftRight.getDividerLocation() | |
353 | ); | |
354 | } else { // required as switch to arabic uses reversed location | |
355 |
1
1. switchOrientation : removed call to javax/swing/JSplitPane::setDividerLocation → NO_COVERAGE |
splitPaneLeftRight.setDividerLocation( |
356 | splitPaneLeftRight.getWidth() - | |
357 |
1
1. switchOrientation : Replaced integer subtraction with addition → NO_COVERAGE |
splitPaneLeftRight.getDividerLocation() |
358 | ); | |
359 | } | |
360 | } | |
361 | | |
362 |
1
1. switchOrientation : removed call to com/jsql/view/swing/tab/TabResults::setComponentOrientation → NO_COVERAGE |
MediatorHelper.tabResults().setComponentOrientation(ComponentOrientation.getOrientation(newLocale)); |
363 | } | |
364 | ||
365 | private void switchMenuItems() { | |
366 | Stream.concat(AppMenubar.MODELS_ITEM.stream(), AppMenubar.MODELS_ITEM_INTO.stream()) | |
367 |
2
1. switchMenuItems : removed call to java/util/stream/Stream::forEach → NO_COVERAGE 2. lambda$switchMenuItems$11 : removed call to javax/swing/JMenuItem::setComponentOrientation → NO_COVERAGE |
.forEach(model -> model.getMenuItem().setComponentOrientation( |
368 |
1
1. lambda$switchMenuItems$11 : negated conditional → NO_COVERAGE |
model.getLanguage().isRightToLeft() |
369 | ? ComponentOrientation.RIGHT_TO_LEFT | |
370 | : ComponentOrientation.LEFT_TO_RIGHT | |
371 | )); | |
372 | } | |
373 | ||
374 | private void switchNetworkTable() { | |
375 | JTableHeader header = MediatorHelper.panelConsoles().getNetworkTable().getTableHeader(); | |
376 | TableColumnModel columnModel = header.getColumnModel(); | |
377 |
1
1. switchNetworkTable : removed call to javax/swing/table/TableColumn::setHeaderValue → NO_COVERAGE |
columnModel.getColumn(0).setHeaderValue(I18nUtil.valueByKey("NETWORK_TAB_URL_COLUMN")); |
378 |
1
1. switchNetworkTable : removed call to javax/swing/table/TableColumn::setHeaderValue → NO_COVERAGE |
columnModel.getColumn(1).setHeaderValue(I18nUtil.valueByKey("NETWORK_TAB_SIZE_COLUMN") +" (KB)"); |
379 |
1
1. switchNetworkTable : removed call to javax/swing/table/TableColumn::setHeaderValue → NO_COVERAGE |
columnModel.getColumn(2).setHeaderValue(I18nUtil.valueByKey("SQLENGINE_STRATEGY")); |
380 |
1
1. switchNetworkTable : removed call to javax/swing/table/TableColumn::setHeaderValue → NO_COVERAGE |
columnModel.getColumn(3).setHeaderValue(I18nUtil.valueByKey("SQLENGINE_METADATA")); |
381 |
1
1. switchNetworkTable : removed call to javax/swing/table/JTableHeader::repaint → NO_COVERAGE |
header.repaint(); |
382 | } | |
383 | | |
384 | | |
385 | // Getter and setter | |
386 | ||
387 | public JMenu getMenuView() { | |
388 |
1
1. getMenuView : replaced return value with null for com/jsql/view/swing/menubar/AppMenubar::getMenuView → NO_COVERAGE |
return this.menuWindows.getMenuView(); |
389 | } | |
390 | ||
391 | public MenuWindows getMenuWindows() { | |
392 |
1
1. getMenuWindows : replaced return value with null for com/jsql/view/swing/menubar/AppMenubar::getMenuWindows → NO_COVERAGE |
return this.menuWindows; |
393 | } | |
394 | } | |
Mutations | ||
87 |
1.1 |
|
88 |
1.1 |
|
91 |
1.1 |
|
94 |
1.1 |
|
95 |
1.1 2.2 |
|
97 |
1.1 |
|
102 |
1.1 |
|
107 |
1.1 |
|
108 |
1.1 |
|
111 |
1.1 |
|
112 |
1.1 |
|
113 |
1.1 |
|
114 |
1.1 |
|
115 |
1.1 |
|
116 |
1.1 |
|
117 |
1.1 |
|
122 |
1.1 |
|
123 |
1.1 |
|
124 |
1.1 |
|
125 |
1.1 |
|
126 |
1.1 |
|
127 |
1.1 |
|
130 |
1.1 |
|
137 |
1.1 |
|
142 |
1.1 |
|
143 |
1.1 |
|
144 |
1.1 |
|
147 |
1.1 |
|
150 |
1.1 |
|
155 |
1.1 |
|
160 |
1.1 |
|
163 |
1.1 |
|
164 |
1.1 |
|
165 |
1.1 |
|
170 |
1.1 |
|
172 |
1.1 2.2 |
|
173 |
1.1 2.2 |
|
174 |
1.1 2.2 |
|
175 |
1.1 2.2 |
|
179 |
1.1 |
|
181 |
1.1 |
|
186 |
1.1 |
|
188 |
1.1 |
|
192 |
1.1 |
|
197 |
1.1 |
|
206 |
1.1 |
|
208 |
1.1 |
|
209 |
1.1 |
|
211 |
1.1 |
|
214 |
1.1 |
|
233 |
1.1 2.2 |
|
234 |
1.1 |
|
238 |
1.1 |
|
243 |
1.1 |
|
244 |
1.1 |
|
245 |
1.1 |
|
248 |
1.1 |
|
249 |
1.1 |
|
252 |
1.1 |
|
255 |
1.1 |
|
257 |
1.1 |
|
258 |
1.1 |
|
259 |
1.1 |
|
260 |
1.1 |
|
262 |
1.1 |
|
264 |
1.1 |
|
269 |
1.1 |
|
273 |
1.1 |
|
281 |
1.1 |
|
283 |
1.1 |
|
284 |
1.1 |
|
285 |
1.1 |
|
286 |
1.1 |
|
287 |
1.1 |
|
288 |
1.1 |
|
290 |
1.1 |
|
294 |
1.1 |
|
298 |
1.1 |
|
299 |
1.1 |
|
303 |
1.1 |
|
311 |
1.1 |
|
312 |
1.1 2.2 |
|
313 |
1.1 2.2 |
|
316 |
1.1 2.2 |
|
318 |
1.1 |
|
319 |
1.1 |
|
320 |
1.1 |
|
321 |
1.1 |
|
323 |
1.1 |
|
327 |
1.1 |
|
335 |
1.1 |
|
337 |
1.1 |
|
344 |
1.1 |
|
345 |
1.1 |
|
346 |
1.1 |
|
347 |
1.1 |
|
349 |
1.1 |
|
351 |
1.1 |
|
355 |
1.1 |
|
357 |
1.1 |
|
362 |
1.1 |
|
367 |
1.1 2.2 |
|
368 |
1.1 |
|
377 |
1.1 |
|
378 |
1.1 |
|
379 |
1.1 |
|
380 |
1.1 |
|
381 |
1.1 |
|
388 |
1.1 |
|
392 |
1.1 |