diff --git a/platform/execution-impl/src/com/intellij/execution/ui/layout/impl/GridCellImpl.java b/platform/execution-impl/src/com/intellij/execution/ui/layout/impl/GridCellImpl.java index af4605b64fc8..d25604939628 100644 --- a/platform/execution-impl/src/com/intellij/execution/ui/layout/impl/GridCellImpl.java +++ b/platform/execution-impl/src/com/intellij/execution/ui/layout/impl/GridCellImpl.java @@ -70,7 +70,7 @@ public final class GridCellImpl implements GridCell { return null; }); - myTabs.getPresentation().setSideComponentVertical(!context.getLayoutSettings().isToolbarHorizontal()) + myTabs.getPresentation().setSideComponentVertical(true) .setFocusCycle(false).setPaintFocus(true) .setTabDraggingEnabled(context.isMoveToGridActionEnabled()).setSideComponentOnTabs(false); diff --git a/platform/execution-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java b/platform/execution-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java index fec68d947269..6afd57399405 100644 --- a/platform/execution-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java +++ b/platform/execution-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java @@ -73,6 +73,7 @@ import java.beans.PropertyChangeListener; import java.util.List; import java.util.*; import java.util.concurrent.CopyOnWriteArraySet; +import java.util.stream.Stream; import static com.intellij.ui.tabs.JBTabsEx.NAVIGATION_ACTIONS_KEY; @@ -109,18 +110,20 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo }; private final Project myProject; - private ActionGroup myTopActions = new DefaultActionGroup(); + private ActionGroup myTopLeftActions = new DefaultActionGroup(); + private ActionGroup myTopRightActions = new DefaultActionGroup(); private final DefaultActionGroup myViewActions = new DefaultActionGroup(); private final Map myMinimizedButtonsPlaceholder = new HashMap<>(); - private final Map myCommonActionsPlaceholder = new HashMap<>(); - private final Map myContextActions = new HashMap<>(); + private final Map myCommonActionsPlaceholder = new HashMap<>(); + private final Map myContextActions = new HashMap<>(); private boolean myUiLastStateWasRestored; private final Set myRestoreStateRequestors = new HashSet<>(); - private String myActionsPlace = ActionPlaces.UNKNOWN; + private String myTopLeftActionsPlace = ActionPlaces.UNKNOWN; + private String myTopRightActionsPlace = ActionPlaces.UNKNOWN; private final IdeFocusManager myFocusManager; private boolean myMinimizeActionEnabled = true; @@ -176,9 +179,16 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo myWindow = window == 0 ? original.findFreeWindow() : window; } - void setTopActions(@NotNull final ActionGroup topActions, @NotNull String place) { - myTopActions = topActions; - myActionsPlace = place; + void setTopLeftActions(@NotNull final ActionGroup topActions, @NotNull String place) { + myTopLeftActions = topActions; + myTopLeftActionsPlace = place; + + rebuildCommonActions(); + } + + void setTopRightActions(@NotNull final ActionGroup topActions, @NotNull String place) { + myTopRightActions = topActions; + myTopRightActionsPlace = place; rebuildCommonActions(); } @@ -832,8 +842,9 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo TabInfo tab = new TabInfo(grid).setObject(getStateFor(content).getTab()).setText("Tab"); - Wrapper left = new Wrapper(); - myCommonActionsPlaceholder.put(grid, left); + Wrapper leftWrapper = new Wrapper(); + Wrapper rightWrapper = new Wrapper(); + myCommonActionsPlaceholder.put(grid, new TopToolbarWrappers(leftWrapper, rightWrapper)); Wrapper minimizedToolbar = new Wrapper(); myMinimizedButtonsPlaceholder.put(grid, minimizedToolbar); @@ -847,7 +858,7 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo TwoSideComponent right = new TwoSideComponent(searchComponent, minimizedToolbar); - NonOpaquePanel sideComponent = new TwoSideComponent(left, right); + NonOpaquePanel sideComponent = new TwoSideComponent(leftWrapper, new TwoSideComponent(right, rightWrapper)); tab.setSideComponent(sideComponent); @@ -926,49 +937,46 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo private boolean rebuildCommonActions() { boolean hasToolbarContent = false; - for (Map.Entry entry : myCommonActionsPlaceholder.entrySet()) { - Wrapper eachPlaceholder = entry.getValue(); - List contentList = entry.getKey().getContents(); + for (Map.Entry entry : myCommonActionsPlaceholder.entrySet()) { + Wrapper leftPlaceHolder = entry.getValue().left; + Wrapper rightPlaceHolder = entry.getValue().right; - Set contents = new HashSet<>(contentList); + TopToolbarContextActions topToolbarContextActions = myContextActions.get(entry.getKey()); - DefaultActionGroup groupToBuild; - JComponent contextComponent = null; - if (isHorizontalToolbar() && contents.size() == 1) { - Content content = contentList.get(0); - groupToBuild = new DefaultActionGroup(); - if (content.getActions() != null) { - groupToBuild.addAll(content.getActions()); - groupToBuild.addSeparator(); - contextComponent = content.getActionsContextComponent(); - } - groupToBuild.addAll(myTopActions); - } - else { - final DefaultActionGroup group = new DefaultActionGroup(); - group.addAll(myTopActions); - groupToBuild = group; + DefaultActionGroup leftGroupToBuild = new DefaultActionGroup(); + leftGroupToBuild.addAll(myTopLeftActions); + final AnAction[] leftActions = leftGroupToBuild.getChildren(null); + + if (topToolbarContextActions == null || !Arrays.equals(leftActions, topToolbarContextActions.left)) { + setActions(leftPlaceHolder, myTopLeftActionsPlace, leftGroupToBuild); } - final AnAction[] actions = groupToBuild.getChildren(null); - if (!Arrays.equals(actions, myContextActions.get(entry.getKey()))) { - String adjustedPlace = myActionsPlace == ActionPlaces.UNKNOWN ? ActionPlaces.TOOLBAR : myActionsPlace; - ActionToolbar tb = myActionManager.createActionToolbar(adjustedPlace, groupToBuild, true); - tb.getComponent().setBorder(null); - tb.setTargetComponent(contextComponent); - eachPlaceholder.setContent(tb.getComponent()); + DefaultActionGroup rightGroupToBuild = new DefaultActionGroup(); + rightGroupToBuild.addAll(myTopRightActions); + final AnAction[] rightActions = rightGroupToBuild.getChildren(null); + + if (topToolbarContextActions == null || !Arrays.equals(rightActions, topToolbarContextActions.right)) { + setActions(rightPlaceHolder, myTopRightActionsPlace, rightGroupToBuild); } - if (groupToBuild.getChildrenCount() > 0) { + myContextActions.put(entry.getKey(), new TopToolbarContextActions(leftActions, rightActions)); + + if (leftGroupToBuild.getChildrenCount() > 0 || rightGroupToBuild.getChildrenCount() > 0) { hasToolbarContent = true; } - - myContextActions.put(entry.getKey(), actions); } return hasToolbarContent; } + private void setActions(Wrapper placeHolder, String place, DefaultActionGroup group) { + String adjustedPlace = place == ActionPlaces.UNKNOWN ? ActionPlaces.TOOLBAR : place; + ActionToolbar tb = myActionManager.createActionToolbar(adjustedPlace, group, true); + tb.getComponent().setBorder(null); + + placeHolder.setContent(tb.getComponent()); + } + private boolean rebuildMinimizedActions() { for (Map.Entry entry : myMinimizedButtonsPlaceholder.entrySet()) { Wrapper eachPlaceholder = entry.getValue(); @@ -1157,17 +1165,6 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo return ContainerUtil.map(myTabs.getTabs(), RunnerContentUi::getGridFor); } - public void setHorizontalToolbar(final boolean state) { - myLayoutSettings.setToolbarHorizontal(state); - for (GridImpl each : getGrids()) { - each.setToolbarHorizontal(state); - } - - myContextActions.clear(); - updateTabsUI(false); - } - - @Override public boolean isSingleSelection() { return false; @@ -1237,7 +1234,8 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo myContextActions.clear(); myOriginal = null; - myTopActions = null; + myTopLeftActions = null; + myTopRightActions = null; myAdditionalFocusActions = null; myLeftToolbarActions = null; } @@ -1296,7 +1294,10 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo } public void updateActionsImmediately() { - StreamEx.of(myToolbar).append(myCommonActionsPlaceholder.values()) + Collection values = myCommonActionsPlaceholder.values(); + Stream leftWrappers = values.stream().map(it -> it.left); + Stream rightWrappers = values.stream().map(it -> it.right); + StreamEx.of(myToolbar).append(leftWrappers).append(rightWrappers) .map(Wrapper::getTargetComponent) .select(ActionToolbar.class) .distinct() @@ -1690,10 +1691,6 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo return myLayoutSettings.getStateFor(content); } - private boolean isHorizontalToolbar() { - return myLayoutSettings.isToolbarHorizontal(); - } - @Override public ActionCallback select(@NotNull final Content content, final boolean requestFocus) { final GridImpl grid = (GridImpl)findGridFor(content); @@ -1994,4 +1991,24 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo each.contentRemoved(content); } } + + private static class TopToolbarContextActions { + public final AnAction[] left; + public final AnAction[] right; + + private TopToolbarContextActions(AnAction[] left, AnAction[] right) { + this.left = left; + this.right = right; + } + } + + private static class TopToolbarWrappers { + public final Wrapper left; + public final Wrapper right; + + private TopToolbarWrappers(Wrapper left, Wrapper right) { + this.left = left; + this.right = right; + } + } } diff --git a/platform/execution-impl/src/com/intellij/execution/ui/layout/impl/RunnerLayout.java b/platform/execution-impl/src/com/intellij/execution/ui/layout/impl/RunnerLayout.java index 70a2c78df68c..efebbda367b1 100644 --- a/platform/execution-impl/src/com/intellij/execution/ui/layout/impl/RunnerLayout.java +++ b/platform/execution-impl/src/com/intellij/execution/ui/layout/impl/RunnerLayout.java @@ -156,14 +156,6 @@ public class RunnerLayout { myTabs.clear(); } - public boolean isToolbarHorizontal() { - return false; - } - - public void setToolbarHorizontal(boolean horizontal) { - myGeneral.horizontalToolbar = horizontal; - } - @NotNull public ViewImpl getStateFor(@NotNull Content content) { return getOrCreateView(getOrCreateContentId(content)); diff --git a/platform/execution-impl/src/com/intellij/execution/ui/layout/impl/RunnerLayoutUiImpl.java b/platform/execution-impl/src/com/intellij/execution/ui/layout/impl/RunnerLayoutUiImpl.java index b723c11a35e3..5340068a671b 100644 --- a/platform/execution-impl/src/com/intellij/execution/ui/layout/impl/RunnerLayoutUiImpl.java +++ b/platform/execution-impl/src/com/intellij/execution/ui/layout/impl/RunnerLayoutUiImpl.java @@ -71,8 +71,22 @@ public class RunnerLayoutUiImpl implements Disposable.Parent, RunnerLayoutUi, La @Override @NotNull + @Deprecated public LayoutViewOptions setTopToolbar(@NotNull ActionGroup actions, @NotNull String place) { - myContentUI.setTopActions(actions, place); + return setTopLeftToolbar(actions, place); + } + + @Override + @NotNull + public LayoutViewOptions setTopLeftToolbar(@NotNull ActionGroup actions, @NotNull String place) { + myContentUI.setTopLeftActions(actions, place); + return this; + } + + @Override + @NotNull + public LayoutViewOptions setTopRightToolbar(@NotNull ActionGroup actions, @NotNull String place) { + myContentUI.setTopRightActions(actions, place); return this; } diff --git a/platform/lang-api/src/com/intellij/execution/ui/layout/LayoutViewOptions.java b/platform/lang-api/src/com/intellij/execution/ui/layout/LayoutViewOptions.java index e904ae827989..81f2488c0d3c 100644 --- a/platform/lang-api/src/com/intellij/execution/ui/layout/LayoutViewOptions.java +++ b/platform/lang-api/src/com/intellij/execution/ui/layout/LayoutViewOptions.java @@ -27,8 +27,15 @@ public interface LayoutViewOptions { String STARTUP = "startup"; @NotNull + @Deprecated LayoutViewOptions setTopToolbar(@NotNull ActionGroup actions, @NotNull String place); + @NotNull + LayoutViewOptions setTopLeftToolbar(@NotNull ActionGroup actions, @NotNull String place); + + @NotNull + LayoutViewOptions setTopRightToolbar(@NotNull ActionGroup actions, @NotNull String place); + @NotNull LayoutViewOptions setLeftToolbar(@NotNull ActionGroup leftToolbar, @NotNull String place);