diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AbstractCommonCheckinAction.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AbstractCommonCheckinAction.kt index 03a6c7f0829a..0782d9d8dce4 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AbstractCommonCheckinAction.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AbstractCommonCheckinAction.kt @@ -22,6 +22,26 @@ private fun getChangesIn(project: Project, roots: Array): Set } abstract class AbstractCommonCheckinAction : AbstractVcsAction(), UpdateInBackground { + override fun update(vcsContext: VcsContext, presentation: Presentation) { + val project = vcsContext.project + + if (project == null || !ProjectLevelVcsManager.getInstance(project).hasActiveVcss()) { + presentation.isEnabledAndVisible = false + } + else if (!approximatelyHasRoots(vcsContext)) { + presentation.isEnabled = false + } + else { + presentation.text = "${getActionName(vcsContext)}..." + presentation.isEnabled = !ProjectLevelVcsManager.getInstance(project).isBackgroundVcsOperationRunning + presentation.isVisible = true + } + } + + protected abstract fun approximatelyHasRoots(dataContext: VcsContext): Boolean + + protected abstract fun getActionName(dataContext: VcsContext): String? + public override fun actionPerformed(context: VcsContext) { LOG.debug("actionPerformed. ") @@ -41,6 +61,16 @@ abstract class AbstractCommonCheckinAction : AbstractVcsAction(), UpdateInBackgr } } + protected open fun getMnemonicsFreeActionName(context: VcsContext): String? = getActionName(context) + + protected abstract fun getRoots(dataContext: VcsContext): Array + + protected open fun prepareRootsForCommit(roots: Array, project: Project): Array { + project.saveDocumentsAndProjectSettings() + + return DescindingFilesFilter.filterDescindingFiles(roots, project) + } + protected open fun performCheckIn(context: VcsContext, project: Project, roots: Array) { LOG.debug("invoking commit dialog after update") @@ -62,16 +92,6 @@ abstract class AbstractCommonCheckinAction : AbstractVcsAction(), UpdateInBackgr CommitChangeListDialog.commitChanges(project, changesToCommit, included, initialChangeList, getExecutor(project), null) } - protected open fun prepareRootsForCommit(roots: Array, project: Project): Array { - project.saveDocumentsAndProjectSettings() - - return DescindingFilesFilter.filterDescindingFiles(roots, project) - } - - protected open fun getMnemonicsFreeActionName(context: VcsContext): String? = getActionName(context) - - protected open fun getExecutor(project: Project): CommitExecutor? = null - protected open fun getInitiallySelectedChangeList(context: VcsContext, project: Project): LocalChangeList? { val manager = ChangeListManager.getInstance(project) @@ -80,25 +100,5 @@ abstract class AbstractCommonCheckinAction : AbstractVcsAction(), UpdateInBackgr return manager.defaultChangeList } - protected abstract fun getActionName(dataContext: VcsContext): String? - - protected abstract fun getRoots(dataContext: VcsContext): Array - - protected abstract fun approximatelyHasRoots(dataContext: VcsContext): Boolean - - override fun update(vcsContext: VcsContext, presentation: Presentation) { - val project = vcsContext.project - - if (project == null || !ProjectLevelVcsManager.getInstance(project).hasActiveVcss()) { - presentation.isEnabledAndVisible = false - } - else if (!approximatelyHasRoots(vcsContext)) { - presentation.isEnabled = false - } - else { - presentation.text = "${getActionName(vcsContext)}..." - presentation.isEnabled = !ProjectLevelVcsManager.getInstance(project).isBackgroundVcsOperationRunning - presentation.isVisible = true - } - } + protected open fun getExecutor(project: Project): CommitExecutor? = null }