mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
git-branches-dashboard: extract "checkout selected branch" action from branches tree double-click handler
This will add ability to assign custom shortcut to this action or remove shortcut and completely disable such behavior if needed. GitOrigin-RevId: b493e7eae23eda5fad8c6f8e52c04d692b4e2771
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c01b1e59cb
commit
290dc663e2
@@ -45,6 +45,9 @@
|
||||
<action id="Git.Uncommit" class="git4idea.reset.GitUncommitAction"/>
|
||||
<action id="Git.Reword.Commit" class="git4idea.rebase.GitRewordAction"/>
|
||||
<action id="Git.Rename.Local.Branch" class="git4idea.ui.branch.dashboard.BranchesDashboardActions$RenameLocalBranch"/>
|
||||
<action id="Git.Checkout.Branch" class="git4idea.ui.branch.dashboard.BranchesDashboardActions$CheckoutSelectedBranchAction">
|
||||
<mouse-shortcut keymap="$default" keystroke="button1 doubleClick"/>
|
||||
</action>
|
||||
<action id="Git.Fixup.To.Commit" class="git4idea.rebase.GitCommitFixupBySubjectAction"/>
|
||||
<action id="Git.Squash.Into.Commit" class="git4idea.rebase.GitCommitSquashBySubjectAction"/>
|
||||
<action id="Git.Interactive.Rebase" class="git4idea.rebase.GitInteractiveRebaseAction"/>
|
||||
|
||||
@@ -278,6 +278,8 @@ action.Git.Fixup.To.Commit.text=Fixup...
|
||||
action.Git.Fixup.To.Commit.description=Create a fixup commit
|
||||
action.Git.Rename.Local.Branch.text=Rename...
|
||||
action.Git.Rename.Local.Branch.description=Rename a local branch
|
||||
action.Git.Checkout.Branch.text=Checkout Selected...
|
||||
action.Git.Checkout.Branch.description=Checkout selected branch
|
||||
action.Git.Reword.Commit.text=Edit Commit Message...
|
||||
action.Git.Reword.Commit.description=Change commit message via reword option of git rebase or amend
|
||||
action.Git.Uncommit.text=Undo Commit...
|
||||
|
||||
@@ -316,20 +316,25 @@ internal object BranchesDashboardActions {
|
||||
}
|
||||
}
|
||||
|
||||
object CheckoutLocalBranchOnDoubleClickHandler {
|
||||
fun install(project: Project, treeComponent: BranchesTreeComponent) {
|
||||
treeComponent.doubleClickHandler = { clickedNode -> doCheckout(clickedNode, project) }
|
||||
class CheckoutSelectedBranchAction : BranchesActionBase() {
|
||||
|
||||
override fun update(e: AnActionEvent, project: Project, branches: Collection<BranchInfo>) {
|
||||
if (branches.size > 1) {
|
||||
e.presentation.isEnabled = false
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
private fun doCheckout(clickedNode: BranchTreeNode, project: Project) {
|
||||
val branchInfo = clickedNode.getNodeDescriptor().branchInfo ?: return
|
||||
if (branchInfo.isLocal) {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.project!!
|
||||
val branch = e.getData(GIT_BRANCHES)!!.firstOrNull() ?: return
|
||||
if (branch.isLocal) {
|
||||
GitBranchPopupActions.LocalBranchActions.CheckoutAction
|
||||
.checkoutBranch(project, branchInfo.repositories, branchInfo.branchName)
|
||||
.checkoutBranch(project, branch.repositories, branch.branchName)
|
||||
}
|
||||
else {
|
||||
GitBranchPopupActions.RemoteBranchActions.CheckoutRemoteBranchAction
|
||||
.checkoutRemoteBranch(project, branchInfo.repositories, branchInfo.branchName)
|
||||
.checkoutRemoteBranch(project, branch.repositories, branch.branchName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ import com.intellij.vcs.log.ui.frame.VcsLogChangeProcessor
|
||||
import com.intellij.vcs.log.visible.VisiblePackRefresher
|
||||
import com.intellij.vcs.log.visible.VisiblePackRefresherImpl
|
||||
import com.intellij.vcs.log.visible.filters.VcsLogFilterObject
|
||||
import git4idea.ui.branch.dashboard.BranchesDashboardActions.CheckoutLocalBranchOnDoubleClickHandler
|
||||
import git4idea.ui.branch.dashboard.BranchesDashboardActions.DeleteBranchAction
|
||||
import git4idea.ui.branch.dashboard.BranchesDashboardActions.FetchAction
|
||||
import git4idea.ui.branch.dashboard.BranchesDashboardActions.GroupByDirectoryAction
|
||||
@@ -121,7 +120,6 @@ internal class BranchesDashboardUi(val project: Project) : Disposable {
|
||||
}
|
||||
|
||||
private fun initMainUi() {
|
||||
CheckoutLocalBranchOnDoubleClickHandler.install(project, tree.component)
|
||||
val diffAction = ShowBranchDiffAction()
|
||||
diffAction.registerCustomShortcutSet(KeymapUtil.getActiveKeymapShortcuts("Diff.ShowDiff"), branchesTreeWithLogPanel)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user