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.manager; | |
12 | ||
13 | import com.jsql.util.I18nUtil; | |
14 | import com.jsql.util.LogLevelUtil; | |
15 | import com.jsql.view.swing.list.ItemList; | |
16 | import com.jsql.view.swing.manager.util.JButtonStateful; | |
17 | import com.jsql.view.swing.manager.util.StateButton; | |
18 | import com.jsql.view.swing.ui.FlatButtonMouseAdapter; | |
19 | import com.jsql.view.swing.util.I18nViewUtil; | |
20 | import com.jsql.view.swing.util.MediatorHelper; | |
21 | import com.jsql.view.swing.util.UiUtil; | |
22 | import org.apache.logging.log4j.LogManager; | |
23 | import org.apache.logging.log4j.Logger; | |
24 | ||
25 | import javax.swing.*; | |
26 | import java.awt.*; | |
27 | import java.util.List; | |
28 | import java.util.stream.Collectors; | |
29 | ||
30 | /** | |
31 | * Manager to read a file from the host. | |
32 | */ | |
33 | public class ManagerFile extends AbstractManagerList { | |
34 | | |
35 | /** | |
36 | * Log4j logger sent to view. | |
37 | */ | |
38 | private static final Logger LOGGER = LogManager.getRootLogger(); | |
39 | ||
40 | /** | |
41 | * Create the manager panel to read a file. | |
42 | */ | |
43 | public ManagerFile() { | |
44 | | |
45 | super("swing/list/file.txt"); | |
46 | | |
47 |
1
1. <init> : removed call to com/jsql/view/swing/manager/ManagerFile::initializeRunButton → NO_COVERAGE |
this.initializeRunButton(); |
48 | ||
49 | this.privilege = new JLabel(I18nUtil.valueByKey("PRIVILEGE_LABEL"), UiUtil.ICON_SQUARE_GREY, SwingConstants.LEFT); | |
50 |
1
1. <init> : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey("PRIVILEGE_LABEL", this.privilege); |
51 |
1
1. <init> : removed call to javax/swing/JLabel::setBorder → NO_COVERAGE |
this.privilege.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, UiUtil.COLOR_DEFAULT_BACKGROUND)); |
52 |
1
1. <init> : removed call to javax/swing/JLabel::setToolTipText → NO_COVERAGE |
this.privilege.setToolTipText(I18nUtil.valueByKey("PRIVILEGE_TOOLTIP")); |
53 | ||
54 |
1
1. <init> : removed call to javax/swing/JLabel::setVisible → NO_COVERAGE |
this.loader.setVisible(false); |
55 | ||
56 | this.lastLine.add(this.privilege); | |
57 | this.lastLine.add(Box.createHorizontalGlue()); | |
58 | this.lastLine.add(this.loader); | |
59 | this.lastLine.add(Box.createRigidArea(new Dimension(5, 0))); | |
60 | this.lastLine.add(this.run); | |
61 | | |
62 |
1
1. <init> : removed call to com/jsql/view/swing/manager/ManagerFile::add → NO_COVERAGE |
this.add(this.lastLine, BorderLayout.SOUTH); |
63 | } | |
64 | ||
65 | private void initializeRunButton() { | |
66 | | |
67 | this.defaultText = "FILE_RUN_BUTTON_LABEL"; | |
68 | this.run = new JButtonStateful(this.defaultText); | |
69 |
1
1. initializeRunButton : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey("FILE_RUN_BUTTON_LABEL", this.run); |
70 |
1
1. initializeRunButton : removed call to com/jsql/view/swing/manager/util/JButtonStateful::setToolTipText → NO_COVERAGE |
this.run.setToolTipText(I18nUtil.valueByKey("FILE_RUN_BUTTON_TOOLTIP")); |
71 | | |
72 |
1
1. initializeRunButton : removed call to com/jsql/view/swing/manager/util/JButtonStateful::setEnabled → NO_COVERAGE |
this.run.setEnabled(false); |
73 |
1
1. initializeRunButton : removed call to com/jsql/view/swing/manager/util/JButtonStateful::setContentAreaFilled → NO_COVERAGE |
this.run.setContentAreaFilled(false); |
74 |
1
1. initializeRunButton : removed call to com/jsql/view/swing/manager/util/JButtonStateful::setBorder → NO_COVERAGE |
this.run.setBorder(BorderFactory.createEmptyBorder(4, 8, 4, 8)); |
75 |
1
1. initializeRunButton : removed call to com/jsql/view/swing/manager/util/JButtonStateful::setBackground → NO_COVERAGE |
this.run.setBackground(UiUtil.COLOR_FOCUS_GAINED); |
76 | | |
77 |
1
1. initializeRunButton : removed call to com/jsql/view/swing/manager/util/JButtonStateful::addMouseListener → NO_COVERAGE |
this.run.addMouseListener(new FlatButtonMouseAdapter(this.run)); |
78 | | |
79 |
1
1. initializeRunButton : removed call to com/jsql/view/swing/manager/util/JButtonStateful::addActionListener → NO_COVERAGE |
this.run.addActionListener(actionEvent -> { |
80 | | |
81 |
1
1. lambda$initializeRunButton$1 : negated conditional → NO_COVERAGE |
if (this.listFile.getSelectedValuesList().isEmpty()) { |
82 | | |
83 | LOGGER.log(LogLevelUtil.CONSOLE_ERROR, "Select at least one file to read in the list"); | |
84 | return; | |
85 | } | |
86 | ||
87 | new Thread( | |
88 | () -> { | |
89 |
1
1. lambda$initializeRunButton$0 : negated conditional → NO_COVERAGE |
if (ManagerFile.this.run.getState() == StateButton.STARTABLE) { |
90 | | |
91 |
1
1. lambda$initializeRunButton$0 : removed call to com/jsql/view/swing/manager/util/JButtonStateful::setText → NO_COVERAGE |
ManagerFile.this.run.setText(I18nViewUtil.valueByKey("FILE_RUN_BUTTON_STOP")); |
92 |
1
1. lambda$initializeRunButton$0 : removed call to com/jsql/view/swing/manager/util/JButtonStateful::setState → NO_COVERAGE |
ManagerFile.this.run.setState(StateButton.STOPPABLE); |
93 |
1
1. lambda$initializeRunButton$0 : removed call to javax/swing/JLabel::setVisible → NO_COVERAGE |
ManagerFile.this.loader.setVisible(true); |
94 | | |
95 |
1
1. lambda$initializeRunButton$0 : removed call to com/jsql/view/swing/manager/ManagerWebShell::clearSelection → NO_COVERAGE |
MediatorHelper.managerWebshell().clearSelection(); |
96 |
1
1. lambda$initializeRunButton$0 : removed call to com/jsql/view/swing/manager/ManagerSqlShell::clearSelection → NO_COVERAGE |
MediatorHelper.managerSqlshell().clearSelection(); |
97 | | |
98 | try { | |
99 | List<String> filePaths = this.listFile.getSelectedValuesList().stream().map(ItemList::toString).collect(Collectors.toList()); | |
100 | MediatorHelper.model().getResourceAccess().readFile(filePaths); | |
101 | | |
102 | } catch (InterruptedException e) { | |
103 | | |
104 | LOGGER.log(LogLevelUtil.IGNORE, e, e); | |
105 |
1
1. lambda$initializeRunButton$0 : removed call to java/lang/Thread::interrupt → NO_COVERAGE |
Thread.currentThread().interrupt(); |
106 | | |
107 | } catch (Exception e) { | |
108 | LOGGER.log(LogLevelUtil.CONSOLE_ERROR, e, e); | |
109 | } | |
110 | } else { | |
111 | | |
112 |
1
1. lambda$initializeRunButton$0 : removed call to com/jsql/model/accessible/ResourceAccess::stopSearchingFile → NO_COVERAGE |
MediatorHelper.model().getResourceAccess().stopSearchingFile(); |
113 |
1
1. lambda$initializeRunButton$0 : removed call to com/jsql/view/swing/manager/util/JButtonStateful::setEnabled → NO_COVERAGE |
ManagerFile.this.run.setEnabled(false); |
114 |
1
1. lambda$initializeRunButton$0 : removed call to com/jsql/view/swing/manager/util/JButtonStateful::setState → NO_COVERAGE |
ManagerFile.this.run.setState(StateButton.STOPPING); |
115 | } | |
116 | }, | |
117 | "ThreadReadFile" | |
118 |
1
1. lambda$initializeRunButton$1 : removed call to java/lang/Thread::start → NO_COVERAGE |
).start(); |
119 | }); | |
120 | } | |
121 | } | |
Mutations | ||
47 |
1.1 |
|
50 |
1.1 |
|
51 |
1.1 |
|
52 |
1.1 |
|
54 |
1.1 |
|
62 |
1.1 |
|
69 |
1.1 |
|
70 |
1.1 |
|
72 |
1.1 |
|
73 |
1.1 |
|
74 |
1.1 |
|
75 |
1.1 |
|
77 |
1.1 |
|
79 |
1.1 |
|
81 |
1.1 |
|
89 |
1.1 |
|
91 |
1.1 |
|
92 |
1.1 |
|
93 |
1.1 |
|
95 |
1.1 |
|
96 |
1.1 |
|
105 |
1.1 |
|
112 |
1.1 |
|
113 |
1.1 |
|
114 |
1.1 |
|
118 |
1.1 |