From b9b769022a59b2eafc0585c215edc7ad0863bf86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Sun, 18 Jul 2021 18:19:04 +0200 Subject: [PATCH] added popup menu entries for collapse operations - closes #1 - thanks to @Davincible for the suggestion --- src/burp/JsonJTree.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/burp/JsonJTree.java b/src/burp/JsonJTree.java index 587c617..ddca325 100644 --- a/src/burp/JsonJTree.java +++ b/src/burp/JsonJTree.java @@ -93,10 +93,32 @@ public void actionPerformed(ActionEvent e) { } }); + popup.addSeparator(); + + addToPopup(popup, "Collapse full tree", new ActionListener() { + public void actionPerformed(ActionEvent e) { + collapseChildren(root); + } + }); + + if (node != root) { + addToPopup(popup, "Collapse subtree below this node", new ActionListener() { + public void actionPerformed(ActionEvent e) { + collapseChildren(node); + } + }); + } popup.show(e.getComponent(), e.getX(), e.getY()); } + private void collapseChildren(DefaultMutableTreeNode node) { + final ArrayList list = Collections.list(node.children()); + for (DefaultMutableTreeNode child : list) collapseChildren(child); + if (node.isRoot()) return; + tree.collapsePath(new TreePath(node.getPath())); + } + private static boolean mayBeJwt(final String value) { return JWT_RE.matcher(value).matches(); }