diff --git a/src/main/kotlin/ee/carlrobert/codegpt/toolwindow/chat/editor/actions/AutoApplyAction.kt b/src/main/kotlin/ee/carlrobert/codegpt/toolwindow/chat/editor/actions/AutoApplyAction.kt index bad4235a..955ea52e 100644 --- a/src/main/kotlin/ee/carlrobert/codegpt/toolwindow/chat/editor/actions/AutoApplyAction.kt +++ b/src/main/kotlin/ee/carlrobert/codegpt/toolwindow/chat/editor/actions/AutoApplyAction.kt @@ -20,7 +20,7 @@ class AutoApplyAction( private val toolwindowEditor: EditorEx, private val filePath: String?, private val virtualFile: VirtualFile?, - private val onApply: () -> Unit, + private val onApply: (AnActionLink) -> Unit, ) : CustomComponentAction, AnAction() { private val anActionLink: AnActionLink = AnActionLink("Apply", this).apply { @@ -29,7 +29,7 @@ class AutoApplyAction( } override fun actionPerformed(e: AnActionEvent) { - onApply() + onApply(anActionLink) } override fun update(e: AnActionEvent) { diff --git a/src/main/kotlin/ee/carlrobert/codegpt/toolwindow/chat/editor/header/DefaultHeaderPanel.kt b/src/main/kotlin/ee/carlrobert/codegpt/toolwindow/chat/editor/header/DefaultHeaderPanel.kt index 8af272e7..6591a2f6 100644 --- a/src/main/kotlin/ee/carlrobert/codegpt/toolwindow/chat/editor/header/DefaultHeaderPanel.kt +++ b/src/main/kotlin/ee/carlrobert/codegpt/toolwindow/chat/editor/header/DefaultHeaderPanel.kt @@ -9,9 +9,12 @@ import com.intellij.openapi.editor.ex.EditorEx import com.intellij.openapi.project.Project import com.intellij.openapi.ui.JBMenuItem import com.intellij.openapi.ui.JBPopupMenu +import com.intellij.openapi.ui.MessageType +import com.intellij.openapi.ui.popup.JBPopupFactory import com.intellij.openapi.vfs.readText import com.intellij.openapi.vfs.writeText import com.intellij.ui.AnimatedIcon +import com.intellij.ui.components.AnActionLink import com.intellij.ui.components.JBLabel import com.intellij.util.ui.JBUI import ee.carlrobert.codegpt.CodeGPTBundle @@ -64,7 +67,7 @@ class DefaultHeaderPanel(config: HeaderConfig) : HeaderPanel(config) { actionGroup.add(CopyAction(editor)) } else { actionGroup.add(AutoApplyAction(project, editor, config.filePath, virtualFile) { - handleApply(project, editor) + handleApply(project, editor, it) }) actionGroup.add(CopyAction(editor)) actionGroup.addSeparator() @@ -73,7 +76,7 @@ class DefaultHeaderPanel(config: HeaderConfig) : HeaderPanel(config) { return createToolbar(actionGroup) } - private fun handleApply(project: Project, editor: EditorEx) { + private fun handleApply(project: Project, editor: EditorEx, link: AnActionLink) { val file = virtualFile ?: EditorUtil.getSelectedEditor(project)?.virtualFile ?: throw IllegalStateException("Virtual file is null") @@ -84,6 +87,15 @@ class DefaultHeaderPanel(config: HeaderConfig) : HeaderPanel(config) { runUndoTransparentWriteAction { file.writeText(editor.document.text) } + val balloon = JBPopupFactory.getInstance() + .createHtmlTextBalloonBuilder( + CodeGPTBundle.get("toolwindow.chat.editor.action.autoApply.successMessage"), + MessageType.INFO, + null + ) + .setFadeoutTime(3000) + .createBalloon() + balloon.showInCenterOf(link) return } diff --git a/src/main/resources/messages/codegpt.properties b/src/main/resources/messages/codegpt.properties index 00810d4d..183f75de 100644 --- a/src/main/resources/messages/codegpt.properties +++ b/src/main/resources/messages/codegpt.properties @@ -199,6 +199,7 @@ toolwindow.chat.editor.diff.retrying=Retrying... toolwindow.chat.editor.action.autoApply.error=Something went wrong while applying changes. {0} toolwindow.chat.editor.action.autoApply.taskTitle=Apply changes toolwindow.chat.editor.action.autoApply.loadingMessage=ProxyAI: Applying changes +toolwindow.chat.editor.action.autoApply.successMessage=Changes successfully applied to the file. diff.acceptedPanel.revertChanges=Revert Changes diff.acceptedPanel.viewDetails=View Details diff.acceptedPanel.before=Before