IJPL-174330 T: [MyNavBarWrapperPanel.runToolbarExists]

(cherry picked from commit 629a60c16c4524d8a931f929d1f80c42f20c7254)

IJ-CR-161755

GitOrigin-RevId: 1046a30750df725874fd142aa7dd0a20ba79c473
This commit is contained in:
Gregory.Shrago
2025-04-30 19:45:01 +04:00
committed by intellij-monorepo-bot
parent 84070aa2ec
commit 00164edaee
3 changed files with 11 additions and 20 deletions

View File

@@ -195,13 +195,12 @@ internal class MyNavBarWrapperPanel(private val project: Project, useAsComponent
//return !UISettings.getInstance().showMainToolbar && runToolbarExists();
}
private fun runToolbarExists(): Boolean {
if (navToolbarGroupExist == null) {
val correctedAction = CustomActionsSchema.getInstance().getCorrectedAction(IdeActions.GROUP_NAVBAR_TOOLBAR)
navToolbarGroupExist = correctedAction is DefaultActionGroup && correctedAction.childrenCount > 0 ||
correctedAction is CustomisedActionGroup && correctedAction.getFirstAction() != null
}
return navToolbarGroupExist!!
private fun runToolbarExists(): Boolean = navToolbarGroupExist ?: run {
when (val o = CustomActionsSchema.getInstance().getCorrectedAction(IdeActions.GROUP_NAVBAR_TOOLBAR)) {
is DefaultActionGroup -> o.childrenCount > 0
is CustomisedActionGroup -> o.defaultChildrenOrStubs.size > 0
else -> false
}.also { navToolbarGroupExist = it }
}
private fun toggleNavPanel(settings: UISettings) {
@@ -315,15 +314,13 @@ private fun isNeedGap(group: AnAction): Boolean {
}
private fun getFirstAction(group: AnAction): AnAction? {
if (group is CustomisedActionGroup) {
return group.getFirstAction()
val actionsOrStubs = when (group) {
is DefaultActionGroup -> group.childActionsOrStubs
is CustomisedActionGroup -> group.defaultChildrenOrStubs
else -> AnAction.EMPTY_ARRAY
}
else if (group !is DefaultActionGroup) {
return null
}
var firstAction: AnAction? = null
for (action in group.getChildActionsOrStubs()) {
for (action in actionsOrStubs) {
if (action is DefaultActionGroup) {
firstAction = getFirstAction(action)
}

View File

@@ -4357,7 +4357,6 @@ f:com.intellij.ide.ui.customization.CustomisedActionGroup
- <init>(java.lang.String,com.intellij.openapi.actionSystem.ActionGroup,com.intellij.ide.ui.customization.CustomActionsSchema,java.lang.String,java.lang.String):V
- equals(java.lang.Object):Z
- getChildren(com.intellij.openapi.actionSystem.AnActionEvent):com.intellij.openapi.actionSystem.AnAction[]
- getFirstAction():com.intellij.openapi.actionSystem.AnAction
- getOrigin():com.intellij.openapi.actionSystem.ActionGroup
- hashCode():I
- resetChildren():V

View File

@@ -60,11 +60,6 @@ public final class CustomisedActionGroup extends ActionGroupWrapper {
delegate, g.getChildActionsOrStubs(), mySchema, myDefaultGroupName, myRootGroupName);
}
public @Nullable AnAction getFirstAction() {
AnAction[] children = getChildren(null);
return children.length > 0 ? children[0] : null;
}
/** @deprecated Use {@link #getDelegate()} instead */
@Deprecated(forRemoval = true)
public @NotNull ActionGroup getOrigin() { return getDelegate(); }