diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewPanel.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewPanel.kt index e90e93d3a126..74f2b7be5996 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewPanel.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewPanel.kt @@ -9,6 +9,7 @@ import com.intellij.openapi.actionSystem.DefaultActionGroup import com.intellij.openapi.actionSystem.toolbarLayout.ToolbarLayoutStrategy import com.intellij.openapi.vcs.VcsBundle import com.intellij.openapi.vcs.changes.ui.ChangesListView +import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManagerListener import com.intellij.openapi.vcs.merge.ChangesViewConflictsBanner import com.intellij.openapi.vcs.merge.MergeConflictManager import com.intellij.ui.ScrollPaneFactory.createScrollPane @@ -87,6 +88,9 @@ class ChangesViewPanel(val changesView: ChangesListView, parentDisposable: Dispo else { conflictsBanner.close() } + ChangeListManager.getInstance(project).invokeAfterUpdate(true) { + project.getMessageBus().syncPublisher(ChangesViewContentManagerListener.TOPIC).toolWindowMappingChanged() + } } } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/vcsToolWindowFactories.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/vcsToolWindowFactories.kt index 1c9f7154c70c..ebe438213f16 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/vcsToolWindowFactories.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/vcsToolWindowFactories.kt @@ -1,6 +1,7 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.openapi.vcs.changes.ui +import com.intellij.icons.AllIcons import com.intellij.ide.IdeBundle import com.intellij.ide.actions.ToolWindowEmptyStateAction.rebuildContentUi import com.intellij.ide.trustedProjects.TrustedProjects @@ -9,10 +10,15 @@ import com.intellij.openapi.actionSystem.ActionManager import com.intellij.openapi.project.Project import com.intellij.openapi.util.registry.Registry import com.intellij.openapi.vcs.ProjectLevelVcsManager +import com.intellij.openapi.vcs.merge.MergeConflictManager import com.intellij.openapi.wm.ToolWindow import com.intellij.openapi.wm.ex.ToolWindowEx +import com.intellij.ui.IconManager +import com.intellij.ui.JBColor +import com.intellij.util.ui.JBUI import com.intellij.util.ui.StatusText import java.util.function.Supplier +import javax.swing.UIManager private class ChangeViewToolWindowFactory : VcsToolWindowFactory() { private val shouldShowWithoutActiveVcs = Registry.get("vcs.empty.toolwindow.show") @@ -85,4 +91,23 @@ private class CommitToolWindowFactory : VcsToolWindowFactory() { rebuildContentUi(toolWindow) } } + + override fun updateState(toolWindow: ToolWindow) { + super.updateState(toolWindow) + + val project = toolWindow.project + when { + !toolWindow.isAvailable || !MergeConflictManager.isNonModalMergeEnabled(project) -> return + !MergeConflictManager.getInstance(project).isMergeConflict() -> toolWindow.setIcon(AllIcons.Toolwindows.ToolWindowCommit) + else -> { + val focusColor = UIManager.getColor("ToolWindow.Button.selectedForeground") + val originalIcon = toolWindow.icon + if (originalIcon != null) { + val badgeColor = JBColor { if (toolWindow.isActive) focusColor else JBUI.CurrentTheme.IconBadge.ERROR } + val badgeIcon = IconManager.getInstance().withIconBadge(originalIcon, badgeColor) + toolWindow.setIcon(badgeIcon) + } + } + } + } }