1 | /******************************************************************************* | |
2 | * Copyhacked (H) 2012-2020. | |
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 about 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.panel.util; | |
12 | ||
13 | import com.jsql.view.swing.scrollpane.LightScrollPane; | |
14 | import com.jsql.view.swing.text.JPopupTextArea; | |
15 | import com.jsql.view.swing.text.JTextAreaPlaceholder; | |
16 | import com.jsql.view.swing.util.MediatorHelper; | |
17 | import com.jsql.view.swing.util.UiUtil; | |
18 | ||
19 | import javax.swing.*; | |
20 | import java.awt.*; | |
21 | import java.awt.event.ActionEvent; | |
22 | import java.awt.event.KeyEvent; | |
23 | import java.awt.event.WindowAdapter; | |
24 | import java.awt.event.WindowEvent; | |
25 | ||
26 | /** | |
27 | * A button displayed in address. | |
28 | */ | |
29 | public class ButtonExpandText extends JButton { | |
30 | ||
31 | /** | |
32 | * Create a button in address bar. | |
33 | */ | |
34 | public ButtonExpandText(String titleFrame, JTextField textFieldHeader) { | |
35 | | |
36 |
1
1. <init> : removed call to com/jsql/view/swing/panel/util/ButtonExpandText::setPreferredSize → NO_COVERAGE |
this.setPreferredSize(new Dimension(18, 16)); |
37 |
1
1. <init> : removed call to com/jsql/view/swing/panel/util/ButtonExpandText::setOpaque → NO_COVERAGE |
this.setOpaque(false); |
38 |
1
1. <init> : removed call to com/jsql/view/swing/panel/util/ButtonExpandText::setContentAreaFilled → NO_COVERAGE |
this.setContentAreaFilled(false); |
39 |
1
1. <init> : removed call to com/jsql/view/swing/panel/util/ButtonExpandText::setBorderPainted → NO_COVERAGE |
this.setBorderPainted(false); |
40 |
1
1. <init> : removed call to com/jsql/view/swing/panel/util/ButtonExpandText::setFocusPainted → NO_COVERAGE |
this.setFocusPainted(false); |
41 | ||
42 |
1
1. <init> : removed call to com/jsql/view/swing/panel/util/ButtonExpandText::setIcon → NO_COVERAGE |
this.setIcon(UiUtil.ICON_EXPAND_TEXT); |
43 | ||
44 | JTextArea textArea = new JPopupTextArea(new JTextAreaPlaceholder("Multiline text")).getProxy(); | |
45 |
1
1. <init> : removed call to javax/swing/text/Caret::setBlinkRate → NO_COVERAGE |
textArea.getCaret().setBlinkRate(500); |
46 | ||
47 | final JDialog frameWithTextarea = new JDialog(MediatorHelper.frame(), titleFrame, true); | |
48 | frameWithTextarea.getContentPane().add(new LightScrollPane(textArea)); | |
49 |
1
1. <init> : removed call to javax/swing/JDialog::pack → NO_COVERAGE |
frameWithTextarea.pack(); |
50 |
1
1. <init> : removed call to javax/swing/JDialog::setSize → NO_COVERAGE |
frameWithTextarea.setSize(400, 300); |
51 |
1
1. <init> : removed call to javax/swing/JDialog::setLocationRelativeTo → NO_COVERAGE |
frameWithTextarea.setLocationRelativeTo(null); |
52 |
1
1. <init> : removed call to javax/swing/JDialog::addWindowListener → NO_COVERAGE |
frameWithTextarea.addWindowListener(new WindowAdapter() { |
53 | @Override | |
54 | public void windowClosing(WindowEvent e) { | |
55 |
1
1. windowClosing : removed call to javax/swing/JTextField::setText → NO_COVERAGE |
textFieldHeader.setText(textArea.getText().replace("\n", "\\n").replace("\r", "\\r")); |
56 |
1
1. windowClosing : removed call to java/awt/event/WindowAdapter::windowClosing → NO_COVERAGE |
super.windowClosing(e); |
57 | } | |
58 | }); | |
59 | ||
60 |
1
1. <init> : removed call to com/jsql/view/swing/panel/util/ButtonExpandText::addActionListener → NO_COVERAGE |
this.addActionListener(e -> { |
61 |
1
1. lambda$new$0 : removed call to javax/swing/JTextArea::setText → NO_COVERAGE |
textArea.setText(textFieldHeader.getText().replace("\\n", "\n").replace("\\r", "\r")); |
62 |
2
1. lambda$new$0 : removed call to javax/swing/JDialog::setVisible → NO_COVERAGE 2. lambda$new$0 : negated conditional → NO_COVERAGE |
frameWithTextarea.setVisible(!frameWithTextarea.isVisible()); |
63 | }); | |
64 | ||
65 | frameWithTextarea.getRootPane() | |
66 | .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) | |
67 |
1
1. <init> : removed call to javax/swing/InputMap::put → NO_COVERAGE |
.put( |
68 | KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), | |
69 | "Cancel" | |
70 | ); | |
71 | frameWithTextarea.getRootPane() | |
72 | .getActionMap() | |
73 |
1
1. <init> : removed call to javax/swing/ActionMap::put → NO_COVERAGE |
.put("Cancel", new AbstractAction() { |
74 | public void actionPerformed(ActionEvent e) { | |
75 |
1
1. actionPerformed : removed call to javax/swing/JDialog::dispose → NO_COVERAGE |
frameWithTextarea.dispose(); |
76 | } | |
77 | }); | |
78 | } | |
79 | } | |
Mutations | ||
36 |
1.1 |
|
37 |
1.1 |
|
38 |
1.1 |
|
39 |
1.1 |
|
40 |
1.1 |
|
42 |
1.1 |
|
45 |
1.1 |
|
49 |
1.1 |
|
50 |
1.1 |
|
51 |
1.1 |
|
52 |
1.1 |
|
55 |
1.1 |
|
56 |
1.1 |
|
60 |
1.1 |
|
61 |
1.1 |
|
62 |
1.1 2.2 |
|
67 |
1.1 |
|
73 |
1.1 |
|
75 |
1.1 |