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