MenuBarCoder.java

1
package com.jsql.view.swing.manager.util;
2
3
import javax.swing.*;
4
import java.awt.event.ActionEvent;
5
import java.awt.event.ActionListener;
6
7
public class MenuBarCoder extends JMenuBar {
8
    
9
    private final JMenu menu;
10
11
    private class MenuItemListener implements ActionListener {
12
        
13
        @Override
14
        public void actionPerformed(ActionEvent e) {
15
            
16
            JMenuItem item = (JMenuItem) e.getSource();
17 1 1. actionPerformed : removed call to javax/swing/JMenu::setText → NO_COVERAGE
            MenuBarCoder.this.menu.setText(item.getText());
18
            
19 1 1. actionPerformed : removed call to javax/swing/JMenu::requestFocus → NO_COVERAGE
            MenuBarCoder.this.menu.requestFocus();
20
        }
21
    }
22
    
23
    public MenuBarCoder(JMenu menu) {
24
        
25
        this.menu = menu;
26
        
27
        var listener = new MenuItemListener();
28 1 1. <init> : removed call to com/jsql/view/swing/manager/util/MenuBarCoder::setListener → NO_COVERAGE
        this.setListener(menu, listener);
29
        
30
        this.add(menu);
31
    }
32
33
    private void setListener(JMenuItem item, ActionListener listener) {
34
        
35 1 1. setListener : negated conditional → NO_COVERAGE
        if (item instanceof JMenu) {
36
            
37
            JMenu menuContainingItems = (JMenu) item;
38
            int countItems = menuContainingItems.getItemCount();
39
            
40 2 1. setListener : negated conditional → NO_COVERAGE
2. setListener : changed conditional boundary → NO_COVERAGE
            for (var i = 0 ; i < countItems ; i++) {
41 1 1. setListener : removed call to com/jsql/view/swing/manager/util/MenuBarCoder::setListener → NO_COVERAGE
                this.setListener(menuContainingItems.getItem(i), listener);
42
            }
43 1 1. setListener : negated conditional → NO_COVERAGE
        } else if (item != null) { // null means separator
44 1 1. setListener : removed call to javax/swing/JMenuItem::addActionListener → NO_COVERAGE
            item.addActionListener(listener);
45
        }
46
    }
47
48
    public static JMenu createMenu(String label) {
49 1 1. createMenu : replaced return value with null for com/jsql/view/swing/manager/util/MenuBarCoder::createMenu → NO_COVERAGE
        return new ComboMenu(label);
50
    }
51
    
52
    public String getSelectedItem() {
53 1 1. getSelectedItem : replaced return value with "" for com/jsql/view/swing/manager/util/MenuBarCoder::getSelectedItem → NO_COVERAGE
        return this.menu.getText();
54
    }
55
}

Mutations

17

1.1
Location : actionPerformed
Killed by : none
removed call to javax/swing/JMenu::setText → NO_COVERAGE

19

1.1
Location : actionPerformed
Killed by : none
removed call to javax/swing/JMenu::requestFocus → NO_COVERAGE

28

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/manager/util/MenuBarCoder::setListener → NO_COVERAGE

35

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

40

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

2.2
Location : setListener
Killed by : none
changed conditional boundary → NO_COVERAGE

41

1.1
Location : setListener
Killed by : none
removed call to com/jsql/view/swing/manager/util/MenuBarCoder::setListener → NO_COVERAGE

43

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

44

1.1
Location : setListener
Killed by : none
removed call to javax/swing/JMenuItem::addActionListener → NO_COVERAGE

49

1.1
Location : createMenu
Killed by : none
replaced return value with null for com/jsql/view/swing/manager/util/MenuBarCoder::createMenu → NO_COVERAGE

53

1.1
Location : getSelectedItem
Killed by : none
replaced return value with "" for com/jsql/view/swing/manager/util/MenuBarCoder::getSelectedItem → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.16.1