| 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.tab; | |
| 12 | ||
| 13 | import com.jsql.util.I18nUtil; | |
| 14 | import com.jsql.view.swing.text.JToolTipI18n; | |
| 15 | import com.jsql.view.swing.util.I18nViewUtil; | |
| 16 | import com.jsql.view.swing.util.MediatorHelper; | |
| 17 | import com.jsql.view.swing.util.ModelSvgIcon; | |
| 18 | import com.jsql.view.swing.util.UiUtil; | |
| 19 | ||
| 20 | import javax.swing.*; | |
| 21 | import java.awt.*; | |
| 22 | import java.awt.event.MouseAdapter; | |
| 23 | import java.awt.event.MouseEvent; | |
| 24 | import java.util.Arrays; | |
| 25 | import java.util.List; | |
| 26 | import java.util.concurrent.atomic.AtomicInteger; | |
| 27 | import java.util.concurrent.atomic.AtomicReference; | |
| 28 | ||
| 29 | /** | |
| 30 | * Panel on the left with functionalities like webshell, file reading and admin page finder. | |
| 31 | */ | |
| 32 | public class TabManagers extends TabbedPaneWheeled { | |
| 33 | ||
| 34 | private final transient List<ModelSvgIcon> iconsTabs = Arrays.asList( | |
| 35 | UiUtil.DATABASE_BOLD, UiUtil.ADMIN, UiUtil.DOWNLOAD, UiUtil.TERMINAL, UiUtil.LOCK, UiUtil.TEXTFIELD, UiUtil.BATCH | |
| 36 | ); | |
| 37 | ||
| 38 | /** | |
| 39 | * Create manager panel. | |
| 40 | */ | |
| 41 | public TabManagers() { | |
| 42 |
1
1. <init> : removed call to com/jsql/view/swing/tab/TabManagers::setName → NO_COVERAGE |
this.setName("tabManagers"); |
| 43 |
1
1. <init> : removed call to com/jsql/view/swing/tab/TabManagers::setMaximumSize → NO_COVERAGE |
this.setMaximumSize(new Dimension(this.getMaximumSize().width, 35)); |
| 44 |
1
1. <init> : removed call to com/jsql/view/swing/tab/TabManagers::setPreferredSize → NO_COVERAGE |
this.setPreferredSize(new Dimension(this.getPreferredSize().width, 35)); |
| 45 | ||
| 46 | AtomicInteger indexTab = new AtomicInteger(); | |
| 47 |
2
1. <init> : removed call to java/util/List::forEach → NO_COVERAGE 2. lambda$new$0 : removed call to com/jsql/view/swing/tab/TabManagers::buildI18nTab → NO_COVERAGE |
this.iconsTabs.forEach(modelSvgIcon -> this.buildI18nTab(modelSvgIcon, indexTab.getAndIncrement())); |
| 48 |
1
1. <init> : removed call to com/jsql/view/swing/tab/TabManagers::addChangeListener → NO_COVERAGE |
this.addChangeListener(e -> { |
| 49 | CardLayout cardLayout = (CardLayout) MediatorHelper.tabManagersCards().getLayout(); | |
| 50 |
1
1. lambda$new$1 : removed call to java/awt/CardLayout::show → NO_COVERAGE |
cardLayout.show(MediatorHelper.tabManagersCards(), this.getTabComponentAt(this.getSelectedIndex()).getName()); |
| 51 | }); | |
| 52 | } | |
| 53 | | |
| 54 | private void buildI18nTab(ModelSvgIcon modelSvgIcon, int index) { | |
| 55 | Icon icon = modelSvgIcon.getIcon(); | |
| 56 | String keyLabel = modelSvgIcon.getKeyLabel(); | |
| 57 | String keyTooltip = modelSvgIcon.getKeyTooltip(); | |
| 58 | AtomicReference<JToolTipI18n> tooltipAtomic = new AtomicReference<>(new JToolTipI18n(I18nUtil.valueByKey(keyTooltip))); | |
| 59 | JLabel labelTab = new JLabel(I18nUtil.valueByKey(keyLabel), icon, SwingConstants.CENTER) { | |
| 60 | @Override | |
| 61 | public JToolTip createToolTip() { | |
| 62 |
1
1. createToolTip : removed call to java/util/concurrent/atomic/AtomicReference::set → NO_COVERAGE |
tooltipAtomic.set(new JToolTipI18n(I18nUtil.valueByKey(keyTooltip))); |
| 63 |
1
1. createToolTip : replaced return value with null for com/jsql/view/swing/tab/TabManagers$1::createToolTip → NO_COVERAGE |
return tooltipAtomic.get(); |
| 64 | } | |
| 65 | }; | |
| 66 | | |
| 67 |
1
1. buildI18nTab : removed call to javax/swing/JLabel::setName → NO_COVERAGE |
labelTab.setName(keyLabel); |
| 68 |
1
1. buildI18nTab : removed call to javax/swing/JLabel::addMouseListener → NO_COVERAGE |
labelTab.addMouseListener(new MouseAdapter() { |
| 69 | @Override | |
| 70 | public void mousePressed(MouseEvent e) { | |
| 71 | CardLayout cardLayout = (CardLayout) MediatorHelper.tabManagersCards().getLayout(); | |
| 72 |
1
1. mousePressed : removed call to java/awt/CardLayout::show → NO_COVERAGE |
cardLayout.show(MediatorHelper.tabManagersCards(), TabManagers.this.getTabComponentAt(index).getName()); |
| 73 |
1
1. mousePressed : removed call to com/jsql/view/swing/tab/TabManagers::setSelectedIndex → NO_COVERAGE |
TabManagers.this.setSelectedIndex(index); |
| 74 | } | |
| 75 | }); | |
| 76 | ||
| 77 |
1
1. buildI18nTab : removed call to com/jsql/view/swing/tab/TabManagers::addTab → NO_COVERAGE |
this.addTab(I18nUtil.valueByKey(keyLabel), icon, null); // Required for i18n to work |
| 78 |
1
1. buildI18nTab : removed call to com/jsql/view/swing/tab/TabManagers::setTabComponentAt → NO_COVERAGE |
this.setTabComponentAt( // TODO Break focus, should not be used |
| 79 | this.indexOfTab(I18nUtil.valueByKey(keyLabel)), | |
| 80 | labelTab | |
| 81 | ); | |
| 82 | ||
| 83 |
1
1. buildI18nTab : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey(keyLabel, labelTab); |
| 84 |
1
1. buildI18nTab : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE |
I18nViewUtil.addComponentForKey(keyTooltip, tooltipAtomic.get()); |
| 85 | | |
| 86 |
1
1. buildI18nTab : removed call to javax/swing/JLabel::setToolTipText → NO_COVERAGE |
labelTab.setToolTipText(I18nUtil.valueByKey(keyTooltip)); |
| 87 | } | |
| 88 | ||
| 89 | public List<ModelSvgIcon> getIconsTabs() { | |
| 90 |
1
1. getIconsTabs : replaced return value with Collections.emptyList for com/jsql/view/swing/tab/TabManagers::getIconsTabs → NO_COVERAGE |
return this.iconsTabs; |
| 91 | } | |
| 92 | } | |
Mutations | ||
| 42 |
1.1 |
|
| 43 |
1.1 |
|
| 44 |
1.1 |
|
| 47 |
1.1 2.2 |
|
| 48 |
1.1 |
|
| 50 |
1.1 |
|
| 62 |
1.1 |
|
| 63 |
1.1 |
|
| 67 |
1.1 |
|
| 68 |
1.1 |
|
| 72 |
1.1 |
|
| 73 |
1.1 |
|
| 77 |
1.1 |
|
| 78 |
1.1 |
|
| 83 |
1.1 |
|
| 84 |
1.1 |
|
| 86 |
1.1 |
|
| 90 |
1.1 |