IDEA-182879 vcs: move Collapse/Expand actions to the right in "Unversioned Files"

This commit is contained in:
Aleksey Pivovarov
2018-05-01 14:51:46 +03:00
parent 94f286e970
commit ebc4a4848a
2 changed files with 26 additions and 8 deletions
@@ -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));
}
@@ -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;
}
}