1 | package com.jsql.view.swing.text; | |
2 | ||
3 | import com.jsql.util.LogLevelUtil; | |
4 | import com.jsql.view.swing.util.UiUtil; | |
5 | import org.apache.commons.lang3.StringUtils; | |
6 | import org.apache.logging.log4j.LogManager; | |
7 | import org.apache.logging.log4j.Logger; | |
8 | ||
9 | import javax.swing.*; | |
10 | import java.awt.*; | |
11 | ||
12 | /** | |
13 | * Textfield with information text displayed when empty. | |
14 | */ | |
15 | public class JTextAreaPlaceholder extends JTextArea { | |
16 | | |
17 | /** | |
18 | * Log4j logger sent to view. | |
19 | */ | |
20 | private static final Logger LOGGER = LogManager.getRootLogger(); | |
21 | | |
22 | /** | |
23 | * Text to display when empty. | |
24 | */ | |
25 | private final String placeholderText; | |
26 | | |
27 | /** | |
28 | * Create a textfield with hint. | |
29 | * @param placeholder Text displayed when empty | |
30 | */ | |
31 | public JTextAreaPlaceholder(String placeholder) { | |
32 | | |
33 | this.placeholderText = placeholder; | |
34 |
1
1. <init> : removed call to com/jsql/view/swing/util/UiUtil::initialize → NO_COVERAGE |
UiUtil.initialize(this); |
35 | } | |
36 | ||
37 | @Override | |
38 | public void paint(Graphics g) { | |
39 | // Fix #6350: ArrayIndexOutOfBoundsException on paint() | |
40 | // Fix #90822: IllegalArgumentException on paint() | |
41 | // Fix #90761: StateInvariantError on paint() | |
42 | // StateInvariantError possible on jdk 8 when WrappedPlainView.drawLine in paint() | |
43 | try { | |
44 |
1
1. paint : removed call to javax/swing/JTextArea::paint → NO_COVERAGE |
super.paint(g); |
45 | | |
46 |
1
1. paint : negated conditional → NO_COVERAGE |
if (StringUtils.isEmpty(this.getText())) { |
47 |
1
1. paint : removed call to com/jsql/view/swing/util/UiUtil::drawPlaceholder → NO_COVERAGE |
UiUtil.drawPlaceholder(this, g, this.placeholderText); |
48 | } | |
49 | } catch (IllegalArgumentException | NullPointerException | ArrayIndexOutOfBoundsException e) { | |
50 | LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e, e); | |
51 | } | |
52 | } | |
53 | } | |
Mutations | ||
34 |
1.1 |
|
44 |
1.1 |
|
46 |
1.1 |
|
47 |
1.1 |