mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Add setTopMiddleToolbar
Fix RIDER-41665 (debug tool window close button inconsistency) GitOrigin-RevId: 4f24382d93075cf9442af8a6d50f19bf650d9a43
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7067226b18
commit
cb8d732078
+28
-5
@@ -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<Object> 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<GridImpl, TopToolbarWrappers> 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;
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user