Skip to content

Commit

Permalink
SLI-1728 Toolwindow icon should not be red when every files are closed
Browse files Browse the repository at this point in the history
  • Loading branch information
nquinquenel committed Dec 6, 2024
1 parent 6b57a68 commit b463c35
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class OnTheFlyFindingsHolder(private val project: Project) : FileEditorManagerLi
currentSecurityHotspotsPerOpenFile.remove(file)
// update only Security Hotspots, issues will be updated in reaction to selectionChanged
updateSecurityHotspots()
if (currentIssuesPerOpenFile.isEmpty()) {
updateCurrentFileTab()
}
}

private fun updateSecurityHotspots() {
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/sonarlint/intellij/ui/CurrentFilePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import javax.swing.JScrollPane;
Expand Down Expand Up @@ -209,13 +210,14 @@ public <T extends Finding> void trySelectFilteredIssue(@Nullable LiveIssue issue
private void updateIcon(@Nullable VirtualFile file, Collection<LiveIssue> issues) {
var toolWindow = ToolWindowManager.getInstance(project).getToolWindow(SONARLINT_TOOLWINDOW_ID);
if (toolWindow != null) {
doUpdateIcon(file, issues, toolWindow);
var isEmpty = issues.stream().filter(i -> !i.isResolved()).collect(Collectors.toSet()).isEmpty();
doUpdateIcon(file, isEmpty, toolWindow);
}
}

private static void doUpdateIcon(@Nullable VirtualFile file, Collection<LiveIssue> issues, ToolWindow toolWindow) {
private static void doUpdateIcon(@Nullable VirtualFile file, boolean isEmpty, ToolWindow toolWindow) {
ApplicationManager.getApplication().assertIsDispatchThread();
boolean empty = file == null || issues.isEmpty();
boolean empty = file == null || isEmpty;
toolWindow.setIcon(empty ? SonarLintIcons.SONARQUBE_FOR_INTELLIJ_EMPTY_TOOLWINDOW : SonarLintIcons.SONARQUBE_FOR_INTELLIJ_TOOLWINDOW);
}

Expand Down

0 comments on commit b463c35

Please sign in to comment.