From a79c5a028ad06d04e50a61a63e43bcf1d1a0587e Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Wed, 27 Nov 2024 16:49:33 +0100 Subject: [PATCH] IJPL-163688 IJPL-161046 vcs: use adaptive layout for Local Changes and Shelve toolwindows Show splitter-preview for vertical toolwindows if they share the toolwindow with VCS-Log. (cherry picked from commit 3711ab15aa5b6d71aa7276312abe957409c1f960) IJ-CR-150517 GitOrigin-RevId: e011ff96a81d6d0495eaa571f59ac0c6e278589a --- platform/vcs-impl/api-dump.txt | 2 ++ .../intellij/openapi/vcs/changes/ChangesViewManager.java | 5 +++-- .../openapi/vcs/changes/PreviewDiffSplitterComponent.kt | 6 ++++++ .../vcs/changes/shelf/ShelvedChangesViewManager.java | 5 +++-- plugins/git4idea/src/git4idea/index/ui/GitStagePanel.kt | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/platform/vcs-impl/api-dump.txt b/platform/vcs-impl/api-dump.txt index 02a9c3658983..002502df3a18 100644 --- a/platform/vcs-impl/api-dump.txt +++ b/platform/vcs-impl/api-dump.txt @@ -1029,6 +1029,8 @@ f:com.intellij.openapi.vcs.changes.PreviewDiffSplitterComponent - closePreview():V - openPreview(Z):Z - f:updatePreview(Z):V +f:com.intellij.openapi.vcs.changes.PreviewDiffSplitterComponentKt +- sf:shouldHaveSplitterDiffPreview(com.intellij.openapi.project.Project,Z):Z c:com.intellij.openapi.vcs.changes.PreviewDiffVirtualFile - com.intellij.diff.editor.DiffVirtualFile - (com.intellij.openapi.vcs.changes.DiffPreviewProvider):V diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java index 4aa7a9a91d52..c4982a4c5d2c 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java @@ -81,12 +81,13 @@ import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreePath; import java.awt.*; -import java.util.List; import java.util.*; +import java.util.List; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; +import static com.intellij.openapi.vcs.changes.PreviewDiffSplitterComponentKt.shouldHaveSplitterDiffPreview; import static com.intellij.openapi.vcs.changes.ui.ChangesTree.DEFAULT_GROUPING_KEYS; import static com.intellij.openapi.vcs.changes.ui.ChangesTree.GROUP_BY_ACTION_GROUP; import static com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager.*; @@ -566,7 +567,7 @@ public class ChangesViewManager implements ChangesViewEx, if (myDisposed) return; boolean isVertical = isToolWindowTabVertical(myProject, LOCAL_CHANGES); - boolean hasSplitterPreview = !isVertical; + boolean hasSplitterPreview = shouldHaveSplitterDiffPreview(myProject, isVertical); boolean isPreviewPanelShown = hasSplitterPreview && myVcsConfiguration.LOCAL_CHANGES_DETAILS_PREVIEW_SHOWN; myCommitPanelSplitter.setOrientation(isPreviewPanelShown || isVertical); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/PreviewDiffSplitterComponent.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/PreviewDiffSplitterComponent.kt index e6f54ec3bf85..de8ce1c257f7 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/PreviewDiffSplitterComponent.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/PreviewDiffSplitterComponent.kt @@ -1,6 +1,8 @@ // Copyright 2000-2021 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.openapi.vcs.changes +import com.intellij.openapi.project.Project +import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager.Companion.isCommitToolWindowShown import com.intellij.ui.OnePixelSplitter import com.intellij.util.IJSwingUtilities.updateComponentTreeUI import com.intellij.util.ui.JBUI.emptySize @@ -51,3 +53,7 @@ class PreviewDiffSplitterComponent( repaint() } } + +fun shouldHaveSplitterDiffPreview(project: Project, isContentVertical: Boolean): Boolean { + return !isContentVertical || !isCommitToolWindowShown(project) +} diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java index bd15e79da611..d7aa86c5abd7 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java @@ -68,14 +68,15 @@ import javax.swing.event.ChangeEvent; import javax.swing.tree.*; import java.awt.*; import java.awt.event.MouseEvent; -import java.util.List; import java.util.*; +import java.util.List; import java.util.function.Predicate; import java.util.function.Supplier; import java.util.stream.Collectors; import static com.intellij.openapi.util.Predicates.nonNull; import static com.intellij.openapi.vcs.VcsNotificationIdsHolder.SHELVE_DELETION_UNDO; +import static com.intellij.openapi.vcs.changes.PreviewDiffSplitterComponentKt.shouldHaveSplitterDiffPreview; import static com.intellij.openapi.vcs.changes.ui.ChangesGroupingSupport.REPOSITORY_GROUPING; import static com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager.SHELF; import static com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager.getToolWindowFor; @@ -750,7 +751,7 @@ public class ShelvedChangesViewManager implements Disposable { private void updatePanelLayout() { boolean isVertical = ChangesViewContentManager.isToolWindowTabVertical(myProject, SHELF); - boolean hasSplitterPreview = !isVertical; + boolean hasSplitterPreview = shouldHaveSplitterDiffPreview(myProject, isVertical); //noinspection DoubleNegation boolean needUpdatePreview = hasSplitterPreview != (mySplitterDiffPreview != null); if (!needUpdatePreview) return; diff --git a/plugins/git4idea/src/git4idea/index/ui/GitStagePanel.kt b/plugins/git4idea/src/git4idea/index/ui/GitStagePanel.kt index e6064663db9b..176aaf2e85f1 100644 --- a/plugins/git4idea/src/git4idea/index/ui/GitStagePanel.kt +++ b/plugins/git4idea/src/git4idea/index/ui/GitStagePanel.kt @@ -228,7 +228,7 @@ internal class GitStagePanel( if (disposableFlag.isDisposed) return val isVertical = isVertical() - val hasSplitterPreview = !isVertical + val hasSplitterPreview = shouldHaveSplitterDiffPreview(project, isVertical) val isPreviewPanelShown = hasSplitterPreview && VcsConfiguration.getInstance(project).LOCAL_CHANGES_DETAILS_PREVIEW_SHOWN val isMessageSplitterVertical = isVertical || isPreviewPanelShown; if (treeMessageSplitter.orientation != isMessageSplitterVertical) {