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