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