From 958784b94700ad2f8d89d836364a9542f75d2a5e Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Mon, 2 Dec 2024 13:24:24 +0100 Subject: [PATCH] IJPL-163688 IJPL-161046 vcs: use adaptive layout for Stash toolwindow Show splitter-preview for vertical toolwindow if it shares the toolwindow with VCS-Log. (cherry picked from commit 874fb91ce8d58fd5373ed9b12f7dd12e12112d2e) IJ-CR-150517 GitOrigin-RevId: 8c3609e6a537f96bf0b7601b297a4c8e0f58f56a --- .../changes/savedPatches/SavedPatchesUi.kt | 19 +++++++++++-------- .../ui/GitStashToggleSplitPreviewAction.kt | 3 ++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/savedPatches/SavedPatchesUi.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/savedPatches/SavedPatchesUi.kt index 74bf66db08d8..ab94bbf6b578 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/savedPatches/SavedPatchesUi.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/savedPatches/SavedPatchesUi.kt @@ -8,6 +8,7 @@ import com.intellij.openapi.actionSystem.* import com.intellij.openapi.project.Project import com.intellij.openapi.util.Disposer import com.intellij.openapi.vcs.VcsBundle +import com.intellij.openapi.vcs.changes.shouldHaveSplitterDiffPreview import com.intellij.ui.* import com.intellij.util.EditSourceOnDoubleClickHandler import com.intellij.util.Processor @@ -23,13 +24,15 @@ import java.awt.FlowLayout import javax.swing.* import javax.swing.border.CompoundBorder -open class SavedPatchesUi(project: Project, - @ApiStatus.Internal val providers: List>, - private val isVertical: () -> Boolean, - private val isWithSplitDiffPreview: () -> Boolean, - private val isShowDiffWithLocal: () -> Boolean, - focusMainUi: (Component?) -> Unit, - disposable: Disposable) : +open class SavedPatchesUi( + private val project: Project, + @ApiStatus.Internal val providers: List>, + private val isVertical: () -> Boolean, + private val isWithSplitDiffPreview: () -> Boolean, + private val isShowDiffWithLocal: () -> Boolean, + focusMainUi: (Component?) -> Unit, + disposable: Disposable, +) : JPanel(BorderLayout()), Disposable, UiDataProvider { protected val patchesTree: SavedPatchesTree @@ -140,7 +143,7 @@ open class SavedPatchesUi(project: Project, private fun updateLayout(isInitial: Boolean) { val isVertical = isVertical() - val isWithSplitPreview = !isVertical && isWithSplitDiffPreview() + val isWithSplitPreview = shouldHaveSplitterDiffPreview(project, isVertical) && isWithSplitDiffPreview() val isChangesSplitterVertical = isVertical || isWithSplitPreview if (treeChangesSplitter.orientation != isChangesSplitterVertical) { treeChangesSplitter.orientation = isChangesSplitterVertical diff --git a/plugins/git4idea/src/git4idea/stash/ui/GitStashToggleSplitPreviewAction.kt b/plugins/git4idea/src/git4idea/stash/ui/GitStashToggleSplitPreviewAction.kt index 8687665eea6c..d16bb96593e0 100644 --- a/plugins/git4idea/src/git4idea/stash/ui/GitStashToggleSplitPreviewAction.kt +++ b/plugins/git4idea/src/git4idea/stash/ui/GitStashToggleSplitPreviewAction.kt @@ -5,6 +5,7 @@ import com.intellij.openapi.actionSystem.ActionUpdateThread import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.project.DumbAwareToggleAction +import com.intellij.openapi.vcs.changes.shouldHaveSplitterDiffPreview import git4idea.config.GitVcsApplicationSettings internal class GitStashToggleSplitPreviewAction : DumbAwareToggleAction() { @@ -15,7 +16,7 @@ internal class GitStashToggleSplitPreviewAction : DumbAwareToggleAction() { e.presentation.isEnabledAndVisible = false return } - e.presentation.isEnabledAndVisible = !isStashTabVertical(project) + e.presentation.isEnabledAndVisible = shouldHaveSplitterDiffPreview(project, isStashTabVertical(project)) } override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.EDT