Skip to content

Commit

Permalink
Expand the tree again after filering (#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
jshiell committed Aug 8, 2024
1 parent 6dd7fd2 commit 6be328b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,8 @@ private SeverityLevel[] getDisplayedSeverities() {
* Refresh the displayed results based on the current filter settings.
*/
public void filterDisplayedResults() {
// TODO be a little nicer here, maintain display state

treeModel.filter(getDisplayedSeverities());
expandTree();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,34 +84,25 @@ public void filter(final SeverityLevel... levels) {
}

private void filter(final boolean sendEvents, final SeverityLevel... levels) {
final Set<MutableTreeNode> changedNodes = new HashSet<>();

for (final ToggleableTreeNode fileNode : visibleRootNode.getAllChildren()) {
boolean childChanged = false;
for (final ToggleableTreeNode problemNode : fileNode.getAllChildren()) {
final ResultTreeNode result = (ResultTreeNode) problemNode.getUserObject();

final boolean resultShouldBeVisible = contains(levels, result.getSeverity());
if (problemNode.isVisible() != resultShouldBeVisible) {
problemNode.setVisible(resultShouldBeVisible);
childChanged = true;
}
}

((ResultTreeNode) fileNode.getUserObject()).setVisibleProblems(fileNode.getChildCount());
final boolean fileNodeShouldBeVisible = fileNode.getChildCount() > 0;
if (fileNode.isVisible() != fileNodeShouldBeVisible) {
fileNode.setVisible(fileNodeShouldBeVisible);
changedNodes.add(visibleRootNode);
} else if (childChanged) {
changedNodes.add(fileNode);
}
}

if (sendEvents) {
for (final MutableTreeNode node : changedNodes) {
nodeStructureChanged(node);
}
nodeStructureChanged(visibleRootNode);
}
}

Expand Down

0 comments on commit 6be328b

Please sign in to comment.