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
This commit is contained in:
Aleksey Pivovarov
2024-12-02 13:24:24 +01:00
committed by intellij-monorepo-bot
parent a79c5a028a
commit 958784b947
2 changed files with 13 additions and 9 deletions

View File

@@ -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<SavedPatchesProvider<*>>,
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<SavedPatchesProvider<*>>,
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

View File

@@ -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