| 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.I18nUtil; | |
| 14 | import com.jsql.util.LogLevelUtil; | |
| 15 | import com.jsql.view.swing.list.ItemList; | |
| 16 | import com.jsql.view.swing.manager.util.StateButton; | |
| 17 | import com.jsql.view.swing.util.I18nViewUtil; | |
| 18 | import com.jsql.view.swing.util.MediatorHelper; | |
| 19 | import org.apache.commons.lang3.StringUtils; | |
| 20 | import org.apache.logging.log4j.LogManager; | |
| 21 | import org.apache.logging.log4j.Logger; | |
| 22 | ||
| 23 | import java.awt.*; | |
| 24 | import java.util.stream.Collectors; | |
| 25 | ||
| 26 | /** | |
| 27 | * Manager to display webpages frequently used as backoffice administration. | |
| 28 | */ | |
| 29 | public class ManagerAdminPage extends AbstractManagerList { | |
| 30 | | |
| 31 | private static final Logger LOGGER = LogManager.getRootLogger(); | |
| 32 | ||
| 33 | /** | |
| 34 | * Create admin page finder. | |
| 35 | */ | |
| 36 | public ManagerAdminPage() { | |
| 37 | super("swing/list/admin-page.txt"); | |
| 38 | ||
| 39 |
1
1. <init> : removed call to com/jsql/view/swing/manager/ManagerAdminPage::buildRunButton → NO_COVERAGE |
this.buildRunButton("ADMIN_PAGE_RUN_BUTTON_LABEL", "ADMIN_PAGE_RUN_BUTTON_TOOLTIP"); |
| 40 |
1
1. <init> : removed call to com/jsql/view/swing/manager/util/JButtonStateful::setName → NO_COVERAGE |
this.run.setName("runManagerAdminPage"); |
| 41 |
2
1. <init> : removed call to com/jsql/view/swing/manager/util/JButtonStateful::addActionListener → NO_COVERAGE 2. lambda$new$0 : removed call to com/jsql/view/swing/manager/ManagerAdminPage::runSearch → NO_COVERAGE |
this.run.addActionListener(actionEvent -> this.runSearch()); |
| 42 |
1
1. <init> : removed call to com/jsql/view/swing/list/DnDList::setName → NO_COVERAGE |
this.listPaths.setName("listManagerAdminPage"); // no tooltip, too annoying |
| 43 | ||
| 44 | this.lastLine.add(this.horizontalGlue); | |
| 45 | this.lastLine.add(this.progressBar); | |
| 46 | this.lastLine.add(this.run); | |
| 47 |
1
1. <init> : removed call to com/jsql/view/swing/manager/ManagerAdminPage::add → NO_COVERAGE |
this.add(this.lastLine, BorderLayout.SOUTH); |
| 48 | } | |
| 49 | ||
| 50 | private void runSearch() { | |
| 51 |
1
1. runSearch : negated conditional → NO_COVERAGE |
if (this.listPaths.getSelectedValuesList().isEmpty()) { |
| 52 | LOGGER.log(LogLevelUtil.CONSOLE_ERROR, "Select at least one admin page in the list"); | |
| 53 | return; | |
| 54 | } | |
| 55 | | |
| 56 | String urlAddressBar = MediatorHelper.panelAddressBar().getTextFieldAddress().getText(); | |
| 57 |
2
1. runSearch : negated conditional → NO_COVERAGE 2. runSearch : negated conditional → NO_COVERAGE |
if (!urlAddressBar.isEmpty() && !urlAddressBar.matches("(?i)^https?://.*")) { |
| 58 |
1
1. runSearch : negated conditional → NO_COVERAGE |
if (!urlAddressBar.matches("(?i)^\\w+://.*")) { |
| 59 | LOGGER.log(LogLevelUtil.CONSOLE_INFORM, () -> I18nUtil.valueByKey("LOG_ADMIN_NO_PROTOCOL")); | |
| 60 | urlAddressBar = "http://"+ urlAddressBar; | |
| 61 | } else { | |
| 62 | LOGGER.log(LogLevelUtil.CONSOLE_INFORM, () -> I18nUtil.valueByKey("LOG_ADMIN_UNKNOWN_PROTOCOL")); | |
| 63 | return; | |
| 64 | } | |
| 65 | } | |
| 66 | | |
| 67 | String urlFinal = urlAddressBar; | |
| 68 |
2
1. lambda$runSearch$3 : removed call to com/jsql/view/swing/manager/ManagerAdminPage::searchAdminPages → NO_COVERAGE 2. runSearch : removed call to java/lang/Thread::start → NO_COVERAGE |
new Thread(() -> this.searchAdminPages(urlFinal), "ThreadAdminPage").start(); |
| 69 | } | |
| 70 | ||
| 71 | private void searchAdminPages(String urlAddressBar) { | |
| 72 |
1
1. searchAdminPages : negated conditional → NO_COVERAGE |
if (this.run.getState() == StateButton.STARTABLE) { |
| 73 |
1
1. searchAdminPages : negated conditional → NO_COVERAGE |
if (StringUtils.isEmpty(urlAddressBar)) { |
| 74 | LOGGER.log(LogLevelUtil.CONSOLE_ERROR, "Missing URL in address bar"); | |
| 75 | } else { | |
| 76 | LOGGER.log(LogLevelUtil.CONSOLE_DEFAULT, "{} admin pages...", () -> I18nUtil.valueByKey("LOG_CHECKING")); | |
| 77 |
1
1. searchAdminPages : removed call to com/jsql/view/swing/manager/util/JButtonStateful::setText → NO_COVERAGE |
this.run.setText(I18nViewUtil.valueByKey("ADMIN_PAGE_RUN_BUTTON_STOP")); |
| 78 |
1
1. searchAdminPages : removed call to com/jsql/view/swing/manager/util/JButtonStateful::setState → NO_COVERAGE |
this.run.setState(StateButton.STOPPABLE); |
| 79 |
1
1. searchAdminPages : removed call to javax/swing/JProgressBar::setVisible → NO_COVERAGE |
this.progressBar.setVisible(true); |
| 80 |
1
1. searchAdminPages : removed call to java/awt/Component::setVisible → NO_COVERAGE |
this.horizontalGlue.setVisible(false); |
| 81 | MediatorHelper.model().getResourceAccess().createAdminPages( | |
| 82 | urlAddressBar, | |
| 83 | this.listPaths.getSelectedValuesList().stream().map(ItemList::toString).collect(Collectors.toList()) | |
| 84 | ); | |
| 85 |
1
1. searchAdminPages : removed call to com/jsql/view/swing/manager/ManagerAdminPage::endProcess → NO_COVERAGE |
this.endProcess(); |
| 86 | } | |
| 87 |
1
1. searchAdminPages : negated conditional → NO_COVERAGE |
} else if (this.run.getState() == StateButton.STOPPABLE) { |
| 88 |
1
1. searchAdminPages : removed call to com/jsql/model/accessible/ResourceAccess::stopSearchAdmin → NO_COVERAGE |
MediatorHelper.model().getResourceAccess().stopSearchAdmin(); |
| 89 |
1
1. searchAdminPages : removed call to com/jsql/view/swing/manager/util/JButtonStateful::setEnabled → NO_COVERAGE |
this.run.setEnabled(false); |
| 90 |
1
1. searchAdminPages : removed call to com/jsql/view/swing/manager/util/JButtonStateful::setState → NO_COVERAGE |
this.run.setState(StateButton.STOPPING); |
| 91 | } | |
| 92 | } | |
| 93 | } | |
Mutations | ||
| 39 |
1.1 |
|
| 40 |
1.1 |
|
| 41 |
1.1 2.2 |
|
| 42 |
1.1 |
|
| 47 |
1.1 |
|
| 51 |
1.1 |
|
| 57 |
1.1 2.2 |
|
| 58 |
1.1 |
|
| 68 |
1.1 2.2 |
|
| 72 |
1.1 |
|
| 73 |
1.1 |
|
| 77 |
1.1 |
|
| 78 |
1.1 |
|
| 79 |
1.1 |
|
| 80 |
1.1 |
|
| 85 |
1.1 |
|
| 87 |
1.1 |
|
| 88 |
1.1 |
|
| 89 |
1.1 |
|
| 90 |
1.1 |