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.text; | |
12 | ||
13 | import com.jsql.util.LogLevelUtil; | |
14 | import org.apache.commons.lang3.StringUtils; | |
15 | import org.apache.logging.log4j.LogManager; | |
16 | import org.apache.logging.log4j.Logger; | |
17 | ||
18 | import javax.swing.*; | |
19 | import java.awt.*; | |
20 | import java.awt.event.FocusAdapter; | |
21 | import java.awt.event.FocusEvent; | |
22 | ||
23 | /** | |
24 | * A JTextArea decorated with popup menu and border. | |
25 | */ | |
26 | public class JPopupTextArea extends JPopupTextComponent<JTextArea> implements DecoratorJComponent<JTextArea> { | |
27 | ||
28 | private static final Logger LOGGER = LogManager.getRootLogger(); | |
29 | ||
30 | /** | |
31 | * Build new instance of readonly JTextArea to decorate. | |
32 | */ | |
33 | public JPopupTextArea() { | |
34 | this(StringUtils.EMPTY); | |
35 | } | |
36 | | |
37 | /** | |
38 | * Build new instance of readonly JTextArea to decorate | |
39 | * with a default placeholder. | |
40 | */ | |
41 | public JPopupTextArea(String placeholder) { | |
42 | this(new JTextAreaPlaceholder(placeholder) { | |
43 | @Override | |
44 | public boolean isEditable() { | |
45 |
1
1. isEditable : replaced boolean return with true for com/jsql/view/swing/text/JPopupTextArea$1::isEditable → NO_COVERAGE |
return false; |
46 | } | |
47 | }); | |
48 | } | |
49 | ||
50 | /** | |
51 | * Build new instance of JTextArea to decorate. | |
52 | */ | |
53 | public JPopupTextArea(JTextArea proxy) { | |
54 | super(proxy); | |
55 | ||
56 | // Side effect: disable caret blink, editable texts must restore blink rate | |
57 |
1
1. <init> : removed call to javax/swing/JTextArea::addFocusListener → NO_COVERAGE |
this.getProxy().addFocusListener(new FocusAdapter() { |
58 | @Override | |
59 | public void focusGained(FocusEvent focusEvent) { | |
60 | // Fix #95769: IllegalArgumentException on setVisible() | |
61 | try { | |
62 |
1
1. focusGained : removed call to javax/swing/text/Caret::setVisible → NO_COVERAGE |
JPopupTextArea.this.getProxy().getCaret().setVisible(true); |
63 | } catch (IllegalArgumentException e) { | |
64 | LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e); | |
65 | } | |
66 |
1
1. focusGained : removed call to javax/swing/text/Caret::setSelectionVisible → NO_COVERAGE |
JPopupTextArea.this.getProxy().getCaret().setSelectionVisible(true); |
67 | } | |
68 | }); | |
69 | ||
70 |
1
1. <init> : removed call to javax/swing/JTextArea::setBorder → NO_COVERAGE |
this.getProxy().setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); |
71 |
1
1. <init> : removed call to javax/swing/JTextArea::setCursor → NO_COVERAGE |
this.getProxy().setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); |
72 | } | |
73 | } | |
Mutations | ||
45 |
1.1 |
|
57 |
1.1 |
|
62 |
1.1 |
|
66 |
1.1 |
|
70 |
1.1 |
|
71 |
1.1 |