vcs: non-modal: Save commit message for current change list on project close (IDEA-219042)

GitOrigin-RevId: d267ddab386b5f1fd7a6243088a0c9c3e6702d5e
This commit is contained in:
Konstantin Kolosovsky
2019-10-13 15:02:11 +00:00
committed by intellij-monorepo-bot
parent b00a983b0e
commit bb618442c0
@@ -1,8 +1,12 @@
// Copyright 2000-2019 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.
package com.intellij.vcs.commit
import com.intellij.application.subscribe
import com.intellij.openapi.Disposable
import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.project.ProjectManagerListener
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.vcs.CheckinProjectPanel
import com.intellij.openapi.vcs.FilePath
@@ -22,7 +26,8 @@ private fun Collection<Change>.toPartialAwareSet() = THashSet(this, ChangeListCh
class ChangesViewCommitWorkflowHandler(
override val workflow: ChangesViewCommitWorkflow,
override val ui: ChangesViewCommitWorkflowUi
) : AbstractCommitWorkflowHandler<ChangesViewCommitWorkflow, ChangesViewCommitWorkflowUi>() {
) : AbstractCommitWorkflowHandler<ChangesViewCommitWorkflow, ChangesViewCommitWorkflowUi>(),
ProjectManagerListener {
override val commitPanel: CheckinProjectPanel = CommitProjectPanelAdapter(this)
override val amendCommitHandler: AmendCommitHandler = AmendCommitHandlerImpl(this)
@@ -56,6 +61,8 @@ class ChangesViewCommitWorkflowHandler(
ui.inclusionModel = inclusionModel
Disposer.register(inclusionModel, Disposable { ui.inclusionModel = null })
ProjectManager.TOPIC.subscribe(this, this)
vcsesChanged() // as currently vcses are set before handler subscribes to corresponding event
}
@@ -211,6 +218,17 @@ class ChangesViewCommitWorkflowHandler(
override fun saveCommitMessage(success: Boolean) = commitMessagePolicy.save(currentChangeList, getCommitMessage(), success)
// save state on project close - using this method ensures change list comment is updated before project state persisting
override fun projectClosingBeforeSave(project: Project) = saveStateBeforeDispose()
// save state on other events - like "settings changed to use commit dialog"
override fun dispose() = saveStateBeforeDispose()
private fun saveStateBeforeDispose() {
saveCommitMessage(false)
currentChangeList = null
}
interface ActivityListener : EventListener {
fun activityStateChanged()
}