[vcs] IJPL-173924 Inline ChangeListViewCommitPanel in ChangesViewCommitPanel

GitOrigin-RevId: 80895b7b8072611c6a427237b16926917b6b3111
This commit is contained in:
Ilia.Shulgin
2025-10-20 19:19:33 +00:00
committed by intellij-monorepo-bot
parent ad9fd9bf0f
commit 2d95b8520b
3 changed files with 127 additions and 10 deletions
+17 -1
View File
@@ -3955,11 +3955,27 @@ a:com.intellij.vcs.commit.ChangeListViewCommitPanel
- f:setEditedCommit(com.intellij.platform.vcs.impl.shared.commit.EditedCommitPresentation):V
- f:setInclusionModel(com.intellij.openapi.vcs.changes.InclusionModel):V
f:com.intellij.vcs.commit.ChangesViewCommitPanel
- com.intellij.vcs.commit.ChangeListViewCommitPanel
- com.intellij.vcs.commit.NonModalCommitPanel
- com.intellij.vcs.commit.ChangesViewCommitWorkflowUi
- activate():Z
- deactivate(Z):V
- dispose():V
- endExecution():V
- expand(java.lang.Object):V
- getCommitProgressUi():com.intellij.vcs.commit.CommitProgressUi
- getDisplayedChanges():java.util.List
- getDisplayedUnversionedFiles():java.util.List
- getEditedCommit():com.intellij.platform.vcs.impl.shared.commit.EditedCommitPresentation
- getIncludedChanges():java.util.List
- getIncludedUnversionedFiles():java.util.List
- getInclusionModel():com.intellij.openapi.vcs.changes.InclusionModel
- isActive():Z
- refreshChangesViewBeforeCommit(kotlin.coroutines.Continuation):java.lang.Object
- select(java.lang.Object):V
- selectFirst(java.util.Collection):V
- setCompletionContext(java.util.List):V
- setEditedCommit(com.intellij.platform.vcs.impl.shared.commit.EditedCommitPresentation):V
- setInclusionModel(com.intellij.openapi.vcs.changes.InclusionModel):V
com.intellij.vcs.commit.ChangesViewCommitWorkflowUi
- com.intellij.vcs.commit.NonModalCommitWorkflowUi
- a:deactivate(Z):V
@@ -123,7 +123,7 @@ abstract class ChangeListViewCommitPanel @ApiStatus.Internal constructor(
}
}
private class ChangeListViewCommitProgressPanel(
internal class ChangeListViewCommitProgressPanel(
project: Project,
private val commitWorkflowUi: ChangesViewCommitWorkflowUi,
commitMessage: EditorTextComponent,
@@ -2,33 +2,135 @@
package com.intellij.vcs.commit
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.WriteIntentReadAction
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.vcs.FilePath
import com.intellij.openapi.vcs.VcsBundle.message
import com.intellij.openapi.vcs.changes.Change
import com.intellij.openapi.vcs.changes.ChangesViewManager
import com.intellij.openapi.vcs.changes.ui.ChangesListView
import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager
import com.intellij.openapi.vcs.changes.InclusionModel
import com.intellij.openapi.vcs.changes.LocalChangeList
import com.intellij.openapi.vcs.changes.ui.*
import com.intellij.openapi.vcs.changes.ui.ChangesBrowserNode.UNVERSIONED_FILES_TAG
import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager.Companion.LOCAL_CHANGES
import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager.Companion.getToolWindowFor
import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManagerListener
import com.intellij.openapi.vcs.changes.ui.isCommitToolWindowShown
import com.intellij.openapi.vcs.changes.ui.VcsTreeModelData.*
import com.intellij.openapi.wm.ToolWindow
import com.intellij.platform.vcs.impl.shared.commit.EditedCommitPresentation
import com.intellij.util.application
import com.intellij.util.ui.UIUtil
import com.intellij.util.ui.tree.TreeUtil.*
import kotlinx.coroutines.CompletableDeferred
import org.jetbrains.annotations.ApiStatus
import javax.swing.JComponent
import kotlin.properties.Delegates.observable
class ChangesViewCommitPanel @ApiStatus.Internal constructor(
project: Project,
private val changesView: ChangesListView,
) : ChangeListViewCommitPanel(project, changesView) {
) : NonModalCommitPanel(project), ChangesViewCommitWorkflowUi {
private var isHideToolWindowOnCommit = false
private val progressPanel = ChangeListViewCommitProgressPanel(project, this, commitMessage.editorField)
private val commitActions = commitActionsPanel.createActions()
private var rootComponent: JComponent? = null
init {
val titleUpdater = ChangesViewCommitTabTitleUpdater(project)
titleUpdater.initSubscription(this)
titleUpdater.updateTitle()
Disposer.register(this, commitMessage)
setProgressComponent(progressPanel)
for (support in EditChangelistSupport.EP_NAME.getExtensionList(project)) {
support.installSearch(commitMessage.editorField, commitMessage.editorField)
}
changesView.setInclusionListener {
WriteIntentReadAction.run { fireInclusionChanged() }
}
changesView.isShowCheckboxes = true
commitActionsPanel.isCommitButtonDefault = {
!progressPanel.isDumbMode && UIUtil.isFocusAncestor(rootComponent ?: component)
}
ChangesViewCommitTabTitleUpdater(project).initSubscription(this)
}
override val isActive: Boolean get() = component.isVisible
@ApiStatus.Internal
fun registerRootComponent(newRootComponent: JComponent) {
logger<ChangesViewCommitPanel>().assertTrue(rootComponent == null)
rootComponent = newRootComponent
commitActions.forEach { it.registerCustomShortcutSet(newRootComponent, this) }
}
override var editedCommit: EditedCommitPresentation? by observable(null) { _, _, newValue ->
ChangesViewManager.getInstanceEx(project).scheduleRefresh {
application.invokeLater { newValue?.let { expand(it) } }
}
}
override fun expand(item: Any) {
val node = changesView.findNodeInTree(item)
node?.let { changesView.expandSafe(it) }
}
override fun select(item: Any) {
val path = changesView.findNodePathInTree(item)
path?.let { selectPath(changesView, it, false) }
}
override fun selectFirst(items: Collection<Any>) {
if (items.isEmpty()) return
val path = treePathTraverser(changesView).preOrderDfsTraversal().find { getLastUserObject(it) in items }
path?.let { selectPath(changesView, it, false) }
}
override fun setCompletionContext(changeLists: List<LocalChangeList>) {
commitMessage.setChangesSupplier(ChangeListChangesSupplier(changeLists))
}
override fun getDisplayedChanges(): List<Change> = all(changesView).userObjects(Change::class.java)
override fun getIncludedChanges(): List<Change> = included(changesView).userObjects(Change::class.java)
override fun getDisplayedUnversionedFiles(): List<FilePath> =
allUnderTag(changesView, UNVERSIONED_FILES_TAG).userObjects(FilePath::class.java)
override fun getIncludedUnversionedFiles(): List<FilePath> =
includedUnderTag(changesView, UNVERSIONED_FILES_TAG).userObjects(FilePath::class.java)
override var inclusionModel: InclusionModel?
get() = changesView.inclusionModel
set(value) {
changesView.setInclusionModel(value)
}
override val commitProgressUi: CommitProgressUi get() = progressPanel
override fun endExecution(): Unit = closeEditorPreviewIfEmpty()
private fun closeEditorPreviewIfEmpty() {
val changesViewManager = ChangesViewManager.getInstance(project) as? ChangesViewManager ?: return
ChangesViewManager.getInstanceEx(project).scheduleRefresh {
application.invokeLater {
changesViewManager.closeEditorPreview(true)
}
}
}
override fun dispose() {
super.dispose()
changesView.isShowCheckboxes = false
changesView.setInclusionListener(null)
}
override fun activate(): Boolean {
val toolWindow = getVcsToolWindow() ?: return false
val contentManager = ChangesViewContentManager.getInstance(project)
@@ -94,8 +196,7 @@ private class ChangesViewCommitTabTitleUpdater(private val project: Project) : C
tabContent.displayName = when {
contentsCount == 1 -> null
project.isCommitToolWindowShown -> message("tab.title.commit")
else -> message("local.changes.tab")
}
}
else ->message("local.changes.tab")
}}
}
}