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
This commit is contained in:
Aleksey Pivovarov
2024-11-27 16:49:33 +01:00
committed by intellij-monorepo-bot
parent 071179ffed
commit a79c5a028a
5 changed files with 15 additions and 5 deletions

View File

@@ -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
- <init>(com.intellij.openapi.vcs.changes.DiffPreviewProvider):V

View File

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

View File

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

View File

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

View File

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