| 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.util; | |
| 12 | ||
| 13 | import com.formdev.flatlaf.FlatLaf; | |
| 14 | import com.formdev.flatlaf.intellijthemes.FlatLightFlatIJTheme; | |
| 15 | import com.jsql.util.I18nUtil; | |
| 16 | import com.jsql.util.LogLevelUtil; | |
| 17 | import com.jsql.view.swing.console.JTextPaneAppender; | |
| 18 | import com.jsql.view.swing.sql.SqlEngine; | |
| 19 | import com.jsql.view.swing.text.action.DeleteNextCharAction; | |
| 20 | import com.jsql.view.swing.text.action.DeletePrevCharAction; | |
| 21 | import org.apache.commons.lang3.StringUtils; | |
| 22 | import org.apache.logging.log4j.LogManager; | |
| 23 | import org.apache.logging.log4j.Logger; | |
| 24 | import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; | |
| 25 | import org.fife.ui.rsyntaxtextarea.Theme; | |
| 26 | ||
| 27 | import javax.swing.*; | |
| 28 | import javax.swing.border.Border; | |
| 29 | import javax.swing.text.DefaultCaret; | |
| 30 | import javax.swing.text.DefaultEditorKit; | |
| 31 | import javax.swing.text.JTextComponent; | |
| 32 | import javax.swing.text.StyleConstants; | |
| 33 | import java.awt.*; | |
| 34 | import java.io.BufferedInputStream; | |
| 35 | import java.io.IOException; | |
| 36 | import java.io.InputStream; | |
| 37 | import java.util.ArrayList; | |
| 38 | import java.util.List; | |
| 39 | import java.util.Objects; | |
| 40 | ||
| 41 | /** | |
| 42 | * Build default component appearance, keyboard shortcuts and icons. | |
| 43 | */ | |
| 44 | public class UiUtil { | |
| 45 | | |
| 46 | private static final Logger LOGGER = LogManager.getRootLogger(); | |
| 47 | ||
| 48 | public static final Border BORDER_5PX = BorderFactory.createEmptyBorder(5, 5, 5, 5); | |
| 49 | ||
| 50 | public static final ImageIcon ICON_FLAG_AR = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/ar.png"))); | |
| 51 | public static final ImageIcon ICON_FLAG_ZH = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/zh.png"))); | |
| 52 | public static final ImageIcon ICON_FLAG_RU = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/ru.png"))); | |
| 53 | public static final ImageIcon ICON_FLAG_TR = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/tr.png"))); | |
| 54 | public static final ImageIcon ICON_FLAG_EN = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/en.png"))); | |
| 55 | public static final ImageIcon ICON_FLAG_FR = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/fr.png"))); | |
| 56 | public static final ImageIcon ICON_FLAG_HI = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/hi.png"))); | |
| 57 | public static final ImageIcon ICON_FLAG_CS = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/cs.png"))); | |
| 58 | public static final ImageIcon ICON_FLAG_DE = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/de.png"))); | |
| 59 | public static final ImageIcon ICON_FLAG_NL = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/nl.png"))); | |
| 60 | public static final ImageIcon ICON_FLAG_ID = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/id.png"))); | |
| 61 | public static final ImageIcon ICON_FLAG_IT = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/it.png"))); | |
| 62 | public static final ImageIcon ICON_FLAG_ES = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/es.png"))); | |
| 63 | public static final ImageIcon ICON_FLAG_PT = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/pt.png"))); | |
| 64 | public static final ImageIcon ICON_FLAG_PL = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/pl.png"))); | |
| 65 | public static final ImageIcon ICON_FLAG_JA = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/ja.png"))); | |
| 66 | public static final ImageIcon ICON_FLAG_KO = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/ko.png"))); | |
| 67 | public static final ImageIcon ICON_FLAG_RO = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/ro.png"))); | |
| 68 | public static final ImageIcon ICON_FLAG_LK = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/lk.png"))); | |
| 69 | public static final ImageIcon ICON_FLAG_SE = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/se.png"))); | |
| 70 | public static final ImageIcon ICON_FLAG_FI = new ImageIcon(Objects.requireNonNull(UiUtil.class.getClassLoader().getResource("swing/images/flags/fi.png"))); | |
| 71 | ||
| 72 | public static final ModelSvgIcon DATABASE_BOLD = new ModelSvgIcon("database-bold", 0x1C274C) | |
| 73 | .withTab("DATABASE_TAB", "DATABASE_TOOLTIP"); | |
| 74 | public static final ModelSvgIcon ADMIN = new ModelSvgIcon("admin", 0.02f) | |
| 75 | .withTab("ADMINPAGE_TAB", "ADMINPAGE_TOOLTIP"); | |
| 76 | public static final ModelSvgIcon DOWNLOAD = new ModelSvgIcon("download", 0.55f) | |
| 77 | .withTab("FILE_TAB", "FILE_TOOLTIP"); | |
| 78 | public static final ModelSvgIcon TERMINAL = new ModelSvgIcon("terminal", 0.50f) | |
| 79 | .withTab("EXPLOIT_TAB", "EXPLOIT_TOOLTIP"); | |
| 80 | public static final ModelSvgIcon UPLOAD = new ModelSvgIcon("upload", 0.55f); | |
| 81 | public static final ModelSvgIcon LOCK = new ModelSvgIcon("lock", 0.02f) | |
| 82 | .withTab("BRUTEFORCE_TAB", "BRUTEFORCE_TOOLTIP"); | |
| 83 | public static final ModelSvgIcon TEXTFIELD = new ModelSvgIcon("textfield", 0.02f) | |
| 84 | .withTab("CODER_TAB", "CODER_TOOLTIP"); | |
| 85 | public static final ModelSvgIcon BATCH = new ModelSvgIcon("batch", 0.02f) | |
| 86 | .withTab("SCANLIST_TAB", "SCANLIST_TOOLTIP"); | |
| 87 | ||
| 88 | public static final ModelSvgIcon TABLE_LINEAR = new ModelSvgIcon("table-linear", 0x212121); | |
| 89 | public static final ModelSvgIcon TABLE_BOLD = new ModelSvgIcon("table-bold", 0x212121); | |
| 90 | public static final ModelSvgIcon NETWORK = new ModelSvgIcon("network", 0.02f); | |
| 91 | public static final ModelSvgIcon DATABASE_LINEAR = new ModelSvgIcon("database-linear", 0x1C274C); | |
| 92 | public static final ModelSvgIcon CUP = new ModelSvgIcon("cup", 0.02f); | |
| 93 | public static final ModelSvgIcon CONSOLE = new ModelSvgIcon("console", 0.02f); | |
| 94 | public static final ModelSvgIcon BINARY = new ModelSvgIcon("binary", 0.02f); | |
| 95 | public static final ModelSvgIcon CHUNK = new ModelSvgIcon("chunk", 0.02f); | |
| 96 | public static final ModelSvgIcon COG = new ModelSvgIcon("cog", 0.02f); | |
| 97 | ||
| 98 | public static final ModelSvgIcon CROSS_RED = new ModelSvgIcon("cross", new Color(0x0F0F0F), null, LogLevelUtil.COLOR_RED, 0.025f); | |
| 99 | private static final String NAME_ARROW = "arrow"; | |
| 100 | private static final String NAME_ARROW_LEFT = "arrow-left"; | |
| 101 | public static final String COMBOBOX_BUTTON_ARROW_COLOR = "ComboBox.buttonArrowColor"; | |
| 102 | public static final ModelSvgIcon ARROW = new ModelSvgIcon(UiUtil.NAME_ARROW, new Color(0x005a96), UiUtil.COMBOBOX_BUTTON_ARROW_COLOR, 1f); | |
| 103 | public static final String COMBOBOX_BUTTON_HOVER_ARROW_COLOR = "ComboBox.buttonHoverArrowColor"; | |
| 104 | public static final ModelSvgIcon ARROW_HOVER = new ModelSvgIcon(UiUtil.NAME_ARROW, new Color(0x005a96), UiUtil.COMBOBOX_BUTTON_HOVER_ARROW_COLOR, 1f); | |
| 105 | public static final String COMBOBOX_BUTTON_PRESSED_ARROW_COLOR = "ComboBox.buttonPressedArrowColor"; | |
| 106 | public static final ModelSvgIcon ARROW_PRESSED = new ModelSvgIcon(UiUtil.NAME_ARROW, new Color(0x005a96), UiUtil.COMBOBOX_BUTTON_PRESSED_ARROW_COLOR, 1f); | |
| 107 | public static final ModelSvgIcon ARROW_LEFT = new ModelSvgIcon(UiUtil.NAME_ARROW_LEFT, new Color(0x005a96), UiUtil.COMBOBOX_BUTTON_ARROW_COLOR, 1f); | |
| 108 | public static final ModelSvgIcon ARROW_LEFT_HOVER = new ModelSvgIcon(UiUtil.NAME_ARROW_LEFT, new Color(0x005a96), UiUtil.COMBOBOX_BUTTON_HOVER_ARROW_COLOR, 1f); | |
| 109 | public static final ModelSvgIcon ARROW_LEFT_PRESSED = new ModelSvgIcon(UiUtil.NAME_ARROW_LEFT, new Color(0x005a96), UiUtil.COMBOBOX_BUTTON_PRESSED_ARROW_COLOR, 1f); | |
| 110 | private static final String NAME_EXPAND = "expand"; | |
| 111 | public static final ModelSvgIcon EXPAND = new ModelSvgIcon(UiUtil.NAME_EXPAND, Color.BLACK, UiUtil.COMBOBOX_BUTTON_ARROW_COLOR, 0.02f); | |
| 112 | public static final ModelSvgIcon EXPAND_HOVER = new ModelSvgIcon(UiUtil.NAME_EXPAND, Color.BLACK, UiUtil.COMBOBOX_BUTTON_HOVER_ARROW_COLOR, 0.02f); | |
| 113 | public static final ModelSvgIcon EXPAND_PRESSED = new ModelSvgIcon(UiUtil.NAME_EXPAND, Color.BLACK, UiUtil.COMBOBOX_BUTTON_PRESSED_ARROW_COLOR, 0.02f); | |
| 114 | ||
| 115 | public static final ModelSvgIcon HOURGLASS = new ModelSvgIcon("hourglass", 0.02f); | |
| 116 | public static final ModelSvgIcon ARROW_UP = new ModelSvgIcon("arrow-up", 0.02f); | |
| 117 | public static final ModelSvgIcon ARROW_DOWN = new ModelSvgIcon("arrow-down", 0.02f); | |
| 118 | public static final ModelSvgIcon SQUARE = new ModelSvgIcon("square", 0.01f); | |
| 119 | public static final ModelSvgIcon TICK_GREEN = new ModelSvgIcon("tick", Color.BLACK, null, LogLevelUtil.COLOR_GREEN, 0.02f); | |
| 120 | public static final ModelSvgIcon GLOBE = new ModelSvgIcon("globe", 0.025f); | |
| 121 | public static final ModelSvgIcon APP_ICON = new ModelSvgIcon("app", 0.04f); | |
| 122 | public static final ModelSvgIcon APP_BIG = new ModelSvgIcon("app", 0.5f); | |
| 123 | public static final ModelSvgIcon APP_MIDDLE = new ModelSvgIcon("app", 0.25f); | |
| 124 | ||
| 125 | public static final String PATH_PAUSE = "swing/images/icons/pause.png"; | |
| 126 | ||
| 127 | public static final String FONT_NAME_MONO_NON_ASIAN = "Ubuntu Mono"; | |
| 128 | public static final int FONT_SIZE_MONO_NON_ASIAN = 14; | |
| 129 | public static final String FONT_NAME_MONO_ASIAN = "Monospace"; | |
| 130 | public static final int FONT_SIZE_MONO_ASIAN = 13; | |
| 131 | | |
| 132 | // Used in Translation Dialog | |
| 133 | // HTML engine considers Monospaced/Monospace to be the same Font | |
| 134 | // Java engine recognizes only Monospaced | |
| 135 | public static final String FONT_NAME_MONOSPACED = "Monospaced"; | |
| 136 | public static final String TEXTAREA_FONT = "TextArea.font"; | |
| 137 | public static final String TEXTPANE_FONT = "TextPane.font"; | |
| 138 | public static final Font FONT_MONO_NON_ASIAN = new Font( | |
| 139 | UiUtil.FONT_NAME_MONO_NON_ASIAN, | |
| 140 | Font.PLAIN, | |
| 141 | UIManager.getDefaults().getFont(UiUtil.TEXTAREA_FONT).getSize() + 2 | |
| 142 | ); | |
| 143 | | |
| 144 | public static final Font FONT_MONO_ASIAN = new Font( | |
| 145 | UiUtil.FONT_NAME_MONO_ASIAN, | |
| 146 | Font.PLAIN, | |
| 147 | UIManager.getDefaults().getFont(UiUtil.TEXTPANE_FONT).getSize() | |
| 148 | ); | |
| 149 | | |
| 150 | public static final Font FONT_MONO_ASIAN_BIG = new Font( | |
| 151 | UiUtil.FONT_NAME_MONO_ASIAN, | |
| 152 | Font.PLAIN, | |
| 153 | UIManager.getDefaults().getFont(UiUtil.TEXTPANE_FONT).getSize() + 2 | |
| 154 | ); | |
| 155 | ||
| 156 | public static final Font FONT_NON_MONO = new Font( | |
| 157 | "Segoe UI", | |
| 158 | Font.PLAIN, | |
| 159 | UIManager.getDefaults().getFont(UiUtil.TEXTPANE_FONT).getSize() | |
| 160 | ); | |
| 161 | | |
| 162 | public static final Font FONT_NON_MONO_BIG = new Font( | |
| 163 | UIManager.getDefaults().getFont("TextField.font").getName(), | |
| 164 | Font.PLAIN, | |
| 165 | UIManager.getDefaults().getFont("TextField.font").getSize() + 2 | |
| 166 | ); | |
| 167 | ||
| 168 | private UiUtil() { | |
| 169 | // Utility class | |
| 170 | } | |
| 171 | ||
| 172 | /** | |
| 173 | * Change the default style of various components. | |
| 174 | */ | |
| 175 | public static void prepareGUI() { | |
| 176 |
1
1. prepareGUI : removed call to com/jsql/view/swing/util/UiUtil::loadFonts → NO_COVERAGE |
UiUtil.loadFonts(); |
| 177 | // timer before closing automatically tooltip | |
| 178 |
2
1. prepareGUI : Replaced integer multiplication with division → NO_COVERAGE 2. prepareGUI : removed call to javax/swing/ToolTipManager::setDismissDelay → NO_COVERAGE |
ToolTipManager.sharedInstance().setDismissDelay(3 * ToolTipManager.sharedInstance().getDismissDelay()); |
| 179 | UIManager.put(UiUtil.TEXTAREA_FONT, UiUtil.FONT_MONO_NON_ASIAN); // required for basic text like chunks tab | |
| 180 | UIManager.put(UiUtil.TEXTPANE_FONT, UIManager.getFont(UiUtil.TEXTAREA_FONT)); // align textpane font | |
| 181 | } | |
| 182 | ||
| 183 | private static void loadFonts() { | |
| 184 | var graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); | |
| 185 | try (InputStream fontStream = new BufferedInputStream( | |
| 186 | Objects.requireNonNull(UiUtil.class.getClassLoader().getResourceAsStream("swing/font/UbuntuMono-R-ctrlchar.ttf")) | |
| 187 | )) { | |
| 188 | var ubuntuFont = Font.createFont(Font.TRUETYPE_FONT, fontStream); | |
| 189 | graphicsEnvironment.registerFont(ubuntuFont); | |
| 190 | } catch (FontFormatException | IOException e) { | |
| 191 | LOGGER.log(LogLevelUtil.CONSOLE_ERROR, "Loading Font Ubuntu Mono with control characters failed", e); | |
| 192 | } | |
| 193 | } | |
| 194 | ||
| 195 | /** | |
| 196 | * Icons for application window. | |
| 197 | * @return List of a 16x16 (default) and 32x32 icon (alt-tab, taskbar) | |
| 198 | */ | |
| 199 | public static List<Image> getIcons() { | |
| 200 | List<Image> images = new ArrayList<>(); | |
| 201 | // Fix #2154: NoClassDefFoundError on read() | |
| 202 | try { | |
| 203 | images.add(UiUtil.APP_ICON.getIcon().getImage()); | |
| 204 | images.add(UiUtil.APP_MIDDLE.getIcon().getImage()); | |
| 205 | images.add(UiUtil.APP_BIG.getIcon().getImage()); | |
| 206 | } catch (NoClassDefFoundError e) { | |
| 207 | LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e, e); | |
| 208 | } | |
| 209 |
1
1. getIcons : replaced return value with Collections.emptyList for com/jsql/view/swing/util/UiUtil::getIcons → NO_COVERAGE |
return images; |
| 210 | } | |
| 211 | | |
| 212 | public static void drawPlaceholder(JTextComponent textComponent, Graphics g, String placeholderText) { | |
| 213 |
2
1. drawPlaceholder : Replaced integer addition with subtraction → NO_COVERAGE 2. drawPlaceholder : removed call to com/jsql/view/swing/util/UiUtil::drawPlaceholder → NO_COVERAGE |
UiUtil.drawPlaceholder(textComponent, g, placeholderText, 0, g.getFontMetrics().getAscent() + 2); |
| 214 | } | |
| 215 | | |
| 216 | public static void drawPlaceholder(JTextComponent textComponent, Graphics g, String placeholderText, int x, int y) { | |
| 217 | int w = textComponent.getWidth(); | |
| 218 | | |
| 219 |
1
1. drawPlaceholder : removed call to java/awt/Graphics2D::setRenderingHint → NO_COVERAGE |
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); |
| 220 | ||
| 221 | var insets = textComponent.getInsets(); | |
| 222 | var fontMetrics = g.getFontMetrics(); | |
| 223 | | |
| 224 | int c0 = UIManager.getColor("TextArea.background").getRGB(); | |
| 225 | int c1 = UIManager.getColor("TextArea.foreground").getRGB(); | |
| 226 | var m = 0xfefefefe; | |
| 227 |
5
1. drawPlaceholder : Replaced Unsigned Shift Right with Shift Left → NO_COVERAGE 2. drawPlaceholder : Replaced bitwise AND with OR → NO_COVERAGE 3. drawPlaceholder : Replaced integer addition with subtraction → NO_COVERAGE 4. drawPlaceholder : Replaced Unsigned Shift Right with Shift Left → NO_COVERAGE 5. drawPlaceholder : Replaced bitwise AND with OR → NO_COVERAGE |
int c2 = ((c0 & m) >>> 1) + ((c1 & m) >>> 1); |
| 228 | | |
| 229 |
1
1. drawPlaceholder : removed call to java/awt/Graphics::setColor → NO_COVERAGE |
g.setColor(new Color(c2, true)); |
| 230 | ||
| 231 |
1
1. drawPlaceholder : negated conditional → NO_COVERAGE |
var fontNonUbuntu = UiUtil.FONT_NON_MONO_BIG.equals(textComponent.getFont()) // when address bar |
| 232 | ? UiUtil.FONT_MONO_ASIAN_BIG.deriveFont(Font.ITALIC) // bigger font | |
| 233 | : UiUtil.FONT_MONO_ASIAN.deriveFont(Font.ITALIC); // fine for address bar, console, textfield | |
| 234 |
1
1. drawPlaceholder : removed call to java/awt/Graphics::setFont → NO_COVERAGE |
g.setFont( |
| 235 |
1
1. drawPlaceholder : negated conditional → NO_COVERAGE |
I18nViewUtil.isNonUbuntu(I18nUtil.getCurrentLocale()) |
| 236 |
1
1. drawPlaceholder : negated conditional → NO_COVERAGE |
|| !ComponentOrientation.getOrientation(I18nUtil.getCurrentLocale()).isLeftToRight() |
| 237 | ? fontNonUbuntu | |
| 238 | : textComponent.getFont().deriveFont(Font.ITALIC) // same | |
| 239 | ); | |
| 240 | ||
| 241 |
1
1. drawPlaceholder : removed call to java/awt/Graphics::drawString → NO_COVERAGE |
g.drawString(placeholderText, ( |
| 242 |
1
1. drawPlaceholder : negated conditional → NO_COVERAGE |
textComponent.getComponentOrientation().isLeftToRight() |
| 243 |
2
1. drawPlaceholder : Replaced integer addition with subtraction → NO_COVERAGE 2. drawPlaceholder : Replaced integer addition with subtraction → NO_COVERAGE |
? x + insets.left + 2 |
| 244 |
5
1. drawPlaceholder : Replaced integer addition with subtraction → NO_COVERAGE 2. drawPlaceholder : Replaced integer addition with subtraction → NO_COVERAGE 3. drawPlaceholder : Replaced integer addition with subtraction → NO_COVERAGE 4. drawPlaceholder : Replaced integer subtraction with addition → NO_COVERAGE 5. drawPlaceholder : Replaced integer multiplication with division → NO_COVERAGE |
: w - (fontMetrics.stringWidth(placeholderText) + insets.left + 2 + 2*x) // 2*x magic number for ar address bar margin |
| 245 | ), y); | |
| 246 | } | |
| 247 | | |
| 248 | public static void init(JTextComponent component) { | |
| 249 |
1
1. init : removed call to javax/swing/text/JTextComponent::setCaret → NO_COVERAGE |
component.setCaret(new DefaultCaret() { |
| 250 | @Override | |
| 251 | public void setSelectionVisible(boolean visible) { | |
| 252 |
1
1. setSelectionVisible : removed call to javax/swing/text/DefaultCaret::setSelectionVisible → NO_COVERAGE |
super.setSelectionVisible(true); |
| 253 | } | |
| 254 | }); | |
| 255 |
1
1. init : removed call to javax/swing/ActionMap::put → NO_COVERAGE |
component.getActionMap().put(DefaultEditorKit.deletePrevCharAction, new DeletePrevCharAction()); |
| 256 |
1
1. init : removed call to javax/swing/ActionMap::put → NO_COVERAGE |
component.getActionMap().put(DefaultEditorKit.deleteNextCharAction, new DeleteNextCharAction()); |
| 257 | } | |
| 258 | ||
| 259 | public static void applySyntaxTheme(RSyntaxTextArea textArea) { | |
| 260 | try { | |
| 261 | boolean isDark = UIManager.getLookAndFeel().getName().matches(".*(Dark|High Contrast).*"); | |
| 262 |
1
1. applySyntaxTheme : negated conditional → NO_COVERAGE |
var xmlTheme = String.format("/org/fife/ui/rsyntaxtextarea/themes/%s.xml", isDark ? "dark" : "default"); |
| 263 | Theme theme = Theme.load(SqlEngine.class.getResourceAsStream(xmlTheme)); | |
| 264 |
1
1. applySyntaxTheme : removed call to org/fife/ui/rsyntaxtextarea/Theme::apply → NO_COVERAGE |
theme.apply(textArea); |
| 265 | } catch (IOException e) { | |
| 266 | throw new IllegalArgumentException(e); | |
| 267 | } | |
| 268 | } | |
| 269 | ||
| 270 | public static void applyTheme(String nameTheme) { | |
| 271 | try { | |
| 272 |
2
1. applyTheme : removed call to javax/swing/UIManager::setLookAndFeel → NO_COVERAGE 2. applyTheme : negated conditional → NO_COVERAGE |
UIManager.setLookAndFeel(StringUtils.isBlank(nameTheme) ? FlatLightFlatIJTheme.class.getName() : nameTheme); |
| 273 | } catch (ClassNotFoundException e) { // when preference is set with a theme name deleted | |
| 274 | LOGGER.log(LogLevelUtil.CONSOLE_JAVA, "Theme not found, falling back to default theme"); | |
| 275 | try { | |
| 276 |
1
1. applyTheme : removed call to javax/swing/UIManager::setLookAndFeel → NO_COVERAGE |
UIManager.setLookAndFeel(FlatLightFlatIJTheme.class.getName()); |
| 277 | } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e2) { | |
| 278 | throw new IllegalArgumentException(e); | |
| 279 | } | |
| 280 | } catch (InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { | |
| 281 | throw new IllegalArgumentException(e); | |
| 282 | } | |
| 283 |
1
1. applyTheme : removed call to com/formdev/flatlaf/FlatLaf::updateUI → NO_COVERAGE |
FlatLaf.updateUI(); // required |
| 284 | ||
| 285 | // required ATTRIBUTE_ALL without color for compatibility with dark/light mode as text is white/black | |
| 286 |
1
1. applyTheme : removed call to javax/swing/text/StyleConstants::setForeground → NO_COVERAGE |
StyleConstants.setForeground(JTextPaneAppender.ATTRIBUTE_WARN, LogLevelUtil.COLOR_RED); |
| 287 |
1
1. applyTheme : removed call to javax/swing/text/StyleConstants::setForeground → NO_COVERAGE |
StyleConstants.setForeground(JTextPaneAppender.ATTRIBUTE_INFORM, LogLevelUtil.COLOR_BLU); |
| 288 |
1
1. applyTheme : removed call to javax/swing/text/StyleConstants::setForeground → NO_COVERAGE |
StyleConstants.setForeground(JTextPaneAppender.ATTRIBUTE_SUCCESS, LogLevelUtil.COLOR_GREEN); |
| 289 | } | |
| 290 | ||
| 291 | public static GridLayout getColumnLayout(int size) { | |
| 292 |
3
1. getColumnLayout : Replaced integer addition with subtraction → NO_COVERAGE 2. getColumnLayout : Replaced integer division with multiplication → NO_COVERAGE 3. getColumnLayout : replaced return value with null for com/jsql/view/swing/util/UiUtil::getColumnLayout → NO_COVERAGE |
return new GridLayout((size + 1) / 2, 2); |
| 293 | } | |
| 294 | } | |
Mutations | ||
| 176 |
1.1 |
|
| 178 |
1.1 2.2 |
|
| 209 |
1.1 |
|
| 213 |
1.1 2.2 |
|
| 219 |
1.1 |
|
| 227 |
1.1 2.2 3.3 4.4 5.5 |
|
| 229 |
1.1 |
|
| 231 |
1.1 |
|
| 234 |
1.1 |
|
| 235 |
1.1 |
|
| 236 |
1.1 |
|
| 241 |
1.1 |
|
| 242 |
1.1 |
|
| 243 |
1.1 2.2 |
|
| 244 |
1.1 2.2 3.3 4.4 5.5 |
|
| 249 |
1.1 |
|
| 252 |
1.1 |
|
| 255 |
1.1 |
|
| 256 |
1.1 |
|
| 262 |
1.1 |
|
| 264 |
1.1 |
|
| 272 |
1.1 2.2 |
|
| 276 |
1.1 |
|
| 283 |
1.1 |
|
| 286 |
1.1 |
|
| 287 |
1.1 |
|
| 288 |
1.1 |
|
| 292 |
1.1 2.2 3.3 |