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