Skip to content

Commit

Permalink
added popup menu entries for collapse operations
Browse files Browse the repository at this point in the history
 - closes #1
 - thanks to @Davincible for the suggestion
  • Loading branch information
dnet committed Jul 18, 2021
1 parent 321eb2c commit b9b7690
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/burp/JsonJTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<DefaultMutableTreeNode> 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();
}
Expand Down

0 comments on commit b9b7690

Please sign in to comment.