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 |
|
19 |
1.1 |
|
28 |
1.1 |
|
35 |
1.1 |
|
40 |
1.1 2.2 |
|
41 |
1.1 |
|
43 |
1.1 |
|
44 |
1.1 |
|
49 |
1.1 |
|
53 |
1.1 |