vcs: avoid iterating over ActionGroup in ChangesBrowserBase

GitOrigin-RevId: 8043bbbb054b1c1edd1dffda9cd535c31aee91c3
This commit is contained in:
Aleksey Pivovarov
2024-03-25 15:36:22 +00:00
committed by intellij-monorepo-bot
parent e5fcb9b747
commit c540356f57
2 changed files with 17 additions and 13 deletions
@@ -6,7 +6,6 @@ import com.intellij.diff.DiffManager;
import com.intellij.diff.chains.DiffRequestChain;
import com.intellij.diff.util.DiffUserDataKeys;
import com.intellij.diff.util.DiffUtil;
import com.intellij.ide.actions.NewActionGroup;
import com.intellij.openapi.ListSelection;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.ActionUtil;
@@ -35,7 +34,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;
/**
* Consider using {@link AsyncChangesBrowserBase} to avoid potentially-expensive tree building operations on EDT.
@@ -107,19 +105,9 @@ public abstract class ChangesBrowserBase extends JPanel implements DataProvider
add(createCenterPanel(), BorderLayout.CENTER);
myToolBarGroup.addAll(createToolbarActions());
myToolBarGroup.addAll(createLastToolbarActions());
myPopupMenuGroup.addAll(createPopupMenuActions());
AnAction groupByAction = ActionManager.getInstance().getAction(ChangesTree.GROUP_BY_ACTION_GROUP);
if (!NewActionGroup.anyActionFromGroupMatches(myToolBarGroup, true, Predicate.isEqual(groupByAction))) {
myToolBarGroup.addSeparator();
myToolBarGroup.add(groupByAction);
}
if (isVerticalToolbar()) {
myToolBarGroup.addSeparator();
myToolBarGroup.addAll(TreeActionsToolbarPanel.createTreeActions());
}
myShowDiffAction.registerCustomShortcutSet(this, null);
DiffUtil.recursiveRegisterShortcutSet(myToolBarGroup, this, null);
}
@@ -187,6 +175,18 @@ public abstract class ChangesBrowserBase extends JPanel implements DataProvider
return Collections.singletonList(myShowDiffAction);
}
@NotNull
protected List<AnAction> createLastToolbarActions() {
List<AnAction> result = new ArrayList<>();
result.add(Separator.getInstance());
result.add(ActionManager.getInstance().getAction(ChangesTree.GROUP_BY_ACTION_GROUP));
if (isVerticalToolbar()) {
result.add(Separator.getInstance());
result.addAll(TreeActionsToolbarPanel.createTreeActions());
}
return result;
}
@NotNull
protected List<AnAction> createPopupMenuActions() {
List<AnAction> actions = new ArrayList<>();
@@ -136,6 +136,10 @@ class VcsLogChangesBrowser internal constructor(project: Project,
)
}
override fun createLastToolbarActions(): List<AnAction> {
return emptyList() // do not duplicate 'ChangesView.GroupBy' group
}
override fun createPopupMenuActions(): List<AnAction> {
return ContainerUtil.append(
super.createPopupMenuActions(),