| 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.manager; | |
| 12 | ||
| 13 | import com.jsql.util.LogLevelUtil; | |
| 14 | import com.jsql.view.swing.list.ItemList; | |
| 15 | import com.jsql.view.swing.manager.util.StateButton; | |
| 16 | import com.jsql.view.swing.util.I18nViewUtil; | |
| 17 | import com.jsql.view.swing.util.MediatorHelper; | |
| 18 | import org.apache.logging.log4j.LogManager; | |
| 19 | import org.apache.logging.log4j.Logger; | |
| 20 | ||
| 21 | import javax.swing.*; | |
| 22 | import java.awt.*; | |
| 23 | import java.awt.event.ActionEvent; | |
| 24 | import java.awt.event.ActionListener; | |
| 25 | import java.util.Arrays; | |
| 26 | import java.util.List; | |
| 27 | import java.util.stream.Collectors; | |
| 28 | ||
| 29 | /** | |
| 30 | * Manager to read a file from the host. | |
| 31 | */ | |
| 32 | public class ManagerFile extends AbstractManagerList { | |
| 33 | ||
| 34 | private static final Logger LOGGER = LogManager.getRootLogger(); | |
| 35 | ||
| 36 | /** | |
| 37 | * Create the manager panel to read a file. | |
| 38 | */ | |
| 39 | public ManagerFile() { | |
| 40 | super("swing/list/file.txt"); | |
| 41 |
1
1. <init> : removed call to com/jsql/view/swing/manager/ManagerFile::buildRunButton → NO_COVERAGE |
this.buildRunButton("FILE_RUN_BUTTON_LABEL", "FILE_RUN_BUTTON_TOOLTIP"); |
| 42 |
1
1. <init> : removed call to com/jsql/view/swing/manager/util/JButtonStateful::setEnabled → NO_COVERAGE |
this.run.setEnabled(false); |
| 43 |
1
1. <init> : removed call to com/jsql/view/swing/manager/util/JButtonStateful::addActionListener → NO_COVERAGE |
this.run.addActionListener(new ActionFile()); |
| 44 |
1
1. <init> : removed call to com/jsql/view/swing/manager/ManagerFile::buildPrivilege → NO_COVERAGE |
this.buildPrivilege(); |
| 45 |
1
1. <init> : removed call to com/jsql/view/swing/manager/ManagerFile::add → NO_COVERAGE |
this.add(this.lastLine, BorderLayout.SOUTH); |
| 46 | } | |
| 47 | ||
| 48 | private class ActionFile implements ActionListener { | |
| 49 | @Override | |
| 50 | public void actionPerformed(ActionEvent e) { | |
| 51 |
1
1. actionPerformed : negated conditional → NO_COVERAGE |
if (ManagerFile.this.listPaths.getSelectedValuesList().isEmpty()) { |
| 52 | LOGGER.log(LogLevelUtil.CONSOLE_ERROR, "Select in the list at least one file to read"); | |
| 53 | return; | |
| 54 | } | |
| 55 | if (!Arrays.asList( | |
| 56 | MediatorHelper.model().getMediatorVendor().getSqlite(), | |
| 57 | MediatorHelper.model().getMediatorVendor().getDerby(), | |
| 58 | MediatorHelper.model().getMediatorVendor().getH2(), | |
| 59 | MediatorHelper.model().getMediatorVendor().getHsqldb(), | |
| 60 | MediatorHelper.model().getMediatorVendor().getMysql(), | |
| 61 | MediatorHelper.model().getMediatorVendor().getPostgres() | |
| 62 |
1
1. actionPerformed : negated conditional → NO_COVERAGE |
).contains(MediatorHelper.model().getMediatorVendor().getVendor())) { |
| 63 | LOGGER.log( | |
| 64 | LogLevelUtil.CONSOLE_ERROR, | |
| 65 | "Read file for [{}] not implemented, share a working example to GitHub to speed up release", | |
| 66 | MediatorHelper.model().getMediatorVendor().getVendor() | |
| 67 | ); | |
| 68 | return; | |
| 69 | } | |
| 70 | new SwingWorker<>() { | |
| 71 | @Override | |
| 72 | protected Object doInBackground() { | |
| 73 |
1
1. doInBackground : removed call to java/lang/Thread::setName → NO_COVERAGE |
Thread.currentThread().setName("SwingWorkerManagerFile"); |
| 74 |
1
1. doInBackground : negated conditional → NO_COVERAGE |
if (ManagerFile.this.run.getState() == StateButton.STARTABLE) { |
| 75 |
1
1. doInBackground : removed call to com/jsql/view/swing/manager/util/JButtonStateful::setText → NO_COVERAGE |
ManagerFile.this.run.setText(I18nViewUtil.valueByKey("FILE_RUN_BUTTON_STOP")); |
| 76 |
1
1. doInBackground : removed call to com/jsql/view/swing/manager/util/JButtonStateful::setState → NO_COVERAGE |
ManagerFile.this.run.setState(StateButton.STOPPABLE); |
| 77 |
1
1. doInBackground : removed call to java/awt/Component::setVisible → NO_COVERAGE |
ManagerFile.this.horizontalGlue.setVisible(false); |
| 78 |
1
1. doInBackground : removed call to javax/swing/JProgressBar::setVisible → NO_COVERAGE |
ManagerFile.this.progressBar.setVisible(true); |
| 79 | try { | |
| 80 | List<String> filePaths = ManagerFile.this.listPaths.getSelectedValuesList().stream().map(ItemList::toString).collect(Collectors.toList()); | |
| 81 | MediatorHelper.model().getResourceAccess().readFile(filePaths); | |
| 82 | } catch (InterruptedException e) { | |
| 83 | LOGGER.log(LogLevelUtil.IGNORE, e, e); | |
| 84 |
1
1. doInBackground : removed call to java/lang/Thread::interrupt → NO_COVERAGE |
Thread.currentThread().interrupt(); |
| 85 | } catch (Exception e) { | |
| 86 | LOGGER.log(LogLevelUtil.CONSOLE_ERROR, e, e); | |
| 87 | } | |
| 88 |
1
1. doInBackground : removed call to com/jsql/view/swing/manager/ManagerFile::endProcess → NO_COVERAGE |
ManagerFile.this.endProcess(); |
| 89 | } else { | |
| 90 |
1
1. doInBackground : removed call to com/jsql/model/accessible/ResourceAccess::stopSearchFile → NO_COVERAGE |
MediatorHelper.model().getResourceAccess().stopSearchFile(); |
| 91 |
1
1. doInBackground : removed call to com/jsql/view/swing/manager/util/JButtonStateful::setEnabled → NO_COVERAGE |
ManagerFile.this.run.setEnabled(false); |
| 92 |
1
1. doInBackground : removed call to com/jsql/view/swing/manager/util/JButtonStateful::setState → NO_COVERAGE |
ManagerFile.this.run.setState(StateButton.STOPPING); |
| 93 | } | |
| 94 | return null; | |
| 95 | } | |
| 96 |
1
1. actionPerformed : removed call to com/jsql/view/swing/manager/ManagerFile$ActionFile$1::execute → NO_COVERAGE |
}.execute(); |
| 97 | } | |
| 98 | } | |
| 99 | } | |
Mutations | ||
| 41 |
1.1 |
|
| 42 |
1.1 |
|
| 43 |
1.1 |
|
| 44 |
1.1 |
|
| 45 |
1.1 |
|
| 51 |
1.1 |
|
| 62 |
1.1 |
|
| 73 |
1.1 |
|
| 74 |
1.1 |
|
| 75 |
1.1 |
|
| 76 |
1.1 |
|
| 77 |
1.1 |
|
| 78 |
1.1 |
|
| 84 |
1.1 |
|
| 88 |
1.1 |
|
| 90 |
1.1 |
|
| 91 |
1.1 |
|
| 92 |
1.1 |
|
| 96 |
1.1 |