EmptyFocusCopy.java

1
package com.jsql.view.swing.terminal;
2
3
import com.jsql.util.LogLevelUtil;
4
import org.apache.logging.log4j.LogManager;
5
import org.apache.logging.log4j.Logger;
6
7
import java.awt.*;
8
import java.awt.datatransfer.DataFlavor;
9
import java.awt.datatransfer.UnsupportedFlavorException;
10
import java.awt.event.MouseEvent;
11
import java.awt.event.MouseListener;
12
import java.io.IOException;
13
import java.util.Arrays;
14
15
/**
16
 * Cancel every mouse click, only gives focus.
17
 */
18
public class EmptyFocusCopy implements MouseListener {
19
20
    private static final Logger LOGGER = LogManager.getRootLogger();
21
22
    private final AbstractExploit abstractExploit;
23
24
    public EmptyFocusCopy(AbstractExploit abstractExploit) {
25
        this.abstractExploit = abstractExploit;
26
    }
27
28
    @Override
29
    public void mousePressed(MouseEvent e) {
30 1 1. mousePressed : removed call to java/awt/event/MouseEvent::consume → NO_COVERAGE
        e.consume();
31
        this.abstractExploit.requestFocusInWindow();
32 1 1. mousePressed : removed call to com/jsql/view/swing/terminal/AbstractExploit::setCaretPosition → NO_COVERAGE
        this.abstractExploit.setCaretPosition(this.abstractExploit.getDocument().getLength());
33 1 1. mousePressed : negated conditional → NO_COVERAGE
        if (Arrays.asList(MouseEvent.BUTTON2, MouseEvent.BUTTON3).contains(e.getButton())) {
34 1 1. mousePressed : removed call to com/jsql/view/swing/terminal/EmptyFocusCopy::pasteClipboard → NO_COVERAGE
            this.pasteClipboard();
35
        }
36
    }
37
38
    private void pasteClipboard() {
39
        try {
40
            String data = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
41 1 1. pasteClipboard : removed call to com/jsql/view/swing/terminal/AbstractExploit::append → NO_COVERAGE
            this.abstractExploit.append(data);
42
        } catch (UnsupportedFlavorException | IOException e) {
43
            LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e, e);
44
        }
45
    }
46
47
    @Override
48
    public void mouseReleased(MouseEvent e) {
49 1 1. mouseReleased : removed call to java/awt/event/MouseEvent::consume → NO_COVERAGE
        e.consume();
50
    }
51
    
52
    @Override
53
    public void mouseExited(MouseEvent e) {
54 1 1. mouseExited : removed call to java/awt/event/MouseEvent::consume → NO_COVERAGE
        e.consume();
55
    }
56
    
57
    @Override
58
    public void mouseEntered(MouseEvent e) {
59 1 1. mouseEntered : removed call to java/awt/event/MouseEvent::consume → NO_COVERAGE
        e.consume();
60
    }
61
    
62
    @Override
63
    public void mouseClicked(MouseEvent e) {
64 1 1. mouseClicked : removed call to java/awt/event/MouseEvent::consume → NO_COVERAGE
        e.consume();
65
    }
66
}

Mutations

30

1.1
Location : mousePressed
Killed by : none
removed call to java/awt/event/MouseEvent::consume → NO_COVERAGE

32

1.1
Location : mousePressed
Killed by : none
removed call to com/jsql/view/swing/terminal/AbstractExploit::setCaretPosition → NO_COVERAGE

33

1.1
Location : mousePressed
Killed by : none
negated conditional → NO_COVERAGE

34

1.1
Location : mousePressed
Killed by : none
removed call to com/jsql/view/swing/terminal/EmptyFocusCopy::pasteClipboard → NO_COVERAGE

41

1.1
Location : pasteClipboard
Killed by : none
removed call to com/jsql/view/swing/terminal/AbstractExploit::append → NO_COVERAGE

49

1.1
Location : mouseReleased
Killed by : none
removed call to java/awt/event/MouseEvent::consume → NO_COVERAGE

54

1.1
Location : mouseExited
Killed by : none
removed call to java/awt/event/MouseEvent::consume → NO_COVERAGE

59

1.1
Location : mouseEntered
Killed by : none
removed call to java/awt/event/MouseEvent::consume → NO_COVERAGE

64

1.1
Location : mouseClicked
Killed by : none
removed call to java/awt/event/MouseEvent::consume → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.22.0