cleanup PresentationFactory.processPresentation

1. Deprecate unnecessary overload
2. Change the order of arguments

GitOrigin-RevId: d4f2e7a4772e4eea9ac0adf5a6d6c157f70a9544
This commit is contained in:
Gregory.Shrago
2024-07-12 02:53:45 +04:00
committed by intellij-monorepo-bot
parent 31d38fd393
commit 58d80c9e7e
6 changed files with 23 additions and 10 deletions

View File

@@ -11842,6 +11842,7 @@ c:com.intellij.openapi.actionSystem.impl.MenuItemPresentationFactory
- sf:HIDE_ICON:com.intellij.openapi.util.Key
- <init>():V
- <init>(Z):V
- p:processPresentation(com.intellij.openapi.actionSystem.AnAction,com.intellij.openapi.actionSystem.Presentation):V
- p:processPresentation(com.intellij.openapi.actionSystem.Presentation):V
c:com.intellij.openapi.actionSystem.impl.MoreActionGroup
- com.intellij.openapi.actionSystem.DefaultActionGroup
@@ -11866,8 +11867,8 @@ c:com.intellij.openapi.actionSystem.impl.PresentationFactory
- f:getPresentation(com.intellij.openapi.actionSystem.AnAction):com.intellij.openapi.actionSystem.Presentation
- isNeedRebuild():Z
- postProcessPresentation(com.intellij.openapi.actionSystem.AnAction,com.intellij.openapi.actionSystem.Presentation):V
- p:processPresentation(com.intellij.openapi.actionSystem.AnAction,com.intellij.openapi.actionSystem.Presentation):V
- p:processPresentation(com.intellij.openapi.actionSystem.Presentation):V
- p:processPresentation(com.intellij.openapi.actionSystem.Presentation,com.intellij.openapi.actionSystem.AnAction):V
- reset():V
- resetNeedRebuild():V
- s:updatePresentation(com.intellij.openapi.actionSystem.AnAction):V

View File

@@ -238,11 +238,11 @@ public class SplitButtonAction extends ActionGroupWrapper implements CustomCompo
@Override
protected void showActionGroupPopup(@NotNull ActionGroup actionGroup, @NotNull AnActionEvent event) {
if (myPopupState.isRecentlyHidden()) return; // do not show new popup
ActionManagerImpl am = (ActionManagerImpl) ActionManager.getInstance();
ActionPopupMenu popupMenu = am.createActionPopupMenu(event.getPlace(), actionGroup, new MenuItemPresentationFactory() {
ActionManagerImpl actionManager = (ActionManagerImpl)event.getActionManager();
ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(event.getPlace(), actionGroup, new MenuItemPresentationFactory() {
@Override
protected void processPresentation(@NotNull Presentation presentation) {
super.processPresentation(presentation);
protected void processPresentation(@NotNull AnAction action, @NotNull Presentation presentation) {
super.processPresentation(action, presentation);
if (StringUtil.defaultIfEmpty(presentation.getText(), "").equals(myPresentation.getText()) &&
StringUtil.defaultIfEmpty(presentation.getDescription(), "").equals(myPresentation.getDescription())) {
presentation.setEnabled(selectedActionEnabled());

View File

@@ -253,8 +253,8 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
private @NotNull MenuItemPresentationFactory createPresentationFactory() {
return new MenuItemPresentationFactory() {
@Override
protected void processPresentation(@NotNull Presentation presentation) {
super.processPresentation(presentation);
protected void processPresentation(@NotNull AnAction action, @NotNull Presentation presentation) {
super.processPresentation(action, presentation);
if (myNoIconsInPopup) {
presentation.setIcon(null);
presentation.setHoveredIcon(null);

View File

@@ -1,6 +1,7 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.actionSystem.impl;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.util.Key;
import org.jetbrains.annotations.ApiStatus;
@@ -17,7 +18,7 @@ public class ActionToolbarPresentationFactory extends PresentationFactory {
private final int myId = ourIdCounter.incrementAndGet();
@Override
protected void processPresentation(@NotNull Presentation presentation) {
protected void processPresentation(@NotNull AnAction action, @NotNull Presentation presentation) {
presentation.putClientProperty(ID_KEY, myId);
}

View File

@@ -2,6 +2,7 @@
package com.intellij.openapi.actionSystem.impl;
import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.util.Key;
import org.jetbrains.annotations.NotNull;
@@ -22,6 +23,16 @@ public class MenuItemPresentationFactory extends PresentationFactory {
this.forceHideIcon = forceHideIcon;
}
@Override
protected void processPresentation(@NotNull AnAction action, @NotNull Presentation presentation) {
if (forceHideIcon || !UISettings.getInstance().getShowIconsInMenus()) {
presentation.setIcon(null);
presentation.setDisabledIcon(null);
presentation.setHoveredIcon(null);
presentation.putClientProperty(HIDE_ICON, Boolean.TRUE);
}
}
@Override
protected void processPresentation(@NotNull Presentation presentation) {
super.processPresentation(presentation);

View File

@@ -44,7 +44,7 @@ public class PresentationFactory {
presentation.setDisabledIcon(templatePresentation.getDisabledIcon());
presentation.putClientProperty(NEED_UPDATE_PRESENTATION, null);
}
processPresentation(presentation, action);
processPresentation(action, presentation);
}
return presentation;
}
@@ -58,7 +58,7 @@ public class PresentationFactory {
return Collections.unmodifiableSet(myPresentations.keySet());
}
protected void processPresentation(@NotNull Presentation presentation, @NotNull AnAction action) {
protected void processPresentation(@NotNull AnAction action, @NotNull Presentation presentation) {
processPresentation(presentation);
}