[actions] IJPL-183357 Popups from notification panel links are shown in the incorrect position

GitOrigin-RevId: da577d0a78505ded5e0c8bb53e7da7fe15bafde3
This commit is contained in:
Yuriy Artamonov
2025-04-09 21:40:40 +00:00
committed by intellij-monorepo-bot
parent 0dae7d13e2
commit 3283f83eb9
2 changed files with 23 additions and 1 deletions
@@ -5872,6 +5872,7 @@ c:com.intellij.ui.EditorNotificationPanel
- f:createActionLabel(java.lang.String,java.lang.String):com.intellij.ui.HyperlinkLabel
- f:createActionLabel(java.lang.String,java.lang.String,Z):com.intellij.ui.HyperlinkLabel
- p:executeAction(java.lang.String):V
- p:executeAction(java.lang.String,javax.swing.event.HyperlinkEvent):V
- findLabelByName(java.lang.String):com.intellij.ui.HyperlinkLabel
- p:getActionPlace():java.lang.String
- getBackground():java.awt.Color
@@ -366,7 +366,16 @@ public class EditorNotificationPanel extends JPanel implements IntentionActionPr
public final @NotNull HyperlinkLabel createActionLabel(@NotNull @LinkLabel String text,
@NotNull @NonNls String actionId,
boolean showInIntentionMenu) {
return createActionLabel(text, () -> executeAction(actionId), showInIntentionMenu);
return createActionLabel(text, new ActionHandler() {
@Override
public void handlePanelActionClick(@NotNull EditorNotificationPanel panel, @NotNull HyperlinkEvent event) {
executeAction(actionId, event);
}
@Override
public void handleQuickFixClick(@NotNull Editor editor, @NotNull PsiFile psiFile) {
}
}, showInIntentionMenu);
}
public final @NotNull HyperlinkLabel createActionLabel(@NotNull @LinkLabel String text,
@@ -449,6 +458,18 @@ public class EditorNotificationPanel extends JPanel implements IntentionActionPr
}
}
protected void executeAction(@NonNls String actionId, @NotNull HyperlinkEvent e) {
AnAction action = ActionManager.getInstance().getAction(actionId);
if (action == null) {
throw new AssertionError("'" + actionId + "' is not an found");
}
DataContext dataContext = DataManager.getInstance().getDataContext(this);
AnActionEvent event = AnActionEvent.createEvent(dataContext, null, getActionPlace(), ActionUiKind.TOOLBAR, e.getInputEvent());
if (ActionUtil.lastUpdateAndCheckDumb(action, event, true)) {
ActionUtil.performActionDumbAwareWithCallbacks(action, event);
}
}
protected @NotNull String getActionPlace() {
return ActionPlaces.UNKNOWN;
}