From bd7a6b4a5b72f4db8e106e0b83a08cab48e7e92a Mon Sep 17 00:00:00 2001 From: Dmitry Zhuravlev Date: Wed, 25 Dec 2019 21:51:40 +0300 Subject: [PATCH] git-branches-dashboard: branch actions invoked via shortcuts should work even if the filtering field explicitly focused GitOrigin-RevId: 8e027404ac7fdc1376af680eaf2cd3827001ad78 --- .../ui/branch/dashboard/BranchesDashboardUi.kt | 14 ++++++++++++-- .../git4idea/ui/branch/dashboard/BranchesTree.kt | 10 +--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/plugins/git4idea/src/git4idea/ui/branch/dashboard/BranchesDashboardUi.kt b/plugins/git4idea/src/git4idea/ui/branch/dashboard/BranchesDashboardUi.kt index 6fbbca07faf3..baa78398998f 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/dashboard/BranchesDashboardUi.kt +++ b/plugins/git4idea/src/git4idea/ui/branch/dashboard/BranchesDashboardUi.kt @@ -21,6 +21,7 @@ import com.intellij.util.ui.JBUI import com.intellij.util.ui.JBUI.Panels.simplePanel import com.intellij.util.ui.StatusText.DEFAULT_EMPTY_TEXT import com.intellij.util.ui.UIUtil +import com.intellij.util.ui.components.BorderLayoutPanel import com.intellij.vcs.log.VcsLogFilterCollection import com.intellij.vcs.log.data.VcsLogData import com.intellij.vcs.log.impl.MainVcsLogUiProperties @@ -55,7 +56,7 @@ internal class BranchesDashboardUi(val project: Project) : Disposable { private val tree = FilteringBranchesTree(project, BranchesTreeComponent(project), uiController) private val branchViewSplitter = BranchViewSplitter() - private val branchesTreePanel = simplePanel().withBorder(createBorder(JBColor.border(), SideBorder.LEFT)) + private val branchesTreePanel = BranchesTreePanel().withBorder(createBorder(JBColor.border(), SideBorder.LEFT)) private val branchesScrollPane = ScrollPaneFactory.createScrollPane(tree.component, true) private val branchesProgressStripe = ProgressStripe(branchesScrollPane, this, ProgressWindow.DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS) private val branchesTreeWithLogPanel = simplePanel(branchesTreePanel) @@ -148,7 +149,7 @@ internal class BranchesDashboardUi(val project: Project) : Disposable { group.add(collapseAllAction) val toolbar = ActionManager.getInstance().createActionToolbar("Git.Cleanup.Branches", group, false) - toolbar.setTargetComponent(tree.component) + toolbar.setTargetComponent(branchesTreePanel) branchesTreeWithLogPanel.addToLeft(toolbar.component) branchesSearchFieldPanel.withBackground(UIUtil.getListBackground()).withBorder(createBorder(JBColor.border(), SideBorder.BOTTOM)) @@ -180,6 +181,15 @@ internal class BranchesDashboardUi(val project: Project) : Disposable { }.registerCustomShortcutSet(KeymapUtil.getActiveKeymapShortcuts("Find"), branchesTreePanel) } + inner class BranchesTreePanel : BorderLayoutPanel(), DataProvider { + override fun getData(dataId: String): Any? { + if (GIT_BRANCHES.`is`(dataId)) { + return tree.getSelectedBranches() + } + return null + } + } + fun getMainComponent(): JComponent { return mainPanel } diff --git a/plugins/git4idea/src/git4idea/ui/branch/dashboard/BranchesTree.kt b/plugins/git4idea/src/git4idea/ui/branch/dashboard/BranchesTree.kt index d545a8eba12f..cdfcbeaaa117 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/dashboard/BranchesTree.kt +++ b/plugins/git4idea/src/git4idea/ui/branch/dashboard/BranchesTree.kt @@ -6,7 +6,6 @@ import com.intellij.icons.AllIcons import com.intellij.ide.dnd.TransferableList import com.intellij.ide.dnd.aware.DnDAwareTree import com.intellij.openapi.actionSystem.ActionManager -import com.intellij.openapi.actionSystem.DataProvider import com.intellij.openapi.application.runInEdt import com.intellij.openapi.project.Project import com.intellij.ui.* @@ -29,7 +28,7 @@ import javax.swing.event.TreeExpansionEvent import javax.swing.event.TreeExpansionListener import javax.swing.tree.TreePath -internal class BranchesTreeComponent(project: Project) : DnDAwareTree(), DataProvider { +internal class BranchesTreeComponent(project: Project) : DnDAwareTree() { var doubleClickHandler: (BranchTreeNode) -> Unit = {} var searchField: SearchTextField? = null @@ -109,13 +108,6 @@ internal class BranchesTreeComponent(project: Project) : DnDAwareTree(), DataPro } } - override fun getData(dataId: String): Any? { - if (GIT_BRANCHES.`is`(dataId)) { - return getSelectedBranches() - } - return null - } - fun getSelectedBranches(): Set { val paths = selectionPaths ?: return emptySet() return paths.asSequence()