[git] IJPL-160069 Reuse "Show tags" action in git log

GitOrigin-RevId: 453b21a663f6354949d37a38aeb0b8cd1d6ba667
This commit is contained in:
Ilia.Shulgin
2024-09-13 12:43:06 +02:00
committed by intellij-monorepo-bot
parent c48e5cef29
commit e3064e3924
8 changed files with 58 additions and 32 deletions

View File

@@ -120,6 +120,7 @@ a:com.intellij.dvcs.branch.DvcsBranchManager
com.intellij.dvcs.branch.DvcsBranchManager$DvcsBranchManagerListener
- branchFavoriteSettingsChanged():V
- branchGroupingSettingsChanged(com.intellij.dvcs.branch.GroupingKey,Z):V
- showTagsSettingsChanged():V
a:com.intellij.dvcs.branch.DvcsBranchPopup
- pf:myCurrentRepository:com.intellij.dvcs.repo.Repository
- pf:myInSpecificRepository:Z

View File

@@ -168,5 +168,7 @@ public abstract class DvcsBranchManager<T extends Repository> {
default void branchFavoriteSettingsChanged() { }
default void branchGroupingSettingsChanged(@NotNull GroupingKey key, boolean state) { }
default void showTagsSettingsChanged() { }
}
}

View File

@@ -51,6 +51,8 @@
class="git4idea.ui.branch.dashboard.BranchesDashboardActions$ChangeBranchFilterAction"/>
<action id="Git.Log.Branches.Navigate.Log.To.Branch.On.Selection"
class="git4idea.ui.branch.dashboard.BranchesDashboardActions$NavigateLogToBranchAction"/>
<separator/>
<action id="git.branches.show.tags" class="git4idea.ui.branch.tree.GitBranchesTreeShowTagsAction"/>
</group>
<group id="Git.Log.Branches.Grouping.Settings" icon="AllIcons.Actions.GroupBy"
class="git4idea.ui.branch.dashboard.BranchesDashboardActions$GroupingSettingsGroup">
@@ -189,7 +191,7 @@
<action id="git.branches.group.by.prefix" class="git4idea.ui.branch.popup.GitBranchesTreePopupGroupByPrefixAction"/>
<action class="git4idea.ui.branch.popup.GitBranchesTreePopupTrackReposSynchronouslyAction"/>
<action id="git.branches.show.recent" class="git4idea.ui.branch.popup.GitBranchesTreePopupShowRecentBranchesAction"/>
<action id="git.branches.show.tags" class="git4idea.ui.branch.popup.GitBranchesTreePopupShowTagsAction"/>
<reference ref="git.branches.show.tags"/>
<action id="git.branches.popup.resize" class="git4idea.ui.branch.popup.GitBranchesTreePopupResizeAction"/>
</group>

View File

@@ -13,10 +13,10 @@ import git4idea.i18n.GitBundle
import git4idea.repo.GitRepository
import git4idea.ui.branch.popup.GitBranchesTreePopupBase
import git4idea.ui.branch.popup.GitBranchesTreePopupMinimalRenderer
import git4idea.ui.branch.popup.GitBranchesTreePopupShowTagsAction
import git4idea.ui.branch.popup.GitBranchesTreePopupStepBase
import git4idea.ui.branch.tree.GitBranchesTreeModel
import git4idea.ui.branch.tree.GitBranchesTreeRenderer
import git4idea.ui.branch.tree.GitBranchesTreeShowTagsAction
import git4idea.ui.branch.tree.GitBranchesTreeSingleRepoModel
import git4idea.ui.branch.tree.createTreePathFor
import java.util.function.Consumer
@@ -85,7 +85,7 @@ class GitCompareWithBranchPopup(
override fun getSearchFiledEmptyText(): String = GitBundle.message(
"git.compare.with.branch.search.field.empty.text",
if (GitBranchesTreePopupShowTagsAction.isSelected(project)) 1 else 0
if (GitBranchesTreeShowTagsAction.isSelected(project)) 1 else 0
)
override fun getTreeEmptyText(searchPattern: String?): String = GitBundle.message("git.compare.with.branch.search.not.found", searchPattern)

View File

@@ -66,6 +66,10 @@ internal class BranchesDashboardController(
override fun branchGroupingSettingsChanged(key: GroupingKey, state: Boolean) {
toggleGrouping(key, state)
}
override fun showTagsSettingsChanged() {
ui.updateBranchesTree(false)
}
})
project.messageBus.connect(this)
.subscribe(GitBranchIncomingOutgoingManager.GIT_INCOMING_OUTGOING_CHANGED, GitIncomingOutgoingListener {

View File

@@ -309,6 +309,10 @@ abstract class GitBranchesTreePopupBase<T : GitBranchesTreePopupStepBase>(
tree.repaint()
}
}
override fun showTagsSettingsChanged() {
refresh()
}
})
}

View File

@@ -106,35 +106,6 @@ internal class GitBranchesTreePopupShowRecentBranchesAction :
}
}
internal class GitBranchesTreePopupShowTagsAction :
ToggleAction(GitBundle.messagePointer("git.branches.popup.show.tags.name")), DumbAware {
override fun update(e: AnActionEvent) {
super.update(e)
e.presentation.isEnabledAndVisible = e.project != null
&& e.getData(GitBranchesTreePopupBase.POPUP_KEY) != null
}
override fun getActionUpdateThread() = ActionUpdateThread.EDT
override fun isSelected(e: AnActionEvent): Boolean =
e.project?.let(GitVcsSettings::getInstance)?.showTags() ?: true
override fun setSelected(e: AnActionEvent, state: Boolean) {
val project = e.project ?: return
GitVcsSettings.getInstance(project).setShowTags(state)
for (repository in GitRepositoryManager.getInstance(project).repositories) {
repository.tagHolder.updateEnabled()
}
e.getRequiredData(GitBranchesTreePopupBase.POPUP_KEY).refresh()
}
companion object {
fun isSelected(project: Project?): Boolean =
project != null && project.let(GitVcsSettings::getInstance).showTags()
}
}
internal class GitBranchesTreePopupFilterSeparatorWithText : DefaultActionGroup(), DumbAware {

View File

@@ -0,0 +1,42 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package git4idea.ui.branch.tree
import com.intellij.dvcs.branch.DvcsBranchManager
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.ToggleAction
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.project.Project
import git4idea.config.GitVcsSettings
import git4idea.i18n.GitBundle
import git4idea.repo.GitRepositoryManager
internal class GitBranchesTreeShowTagsAction :
ToggleAction(GitBundle.messagePointer("git.branches.popup.show.tags.name")), DumbAware {
override fun update(e: AnActionEvent) {
super.update(e)
e.presentation.isEnabledAndVisible = e.project != null
}
override fun getActionUpdateThread() = ActionUpdateThread.EDT
override fun isSelected(e: AnActionEvent): Boolean =
e.project?.let(GitVcsSettings::getInstance)?.showTags() ?: true
override fun setSelected(e: AnActionEvent, state: Boolean) {
val project = e.project ?: return
GitVcsSettings.getInstance(project).setShowTags(state)
for (repository in GitRepositoryManager.getInstance(project).repositories) {
repository.tagHolder.updateEnabled()
}
project.getMessageBus().syncPublisher(DvcsBranchManager.DVCS_BRANCH_SETTINGS_CHANGED).showTagsSettingsChanged()
}
companion object {
fun isSelected(project: Project?): Boolean =
project != null && project.let(GitVcsSettings::getInstance).showTags()
}
}