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.tree.model; | |
12 | ||
13 | import com.jsql.model.bean.database.Column; | |
14 | import com.jsql.view.swing.util.UiUtil; | |
15 | ||
16 | import javax.swing.*; | |
17 | import javax.swing.tree.DefaultMutableTreeNode; | |
18 | import javax.swing.tree.TreePath; | |
19 | import java.awt.*; | |
20 | import java.awt.event.MouseEvent; | |
21 | ||
22 | /** | |
23 | * Model for default item used on an empty tree. | |
24 | */ | |
25 | public class NodeModelEmpty extends AbstractNodeModel { | |
26 | | |
27 | /** | |
28 | * Flat node for empty tree. | |
29 | * @param textNode | |
30 | */ | |
31 | public NodeModelEmpty(String textNode) { | |
32 | super(textNode); | |
33 | } | |
34 | ||
35 | public NodeModelEmpty(Column column) { | |
36 | super(column); | |
37 | } | |
38 | ||
39 | @Override | |
40 | public Component getComponent( | |
41 | final JTree tree, Object nodeRenderer, final boolean isSelected, boolean isLeaf, boolean hasFocus | |
42 | ) { | |
43 | DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) nodeRenderer; | |
44 | var panelEmpty = new JPanel(new BorderLayout()); | |
45 | var labelEmpty = new JLabel(currentNode.getUserObject().toString()); | |
46 | panelEmpty.add(labelEmpty); | |
47 |
1
1. getComponent : removed call to javax/swing/JLabel::setBorder → NO_COVERAGE |
labelEmpty.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); |
48 | | |
49 |
1
1. getComponent : negated conditional → NO_COVERAGE |
if (isSelected) { |
50 | | |
51 |
1
1. getComponent : removed call to javax/swing/JPanel::setBackground → NO_COVERAGE |
panelEmpty.setBackground(UiUtil.COLOR_FOCUS_GAINED); |
52 |
1
1. getComponent : removed call to javax/swing/JLabel::setBorder → NO_COVERAGE |
labelEmpty.setBorder(UiUtil.BORDER_FOCUS_GAINED); |
53 | | |
54 | } else { | |
55 | | |
56 |
1
1. getComponent : removed call to javax/swing/JPanel::setBackground → NO_COVERAGE |
panelEmpty.setBackground(Color.WHITE); |
57 |
1
1. getComponent : removed call to javax/swing/JLabel::setBorder → NO_COVERAGE |
labelEmpty.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); |
58 | } | |
59 | ||
60 |
1
1. getComponent : replaced return value with null for com/jsql/view/swing/tree/model/NodeModelEmpty::getComponent → NO_COVERAGE |
return panelEmpty; |
61 | } | |
62 | ||
63 | @Override | |
64 | protected Icon getLeafIcon(boolean leaf) { | |
65 | // No icon for default node | |
66 | return null; | |
67 | } | |
68 | | |
69 | @Override | |
70 | public void runAction() { | |
71 | // Not used | |
72 | } | |
73 | | |
74 | @Override | |
75 | protected void buildMenu(JPopupMenuCustomExtract tablePopupMenu, TreePath path) { | |
76 | // Not used | |
77 | } | |
78 | | |
79 | @Override | |
80 | public void showPopup(final DefaultMutableTreeNode currentTableNode, TreePath path, MouseEvent e) { | |
81 | // Not used | |
82 | } | |
83 | | |
84 | @Override | |
85 | public boolean isPopupDisplayable() { | |
86 |
1
1. isPopupDisplayable : replaced boolean return with true for com/jsql/view/swing/tree/model/NodeModelEmpty::isPopupDisplayable → NO_COVERAGE |
return false; |
87 | } | |
88 | } | |
Mutations | ||
47 |
1.1 |
|
49 |
1.1 |
|
51 |
1.1 |
|
52 |
1.1 |
|
56 |
1.1 |
|
57 |
1.1 |
|
60 |
1.1 |
|
86 |
1.1 |