package org.iwakura.larcjb.actions import com.intellij.openapi.actionSystem.ActionManager import com.intellij.openapi.actionSystem.ActionUpdateThread import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAware import com.intellij.openapi.vcs.ProjectLevelVcsManager import org.iwakura.larcjb.LarcVcs /** * Action to open commit dialog for Larc. */ class LarcCommitAction : AnAction(), DumbAware { override fun actionPerformed(e: AnActionEvent) { /* Trigger the standard IDE commit action */ val checkinAction = ActionManager.getInstance().getAction("CheckinProject") checkinAction?.actionPerformed(e) } override fun update(e: AnActionEvent) { val project = e.project if (project == null) { e.presentation.isEnabledAndVisible = false return } /* Check if Larc is active for any root */ val vcsManager = ProjectLevelVcsManager.getInstance(project) val hasLarcRoots = vcsManager.allVcsRoots.any { it.vcs?.name == LarcVcs.NAME } e.presentation.isEnabledAndVisible = hasLarcRoots } override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT }