From ebc4a4848ae1e239605bd2a60ec97a8831b9059a Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Tue, 1 May 2018 13:21:32 +0300 Subject: [PATCH] IDEA-182879 vcs: move Collapse/Expand actions to the right in "Unversioned Files" --- .../vcs/changes/SpecificFilesViewDialog.java | 11 ++++++--- .../changes/ui/TreeActionsToolbarPanel.java | 23 +++++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/SpecificFilesViewDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/SpecificFilesViewDialog.java index f739c96140cf..2be225462c7e 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/SpecificFilesViewDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/SpecificFilesViewDialog.java @@ -10,6 +10,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.vcs.changes.ui.ChangesBrowserNode; import com.intellij.openapi.vcs.changes.ui.ChangesListView; +import com.intellij.openapi.vcs.changes.ui.TreeActionsToolbarPanel; import com.intellij.openapi.vcs.changes.ui.TreeModelBuilder; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.GuiUtils; @@ -107,10 +108,14 @@ abstract class SpecificFilesViewDialog extends DialogWrapper { final Expander expander = new Expander(); group.addSeparator(); group.add(ActionManager.getInstance().getAction(GROUP_BY_ACTION_GROUP)); - group.add(cam.createExpandAllAction(expander, myView)); - group.add(cam.createCollapseAllAction(expander, myView)); - myPanel.add(actionToolbar.getComponent(), BorderLayout.NORTH); + DefaultActionGroup treeActions = new DefaultActionGroup(); + treeActions.add(cam.createExpandAllHeaderAction(expander, myView)); + treeActions.add(cam.createCollapseAllHeaderAction(expander, myView)); + + JPanel toolbarPanel = new TreeActionsToolbarPanel(actionToolbar, treeActions); + + myPanel.add(toolbarPanel, BorderLayout.NORTH); myPanel.add(ScrollPaneFactory.createScrollPane(myView), BorderLayout.CENTER); myView.getGroupingSupport().setGroupingKeysOrSkip(set(DEFAULT_GROUPING_KEYS)); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/TreeActionsToolbarPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/TreeActionsToolbarPanel.java index 7b0907906cd5..0d929605c8ef 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/TreeActionsToolbarPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/TreeActionsToolbarPanel.java @@ -1,6 +1,7 @@ // Copyright 2000-2018 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.ui; +import com.intellij.openapi.actionSystem.ActionGroup; import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.ActionToolbar; import com.intellij.openapi.actionSystem.DefaultActionGroup; @@ -14,12 +15,16 @@ public class TreeActionsToolbarPanel extends JPanel { this(toolbar.getComponent(), tree); } - public TreeActionsToolbarPanel(@NotNull Component toolbarComponent, @NotNull ChangesTree tree) { - super(new BorderLayout()); + public TreeActionsToolbarPanel(@NotNull ActionToolbar toolbar, @NotNull ActionGroup group) { + this(toolbar.getComponent(), group); + } - DefaultActionGroup group = new DefaultActionGroup(); - group.add(tree.createExpandAllAction(true)); - group.add(tree.createCollapseAllAction(true)); + public TreeActionsToolbarPanel(@NotNull Component toolbarComponent, @NotNull ChangesTree tree) { + this(toolbarComponent, createTreeActions(tree)); + } + + public TreeActionsToolbarPanel(@NotNull Component toolbarComponent, @NotNull ActionGroup group) { + super(new BorderLayout()); ActionToolbar additionalToolbar = ActionManager.getInstance().createActionToolbar("TreeActionsToolbar", group, true); additionalToolbar.setTargetComponent(this); @@ -28,4 +33,12 @@ public class TreeActionsToolbarPanel extends JPanel { add(toolbarComponent, BorderLayout.CENTER); add(additionalToolbar.getComponent(), BorderLayout.EAST); } + + @NotNull + private static DefaultActionGroup createTreeActions(@NotNull ChangesTree tree) { + DefaultActionGroup group = new DefaultActionGroup(); + group.add(tree.createExpandAllAction(true)); + group.add(tree.createCollapseAllAction(true)); + return group; + } }