vcs: non-modal: Make "Switch to Commit Dialog" action available in search everywhere
[idea/community.git] / platform / vcs-impl / src / com / intellij / vcs / commit / SwitchToCommitDialogAction.kt
1 // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2 package com.intellij.vcs.commit
3
4 import com.intellij.openapi.actionSystem.ActionManager
5 import com.intellij.openapi.actionSystem.AnActionEvent
6 import com.intellij.openapi.actionSystem.IdeActions.ACTION_CHECKIN_PROJECT
7 import com.intellij.openapi.actionSystem.ex.ActionUtil.invokeAction
8 import com.intellij.openapi.project.DumbAwareAction
9 import com.intellij.openapi.vcs.actions.isProjectUsesNonModalCommit
10 import com.intellij.vcs.commit.CommitWorkflowManager.Companion.setCommitFromLocalChanges
11
12 private class SwitchToCommitDialogAction : DumbAwareAction() {
13   override fun update(e: AnActionEvent) {
14     e.presentation.isEnabledAndVisible = e.isProjectUsesNonModalCommit()
15   }
16
17   override fun actionPerformed(e: AnActionEvent) {
18     setCommitFromLocalChanges(false)
19
20     val commitAction = ActionManager.getInstance().getAction(ACTION_CHECKIN_PROJECT) ?: return
21     invokeAction(commitAction, e.dataContext, e.place, e.inputEvent, null)
22   }
23 }