IJPL-158093 NPE when clicking Choose direction in the editor

GitOrigin-RevId: 6d6cc1d9bb6e0b87d4675adefaaba6889c58df0f
This commit is contained in:
Gregory.Shrago
2024-07-12 17:47:41 +04:00
committed by intellij-monorepo-bot
parent 60ab8bb505
commit b1deee469d
4 changed files with 26 additions and 22 deletions

View File

@@ -964,6 +964,7 @@ a:com.intellij.openapi.actionSystem.ActionPlaces
- sf:EDITOR_HINT:java.lang.String
- sf:EDITOR_INLAY:java.lang.String
- sf:EDITOR_INSPECTIONS_TOOLBAR:java.lang.String
- sf:EDITOR_NOTIFICATION_POPUP:java.lang.String
- sf:EDITOR_POPUP:java.lang.String
- sf:EDITOR_TAB:java.lang.String
- sf:EDITOR_TAB_POPUP:java.lang.String

View File

@@ -41,6 +41,7 @@ public abstract class ActionPlaces {
public static final String EDITOR_GUTTER = "ICON_NAVIGATION";
public static final String EDITOR_GUTTER_POPUP = "ICON_NAVIGATION_SECONDARY_BUTTON";
public static final String EDITOR_ANNOTATIONS_AREA_POPUP = "EditorAnnotationsAreaPopup";
public static final String EDITOR_NOTIFICATION_POPUP = "EDITOR_NOTIFICATION_POPUP";
public static final String EDITOR_INLAY = "EditorInlay";
public static final String RIGHT_EDITOR_GUTTER_POPUP = "RightEditorGutterPopup";
public static final String COMMANDER_POPUP = "CommanderPopup";
@@ -251,7 +252,7 @@ public abstract class ActionPlaces {
CHANGES_VIEW_POPUP, DATABASE_VIEW_POPUP, REMOTE_HOST_VIEW_POPUP, REMOTE_HOST_DIALOG_POPUP, TFS_TREE_POPUP,
ACTION_PLACE_VCS_QUICK_LIST_POPUP_ACTION, PHING_EXPLORER_POPUP, NAVIGATION_BAR_POPUP, JS_BUILD_TOOL_POPUP,
V8_CPU_PROFILING_POPUP, V8_HEAP_PROFILING_POPUP, V8_HEAP_PROFILING_POPUP, RUN_DASHBOARD_POPUP, SERVICES_POPUP, EDITOR_GUTTER_POPUP,
EDITOR_ANNOTATIONS_AREA_POPUP,
EDITOR_ANNOTATIONS_AREA_POPUP, EDITOR_NOTIFICATION_POPUP,
RUN_ANYTHING_POPUP, RUN_TOOLBAR_LEFT_SIDE,
VCS_LOG_TABLE_PLACE, VCS_HISTORY_PLACE, VCS_LOG_TOOLBAR_POPUP_PLACE, VCS_LOG_BRANCHES_PLACE, VCS_TOOLBAR_WIDGET,
PROJECT_WIDGET_POPUP,

View File

@@ -196,7 +196,10 @@ class ActionMenuItem internal constructor(action: AnAction,
if (ActionPlaces.MAIN_MENU == place && SystemInfo.isMacSystemMenu) {
state = isToggled
screenMenuItemPeer?.setState(isToggled)
setIcon(wrapNullIcon(icon)!!)
}
val adjustedIcon = adjustIcon(presentation.icon)
if (adjustedIcon != null) {
setIcon(adjustedIcon)
}
else if (isToggled) {
setToggledIcon()
@@ -220,21 +223,20 @@ class ActionMenuItem internal constructor(action: AnAction,
if (selected == null) {
selected = icon
}
setIcon(wrapNullIcon(if (presentation.isEnabled) icon else disabled))
setSelectedIcon(wrapNullIcon(selected))
setDisabledIcon(wrapNullIcon(disabled))
setIcon(adjustIcon(if (presentation.isEnabled) icon else disabled))
setSelectedIcon(adjustIcon(selected))
setDisabledIcon(adjustIcon(disabled))
}
}
private fun wrapNullIcon(icon: Icon?): Icon? {
private fun adjustIcon(icon: Icon?): Icon? {
val isMainMenu = ActionPlaces.MAIN_MENU == place
if (isMainMenu && isShowNoIcons(actionRef.getAction())) {
return null
return when {
isMainMenu && isShowNoIcons(actionRef.getAction()) -> null
!isAligned || !isAlignedInGroup -> return icon
isMainMenu && icon == null && SystemInfo.isMacSystemMenu -> EMPTY_MENU_ACTION_ICON
else -> icon
}
if (!isAligned || !isAlignedInGroup) {
return icon
}
return if (icon == null && SystemInfo.isMacSystemMenu && ActionPlaces.MAIN_MENU == place) EMPTY_MENU_ACTION_ICON else icon
}
override fun setIcon(icon: Icon?) {

View File

@@ -59,18 +59,18 @@ final class BidiContentNotificationProvider implements EditorNotificationProvide
};
}
private static void showChooserPopup(Editor editor) {
private static void showChooserPopup(@NotNull Editor editor) {
ActionManager actionManager = ActionManager.getInstance();
AnAction group = actionManager.getAction(IdeActions.GROUP_EDITOR_BIDI_TEXT_DIRECTION);
if (group instanceof ActionGroup) {
JPopupMenu popupMenu = actionManager.createActionPopupMenu(ActionPlaces.MAIN_MENU, (ActionGroup)group).getComponent();
AWTEvent event = IdeEventQueue.getInstance().getTrueCurrentEvent();
if (event instanceof MouseEvent && ((MouseEvent)event).getComponent().isShowing()) {
JBPopupMenu.showByEvent((MouseEvent)event, popupMenu);
}
else {
JBPopupMenu.showByEditor(editor, popupMenu);
}
if (!(group instanceof ActionGroup)) return;
JPopupMenu popupMenu = actionManager.createActionPopupMenu(
ActionPlaces.EDITOR_NOTIFICATION_POPUP, (ActionGroup)group).getComponent();
AWTEvent event = IdeEventQueue.getInstance().getTrueCurrentEvent();
if (event instanceof MouseEvent && ((MouseEvent)event).getComponent().isShowing()) {
JBPopupMenu.showByEvent((MouseEvent)event, popupMenu);
}
else {
JBPopupMenu.showByEditor(editor, popupMenu);
}
}
}