Skip to content

Commit

Permalink
added a filter for multi-module
Browse files Browse the repository at this point in the history
  • Loading branch information
eyalk007 committed Sep 19, 2024
1 parent b37a752 commit 79cd857
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/main/java/com/jfrog/ide/idea/ui/LocalComponentsTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.io.IOException;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

/**
* @author yahavi
Expand Down Expand Up @@ -113,12 +114,12 @@ private void handleContextMenu(ComponentsTree tree, MouseEvent e) {
if (selectedPath == null) {
return;
}

Object selected = selectedPath.getLastPathComponent();

if (selected instanceof DependencyNode) {

this.createNodePopupMenu((DependencyNode) selected);
DescriptorFileTreeNode descriptorFileTreeNode = (DescriptorFileTreeNode) selectedPath.getParentPath().getLastPathComponent();
String descriptorPath = descriptorFileTreeNode.getSubtitle();
this.createNodePopupMenu((DependencyNode) selected, descriptorPath);
} else if (selected instanceof VulnerabilityNode) {
createIgnoreRuleOption((VulnerabilityNode) selected, e);
} else if (selected instanceof ApplicableIssueNode) {
Expand All @@ -138,11 +139,20 @@ private void createIgnoreRuleOption(VulnerabilityNode selectedIssue, MouseEvent
toolTip.setEnabled(true);
}

private void createNodePopupMenu(DependencyNode selectedNode) {
private void createNodePopupMenu(DependencyNode selectedNode, String descriptorPath) {
popupMenu.removeAll();
NavigationService navigationService = NavigationService.getInstance(project);
Set<NavigationTarget> navigationCandidates = navigationService.getNavigation(selectedNode);
addNodeNavigation(navigationCandidates);
//filtering candidates in case of multi module project
Set<NavigationTarget> filteredCandidates = navigationCandidates.stream()
.filter(navigationTarget ->
descriptorPath.equals(navigationTarget.getElement()
.getContainingFile()
.getVirtualFile()
.getPath()))
.collect(Collectors.toSet());

addNodeNavigation(filteredCandidates);
}

private void addNodeNavigation(Set<NavigationTarget> navigationCandidates) {
Expand Down

0 comments on commit 79cd857

Please sign in to comment.