11package com.github.lppedd.cc.vcs
22
33import com.github.lppedd.cc.CC
4+ import com.github.lppedd.cc.CCBundle
45import com.intellij.openapi.actionSystem.ActionUpdateThread
56import com.intellij.openapi.actionSystem.AnActionEvent
7+ import com.intellij.openapi.actionSystem.PlatformCoreDataKeys
68import com.intellij.openapi.project.DumbAwareAction
9+ import com.intellij.openapi.ui.popup.JBPopupFactory
710import com.intellij.openapi.vcs.CommitMessageI
811import com.intellij.openapi.vcs.VcsDataKeys
12+ import java.awt.Component
913
1014/* *
1115 * @author Edoardo Luppi
@@ -32,10 +36,21 @@ internal class ClearLocalMessageHistoryAction : DumbAwareAction() {
3236
3337 override fun actionPerformed (event : AnActionEvent ) {
3438 val project = event.project ? : return
35- val recentCommitsService = RecentCommitsService .getInstance(project)
36- recentCommitsService.clearLocalMessageHistory()
39+ val component = getActionComponent(event) ? : return
40+ val popup = JBPopupFactory .getInstance().createConfirmation(
41+ /* title = */ CCBundle [" action.cc.vcs.clearLocalMessageHistory.text" ],
42+ /* onYes = */ { RecentCommitsService .getInstance(project).clearLocalMessageHistory() },
43+ /* defaultOptionIndex = */ 1 ,
44+ )
45+
46+ if (popup.canShow()) {
47+ popup.showUnderneathOf(component)
48+ }
3749 }
3850
3951 private fun getCommitMessagePanel (event : AnActionEvent ): CommitMessageI ? =
4052 event.getData(VcsDataKeys .COMMIT_MESSAGE_CONTROL )
53+
54+ private fun getActionComponent (event : AnActionEvent ): Component ? =
55+ event.inputEvent?.component ? : event.getData(PlatformCoreDataKeys .CONTEXT_COMPONENT )
4156}
0 commit comments