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 653460b56cf7..1e0923b9dbc5 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 @@ -112,6 +112,7 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo private final Project myProject; private ActionGroup myTopLeftActions = new DefaultActionGroup(); + private ActionGroup myTopMiddleActions = new DefaultActionGroup(); private ActionGroup myTopRightActions = new DefaultActionGroup(); private final DefaultActionGroup myViewActions = new DefaultActionGroup(); @@ -124,6 +125,7 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo private final Set myRestoreStateRequestors = new HashSet<>(); private String myTopLeftActionsPlace = ActionPlaces.UNKNOWN; + private String myTopMiddleActionsPlace = ActionPlaces.UNKNOWN; private String myTopRightActionsPlace = ActionPlaces.UNKNOWN; private final IdeFocusManager myFocusManager; @@ -187,6 +189,13 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo rebuildCommonActions(); } + void setTopMiddleActions(final @NotNull ActionGroup topActions, @NotNull String place) { + myTopMiddleActions = topActions; + myTopMiddleActionsPlace = place; + + rebuildCommonActions(); + } + void setTopRightActions(final @NotNull ActionGroup topActions, @NotNull String place) { myTopRightActions = topActions; myTopRightActionsPlace = place; @@ -838,8 +847,9 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo TabInfo tab = new TabInfo(grid).setObject(getStateFor(content).getTab()).setText("Tab"); Wrapper leftWrapper = new Wrapper(); + Wrapper middleWrapper = new Wrapper(); Wrapper rightWrapper = new Wrapper(); - myCommonActionsPlaceholder.put(grid, new TopToolbarWrappers(leftWrapper, rightWrapper)); + myCommonActionsPlaceholder.put(grid, new TopToolbarWrappers(leftWrapper, middleWrapper, rightWrapper)); Wrapper minimizedToolbar = new Wrapper(); myMinimizedButtonsPlaceholder.put(grid, minimizedToolbar); @@ -853,7 +863,7 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo TwoSideComponent right = new TwoSideComponent(searchComponent, minimizedToolbar); - NonOpaquePanel sideComponent = new TwoSideComponent(leftWrapper, new TwoSideComponent(right, rightWrapper)); + NonOpaquePanel sideComponent = new TwoSideComponent(leftWrapper, new TwoSideComponent(middleWrapper, new TwoSideComponent(right, rightWrapper))); tab.setSideComponent(sideComponent); @@ -933,6 +943,7 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo boolean hasToolbarContent = false; for (Map.Entry entry : myCommonActionsPlaceholder.entrySet()) { Wrapper leftPlaceHolder = entry.getValue().left; + Wrapper middlePlaceHolder = entry.getValue().middle; Wrapper rightPlaceHolder = entry.getValue().right; TopToolbarContextActions topToolbarContextActions = myContextActions.get(entry.getKey()); @@ -945,6 +956,14 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo setActions(leftPlaceHolder, myTopLeftActionsPlace, leftGroupToBuild); } + DefaultActionGroup middleGroupToBuild = new DefaultActionGroup(); + middleGroupToBuild.addAll(myTopMiddleActions); + final AnAction[] middleActions = middleGroupToBuild.getChildren(null); + + if (topToolbarContextActions == null || !Arrays.equals(middleActions, topToolbarContextActions.middle)) { + setActions(middlePlaceHolder, myTopMiddleActionsPlace, middleGroupToBuild); + } + DefaultActionGroup rightGroupToBuild = new DefaultActionGroup(); rightGroupToBuild.addAll(myTopRightActions); final AnAction[] rightActions = rightGroupToBuild.getChildren(null); @@ -953,7 +972,7 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo setActions(rightPlaceHolder, myTopRightActionsPlace, rightGroupToBuild); } - myContextActions.put(entry.getKey(), new TopToolbarContextActions(leftActions, rightActions)); + myContextActions.put(entry.getKey(), new TopToolbarContextActions(leftActions, middleActions, rightActions)); if (leftGroupToBuild.getChildrenCount() > 0 || rightGroupToBuild.getChildrenCount() > 0) { hasToolbarContent = true; @@ -1968,20 +1987,24 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo private static class TopToolbarContextActions { public final AnAction[] left; + public final AnAction[] middle; public final AnAction[] right; - private TopToolbarContextActions(AnAction[] left, AnAction[] right) { + private TopToolbarContextActions(AnAction[] left, AnAction[] middle, AnAction[] right) { this.left = left; + this.middle = middle; this.right = right; } } private static class TopToolbarWrappers { public final Wrapper left; + public final Wrapper middle; public final Wrapper right; - private TopToolbarWrappers(Wrapper left, Wrapper right) { + private TopToolbarWrappers(Wrapper left, Wrapper middle, Wrapper right) { this.left = left; + this.middle = middle; this.right = right; } } 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 5340068a671b..886a7bb3c1fe 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 @@ -83,6 +83,13 @@ public class RunnerLayoutUiImpl implements Disposable.Parent, RunnerLayoutUi, La return this; } + @Override + @NotNull + public LayoutViewOptions setTopMiddleToolbar(@NotNull ActionGroup actions, @NotNull String place) { + myContentUI.setTopMiddleActions(actions, place); + return this; + } + @Override @NotNull public LayoutViewOptions setTopRightToolbar(@NotNull ActionGroup actions, @NotNull String place) { 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 28b3c792cf95..bb9393e8294f 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 @@ -21,6 +21,9 @@ public interface LayoutViewOptions { @NotNull LayoutViewOptions setTopLeftToolbar(@NotNull ActionGroup actions, @NotNull String place); + @NotNull + LayoutViewOptions setTopMiddleToolbar(@NotNull ActionGroup actions, @NotNull String place); + @NotNull LayoutViewOptions setTopRightToolbar(@NotNull ActionGroup actions, @NotNull String place); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab2.kt b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab2.kt index c2a204758990..ff96d9835ad1 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab2.kt +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab2.kt @@ -240,7 +240,13 @@ class XDebugSessionTab2( val singleContent = toolWindow.contentManager.contents.singleOrNull() val headerVisible = toolWindow.isHeaderVisible - val toolbar = DefaultActionGroup().apply { + val topRightToolbar = DefaultActionGroup().apply { + if (headerVisible) return@apply + addAll(toolWindow.decorator.headerToolbar.actions) + } + myUi.options.setTopRightToolbar(topRightToolbar, ActionPlaces.DEBUGGER_TOOLBAR) + + val topMiddleToolbar = DefaultActionGroup().apply { if (singleContent == null || headerVisible) return@apply add(object : AnAction() { @@ -249,13 +255,13 @@ class XDebugSessionTab2( } override fun update(e: AnActionEvent) { - e.presentation.text = "Close" + e.presentation.text = "Close debug session" e.presentation.icon = AllIcons.Actions.Close } }) - addAll(toolWindow.decorator.headerToolbar.actions) + addSeparator() } - myUi.options.setTopRightToolbar(toolbar, ActionPlaces.DEBUGGER_TOOLBAR) + myUi.options.setTopMiddleToolbar(topMiddleToolbar, ActionPlaces.DEBUGGER_TOOLBAR) toolWindow.decorator.isHeaderVisible = headerVisible