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(); }