mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 17:20:55 +07:00
Add setTopLeftToolbar and setTopRightToolbar Api
Remove useless isToolbarHorizontal and setToolbarHorizontal methods GitOrigin-RevId: afe121b62db941e2959b1a94c529502599fbb5ba
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0509ecee4a
commit
623a38b62d
@@ -70,7 +70,7 @@ public final class GridCellImpl implements GridCell {
|
|||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
myTabs.getPresentation().setSideComponentVertical(!context.getLayoutSettings().isToolbarHorizontal())
|
myTabs.getPresentation().setSideComponentVertical(true)
|
||||||
.setFocusCycle(false).setPaintFocus(true)
|
.setFocusCycle(false).setPaintFocus(true)
|
||||||
.setTabDraggingEnabled(context.isMoveToGridActionEnabled()).setSideComponentOnTabs(false);
|
.setTabDraggingEnabled(context.isMoveToGridActionEnabled()).setSideComponentOnTabs(false);
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ import java.beans.PropertyChangeListener;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CopyOnWriteArraySet;
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static com.intellij.ui.tabs.JBTabsEx.NAVIGATION_ACTIONS_KEY;
|
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 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 DefaultActionGroup myViewActions = new DefaultActionGroup();
|
||||||
|
|
||||||
private final Map<GridImpl, Wrapper> myMinimizedButtonsPlaceholder = new HashMap<>();
|
private final Map<GridImpl, Wrapper> myMinimizedButtonsPlaceholder = new HashMap<>();
|
||||||
private final Map<GridImpl, Wrapper> myCommonActionsPlaceholder = new HashMap<>();
|
private final Map<GridImpl, TopToolbarWrappers> myCommonActionsPlaceholder = new HashMap<>();
|
||||||
private final Map<GridImpl, AnAction[]> myContextActions = new HashMap<>();
|
private final Map<GridImpl, TopToolbarContextActions> myContextActions = new HashMap<>();
|
||||||
|
|
||||||
private boolean myUiLastStateWasRestored;
|
private boolean myUiLastStateWasRestored;
|
||||||
|
|
||||||
private final Set<Object> myRestoreStateRequestors = new HashSet<>();
|
private final Set<Object> myRestoreStateRequestors = new HashSet<>();
|
||||||
private String myActionsPlace = ActionPlaces.UNKNOWN;
|
private String myTopLeftActionsPlace = ActionPlaces.UNKNOWN;
|
||||||
|
private String myTopRightActionsPlace = ActionPlaces.UNKNOWN;
|
||||||
private final IdeFocusManager myFocusManager;
|
private final IdeFocusManager myFocusManager;
|
||||||
|
|
||||||
private boolean myMinimizeActionEnabled = true;
|
private boolean myMinimizeActionEnabled = true;
|
||||||
@@ -176,9 +179,16 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo
|
|||||||
myWindow = window == 0 ? original.findFreeWindow() : window;
|
myWindow = window == 0 ? original.findFreeWindow() : window;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTopActions(@NotNull final ActionGroup topActions, @NotNull String place) {
|
void setTopLeftActions(@NotNull final ActionGroup topActions, @NotNull String place) {
|
||||||
myTopActions = topActions;
|
myTopLeftActions = topActions;
|
||||||
myActionsPlace = place;
|
myTopLeftActionsPlace = place;
|
||||||
|
|
||||||
|
rebuildCommonActions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setTopRightActions(@NotNull final ActionGroup topActions, @NotNull String place) {
|
||||||
|
myTopRightActions = topActions;
|
||||||
|
myTopRightActionsPlace = place;
|
||||||
|
|
||||||
rebuildCommonActions();
|
rebuildCommonActions();
|
||||||
}
|
}
|
||||||
@@ -832,8 +842,9 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo
|
|||||||
|
|
||||||
TabInfo tab = new TabInfo(grid).setObject(getStateFor(content).getTab()).setText("Tab");
|
TabInfo tab = new TabInfo(grid).setObject(getStateFor(content).getTab()).setText("Tab");
|
||||||
|
|
||||||
Wrapper left = new Wrapper();
|
Wrapper leftWrapper = new Wrapper();
|
||||||
myCommonActionsPlaceholder.put(grid, left);
|
Wrapper rightWrapper = new Wrapper();
|
||||||
|
myCommonActionsPlaceholder.put(grid, new TopToolbarWrappers(leftWrapper, rightWrapper));
|
||||||
|
|
||||||
Wrapper minimizedToolbar = new Wrapper();
|
Wrapper minimizedToolbar = new Wrapper();
|
||||||
myMinimizedButtonsPlaceholder.put(grid, minimizedToolbar);
|
myMinimizedButtonsPlaceholder.put(grid, minimizedToolbar);
|
||||||
@@ -847,7 +858,7 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo
|
|||||||
TwoSideComponent right = new TwoSideComponent(searchComponent, minimizedToolbar);
|
TwoSideComponent right = new TwoSideComponent(searchComponent, minimizedToolbar);
|
||||||
|
|
||||||
|
|
||||||
NonOpaquePanel sideComponent = new TwoSideComponent(left, right);
|
NonOpaquePanel sideComponent = new TwoSideComponent(leftWrapper, new TwoSideComponent(right, rightWrapper));
|
||||||
|
|
||||||
tab.setSideComponent(sideComponent);
|
tab.setSideComponent(sideComponent);
|
||||||
|
|
||||||
@@ -926,49 +937,46 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo
|
|||||||
|
|
||||||
private boolean rebuildCommonActions() {
|
private boolean rebuildCommonActions() {
|
||||||
boolean hasToolbarContent = false;
|
boolean hasToolbarContent = false;
|
||||||
for (Map.Entry<GridImpl, Wrapper> entry : myCommonActionsPlaceholder.entrySet()) {
|
for (Map.Entry<GridImpl, TopToolbarWrappers> entry : myCommonActionsPlaceholder.entrySet()) {
|
||||||
Wrapper eachPlaceholder = entry.getValue();
|
Wrapper leftPlaceHolder = entry.getValue().left;
|
||||||
List<Content> contentList = entry.getKey().getContents();
|
Wrapper rightPlaceHolder = entry.getValue().right;
|
||||||
|
|
||||||
Set<Content> contents = new HashSet<>(contentList);
|
TopToolbarContextActions topToolbarContextActions = myContextActions.get(entry.getKey());
|
||||||
|
|
||||||
DefaultActionGroup groupToBuild;
|
DefaultActionGroup leftGroupToBuild = new DefaultActionGroup();
|
||||||
JComponent contextComponent = null;
|
leftGroupToBuild.addAll(myTopLeftActions);
|
||||||
if (isHorizontalToolbar() && contents.size() == 1) {
|
final AnAction[] leftActions = leftGroupToBuild.getChildren(null);
|
||||||
Content content = contentList.get(0);
|
|
||||||
groupToBuild = new DefaultActionGroup();
|
if (topToolbarContextActions == null || !Arrays.equals(leftActions, topToolbarContextActions.left)) {
|
||||||
if (content.getActions() != null) {
|
setActions(leftPlaceHolder, myTopLeftActionsPlace, leftGroupToBuild);
|
||||||
groupToBuild.addAll(content.getActions());
|
|
||||||
groupToBuild.addSeparator();
|
|
||||||
contextComponent = content.getActionsContextComponent();
|
|
||||||
}
|
|
||||||
groupToBuild.addAll(myTopActions);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
final DefaultActionGroup group = new DefaultActionGroup();
|
|
||||||
group.addAll(myTopActions);
|
|
||||||
groupToBuild = group;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final AnAction[] actions = groupToBuild.getChildren(null);
|
DefaultActionGroup rightGroupToBuild = new DefaultActionGroup();
|
||||||
if (!Arrays.equals(actions, myContextActions.get(entry.getKey()))) {
|
rightGroupToBuild.addAll(myTopRightActions);
|
||||||
String adjustedPlace = myActionsPlace == ActionPlaces.UNKNOWN ? ActionPlaces.TOOLBAR : myActionsPlace;
|
final AnAction[] rightActions = rightGroupToBuild.getChildren(null);
|
||||||
ActionToolbar tb = myActionManager.createActionToolbar(adjustedPlace, groupToBuild, true);
|
|
||||||
tb.getComponent().setBorder(null);
|
if (topToolbarContextActions == null || !Arrays.equals(rightActions, topToolbarContextActions.right)) {
|
||||||
tb.setTargetComponent(contextComponent);
|
setActions(rightPlaceHolder, myTopRightActionsPlace, rightGroupToBuild);
|
||||||
eachPlaceholder.setContent(tb.getComponent());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groupToBuild.getChildrenCount() > 0) {
|
myContextActions.put(entry.getKey(), new TopToolbarContextActions(leftActions, rightActions));
|
||||||
|
|
||||||
|
if (leftGroupToBuild.getChildrenCount() > 0 || rightGroupToBuild.getChildrenCount() > 0) {
|
||||||
hasToolbarContent = true;
|
hasToolbarContent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
myContextActions.put(entry.getKey(), actions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return hasToolbarContent;
|
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() {
|
private boolean rebuildMinimizedActions() {
|
||||||
for (Map.Entry<GridImpl, Wrapper> entry : myMinimizedButtonsPlaceholder.entrySet()) {
|
for (Map.Entry<GridImpl, Wrapper> entry : myMinimizedButtonsPlaceholder.entrySet()) {
|
||||||
Wrapper eachPlaceholder = entry.getValue();
|
Wrapper eachPlaceholder = entry.getValue();
|
||||||
@@ -1157,17 +1165,6 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo
|
|||||||
return ContainerUtil.map(myTabs.getTabs(), RunnerContentUi::getGridFor);
|
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
|
@Override
|
||||||
public boolean isSingleSelection() {
|
public boolean isSingleSelection() {
|
||||||
return false;
|
return false;
|
||||||
@@ -1237,7 +1234,8 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo
|
|||||||
myContextActions.clear();
|
myContextActions.clear();
|
||||||
|
|
||||||
myOriginal = null;
|
myOriginal = null;
|
||||||
myTopActions = null;
|
myTopLeftActions = null;
|
||||||
|
myTopRightActions = null;
|
||||||
myAdditionalFocusActions = null;
|
myAdditionalFocusActions = null;
|
||||||
myLeftToolbarActions = null;
|
myLeftToolbarActions = null;
|
||||||
}
|
}
|
||||||
@@ -1296,7 +1294,10 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateActionsImmediately() {
|
public void updateActionsImmediately() {
|
||||||
StreamEx.of(myToolbar).append(myCommonActionsPlaceholder.values())
|
Collection<TopToolbarWrappers> values = myCommonActionsPlaceholder.values();
|
||||||
|
Stream<Wrapper> leftWrappers = values.stream().map(it -> it.left);
|
||||||
|
Stream<Wrapper> rightWrappers = values.stream().map(it -> it.right);
|
||||||
|
StreamEx.of(myToolbar).append(leftWrappers).append(rightWrappers)
|
||||||
.map(Wrapper::getTargetComponent)
|
.map(Wrapper::getTargetComponent)
|
||||||
.select(ActionToolbar.class)
|
.select(ActionToolbar.class)
|
||||||
.distinct()
|
.distinct()
|
||||||
@@ -1690,10 +1691,6 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo
|
|||||||
return myLayoutSettings.getStateFor(content);
|
return myLayoutSettings.getStateFor(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isHorizontalToolbar() {
|
|
||||||
return myLayoutSettings.isToolbarHorizontal();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionCallback select(@NotNull final Content content, final boolean requestFocus) {
|
public ActionCallback select(@NotNull final Content content, final boolean requestFocus) {
|
||||||
final GridImpl grid = (GridImpl)findGridFor(content);
|
final GridImpl grid = (GridImpl)findGridFor(content);
|
||||||
@@ -1994,4 +1991,24 @@ public final class RunnerContentUi implements ContentUI, Disposable, CellTransfo
|
|||||||
each.contentRemoved(content);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,14 +156,6 @@ public class RunnerLayout {
|
|||||||
myTabs.clear();
|
myTabs.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isToolbarHorizontal() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setToolbarHorizontal(boolean horizontal) {
|
|
||||||
myGeneral.horizontalToolbar = horizontal;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ViewImpl getStateFor(@NotNull Content content) {
|
public ViewImpl getStateFor(@NotNull Content content) {
|
||||||
return getOrCreateView(getOrCreateContentId(content));
|
return getOrCreateView(getOrCreateContentId(content));
|
||||||
|
|||||||
@@ -71,8 +71,22 @@ public class RunnerLayoutUiImpl implements Disposable.Parent, RunnerLayoutUi, La
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@Deprecated
|
||||||
public LayoutViewOptions setTopToolbar(@NotNull ActionGroup actions, @NotNull String place) {
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,15 @@ public interface LayoutViewOptions {
|
|||||||
String STARTUP = "startup";
|
String STARTUP = "startup";
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@Deprecated
|
||||||
LayoutViewOptions setTopToolbar(@NotNull ActionGroup actions, @NotNull String place);
|
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
|
@NotNull
|
||||||
LayoutViewOptions setLeftToolbar(@NotNull ActionGroup leftToolbar, @NotNull String place);
|
LayoutViewOptions setLeftToolbar(@NotNull ActionGroup leftToolbar, @NotNull String place);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user