| 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.view.swing.action.ActionCloseTabResult; | |
| 14 | import com.jsql.view.swing.util.MediatorHelper; | |
| 15 | ||
| 16 | import javax.swing.*; | |
| 17 | import java.awt.*; | |
| 18 | import java.awt.event.MouseEvent; | |
| 19 | import java.awt.event.MouseListener; | |
| 20 | ||
| 21 | /** | |
| 22 | * Panel displayed as a header for tabs. | |
| 23 | * Compatible with i18n. | |
| 24 | */ | |
| 25 | public class TabHeader extends JPanel implements MouseListener { | |
| 26 | | |
| 27 | private final JLabel tabLabel = new JLabel(); | |
| 28 | ||
| 29 | public TabHeader(String label, Icon imageIcon) { | |
| 30 | super(new BorderLayout()); | |
| 31 |
1
1. <init> : removed call to com/jsql/view/swing/tab/TabHeader::setOpaque → NO_COVERAGE |
this.setOpaque(false); // required for transparency |
| 32 |
1
1. <init> : removed call to javax/swing/JLabel::setIcon → NO_COVERAGE |
this.tabLabel.setIcon(imageIcon); |
| 33 |
1
1. <init> : removed call to javax/swing/JLabel::setText → NO_COVERAGE |
this.tabLabel.setText(label); |
| 34 |
1
1. <init> : removed call to javax/swing/JLabel::setName → NO_COVERAGE |
this.tabLabel.setName(label.trim()); |
| 35 | this.add(this.tabLabel); | |
| 36 | } | |
| 37 | ||
| 38 | /** | |
| 39 | * Action for close button: remove tab. | |
| 40 | */ | |
| 41 | @Override | |
| 42 | public void mouseClicked(MouseEvent e) { | |
| 43 |
1
1. mouseClicked : negated conditional → NO_COVERAGE |
if (SwingUtilities.isRightMouseButton(e)) { |
| 44 | return; | |
| 45 | } | |
| 46 | int closeTabNumber = MediatorHelper.tabResults().indexOfTabComponent(this); | |
| 47 |
1
1. mouseClicked : removed call to com/jsql/view/swing/action/ActionCloseTabResult::perform → NO_COVERAGE |
ActionCloseTabResult.perform(closeTabNumber); |
| 48 | } | |
| 49 | ||
| 50 | @Override | |
| 51 | public void mouseEntered(MouseEvent e) { | |
| 52 | // Do nothing | |
| 53 | } | |
| 54 | | |
| 55 | @Override | |
| 56 | public void mouseExited(MouseEvent e) { | |
| 57 | // Do nothing | |
| 58 | } | |
| 59 | | |
| 60 | @Override | |
| 61 | public void mousePressed(MouseEvent e) { | |
| 62 | // Do nothing | |
| 63 | } | |
| 64 | | |
| 65 | @Override | |
| 66 | public void mouseReleased(MouseEvent e) { | |
| 67 | // Do nothing | |
| 68 | } | |
| 69 | ||
| 70 | public JLabel getTabLabel() { | |
| 71 |
1
1. getTabLabel : replaced return value with null for com/jsql/view/swing/tab/TabHeader::getTabLabel → NO_COVERAGE |
return this.tabLabel; |
| 72 | } | |
| 73 | } | |
Mutations | ||
| 31 |
1.1 |
|
| 32 |
1.1 |
|
| 33 |
1.1 |
|
| 34 |
1.1 |
|
| 43 |
1.1 |
|
| 47 |
1.1 |
|
| 71 |
1.1 |