|
1 | 1 | package gui;
|
2 | 2 |
|
3 |
| -import burp.BurpExtender; |
4 |
| -import javax.swing.tree.TreeSelectionModel; |
5 |
| -import model.BurpCertificateBuilder; |
6 | 3 | import application.CertificateTabController;
|
7 | 4 | import model.BurpCertificate;
|
| 5 | +import model.BurpCertificateBuilder; |
8 | 6 | import model.ObjectIdentifier;
|
9 | 7 | import net.miginfocom.swing.MigLayout;
|
10 | 8 |
|
11 | 9 | import javax.swing.*;
|
12 |
| -import javax.swing.event.TreeSelectionEvent; |
13 |
| -import javax.swing.event.TreeSelectionListener; |
14 | 10 | import javax.swing.tree.DefaultMutableTreeNode;
|
15 | 11 | import javax.swing.tree.DefaultTreeModel;
|
| 12 | +import javax.swing.tree.TreeSelectionModel; |
16 | 13 | import java.awt.*;
|
17 | 14 | import java.awt.event.ActionEvent;
|
18 | 15 | import java.awt.event.ActionListener;
|
@@ -150,16 +147,34 @@ public void actionPerformed(ActionEvent e) {
|
150 | 147 | certificateTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode("root"));
|
151 | 148 | certificateTree = new JTree(certificateTreeModel);
|
152 | 149 | certificateTree.setRootVisible(false);
|
| 150 | + certificateTree.setShowsRootHandles(true); |
| 151 | + certificateTree.setCellRenderer((tree, value, selected, expanded, leaf, row, hasFocus) -> { |
| 152 | + var label = new JLabel(); |
| 153 | + label.setText(value.toString()); |
| 154 | + if (leaf) { |
| 155 | + label.setIcon(UIManager.getIcon("Tree.leafIcon")); |
| 156 | + } else if (expanded) { |
| 157 | + label.setIcon(UIManager.getIcon("Tree.openIcon")); |
| 158 | + } else { |
| 159 | + label.setIcon(UIManager.getIcon("Tree.closedIcon")); |
| 160 | + } |
| 161 | + if (selected) { |
| 162 | + label.setForeground(UIManager.getColor("Tree.selectionForeground")); |
| 163 | + label.setBackground(UIManager.getColor("Tree.selectionBackground")); |
| 164 | + } else { |
| 165 | + label.setForeground(UIManager.getColor("Tree.textForeground")); |
| 166 | + label.setBackground(UIManager.getColor("Tree.textBackground")); |
| 167 | + } |
| 168 | + return label; |
| 169 | + }); |
153 | 170 | certificateTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
|
154 |
| - certificateTree.addTreeSelectionListener(new TreeSelectionListener() { |
155 |
| - public void valueChanged(TreeSelectionEvent e) { |
156 |
| - DefaultMutableTreeNode node = (DefaultMutableTreeNode) certificateTree.getLastSelectedPathComponent(); |
157 |
| - if (node == null || node.getUserObject() instanceof String) { |
158 |
| - return; |
159 |
| - } |
160 |
| - BurpCertificate burpCertificate = (BurpCertificate) node.getUserObject(); |
161 |
| - certificateTabController.setCertificateDetails(burpCertificate); |
| 171 | + certificateTree.addTreeSelectionListener(event -> { |
| 172 | + DefaultMutableTreeNode node = (DefaultMutableTreeNode) certificateTree.getLastSelectedPathComponent(); |
| 173 | + if (node == null || node.getUserObject() instanceof String) { |
| 174 | + return; |
162 | 175 | }
|
| 176 | + BurpCertificate burpCertificate = (BurpCertificate) node.getUserObject(); |
| 177 | + certificateTabController.setCertificateDetails(burpCertificate); |
163 | 178 | });
|
164 | 179 |
|
165 | 180 | txtStatus = new JTextPane();
|
@@ -500,19 +515,6 @@ public void actionPerformed(ActionEvent e) {
|
500 | 515 | this.setLayout(new MigLayout());
|
501 | 516 | this.add(topPanel, "wrap");
|
502 | 517 | this.add(scrollableBottomPanel, "width 100%");
|
503 |
| - |
504 |
| - // In the default look and feel the JTree component does not render correctly. |
505 |
| - // Icons are missing and tree notes are not correctly indented. |
506 |
| - // This workaround should changes the look and feel of the JTree only. |
507 |
| - // https://forum.portswigger.net/thread/jtree-not-rendering-correctly-with-burpsuite-s-look-and-feel-2a164857?CategoryId=bug-reports |
508 |
| - try { |
509 |
| - var lookAndFeel = UIManager.getLookAndFeel(); |
510 |
| - UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); |
511 |
| - SwingUtilities.updateComponentTreeUI(certificateTree); |
512 |
| - UIManager.setLookAndFeel(lookAndFeel); |
513 |
| - } catch (Exception exc) { |
514 |
| - BurpExtender.api.logging().logToError(exc); |
515 |
| - } |
516 | 518 | }
|
517 | 519 |
|
518 | 520 | public void setCertificateTabController(CertificateTabController certificateTabController) {
|
@@ -763,7 +765,6 @@ public boolean isAutoSubjectKeyIdentifier() {
|
763 | 765 |
|
764 | 766 | public void setCertificateRootNode(DefaultMutableTreeNode rootNode) {
|
765 | 767 | this.certificateTreeModel.setRoot(rootNode);
|
766 |
| - certificateTree.setModel(certificateTreeModel); |
767 | 768 | }
|
768 | 769 |
|
769 | 770 | public void setAllExtensions(List<String> allExtensions) {
|
|
0 commit comments